Rehabilitate tests

This commit is contained in:
nolash 2021-04-30 16:15:25 +02:00
parent 44c077c8d3
commit 7afd00cfb8
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
10 changed files with 45 additions and 30 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceCode","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceCode","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_toAddress","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = eth-address-index name = eth-address-index
version = 0.1.1a9 version = 0.1.1a10
description = Signed metadata declarations for ethereum addresses description = Signed metadata declarations for ethereum addresses
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no

View File

@ -35,7 +35,8 @@ class Test(EthTesterCase):
super(Test, self).setUp() super(Test, self).setUp()
self.description = add_0x(os.urandom(32).hex()) self.description = add_0x(os.urandom(32).hex())
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id()) #c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(self.accounts[0], self.description) (tx_hash_hex, o) = c.constructor(self.accounts[0], self.description)
self.rpc.do(o) self.rpc.do(o)
@ -45,7 +46,8 @@ class Test(EthTesterCase):
self.address = r['contract_address'] self.address = r['contract_address']
c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id()) #c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6) (tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6)
self.rpc.do(o) self.rpc.do(o)
@ -55,7 +57,8 @@ class Test(EthTesterCase):
self.foo_token_address = r['contract_address'] self.foo_token_address = r['contract_address']
c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id()) #c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(self.accounts[0], 'BarToken', 'BAR', 6) (tx_hash_hex, o) = c.constructor(self.accounts[0], 'BarToken', 'BAR', 6)
self.rpc.do(o) self.rpc.do(o)
@ -66,23 +69,22 @@ class Test(EthTesterCase):
self.bar_token_address = r['contract_address'] self.bar_token_address = r['contract_address']
def test_basic(self): def test_basic(self):
d = add_0x(os.urandom(32).hex()) d = add_0x(os.urandom(32).hex())
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.bar_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.bar_token_address, d)
self.rpc.do(o) self.rpc.do(o)
@ -101,20 +103,20 @@ class Test(EthTesterCase):
d_two = add_0x(os.urandom(32).hex()) d_two = add_0x(os.urandom(32).hex())
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d_two) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d_two)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.bar_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.bar_token_address, d)
self.rpc.do(o) self.rpc.do(o)
@ -130,17 +132,17 @@ class Test(EthTesterCase):
d = add_0x(os.urandom(32).hex()) d = add_0x(os.urandom(32).hex())
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, d)
self.rpc.do(o) self.rpc.do(o)
@ -161,17 +163,17 @@ class Test(EthTesterCase):
d = '0x' + os.urandom(32).hex() d = '0x' + os.urandom(32).hex()
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d)
self.rpc.do(o) self.rpc.do(o)
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
c = AddressDeclarator(signer=self.signer, nonce_oracle=nonce_oracle) c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, d) (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, d)
self.rpc.do(o) self.rpc.do(o)

View File

@ -30,7 +30,8 @@ class Test(EthTesterCase):
def setUp(self): def setUp(self):
super(Test, self).setUp() super(Test, self).setUp()
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = TokenUniqueSymbolIndex(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id()) #c = TokenUniqueSymbolIndex(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(self.accounts[0]) (tx_hash_hex, o) = c.constructor(self.accounts[0])
self.rpc.do(o) self.rpc.do(o)
@ -40,7 +41,8 @@ class Test(EthTesterCase):
self.address = r['contract_address'] self.address = r['contract_address']
c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id()) #c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6) (tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6)
self.rpc.do(o) self.rpc.do(o)
@ -53,11 +55,12 @@ class Test(EthTesterCase):
def test_register(self): def test_register(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
c = TokenUniqueSymbolIndex(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id()) #c = TokenUniqueSymbolIndex(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.register(self.address, self.accounts[0], self.token_address) (tx_hash_hex, o) = c.register(self.address, self.accounts[0], self.token_address)
self.rpc.do(o) self.rpc.do(o)
e = unpack(bytes.fromhex(strip_0x(o['params'][0])), chain_id=self.chain_spec.chain_id()) e = unpack(bytes.fromhex(strip_0x(o['params'][0])), self.chain_spec)
logg.debug('e {}'.format(e)) logg.debug('e {}'.format(e))
o = receipt(tx_hash_hex) o = receipt(tx_hash_hex)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceCode","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceCode","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_toAddress","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

View File

@ -6,6 +6,7 @@ contract TokenUniqueSymbolIndex {
// EIP 173 // EIP 173
address public owner; address public owner;
address newOwner;
mapping ( bytes32 => uint256 ) public registry; mapping ( bytes32 => uint256 ) public registry;
address[] tokens; address[] tokens;
@ -26,15 +27,17 @@ contract TokenUniqueSymbolIndex {
return false; return false;
} }
// Implements AccountsIndex
function entry(uint256 _idx) public view returns ( address ) { function entry(uint256 _idx) public view returns ( address ) {
return tokens[_idx + 1]; return tokens[_idx + 1];
} }
// EIP 173 // EIP 173
function transferOwnership() public { function transferOwnership(address _toAddress) public returns (bool) {
revert("owner cannot be changed"); require(ms
} }
// Implements Registry
function addressOf(bytes32 _key) public view returns ( address ) { function addressOf(bytes32 _key) public view returns ( address ) {
uint256 idx; uint256 idx;
@ -63,6 +66,13 @@ contract TokenUniqueSymbolIndex {
return true; return true;
} }
// Implements AccountsIndex
function add(address _token) public returns (bool) {
return register(_token);
}
// Implements AccountsIndex
function entryCount() public view returns ( uint256 ) { function entryCount() public view returns ( uint256 ) {
return tokens.length - 1; return tokens.length - 1;
} }