mirror of
				git://holbrook.no/eth-accounts-index
				synced 2025-11-04 12:48:24 +01:00 
			
		
		
		
	Repair token count
This commit is contained in:
		
							parent
							
								
									6dd8e9b55e
								
							
						
					
					
						commit
						1493f7d860
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -94,6 +94,11 @@ class AccountsIndex(TxFactory):
 | 
			
		||||
        return abi_decode_single(ABIContractType.ADDRESS, v)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def parse_entry_count(self, v):
 | 
			
		||||
        return abi_decode_single(ABIContractType.UINT256, v)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def parse_have(self, v):
 | 
			
		||||
        return abi_decode_single(ABIContractType.BOOLEAN, v)
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
[metadata]
 | 
			
		||||
name = eth-accounts-index
 | 
			
		||||
version = 0.0.11a11
 | 
			
		||||
version = 0.0.11a12
 | 
			
		||||
description = Accounts index evm contract tooling with permissioned writes
 | 
			
		||||
author = Louis Holbrook
 | 
			
		||||
author_email = dev@holbrook.no
 | 
			
		||||
 | 
			
		||||
@ -97,12 +97,44 @@ class Test(EthTesterCase):
 | 
			
		||||
 | 
			
		||||
        nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
 | 
			
		||||
        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)
 | 
			
		||||
        #r = self.conn.do(o)
 | 
			
		||||
        #self.assertEqual(tx_hash, r)
 | 
			
		||||
        (tx_hash, o) = c.add(self.address, self.accounts[0], a) #, tx_format=TxFormat.RLP_SIGNED)
 | 
			
		||||
        r = self.conn.do(o)
 | 
			
		||||
        self.assertEqual(tx_hash, r)
 | 
			
		||||
        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
 | 
			
		||||
#    def test_access(self):
 | 
			
		||||
#        registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
 | 
			
		||||
@ -129,14 +161,7 @@ class Test(EthTesterCase):
 | 
			
		||||
#        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):
 | 
			
		||||
#        registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
 | 
			
		||||
#        tx_hash = registry.add(self.w3.eth.accounts[2])
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@ contract CustodialAccountIndex {
 | 
			
		||||
 | 
			
		||||
	// Implements AccountsIndex
 | 
			
		||||
	function entryCount() public returns (uint256) {
 | 
			
		||||
		return count - 1;
 | 
			
		||||
		return entries.length - 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Implements EIP173
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user