From e7fcde7530a6093235660daed758c76e84669e72 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 29 Nov 2021 15:39:16 +0100 Subject: [PATCH] Remove randbytes call --- cic/ext/eth/__init__.py | 22 ++++++++++++++++++++-- cic/ext/eth/rpc.py | 14 ++++++++++++++ tests/base_cic.py | 18 +++++++++++++----- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/cic/ext/eth/__init__.py b/cic/ext/eth/__init__.py index d2c3bfa..0145524 100644 --- a/cic/ext/eth/__init__.py +++ b/cic/ext/eth/__init__.py @@ -38,7 +38,25 @@ logg = logging.getLogger(__name__) class CICEth(Extension): def __init__(self, chain_spec, resources, proof, signer=None, rpc=None, outputs_writer=None, fee_oracle=None): - """resources will be modified + + """Implementation for the eth extension. + + The state of the resources instance will be modified. + + :param chain_spec: Chain Spec that extension will operate for + :type chain_spec: chainlib.chain.ChainSpec + :param resources: Chain application resources to deploy or interface with + :type resources: dict + :param proof: Proof object to publish + :type proof: cic.proof.Proof + :param signer: Signer capable of generating signatures for chain aplication deployments + :type signer: funga.signer.Signer + :param rpc: RPC adapter capable of submitting and querying the chain network node + :type rpc: chainlib.connection.RPCConnection + :param outputs_writer: Writer interface receiving the output of the processor + :type outputs_writer: cic.output.OutputWriter + :param fee_oracle: Fee oracle required by signer + :type fee_oracle: chainlib.fee.FeeOracle """ super(CICEth, self).__init__(chain_spec, resources, proof, signer=signer, rpc=rpc, outputs_writer=outputs_writer) self.fee_oracle = fee_oracle @@ -48,7 +66,7 @@ class CICEth(Extension): elif self.signer != None: self.tx_format = TxFormat.RLP_SIGNED - + def __detect_arg_type(self, v): typ = None try: diff --git a/cic/ext/eth/rpc.py b/cic/ext/eth/rpc.py index 9130084..8d53582 100644 --- a/cic/ext/eth/rpc.py +++ b/cic/ext/eth/rpc.py @@ -16,11 +16,25 @@ logg = logging.getLogger(__name__) class EthKeystoreDirectory(DictKeystore, KeystoreDirectory): + """Combination of DictKeystore and KeystoreDirectory + + TODO: Move to funga + """ pass def parse_adapter(config, signer_hint): + """Determine and instantiate signer and rpc from configuration. + + If either could not be determined, None is returned. + :param config: Configuration object implementing the get() method + :type config: dict, object with get() + :param signer_hint: Signer resource description (e.g. keystore directory) + :type signer_hint: str + :rtype: tuple; chainlib.connection.RPCConnection, funga.signer.Signer + :return: RPC interface, signer interface + """ keystore = None if signer_hint == None: logg.info('signer hint missing') diff --git a/tests/base_cic.py b/tests/base_cic.py index 75d7f45..e50c7dc 100644 --- a/tests/base_cic.py +++ b/tests/base_cic.py @@ -31,11 +31,19 @@ class TestCICBase(unittest.TestCase): super(TestCICBase, self).setUp() random.seed(42) - addresses = [ - add_0x(random.randbytes(20).hex()), - add_0x(random.randbytes(20).hex()), - add_0x(random.randbytes(20).hex()), - ] + f = open('/dev/urandom', 'rb') + addresses = [] + for i in range(3): + address_bytes = f.read(32) + addresses.append(add_0x(address_bytes.hex())) + f.close() + +# addresses = [ +# add_0x(random.randbytes(20).hex()), +# add_0x(random.randbytes(20).hex()), +# add_0x(random.randbytes(20).hex()), +# ] + self.token_symbol = 'FOO' self.token_address = add_0x(random.randbytes(32).hex()) self.token_index_address = add_0x(random.randbytes(32).hex())