mirror of
git://holbrook.no/eth-address-index
synced 2024-11-27 02:36:45 +01:00
Implement all default tests for kv
This commit is contained in:
parent
8521b32382
commit
155f8caf9b
@ -1,3 +1,7 @@
|
||||
- 0.7.1
|
||||
* Add topic option to declarations
|
||||
- 0.7.0
|
||||
* Change license
|
||||
- 0.6.3
|
||||
* Add contract metadata
|
||||
- 0.6.2
|
||||
|
@ -12,7 +12,7 @@ from giftable_erc20_token import GiftableToken
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator.declarator import AddressDeclarator
|
||||
from eth_address_declarator.kv import AddressDeclaratorKV
|
||||
#from eth_address_declarator.kv import AddressDeclaratorKV
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logg = logging.getLogger()
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = eth-address-index
|
||||
version = 0.7.0
|
||||
version = 0.7.1
|
||||
description = Signed metadata declarations for ethereum addresses
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
@ -149,113 +149,117 @@ class TestAddressDeclarator(TestAddressDeclaratorBase):
|
||||
self.assertEqual(strip_0x(r)[128:], strip_0x(v_two))
|
||||
|
||||
|
||||
# def test_declarator_to_subject(self):
|
||||
# d = add_0x(os.urandom(32).hex())
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
# c = Declarator(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)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
# c = Declarator(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)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
# c = Declarator(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)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# o = c.declaration_address_at(self.address, self.accounts[1], 0, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
||||
#
|
||||
# o = c.declaration_address_at(self.address, self.accounts[2], 0, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
||||
#
|
||||
# o = c.declaration_address_at(self.address, self.accounts[1], 1, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.bar_token_address))
|
||||
#
|
||||
#
|
||||
# def test_subject_to_declarator(self):
|
||||
# d = '0x' + os.urandom(32).hex()
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
# c = Declarator(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)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
# c = Declarator(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)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
# c = Declarator(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)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# o = c.declarator_address_at(self.address, self.foo_token_address, 0, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[1]))
|
||||
#
|
||||
# o = c.declarator_address_at(self.address, self.foo_token_address, 1, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
||||
#
|
||||
#
|
||||
# def test_three_first(self):
|
||||
# d = []
|
||||
# for i in range(3):
|
||||
# d.append(add_0x(os.urandom(32).hex()))
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
# c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
#
|
||||
# for proof in d:
|
||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
#
|
||||
# o = c.declaration(self.address, self.accounts[0], self.foo_token_address, sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# proofs = c.parse_declaration(r)
|
||||
# self.assertEqual(len(proofs), 3)
|
||||
#
|
||||
# for i in range(3):
|
||||
# self.assertEqual(proofs[i], strip_0x(d[i]))
|
||||
#
|
||||
#
|
||||
# def test_three_first_different(self):
|
||||
# d = []
|
||||
# a = []
|
||||
# for i in range(3):
|
||||
# d.append(add_0x(os.urandom(32).hex()))
|
||||
# a.append(add_0x(os.urandom(20).hex()))
|
||||
#
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
# c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
#
|
||||
# for i in range(3):
|
||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], a[i], d[i])
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# for i in range(3):
|
||||
# o = c.declarator_count(self.address, a[i], sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
#
|
||||
# o = c.declaration(self.address, self.accounts[0], a[i], sender_address=self.accounts[0])
|
||||
# r = self.rpc.do(o)
|
||||
# proofs = c.parse_declaration(r)
|
||||
# self.assertEqual(len(proofs), 1)
|
||||
# self.assertEqual(proofs[0], strip_0x(d[i]))
|
||||
def test_declarator_to_subject(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(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, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
c = Declarator(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, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(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, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declaration_address_at(self.address, self.accounts[1], 0, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
||||
|
||||
o = c.declaration_address_at(self.address, self.accounts[2], 0, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
||||
|
||||
o = c.declaration_address_at(self.address, self.accounts[1], 1, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.bar_token_address))
|
||||
|
||||
|
||||
def test_subject_to_declarator(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(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, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
c = Declarator(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, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(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, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declarator_address_at(self.address, self.foo_token_address, 0, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[1]))
|
||||
|
||||
o = c.declarator_address_at(self.address, self.foo_token_address, 1, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
||||
|
||||
|
||||
def test_three_first(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = []
|
||||
for i in range(3):
|
||||
v.append(add_0x(os.urandom(32).hex()))
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
for proof in v:
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[0], self.foo_token_address, topic=k, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
proofs = c.parse_declaration(r)
|
||||
self.assertEqual(len(proofs), 3)
|
||||
|
||||
for i in range(3):
|
||||
self.assertEqual(proofs[i], strip_0x(v[i]))
|
||||
|
||||
|
||||
def test_three_first_different(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = []
|
||||
a = []
|
||||
for i in range(3):
|
||||
v.append(add_0x(os.urandom(32).hex()))
|
||||
a.append(add_0x(os.urandom(20).hex()))
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
for i in range(3):
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], a[i], v[i], topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
for i in range(3):
|
||||
o = c.declarator_count(self.address, a[i], sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[0], a[i], topic=k, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
proofs = c.parse_declaration(r)
|
||||
self.assertEqual(len(proofs), 1)
|
||||
self.assertEqual(proofs[0], strip_0x(v[i]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,6 +1,6 @@
|
||||
pragma solidity >0.6.11;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
contract AddressDeclarator {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user