Sohail/fix duplicate token entry base 0.4.0 (#3)

* feat: remove unique token check from register fn

* tests: add duplicate entry test

- add FOO
- add FOO

* bump: v0.4.1
master
Mohamed Sohail 5 months ago committed by GitHub
parent 179a6d4e03
commit 9bad5b5ccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      python/okota/data/TokenUniqueSymbolIndexAddressDeclarator.bin
  2. 2
      python/setup.cfg
  3. 33
      python/tests/test_tokenindex.py
  4. 3
      solidity/TokenUniqueSymbolIndexAddressDeclarator.sol

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
[metadata]
name = okota
version = 0.4.0
version = 0.4.1
description = Registries for CIC using the eth-address-index backend
author = Louis Holbrook
author_email = dev@holbrook.no

@ -25,7 +25,7 @@ from okota.token_index.index import (
# test imports
from eth_address_declarator.unittest import TestAddressDeclaratorBase
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.INFO)
logg = logging.getLogger()
testdir = os.path.dirname(__file__)
@ -54,12 +54,11 @@ class TestTokenIndex(TestAddressDeclaratorBase):
r = self.rpc.do(o)
self.assertEqual(r['status'], 1)
def test_register(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = CICTokenIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
logg.info('using token index {}'.format(self.token_index_address))
(tx_hash_hex, o) = c.add(self.token_index_address, self.accounts[0], self.foo_token_address)
self.rpc.do(o)
e = unpack(bytes.fromhex(strip_0x(o['params'][0])), self.chain_spec)
@ -99,6 +98,34 @@ class TestTokenIndex(TestAddressDeclaratorBase):
identifier = to_identifier('foo')
self.assertEqual(proofs[0], identifier)
def test_duplicate_entry(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
gft = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = gft.constructor(self.accounts[0], 'FooTokenRedeploy', 'FOO', 6)
self.rpc.do(o)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
self.assertEqual(r['status'], 1)
self.foo_token_address_redeploy = r['contract_address']
logg.info('second foo token deployed with address {}'.format(self.foo_token_address_redeploy))
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = CICTokenIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
logg.info('using token index {}'.format(self.token_index_address))
(tx_hash_hex, o) = c.add(self.token_index_address, self.accounts[0], self.foo_token_address_redeploy)
self.rpc.do(o)
e = unpack(bytes.fromhex(strip_0x(o['params'][0])), self.chain_spec)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
self.assertEqual(r['status'], 1)
o = c.address_of(self.token_index_address, 'FOO', sender_address=self.accounts[0])
r = self.rpc.do(o)
address = c.parse_address_of(r)
self.assertEqual(address, strip_0x(self.foo_token_address_redeploy))
if __name__ == '__main__':
unittest.main()

@ -55,9 +55,6 @@ contract TokenUniqueSymbolIndexAddressDeclarator {
require(ok);
require(r[31] == 0x01);
idx = registry[token_symbol_key];
require(idx == 0);
registry[token_symbol_key] = tokens.length;
tokens.push(_token);

Loading…
Cancel
Save