Add address declarator

This commit is contained in:
nolash 2021-10-10 14:06:40 +02:00
parent 5f126d8d59
commit 7f18b6d6d2
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 31 additions and 2 deletions

View File

@ -7,6 +7,7 @@ from chainlib.chain import ChainSpec
from chainlib.eth.tx import TxFormat
from chainlib.eth.connection import RPCConnection
from eth_token_index import TokenUniqueSymbolIndex
from eth_address_declarator import Declarator
logg = logging.getLogger(__name__)
@ -37,7 +38,7 @@ class CICEth:
def process_token_index(self):
c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer) # tx_format = None
c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer)
contract_address = self.resources['token_index']['reference']
signer_address = self.resources['token_index']['key_address']
@ -54,6 +55,26 @@ class CICEth:
return r
def process_address_declarator(self):
c = Declarator(self.chain_spec, signer=self.signer)
contract_address = self.resources['address_declarator']['reference']
signer_address = self.resources['address_declarator']['key_address']
r = []
for proof in self.proofs:
o = c.add_declaration(contract_address, signer_address, self.token_address, proof, tx_format=self.tx_format)
if self.rpc != None:
r.append(self.rpc.do(o[1]))
elif self.signer != None:
r.append(o[1])
else:
r.append(o)
self.outputs += r
return r
def process(self):
self.token_address = self.resources['token']['reference']
if self.token_address == None:

View File

@ -35,6 +35,10 @@ class TestCICEthBase(EthTesterCase):
'reference': self.token_index_address,
'key_address': addresses[1],
},
'address_declarator': {
'reference': self.token_index_address,
'key_address': addresses[2],
},
}
self.proofs = []
for i in range(3):

View File

@ -22,7 +22,11 @@ class TestCICEthOffline(TestCICEthBase):
def test_offline_address_declarator(self):
pass
self.adapter.token_address = self.token_address
v = self.adapter.process_address_declarator()
self.assertEqual(v[0][:8], 'ae47ece0')
self.assertEqual(len(v), 3)
if __name__ == '__main__':
unittest.main()