How to use list_addresses method in tempest

Best Python code snippet using tempest_python

wallet_addresses.py

Source:wallet_addresses.py Github

copy

Full Screen

...25 extra_args=[[nuparams(NU5_BRANCH_ID, 2),]] * self.num_nodes)26 connect_nodes_bi(self.nodes, 0, 1)27 self.is_network_split = False28 self.sync_all()29 def list_addresses(self, node, expected_sources):30 addrs = self.nodes[node].listaddresses()31 sources = [s['source'] for s in addrs]32 # Sources should be unique.33 assert_equal(len(set(sources)), len(sources))34 assert_equal(set(sources), set(expected_sources))35 # Extract a list of all addresses from the output.36 all_addrs = [37 source.get('transparent', {}).get('addresses', []) +38 source.get('transparent', {}).get('changeAddresses', []) +39 source.get('sprout', {}).get('addresses', []) +40 [s['addresses'] for s in source.get('sapling', [])] +41 [[a['address'] for a in s['addresses']] for s in source.get('unified', [])]42 for source in addrs]43 all_addrs = [a for s in all_addrs for a in s]44 all_addrs = [a if type(a) == list else [a] for a in all_addrs]45 all_addrs = [a for s in all_addrs for a in s]46 assert_equal(len(set(all_addrs)), len(all_addrs), "Duplicates in listaddresses output: %s" % addrs)47 return addrs48 def run_test(self):49 def get_source(listed_addresses, source):50 return next(src for src in listed_addresses if src['source'] == source)51 print("Testing height 1 (Sapling)")52 self.nodes[0].generate(1)53 self.sync_all()54 assert_equal(self.nodes[0].getblockcount(), 1)55 listed_addresses = self.list_addresses(0, ['mnemonic_seed'])56 # There should be a single address from the coinbase, which was derived57 # from the mnemonic seed.58 assert 'transparent' in get_source(listed_addresses, 'mnemonic_seed')59 # If we import a t-address, we should see imported_watchonly as a source.60 taddr_import = self.nodes[1].getnewaddress()61 self.nodes[0].importaddress(taddr_import)62 listed_addresses = self.list_addresses(0, ['imported_watchonly', 'mnemonic_seed'])63 imported_watchonly_src = get_source(listed_addresses, 'imported_watchonly')64 assert_equal(imported_watchonly_src['transparent']['addresses'][0], taddr_import)65 account = self.nodes[0].z_getnewaccount()['account']66 sprout_1 = self.nodes[0].z_getnewaddress('sprout')67 sapling_1 = self.nodes[0].z_getnewaddress('sapling')68 unified_1 = self.nodes[0].z_getaddressforaccount(account)['address']69 types_and_addresses = [70 ('sprout', sprout_1),71 ('sapling', sapling_1),72 ('unified', unified_1),73 ]74 for addr_type, addr in types_and_addresses:75 res = self.nodes[0].z_validateaddress(addr)76 assert res['isvalid']77 # assert res['ismine'] # this isn't present for unified addresses78 assert_equal(res['type'], addr_type)79 # We should see the following sources:80 # - imported_watchonly (for the previously-imported t-addr)81 # - legacy_random (for the new Sprout address)82 # - mnemonic_seed (for the previous t-addrs and the new Sapling and Unified addrs)83 listed_addresses = self.list_addresses(0, ['imported_watchonly', 'legacy_random', 'mnemonic_seed'])84 legacy_random_src = get_source(listed_addresses, 'legacy_random')85 mnemonic_seed_src = get_source(listed_addresses, 'mnemonic_seed')86 # Check Sprout addrs87 assert_equal(legacy_random_src['sprout']['addresses'], [sprout_1])88 # Check Sapling addrs89 assert_equal(90 set([(obj['zip32KeyPath'], x) for obj in mnemonic_seed_src['sapling'] for x in obj['addresses']]),91 set([("m/32'/1'/2147483647'/0'", sapling_1)]),92 )93 # Check Unified addrs94 unified_obj = mnemonic_seed_src['unified']95 assert_equal(unified_obj[0]['account'], 0)96 assert_equal(unified_obj[0]['addresses'][0]['address'], unified_1)97 assert 'diversifier_index' in unified_obj[0]['addresses'][0]98 assert_equal(unified_obj[0]['addresses'][0]['receiver_types'], ['p2pkh', 'sapling', 'orchard'])99 # import the key for sapling_1 into node 1100 sapling_1_key = self.nodes[0].z_exportkey(sapling_1)101 self.nodes[1].z_importkey(sapling_1_key)102 # verify that we see the imported source103 listed_addresses = self.list_addresses(1, ['imported', 'mnemonic_seed'])104 imported_src = get_source(listed_addresses, 'imported')105 assert_equal(imported_src['sapling'][0]['addresses'], [sapling_1])106 # stop the nodes & restart to ensure that the imported address107 # still shows up in listaddresses output108 stop_nodes(self.nodes)109 wait_bitcoinds()110 self.setup_network()111 listed_addresses = self.list_addresses(1, ['imported', 'mnemonic_seed'])112 imported_src = get_source(listed_addresses, 'imported')113 assert_equal(imported_src['sapling'][0]['addresses'], [sapling_1])114 print("Testing height 2 (NU5)")115 self.nodes[0].generate(1)116 self.sync_all()117 assert_equal(self.nodes[0].getblockcount(), 2)118 # Sprout address generation is no longer allowed119 sapling_2 = self.nodes[0].z_getnewaddress('sapling')120 unified_2 = self.nodes[0].z_getaddressforaccount(account)['address']121 types_and_addresses = [122 ('sapling', sapling_2),123 ('unified', unified_2),124 ]125 for addr_type, addr in types_and_addresses:126 res = self.nodes[0].z_validateaddress(addr)127 assert res['isvalid']128 # assert res['ismine'] # this isn't present for unified addresses129 assert_equal(res['type'], addr_type)130 # We should see the same sources (address generation does not change across the NU5 boundary).131 listed_addresses = self.list_addresses(0, ['imported_watchonly', 'legacy_random', 'mnemonic_seed'])132 legacy_random_src = get_source(listed_addresses, 'legacy_random')133 mnemonic_seed_src = get_source(listed_addresses, 'mnemonic_seed')134 # Check Sprout addrs135 assert_equal(legacy_random_src['sprout']['addresses'], [sprout_1])136 # Check Sapling addrs137 assert_equal(138 set([(obj['zip32KeyPath'], x) for obj in mnemonic_seed_src['sapling'] for x in obj['addresses']]),139 set([140 ("m/32'/1'/2147483647'/0'", sapling_1),141 ("m/32'/1'/2147483647'/1'", sapling_2),142 ]),143 )144 # Check Unified addrs145 unified_obj = mnemonic_seed_src['unified']146 assert_equal(unified_obj[0]['account'], 0)147 assert_equal(148 set([addr['address'] for addr in unified_obj[0]['addresses']]),149 set([unified_1, unified_2]),150 )151 assert 'diversifier_index' in unified_obj[0]['addresses'][0]152 assert 'diversifier_index' in unified_obj[0]['addresses'][1]153 assert_equal(unified_obj[0]['addresses'][0]['receiver_types'], ['p2pkh', 'sapling', 'orchard'])154 assert_equal(unified_obj[0]['addresses'][1]['receiver_types'], ['p2pkh', 'sapling', 'orchard'])155 print("Generate mature coinbase, spend to create and detect change")156 self.nodes[0].generate(100)157 self.sync_all()158 self.nodes[0].sendmany('', {taddr_import: 1})159 listed_addresses = self.list_addresses(0, ['imported_watchonly', 'legacy_random', 'mnemonic_seed'])160 mnemonic_seed_src = get_source(listed_addresses, 'mnemonic_seed')161 assert len(mnemonic_seed_src['transparent']['changeAddresses']) > 0162if __name__ == '__main__':...

