def test_new_from_user_input_defaults(self, mock_check_chain_id): client = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 1 }) self.assertEqual(client.chain_id, 1) self.assertTrue( bool(client.address) ) # Ensure we got an address (private key was generated for us) self.assertEqual( client.rpc_address, "http://internal-Parity-Mainnet-Internal-1844666982.us-west-2.elb.amazonaws.com:8545" ) mock_check_chain_id.return_value = 3 client = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 3 }) self.assertEqual( client.rpc_address, "http://internal-Parity-Ropsten-Internal-1699752391.us-west-2.elb.amazonaws.com:8545" ) mock_check_chain_id.return_value = 1 client = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 61 }) self.assertEqual( client.rpc_address, "http://internal-Parity-Classic-Internal-2003699904.us-west-2.elb.amazonaws.com:8545" ) self.assertEqual(client.chain_id, 61) # Ensure the chain id for ETC mainnet is correct mock_check_chain_id.return_value = 2 client = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 62 }) self.assertEqual( client.rpc_address, "http://internal-Parity-Morden-Internal-26081757.us-west-2.elb.amazonaws.com:8545" ) self.assertEqual(client.chain_id, 62) # Ensure the chain id for ETC testnet is correct
def create_ethereum_interchain_v1(user_data: Dict[str, Any], conflict_check: bool = True) -> Dict[str, Any]: client = eth.new_from_user_input(user_data) if conflict_check and interchain_dao.does_interchain_exist("ethereum", client.name): _log.error("Ethereum network is already registered") raise exceptions.InterchainConflict(f"An ethereum interchain network with the name {client.name} is already registered") interchain_dao.save_interchain_client(client) return _get_output_dto_v1(client)
def test_new_from_user_input_sets_good_private_keys( self, mock_check_chain_id): # Good hex key without 0x clienta = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 1, "private_key": "7796b9ac433fab2a83d281e8064f29c935133139b62ec52c8e73de28440c0dc6" }) # Good hex key with 0x clientb = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 1, "private_key": "0x7796b9ac433fab2a83d281e8064f29c935133139b62ec52c8e73de28440c0dc6" }) # Good base64 key clientc = eth.new_from_user_input({ "version": "1", "name": "banana", "chain_id": 1, "private_key": "d5a5rEM/qyqD0oHoBk8pyTUTMTm2LsUsjnPeKEQMDcY=" }) self.assertEqual( clienta.priv_key.to_bytes(), b"w\x96\xb9\xacC?\xab*\x83\xd2\x81\xe8\x06O)\xc95\x1319\xb6.\xc5,\x8es\xde(D\x0c\r\xc6" ) self.assertEqual( clientb.priv_key.to_bytes(), b"w\x96\xb9\xacC?\xab*\x83\xd2\x81\xe8\x06O)\xc95\x1319\xb6.\xc5,\x8es\xde(D\x0c\r\xc6" ) self.assertEqual( clientc.priv_key.to_bytes(), b"w\x96\xb9\xacC?\xab*\x83\xd2\x81\xe8\x06O)\xc95\x1319\xb6.\xc5,\x8es\xde(D\x0c\r\xc6" )
def create_ethereum_interchain_v1(user_data: Dict[str, Any]) -> Dict[str, Any]: client = eth.new_from_user_input(user_data) interchain_dao.save_interchain_client(client) return _get_output_dto_v1(client)