def test_wallet_create_successfully(self): """Case both of each wallets are created successfully without a private key.""" wallet1 = KeyWallet.create() wallet2 = KeyWallet.create() self.assertTrue(wallet1.get_address() != wallet2.get_address()) self.assertTrue(is_wallet_address(wallet1.get_address())) self.assertTrue(is_wallet_address(wallet2.get_address()))
def _transfer_token(self, _from: KeyWallet, _to: KeyWallet, _statue: bool): value = 500 params = { '_to': _to.get_address(), '_value': value, } transaction = CallTransactionBuilder() \ .from_(_from.get_address()) \ .to(self._score_address) \ .step_limit(10_000_000) \ .nid(3) \ .nonce(100) \ .method("transfer") \ .params(params) \ .build() signed_transaction = SignedTransaction(transaction, _from) tx_result = self.process_transaction(signed_transaction, self.icon_service) #self.logger.debug('TX RESULT : %s' % tx_result) self.assertTrue('status' in tx_result) self.assertEqual(1, tx_result['status']) if _statue: response = self._call_balance(_to.get_address()) self.assertEqual(hex(value), response)
def searchWallet(request): # print(request.body); if os.path.exists (BASE_DIR+"/keystore/"+request.session.session_key+'/'+request.session['keystore']): try: data = json.loads(request.body) j = json.loads(data) password = j['keystore_password'] wallet = KeyWallet.load(BASE_DIR+"/keystore/"+request.session.session_key+'/'+request.session['keystore'],password); params = { "address" : wallet.get_address()} print("wallet addr >> "+ wallet.get_address()) return JsonResponse(params) except Exception as e: return JsonResponse({"status":"fail", "msg":str(e)}) try: data = json.loads(request.body) # print("json.loads(value) >> "+data) # print(type(data)) j = json.loads(data) # print("json.loads(json) >> "+j['private_key']) key = bytes.fromhex(j['private_key']) # print("bytes json['private_key'] >> ") # print(key) wallet = KeyWallet.load(key) params = { "address" : wallet.get_address()} print("wallet addr >> "+ wallet.get_address()) return JsonResponse(params) except Exception: return JsonResponse({"status":"fail"})
def test_wallet_load_by_private_key(self): """A wallet loads by a private key correctly.""" # Creates a wallet. private_key_object = PrivateKey() private_key = private_key_object.private_key wallet1 = KeyWallet.load(private_key) # Checks a private key as same. self.assertEqual(private_key.hex(), wallet1.get_private_key()) # Checks a wallet's address is correct. self.assertTrue(is_wallet_address(wallet1.get_address())) # Creates the other wallet. private_key_object2 = PrivateKey() private_key2 = private_key_object2.private_key wallet2 = KeyWallet.load(private_key2) # Checks a private key as same. self.assertEqual(private_key2.hex(), wallet2.get_private_key()) # Checks a wallet's address is correct. self.assertTrue(is_wallet_address(wallet2.get_address())) self.assertNotEqual(private_key2, private_key)
def setUpClass(cls): icon_endpoint = os.environ['ICON_ENDPOINT'] if icon_endpoint == 'testnet': cls.icon_service = IconService( HTTPProvider('https://bicon.net.solidwallet.io/api/v3')) cls.act_kard_score_address = 'cx3d85fc30097cb8b18eb52de927b444833c690705' cls.act_ace_score_address = 'cxdccbc7ee2d5581e62c8ba300219a5e8d05b58215' else: cls.icon_service = IconService( HTTPProvider('http://127.0.0.1:9000/api/v3')) cls.act_kard_score_address = 'cx3d85fc30097cb8b18eb52de927b444833c690705' cls.act_ace_score_address = 'cxdccbc7ee2d5581e62c8ba300219a5e8d05b58215' cls.owner_wallet = KeyWallet.load('conf/test_owner.keystore', 'test123!') cls.user1_wallet = KeyWallet.load('conf/test_user1.keystore', 'test123!') cls.user2_wallet = KeyWallet.load('conf/test_user2.keystore', 'test123!') totalSupply = total_supply(cls.act_kard_score_address, cls.owner_wallet.get_address()) print(f'[KARD]total_supply = {totalSupply}') totalSupply = total_supply(cls.act_ace_score_address, cls.owner_wallet.get_address()) print(f'[A.C.E]total_supply = {totalSupply}') owner_balance = balance_of(cls.act_kard_score_address, cls.owner_wallet.get_address(), cls.owner_wallet.get_address()) print('[KARD]owner_balance = {}'.format(owner_balance)) user1_balance = balance_of(cls.act_kard_score_address, cls.user1_wallet.get_address(), cls.user1_wallet.get_address()) print('[KARD]user1_balance = {}'.format(user1_balance)) user2_balance = balance_of(cls.act_kard_score_address, cls.user2_wallet.get_address(), cls.user2_wallet.get_address()) print('[KARD]user2_balance = {}'.format(user2_balance)) owner_balance = balance_of(cls.act_ace_score_address, cls.owner_wallet.get_address(), cls.owner_wallet.get_address()) print('[A.C.E]owner_balance = {}'.format(owner_balance)) user1_balance = balance_of(cls.act_ace_score_address, cls.user1_wallet.get_address(), cls.user1_wallet.get_address()) print('[A.C.E]user1_balance = {}'.format(user1_balance)) user2_balance = balance_of(cls.act_ace_score_address, cls.user2_wallet.get_address(), cls.user2_wallet.get_address()) print('[A.C.E]user2_balance = {}'.format(user2_balance))
def test_wallet_store_overwriting(self): """Case when overwriting the existing keystore file.""" wallet = KeyWallet.create() wallet.store(self.TEST_NEW_PATH, self.TEST_KEYSTORE_FILE_NEW_PASSWORD) wallet2 = KeyWallet.create() self.assertRaises(KeyStoreException, wallet2.store, self.TEST_NEW_PATH, self.TEST_KEYSTORE_FILE_NEW_PASSWORD)
def transfer(self, conf: dict) -> dict: """Transfer ICX Coin. :param conf: transfer command configuration. :return: response of transfer. """ # check value type (must be int), address and keystore file # if valid, return user input password password = conf.get('password', None) password = self._check_transfer(conf, password) if password: try: wallet = KeyWallet.load(conf['keyStore'], password) from_ = wallet.get_address() except KeyStoreException as e: print(e.args[0]) return None else: # make dummy wallet wallet = KeyWallet.create() from_ = conf['from'] uri, version = uri_parser(conf['uri']) icon_service = IconService(HTTPProvider(uri, version)) transaction = TransactionBuilder() \ .from_(from_) \ .to(conf['to']) \ .value(int(conf['value'])) \ .nid(convert_hex_str_to_int(conf['nid'])) \ .timestamp(int(time() * 10 ** 6)) \ .build() if 'stepLimit' not in conf: step_limit = icon_service.estimate_step(transaction) else: step_limit = convert_hex_str_to_int(conf['stepLimit']) transaction.step_limit = step_limit # Returns the signed transaction object having a signature signed_transaction = SignedTransaction(transaction, wallet) if not password: signed_transaction.signed_transaction_dict['signature'] = 'sig' # Sends transaction and return response response = send_transaction_with_logger(icon_service, signed_transaction, uri) if 'result' in response: print('Send transfer request successfully.') tx_hash = response['result'] print(f"transaction hash: {tx_hash}") else: print('Got an error response') print(json.dumps(response, indent=4)) return response
def _show_mine(self, _from: KeyWallet = KeyWallet.create()): call = CallBuilder().from_(_from.get_address()) \ .to(self._sample_game_score_address) \ .method("showMine") \ .build() response = self.process_call(call, self.icon_service) return response
def test_4_register_100_preps_and_check_total_delegated(self): accounts = [KeyWallet.create() for _ in range(100)] tx_list = self._distribute_icx(accounts) self.process_transaction_bulk(tx_list, self.icon_service) tx_list = [] for i in range(100): params = { "name": f"banana node{i}", "email": f"banana@banana{i}.com", "website": f"https://banana{i}.com", "details": f"detail{i}", "publicKey": f"0x1234", "p2pEndPoint": f"target://{i}.213.123.123:7100" } tx = self.create_register_prep_tx(accounts[i], params, step_limit=10000000) tx_list.append(tx) tx_results = self.process_transaction_bulk(tx_list, self.icon_service) for result in tx_results: self.assertEqual(result['status'], 1) # check total delegated # distribute icx delegators = [KeyWallet.create() for _ in range(10)] tx_list = self._distribute_icx(delegators) self.process_transaction_bulk(tx_list, self.icon_service) # stake stake_tx_list = [] for index, key_wallet in enumerate(delegators): tx = self.create_set_stake_tx(key_wallet, 10**18) stake_tx_list.append(tx) self.process_transaction_bulk(stake_tx_list, self.icon_service) # delegate delegate_info_list = [] delegate_amount = [100 - i for i in range(100)] for index, key_wallet in enumerate(accounts): delegate_info = (key_wallet, 100 - index) delegate_info_list.append(delegate_info) delegate_tx_list = [] for index, key_wallet in enumerate(delegators): tx = self.create_set_delegation_tx( key_wallet, delegate_info_list[index * 10:index * 10 + 10], step_limit=10000000) delegate_tx_list.append(tx) self.process_transaction_bulk(delegate_tx_list, self.icon_service) # check total Delegated 50 to 70 response_50_to_70 = self.get_prep_list(50, 70) print(response_50_to_70)
def _show_mine(self, _from: KeyWallet): params = {"_from": _from.get_address()} call = CallBuilder().from_(_from.get_address())\ .to(self._sample_game_score_address) \ .method("showMine") \ .params(params) \ .build() response = self.process_call(call, self.icon_service) return response
def sendtx(self, conf: dict): """Send transaction. :param conf: sendtx command configuration. :return: response of transfer. """ with open(conf['json_file'], 'r') as jf: payload = json.load(jf) password = conf.get('password', None) password = self._check_sendtx(conf, password) params = payload['params'] if password and conf.get('keyStore'): try: wallet = KeyWallet.load(conf['keyStore'], password) params['from'] = wallet.get_address() except KeyStoreException as e: print(e.args[0]) return None else: # make dummy wallet wallet = KeyWallet.create() uri, version = uri_parser(conf['uri']) icon_service = IconService(HTTPProvider(uri, version)) transaction = self.get_transaction(conf, params) if 'stepLimit' not in conf: step_limit = icon_service.estimate_step(transaction) else: step_limit = convert_hex_str_to_int(conf['stepLimit']) transaction.step_limit = step_limit signed_transaction = SignedTransaction(transaction, wallet) if not password: signed_transaction.signed_transaction_dict['signature'] = 'sig' # Sends transaction response = send_transaction_with_logger(icon_service, signed_transaction, uri) if 'result' in response: print('Send transaction request successfully.') tx_hash = response['result'] print(f"transaction hash: {tx_hash}") else: print('Got an error response') print(json.dumps(response, indent=4)) return response
def _get_status(self, _from: KeyWallet): params = {"_gameroomId": _from.get_address()} call = CallBuilder().from_(_from.get_address())\ .to(self._sample_game_score_address) \ .method("getGameRoomStatus") \ .params(params) \ .build() # Sends the call request response = self.process_call(call, self.icon_service) return response
def setUpClass(cls): cls._score_root_path = '.testscore' cls._state_db_root_path = '.teststatedb' cls._icx_factor = 10**18 cls._genesis: 'KeyWallet' = KeyWallet.create() cls._fee_treasury: 'KeyWallet' = KeyWallet.create() cls._test1: 'KeyWallet' = KeyWallet.load( bytes.fromhex(TEST1_PRIVATE_KEY)) cls._wallet_array = [KeyWallet.load(v) for v in TEST_ACCOUNTS]
def __init__(self): self.handlers = [ self._set_revision, self._update_governance_score, self._set_step_cost, ] self.revision = 0 self.gs_version = "0.0.0" self.key_wallet = KeyWallet.load(bytes.fromhex(TEST1_PRIVATE_KEY)) self.preps = [] for prep in self.PREPS: self.preps.append(KeyWallet.load(prep)) uri, version = uri_parser("http://127.0.0.1:9000/api/v3") self.icon_service = IconService(HTTPProvider(uri, version))
def setUp(self): super().setUp() self.contracts = {} self.contracts['sicx1'] = "cx20fa65cffc720db31e78fba6db5d58f58babd933" self.contracts['staking1'] = "cx25c39ed0d27853e44af8ab2739d6af832f35d533" self.contracts['staking2'] = "cx8b250e76bc919f73068571c26cadecde69e63b46" self.contracts['staking3'] = "cx3502e9af253098d187578ca826fe71032f116e47" # WARNING: ICON service emulation is not working with IISS. # You can stake and delegate but can't get any I-Score for reward. # If you want to test IISS stuff correctly, set self.icon_service and send requests to the network self.icon_service = IconService(HTTPProvider(self.TEST_HTTP_ENDPOINT_URI_V3)) private2="093f12dba9dc75da81ecafc88de73ef9b311b555939aeb5a875dc6ad8feef424" private3="167f6ec1694ab63243efdce98f6f6bfdcef0575cefbb86ffe3826f8373f12b85" self._test2 = KeyWallet.load(bytes.fromhex(private2)) self._test3 = KeyWallet.load(bytes.fromhex(private3))
def test_make_key_store_content(self): # make keystore file content = KeyWallet.create() content.store(self.keystore_path, self.keystore_password) # get private key from keystore file # written_key = key_from_key_store(file_path=self.keystore_path, password=self.keystore_password) written_key = convert_hex_str_to_bytes( KeyWallet.load(self.keystore_path, self.keystore_password).get_private_key()) self.assertTrue(isinstance(written_key, bytes)) os.remove(self.keystore_path)
def add_token_test(request): # Withouth all the mapping fusiness. This just min ts the token and show it up #Connect to Federico wallet Method node_uri = "https://bicon.net.solidwallet.io/api/v3" network_id = 3 hello_world_address = "cx2a96ae73368ee622f29ea6df5a9e621059326feb" keystore_path = "./walletFEDEKEYSTORE.119Z--hx8bad34f951350f2805af083b50562529241c5baf" keystore_pw = "Darkarior448!" wallet = KeyWallet.load(keystore_path, keystore_pw) tester_addr = wallet.get_address() icon_service = IconService(HTTPProvider(node_uri)) #Checking the wallet data print("address: ", wallet.get_address()) # Returns an address print("private key: ", wallet.get_private_key()) # Returns a private key tester_addr = wallet.get_address() icon_service = IconService(HTTPProvider(node_uri)) service_adress = "cx312f84fa11a0d315ea4331c5e601d3c4897575f8" # TODO Here put the receiver address from the current logged in data receiver_address = tester_addr # Way to large # tokenId = uuid.uuid1().int tokenId_start = int(str(uuid.uuid1().int)[:5]) tokenId = tokenId_start + int(round(time.time() * 1000)) firebase_id = request.session['local_id'] champType = 1 addChampionToDB(firebase_id, tokenId, champType) params = { '_to': receiver_address, '_tokenId': tokenId, } transaction = CallTransactionBuilder().from_(tester_addr)\ .to(service_adress)\ .method("mint")\ .nid(3)\ .nonce(100)\ .params(params)\ .step_limit(1000000)\ .build() # Returns the signed transaction object having a signature signed_transaction = SignedTransaction(transaction, wallet) # Sends the transaction tx_hash = icon_service.send_transaction(signed_transaction) print(tx_hash) context = {'newChampionName': "example"} return render(request, join('core', 'champion_added.html'), context)
def icx_transfer_call(icon_integrate_test_base: IconIntegrateTestBase, from_: KeyWallet, to_: str, value: int = 0, icon_service: IconService = None) -> dict: """Sends the transaction sending ICX by using SDK :param icon_integrate_test_base: IconIntegrateTestBase :param from_: wallet address making a transaction :param to_: wallet address to receive coin or SCORE address to receive a transaction :param value: amount of ICX to be sent (Optional) :param icon_service: IconService :return: transaction result as dict """ # Generates an instance of transaction for calling method in SCORE. transaction = TransactionBuilder() \ .from_(from_.get_address()) \ .to(to_) \ .step_limit(10_000_000) \ .nid(3) \ .nonce(100) \ .value(value) \ .build() # Returns the signed transaction object having a signature signed_transaction = SignedTransaction(transaction, from_) # Sends the transaction to the network tx_result = icon_integrate_test_base.process_transaction( signed_transaction, icon_service) assert 'status' in tx_result assert 1 == tx_result['status'] return tx_result
def __gen_conf_file() -> list: result = [] if os.path.exists(FN_CLI_CONF) is False: result.append(FN_CLI_CONF[2:]) write_file('./', FN_CLI_CONF, json.dumps(tbears_cli_config, indent=4)) if os.path.exists(FN_SERVER_CONF) is False: result.append(FN_SERVER_CONF[2:]) server_config_json = make_server_config(tbears_server_config) write_file('./', FN_SERVER_CONF, json.dumps(server_config_json, indent=4)) # mkdir keystore keystore_dir = "./keystore" if os.path.exists(keystore_dir) is False: os.mkdir(keystore_dir) # gen keystore files write_file(keystore_dir, FN_KEYSTORE_TEST1, json.dumps(keystore_test1, indent=4)) # keystore file for main P-Rep main_prep_count = tbears_server_config.get(TConfigKey.PREP_MAIN_PREPS, 0) for i, prep in enumerate(TEST_ACCOUNTS[:main_prep_count]): wallet = KeyWallet.load(prep) wallet.store(file_path=os.path.join(keystore_dir, f"prep{i}_keystore"), password=f"prep{i}_Account") result.append(keystore_dir + "/*") return result
def __init__(self, node_conf_path: str, wallet_path: str, passwd: str): # Node configuration to be connected with open(node_conf_path, "r") as f: node_conf = json.load(f) self._my_chain_name = node_conf["chain_name"] self._nid = int(node_conf["nid"], 16) self.web_protocol = node_conf["web_protocol"] if self.web_protocol == "ssl": self._icon_service = IconService( HTTPProvider("https://" + node_conf["address"], 3)) self._ws_block = f"wss://{node_conf['address']}/api/ws/{node_conf['channel']}" elif self.web_protocol == "http": self._icon_service = IconService( HTTPProvider("http://" + node_conf["address"], 3)) self._ws_block = f"ws://{node_conf['address']}/api/node/{node_conf['channel']}" else: print("[error] Not supported web_protocol") sys.exit() # Set wallet of actor self._wallet = KeyWallet.load(wallet_path, passwd) self._score_info = node_conf["scores"]
def setUpClass(self): self._currentDirPath = path.abspath(path.dirname(__file__)) self._walletOfTest1 = KeyWallet.load( f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_TEST1}', 'test1_Account') self._walletOfUc = KeyWallet.load( f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_UC}', TEST_KEYSTORE_PW) self._walletOfProvider = KeyWallet.load( f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_PROVIDER}', TEST_KEYSTORE_PW) self._walletOfCustomer = KeyWallet.load( f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_CUSTOMER}', TEST_KEYSTORE_PW) self._iconService = IconService( HTTPProvider(TEST_HTTP_ENDPOINT_URI_V3))
def create_writer(url: str, nid: int, keystore_path: str, password: str) -> PRepToolsWriter: icon_service = create_icon_service(url) owner_wallet = KeyWallet.load(keystore_path, password) return PRepToolsWriter(icon_service, nid, owner_wallet)
def generate_tx(file, password, icx_value, to_addr, nid, api_url, is_send, timestamp): step_limit = 1000000 value = int(icx_value * 10**18) wallet = KeyWallet.load(file, password) owner_from_addr = wallet.get_address() transaction = TransactionBuilder() \ .from_(owner_from_addr) \ .to(to_addr) \ .step_limit(step_limit) \ .nid(int(nid)) \ .nonce(100) \ .value(value) \ .timestamp(timestamp)\ .build() signed_params = SignedTransaction(transaction, wallet) signed_payload = { 'jsonrpc': '2.0', 'method': "icx_sendTransaction", 'id': 1234, "params": signed_params.signed_transaction_dict } kvPrint("[before] signed_payload", json.dumps(signed_payload, indent=4, sort_keys=True)) kvPrint("[before] calculate the tx_hash", f"0x{generate_message(signed_params.signed_transaction_dict)}") if is_send: print("===== send tx =====") provider = HTTPProvider(f"{api_url}/api/v3") icon_service = IconService(provider) tx_hash = icon_service.send_transaction(signed_params) kvPrint(f"[after] sendTX() txResult", tx_hash) return signed_payload
def keyinfo(self, conf: dict): """Show a keystore information with the the specified path and password. :param conf: keyinfo command configuration """ password = conf.get('password', None) password = self._check_keyinfo(password) try: wallet = KeyWallet.load(conf['path'], password) key_info = { "address": wallet.get_address(), "publicKey": convert_bytes_to_hex_str(wallet.public_key) } if conf['privateKey']: key_info['privateKey'] = add_0x_prefix(wallet.get_private_key()) print(json.dumps(key_info, indent=4)) return key_info except KeyStoreException as e: print(e.args[0])
def __init__(self, node_conf_path: str, wallet_path: str, passwd: str): # Node configuration to be connected with open(node_conf_path, "r") as f: node_conf = json.load(f) self._my_chain_name = node_conf["chain_name"] self._nid = int(node_conf["nid"], 16) if node_conf["web_protocol"] == "ssl": self._icon_service = IconService( HTTPProvider("https://" + node_conf["address"], 3)) else: self._icon_service = IconService( HTTPProvider("http://" + node_conf["address"], 3)) print( f"--------------------------------<Connecting node>--------------------------------" ) print(f" - address : {node_conf['address']}") print(f" - chain_name : {self._my_chain_name}") print(f" - nid : {self._nid}") print( f"---------------------------------------------------------------------------------" ) # Set wallet of deployer self._wallet = KeyWallet.load(wallet_path, passwd) # print(f"pk: {self._wallet.get_private_key()}") # Set deployed score address self._score_addr = "" # It will be set after deployment self._score_path = "" self._score_params = {} self._score_info = ""
def _make_account(self, balance: int = 1000) -> 'KeyWallet': # create account account: 'KeyWallet' = KeyWallet.create() # Generates an instance of transaction for sending icx. transaction = TransactionBuilder() \ .from_(self._test1.get_address()) \ .to(account.get_address()) \ .value(balance) \ .step_limit(1000000) \ .nid(3) \ .nonce(100) \ .build() # Returns the signed transaction object having a signature signed_transaction = SignedTransaction(transaction, self._test1) # process the transaction tx_result = self.process_transaction(signed_transaction, self.icon_service) self.assertTrue('status' in tx_result) self.assertEqual(1, tx_result['status']) return account
def load_keystore(keystore, passwd=None): try: if passwd is None: passwd = getpass.getpass() return KeyWallet.load(keystore.name, passwd) except KeyStoreException as e: die(e.message)
def _transaction_call(self, from_: KeyWallet, to_: str, method: str, params: dict = None) -> dict: # Generates an instance of transaction for calling method in SCORE. transaction = CallTransactionBuilder() \ .from_(from_.get_address()) \ .to(to_) \ .step_limit(10_000_000) \ .nid(3) \ .nonce(100) \ .method(method) \ .params(params) \ .build() # Returns the signed transaction object having a signature signed_transaction = SignedTransaction(transaction, from_) # Sends the transaction to the network tx_result = self.process_transaction(signed_transaction, self.icon_service) self.assertTrue('status' in tx_result) self.assertEqual(1, tx_result['status']) return tx_result
def test_3_register_one_prep(self): account = KeyWallet.create() tx = self.create_transfer_icx_tx(self._test1, account.get_address(), 10**18) tx_result = self.process_transaction(tx, self.icon_service) self.assertEqual(tx_result['status'], 1) params = { "name": "banana node", "email": "*****@*****.**", "website": "https://banana.com", "details": "detail", "publicKey": "0x1234", "p2pEndPoint": "target://123.213.123.123:7100" } tx = self.create_register_prep_tx(account, params) tx_result = self.process_transaction(tx, self.icon_service) self.assertEqual(tx_result['status'], 1) # set prep on pre-voting params1 = { "name": "apple node", "email": "*****@*****.**", "website": "https://apple.com", "details": "detail", "p2pEndPoint": "target://123.213.123.123:7100" } tx = self.create_set_prep_tx(account, set_data=params1) tx_result = self.process_transaction(tx, self.icon_service) self.assertEqual(tx_result['status'], 1) response = self.get_prep(account) prep_data = response['registration'] self.assertEqual(prep_data['name'], params1['name']) self.assertEqual(prep_data['email'], params1['email']) self.assertEqual(prep_data['website'], params1['website']) self.assertEqual(prep_data['details'], params1['details']) self.assertEqual(prep_data['p2pEndPoint'], params1['p2pEndPoint']) # set irep on pre-voting irep = 40000 params = { "name": "apple node2", "email": "*****@*****.**", "website": "https://apple.com", "details": "detail", "p2pEndPoint": "target://123.213.123.123:7100", } tx = self.create_set_prep_tx(account, irep, params) tx_result = self.process_transaction(tx, self.icon_service) self.assertEqual(tx_result['status'], 0) response = self.get_prep(account) prep_data = response['registration'] self.assertEqual(prep_data['name'], params1['name']) self.assertEqual(prep_data['email'], params1['email']) self.assertEqual(prep_data['website'], params1['website']) self.assertEqual(prep_data['details'], params1['details']) self.assertEqual(prep_data['p2pEndPoint'], params1['p2pEndPoint']) self.assertNotEqual(prep_data['irep'], hex(irep))
def create_writer(keystore_path, password): icon_service = IconService() wallet = KeyWallet.load(keystore_path, password) writer = PRepToolsWriter(icon_service, 3, wallet) writer.set_on_send_request(lambda x: True) return writer
def setUp(self): self.wallet = KeyWallet.load(keystore_path, keystore_pw) self.tester_addr = self.wallet.get_address() self.icon_service = IconService(HTTPProvider(node_uri))