Full Screen

Full Screen

flyweight.py

Source:flyweight.py Github

copy

Full Screen

...38 self.address_number: str39 self.address_details: str40 def add_address(self, address: Address) -> None:41 self._addresses.append(address)42 def list_addresses(self) -> None:43 for address in self._addresses:44 address.show_address(self.address_number, self.address_details)45class Address:46 """Flyweight"""47 def __init__(self, street: str, neighbourhood: str, zip_code: str) -> None:48 self._street = street49 self._neighbourhood = neighbourhood50 self._zip_code = zip_code51 def show_address(self, address_number: str, address_details: str) -> None:52 print(53 self._street, address_number, self._neighbourhood, address_details,54 self._zip_code55 )56class AddressFactory:57 _addresses: Dict = {}58 def _get_key(self, **kwargs) -> str:59 return ''.join(kwargs.values())60 def get_address(self, **kwargs) -> Address:61 key = self._get_key(**kwargs)62 try:63 address_flyweight = self._addresses[key]64 print('Usando objeto já criado')65 except KeyError:66 address_flyweight = Address(**kwargs)67 self._addresses[key] = address_flyweight68 print('Criando novo objeto')69 return address_flyweight70if __name__ == "__main__":71 address_factory = AddressFactory()72 a1 = address_factory.get_address(73 street='Av Brasil',74 neighbourhood='Centro',75 zip_code='000000-000'76 )77 a2 = address_factory.get_address(78 street='Av Brasil ',79 neighbourhood='Centro',80 zip_code='000000-000'81 )82 luiz = Client('Luiz')83 luiz.address_number = '50'84 luiz.address_details = 'Casa'85 luiz.add_address(a1)86 luiz.list_addresses()87 joana = Client('joana')88 joana.address_number = '250A'89 joana.address_details = 'AP 555'90 joana.add_address(a2)91 joana.list_addresses()...

