mirror of
git://holbrook.no/eth-contract-registry
synced 2024-12-22 12:27:31 +01:00
rehabilitate tests, replace seal with transferownership
This commit is contained in:
parent
ddfb1d3e01
commit
657137efb0
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,6 @@
|
|||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.egg-info
|
||||||
|
gmon.out
|
||||||
__pycache__
|
__pycache__
|
||||||
*.pyc
|
*.pyc
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
|
[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
|
||||||
|
BIN
python/gmon.out
BIN
python/gmon.out
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = eth-contract-registry
|
name = eth-contract-registry
|
||||||
version = 0.5.4a10
|
version = 0.5.5a1
|
||||||
description = Ethereum Smart Contract key-value registry
|
description = Ethereum Smart Contract key-value registry
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# external imports
|
# external imports
|
||||||
from chainlib.eth.pytest import *
|
from chainlib.eth.pytest import *
|
||||||
from contract_registry.pytest import *
|
from eth_contract_registry.pytest import *
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ from hexathon import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from contract_registry.registry import Registry
|
from eth_contract_registry.registry import Registry
|
||||||
from contract_registry.encoding import from_identifier_hex
|
from eth_contract_registry.encoding import from_identifier_hex
|
||||||
from contract_registry.pytest.fixtures_registry import valid_identifiers
|
from eth_contract_registry.pytest.fixtures_registry import valid_identifiers
|
||||||
|
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
|
|
||||||
@ -33,43 +33,33 @@ valid_identifiers += [
|
|||||||
]
|
]
|
||||||
|
|
||||||
def test_set(
|
def test_set(
|
||||||
|
default_chain_spec,
|
||||||
registry,
|
registry,
|
||||||
eth_accounts,
|
eth_accounts,
|
||||||
eth_rpc,
|
eth_rpc,
|
||||||
eth_signer,
|
eth_signer,
|
||||||
|
roles,
|
||||||
):
|
):
|
||||||
|
|
||||||
addr_registry = to_checksum_address(os.urandom(20).hex())
|
addr_registry = to_checksum_address(os.urandom(20).hex())
|
||||||
addr_foo = to_checksum_address(os.urandom(20).hex())
|
addr_foo = to_checksum_address(os.urandom(20).hex())
|
||||||
bogus_hash = add_0x(os.urandom(32).hex())
|
bogus_hash = add_0x(os.urandom(32).hex())
|
||||||
|
|
||||||
#conn = RPCConnection.connect('default')
|
nonce_oracle = RPCNonceOracle(roles['CONTRACT_DEPLOYER'], eth_rpc)
|
||||||
nonce_oracle = RPCNonceOracle(eth_accounts[0], eth_rpc)
|
builder = Registry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle)
|
||||||
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'
|
|
||||||
|
|
||||||
o = builder.address_of(registry, 'ContractRegistry', sender_address=eth_accounts[0])
|
o = builder.address_of(registry, 'ContractRegistry', sender_address=eth_accounts[0])
|
||||||
r = eth_rpc.do(o)
|
r = eth_rpc.do(o)
|
||||||
r = abi_decode_single(ABIContractType.ADDRESS, r)
|
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)
|
r = eth_rpc.do(o)
|
||||||
o = receipt(r)
|
o = receipt(r)
|
||||||
rcpt = eth_rpc.do(o)
|
rcpt = eth_rpc.do(o)
|
||||||
assert rcpt['status'] == 0
|
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)
|
r = eth_rpc.do(o)
|
||||||
o = receipt(r)
|
o = receipt(r)
|
||||||
rcpt = eth_rpc.do(o)
|
rcpt = eth_rpc.do(o)
|
||||||
|
@ -6,5 +6,5 @@ all:
|
|||||||
$(SOLC) --abi Registry.sol --evm-version byzantium | awk 'NR>3' > Registry.json
|
$(SOLC) --abi Registry.sol --evm-version byzantium | awk 'NR>3' > Registry.json
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
cp -v *{json,bin} ../python/contract_registry/data/
|
cp -v *{json,bin} ../python/eth_contract_registry/data/
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ pragma solidity >0.6.11;
|
|||||||
|
|
||||||
|
|
||||||
contract CICRegistry {
|
contract CICRegistry {
|
||||||
|
// Implements EIP 173
|
||||||
address public owner;
|
address public owner;
|
||||||
|
|
||||||
bytes32[] public identifiers;
|
bytes32[] public identifiers;
|
||||||
@ -38,12 +39,14 @@ contract CICRegistry {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function seal() public returns (bool) {
|
// Implements EIP 173
|
||||||
// require(msg.sender == owner);
|
function transferOwnership(address _newOwner) public returns (bool) {
|
||||||
// owner = address(0);
|
require(msg.sender == owner);
|
||||||
// return true;
|
owner = _newOwner;
|
||||||
// }
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements Registry
|
||||||
function addressOf(bytes32 _identifier) public view returns (address) {
|
function addressOf(bytes32 _identifier) public view returns (address) {
|
||||||
return entries[_identifier];
|
return entries[_identifier];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user