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
|
- 0.6.3
|
||||||
* Add contract metadata
|
* Add contract metadata
|
||||||
- 0.6.2
|
- 0.6.2
|
||||||
|
@ -12,7 +12,7 @@ from giftable_erc20_token import GiftableToken
|
|||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from eth_address_declarator.declarator import AddressDeclarator
|
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)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = eth-address-index
|
name = eth-address-index
|
||||||
version = 0.7.0
|
version = 0.7.1
|
||||||
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
|
||||||
|
@ -149,113 +149,117 @@ class TestAddressDeclarator(TestAddressDeclaratorBase):
|
|||||||
self.assertEqual(strip_0x(r)[128:], strip_0x(v_two))
|
self.assertEqual(strip_0x(r)[128:], strip_0x(v_two))
|
||||||
|
|
||||||
|
|
||||||
# def test_declarator_to_subject(self):
|
def test_declarator_to_subject(self):
|
||||||
# d = add_0x(os.urandom(32).hex())
|
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)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, d)
|
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# self.rpc.do(o)
|
(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)
|
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, d)
|
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# self.rpc.do(o)
|
(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)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, d)
|
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# self.rpc.do(o)
|
(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)
|
o = c.declaration_address_at(self.address, self.accounts[1], 0, sender_address=self.accounts[0])
|
||||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
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)
|
o = c.declaration_address_at(self.address, self.accounts[2], 0, sender_address=self.accounts[0])
|
||||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
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)
|
o = c.declaration_address_at(self.address, self.accounts[1], 1, sender_address=self.accounts[0])
|
||||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.bar_token_address))
|
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()
|
def test_subject_to_declarator(self):
|
||||||
#
|
k = add_0x(os.urandom(32).hex())
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
v = add_0x(os.urandom(32).hex())
|
||||||
# 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)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# self.rpc.do(o)
|
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)
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
self.rpc.do(o)
|
||||||
# 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)
|
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||||
# self.rpc.do(o)
|
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)
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
self.rpc.do(o)
|
||||||
# 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)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# self.rpc.do(o)
|
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)
|
||||||
# o = c.declarator_address_at(self.address, self.foo_token_address, 0, sender_address=self.accounts[0])
|
self.rpc.do(o)
|
||||||
# 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, 0, sender_address=self.accounts[0])
|
||||||
#
|
r = self.rpc.do(o)
|
||||||
# o = c.declarator_address_at(self.address, self.foo_token_address, 1, sender_address=self.accounts[0])
|
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[1]))
|
||||||
# r = self.rpc.do(o)
|
|
||||||
# self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
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):
|
def test_three_first(self):
|
||||||
# d.append(add_0x(os.urandom(32).hex()))
|
k = add_0x(os.urandom(32).hex())
|
||||||
#
|
v = []
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
for i in range(3):
|
||||||
# c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
v.append(add_0x(os.urandom(32).hex()))
|
||||||
#
|
|
||||||
# for proof in d:
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof)
|
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# self.rpc.do(o)
|
|
||||||
#
|
for proof in v:
|
||||||
# o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof, topic=k)
|
||||||
# r = self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# self.assertEqual(c.parse_declarator_count(r), 1)
|
|
||||||
#
|
o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
||||||
# o = c.declaration(self.address, self.accounts[0], self.foo_token_address, sender_address=self.accounts[0])
|
r = self.rpc.do(o)
|
||||||
# r = self.rpc.do(o)
|
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||||
# proofs = c.parse_declaration(r)
|
|
||||||
# self.assertEqual(len(proofs), 3)
|
o = c.declaration(self.address, self.accounts[0], self.foo_token_address, topic=k, sender_address=self.accounts[0])
|
||||||
#
|
r = self.rpc.do(o)
|
||||||
# for i in range(3):
|
proofs = c.parse_declaration(r)
|
||||||
# self.assertEqual(proofs[i], strip_0x(d[i]))
|
self.assertEqual(len(proofs), 3)
|
||||||
#
|
|
||||||
#
|
for i in range(3):
|
||||||
# def test_three_first_different(self):
|
self.assertEqual(proofs[i], strip_0x(v[i]))
|
||||||
# d = []
|
|
||||||
# a = []
|
|
||||||
# for i in range(3):
|
def test_three_first_different(self):
|
||||||
# d.append(add_0x(os.urandom(32).hex()))
|
k = add_0x(os.urandom(32).hex())
|
||||||
# a.append(add_0x(os.urandom(20).hex()))
|
v = []
|
||||||
#
|
a = []
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
for i in range(3):
|
||||||
# c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
v.append(add_0x(os.urandom(32).hex()))
|
||||||
#
|
a.append(add_0x(os.urandom(20).hex()))
|
||||||
# for i in range(3):
|
|
||||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], a[i], d[i])
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# self.rpc.do(o)
|
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
#
|
|
||||||
# for i in range(3):
|
for i in range(3):
|
||||||
# o = c.declarator_count(self.address, a[i], sender_address=self.accounts[0])
|
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], a[i], v[i], topic=k)
|
||||||
# r = self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# self.assertEqual(c.parse_declarator_count(r), 1)
|
|
||||||
#
|
for i in range(3):
|
||||||
# o = c.declaration(self.address, self.accounts[0], a[i], sender_address=self.accounts[0])
|
o = c.declarator_count(self.address, a[i], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# proofs = c.parse_declaration(r)
|
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||||
# self.assertEqual(len(proofs), 1)
|
|
||||||
# self.assertEqual(proofs[0], strip_0x(d[i]))
|
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__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
pragma solidity >0.6.11;
|
pragma solidity >0.6.11;
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
contract AddressDeclarator {
|
contract AddressDeclarator {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user