Full Screen

Full Screen

bfe_addresses.py

Source:bfe_addresses.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2##3## This file is part of Invenio.4## Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 CERN.5##6## Invenio is free software; you can redistribute it and/or7## modify it under the terms of the GNU General Public License as8## published by the Free Software Foundation; either version 2 of the9## License, or (at your option) any later version.10##11## Invenio is distributed in the hope that it will be useful, but12## WITHOUT ANY WARRANTY; without even the implied warranty of13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14## General Public License for more details.15##16## You should have received a copy of the GNU General Public License17## along with Invenio; if not, write to the Free Software Foundation, Inc.,18## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.19"""BibFormat element - Prints list of addresses20"""21__revision__ = "$Id$"22import cgi23from urllib import quote24from invenio.config import CFG_SITE_URL25def format_element(bfo, separator="; ", print_link="yes"):26 """27 Prints a list of addresses linked to this report28 @param separator: the separator between addresses.29 @param print_link: Links the addresses to search engine (HTML links) if 'yes'30 """31 addresses = bfo.fields('270')32 list_addresses = []33 if print_link.lower() == 'yes':34 for address in addresses:35 list_addresses.append('<a href="'+CFG_SITE_URL+'/search?f=author&p='+ \36 quote(address.get('p', "")) + \37 '&amp;ln=' + bfo.lang + \38 '">'+cgi.escape(address.get('p', "")) + \39 '</a>')40 list_addresses.append(cgi.escape(address.get('g', "")))41 else:42 for address in addresses:43 list_addresses.append(cgi.escape(address.get('p', "")))44 list_addresses.append(cgi.escape(address.get('g', "")))45 return separator.join(list_addresses)46def escape_values(bfo):47 """48 Called by BibFormat in order to check if output of this element49 should be escaped.50 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful