rehabilitate tests, replace seal with transferownership

This commit is contained in:
nolash
2021-04-30 12:01:08 +02:00
parent ddfb1d3e01
commit 657137efb0
9 changed files with 27 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
# external imports
from chainlib.eth.pytest import *
from contract_registry.pytest import *
from eth_contract_registry.pytest import *

View File

@@ -22,9 +22,9 @@ from hexathon import (
)
# local imports
from contract_registry.registry import Registry
from contract_registry.encoding import from_identifier_hex
from contract_registry.pytest.fixtures_registry import valid_identifiers
from eth_contract_registry.registry import Registry
from eth_contract_registry.encoding import from_identifier_hex
from eth_contract_registry.pytest.fixtures_registry import valid_identifiers
logg = logging.getLogger()
@@ -33,43 +33,33 @@ valid_identifiers += [
]
def test_set(
default_chain_spec,
registry,
eth_accounts,
eth_rpc,
eth_signer,
roles,
):
addr_registry = to_checksum_address(os.urandom(20).hex())
addr_foo = to_checksum_address(os.urandom(20).hex())
bogus_hash = add_0x(os.urandom(32).hex())
#conn = RPCConnection.connect('default')
nonce_oracle = RPCNonceOracle(eth_accounts[0], eth_rpc)
builder = Registry(signer=eth_signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = builder.set(registry, eth_accounts[0], 'ContractRegistry', addr_registry, bogus_hash, bogus_hash)
r = eth_rpc.do(o)
o = receipt(r)
rcpt = eth_rpc.do(o)
assert rcpt['status'] == 1
o = builder.identifier(registry, 0, sender_address=eth_accounts[0])
r = eth_rpc.do(o)
r = from_identifier_hex(r)
assert r == 'ContractRegistry'
nonce_oracle = RPCNonceOracle(roles['CONTRACT_DEPLOYER'], eth_rpc)
builder = Registry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle)
o = builder.address_of(registry, 'ContractRegistry', sender_address=eth_accounts[0])
r = eth_rpc.do(o)
r = abi_decode_single(ABIContractType.ADDRESS, r)
assert r == addr_registry
assert r == registry
(tx_hash_hex, o) = builder.set(registry, eth_accounts[0], 'ContractRegistry', addr_registry, bogus_hash, bogus_hash)
(tx_hash_hex, o) = builder.set(registry, roles['CONTRACT_DEPLOYER'], 'ContractRegistry', addr_registry, bogus_hash, bogus_hash)
r = eth_rpc.do(o)
o = receipt(r)
rcpt = eth_rpc.do(o)
assert rcpt['status'] == 0
(tx_hash_hex, o) = builder.set(registry, eth_accounts[0], 'FooContract', addr_foo, bogus_hash, bogus_hash)
(tx_hash_hex, o) = builder.set(registry, roles['CONTRACT_DEPLOYER'], 'FooContract', addr_foo, bogus_hash, bogus_hash)
r = eth_rpc.do(o)
o = receipt(r)
rcpt = eth_rpc.do(o)