Repair token count

This commit is contained in:
nolash 2021-05-13 17:55:05 +02:00
parent 6dd8e9b55e
commit 1493f7d860
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 44 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -94,6 +94,11 @@ class AccountsIndex(TxFactory):
return abi_decode_single(ABIContractType.ADDRESS, v) return abi_decode_single(ABIContractType.ADDRESS, v)
@classmethod
def parse_entry_count(self, v):
return abi_decode_single(ABIContractType.UINT256, v)
@classmethod @classmethod
def parse_have(self, v): def parse_have(self, v):
return abi_decode_single(ABIContractType.BOOLEAN, v) return abi_decode_single(ABIContractType.BOOLEAN, v)

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = eth-accounts-index name = eth-accounts-index
version = 0.0.11a11 version = 0.0.11a12
description = Accounts index evm contract tooling with permissioned writes description = Accounts index evm contract tooling with permissioned writes
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no

View File

@ -97,12 +97,44 @@ class Test(EthTesterCase):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash, o) = c.add(self.address, self.accounts[0], a, tx_format=TxFormat.RLP_SIGNED) (tx_hash, o) = c.add(self.address, self.accounts[0], a) #, tx_format=TxFormat.RLP_SIGNED)
#r = self.conn.do(o) r = self.conn.do(o)
#self.assertEqual(tx_hash, r) self.assertEqual(tx_hash, r)
logg.debug('o {}'.format(o)) logg.debug('o {}'.format(o))
def test_4_indices(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
o = c.entry_count(self.address, sender_address=self.accounts[0])
r = self.conn.do(o)
count = c.parse_entry_count(r)
self.assertEqual(count, 0)
b = os.urandom(20)
a = to_checksum_address(b.hex())
(tx_hash, o) = c.add(self.address, self.accounts[0], a)
r = self.conn.do(o)
b = os.urandom(20)
aa = to_checksum_address(b.hex())
(tx_hash, o) = c.add(self.address, self.accounts[0], aa)
r = self.conn.do(o)
o = c.entry_count(self.address, sender_address=self.accounts[0])
r = self.conn.do(o)
count = c.parse_entry_count(r)
self.assertEqual(count, 2)
#registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
#registry.add(self.w3.eth.accounts[2])
#self.assertFalse(registry.have(self.w3.eth.accounts[3]))
# TODO: reinstate all tests # TODO: reinstate all tests
# def test_access(self): # def test_access(self):
# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) # registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
@ -129,14 +161,7 @@ class Test(EthTesterCase):
# self.assertEqual(registry.count(), 3) # self.assertEqual(registry.count(), 3)
# #
# #
# def test_indices(self):
# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
# registry.add(self.w3.eth.accounts[2])
#
# self.assertTrue(registry.have(self.w3.eth.accounts[2]))
# self.assertFalse(registry.have(self.w3.eth.accounts[3]))
#
#
# def test_no_duplicates(self): # def test_no_duplicates(self):
# registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1]) # registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
# tx_hash = registry.add(self.w3.eth.accounts[2]) # tx_hash = registry.add(self.w3.eth.accounts[2])

View File

@ -54,7 +54,7 @@ contract CustodialAccountIndex {
// Implements AccountsIndex // Implements AccountsIndex
function entryCount() public returns (uint256) { function entryCount() public returns (uint256) {
return count - 1; return entries.length - 1;
} }
// Implements EIP173 // Implements EIP173