mirror of https://github.com/nucypher/nucypher.git
[KMS-ETH]- PopulusContract -=> Contract
parent
64a0558e0a
commit
0e5c192f01
|
@ -64,12 +64,11 @@ class NuCypherKMSTokenAgent(EthereumContractAgent):
|
|||
|
||||
class MinerAgent(EthereumContractAgent):
|
||||
"""
|
||||
Wraps NuCypher's Escrow solidity smart contract, and manages a PopulusContract.
|
||||
Wraps NuCypher's Escrow solidity smart contract, and manages a... PopulusContract?
|
||||
|
||||
In order to become a participant of the network,
|
||||
a miner locks tokens by depositing to the Escrow contract address
|
||||
for a duration measured in periods.
|
||||
|
||||
"""
|
||||
|
||||
_deployer = MinerEscrowDeployer
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
from ethereum.tester import TransactionFailed
|
||||
from populus.contracts.contract import PopulusContract
|
||||
from web3.contract import Contract
|
||||
|
||||
|
||||
def test_dispatcher(web3, chain):
|
||||
|
@ -38,7 +38,7 @@ def test_dispatcher(web3, chain):
|
|||
contract_instance = web3.eth.contract(
|
||||
contract_interface.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Only owner can change target address for dispatcher
|
||||
with pytest.raises(TransactionFailed):
|
||||
|
@ -128,7 +128,7 @@ def test_dispatcher(web3, chain):
|
|||
contract_instance = web3.eth.contract(
|
||||
contract2_lib.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Check new method and finish upgrade method
|
||||
assert contract_instance.call().storageValueToCheck() == 1
|
||||
|
@ -182,7 +182,7 @@ def test_dispatcher(web3, chain):
|
|||
contract_instance = web3.eth.contract(
|
||||
contract1_lib.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
tx = contract_instance.transact().createEvent(33)
|
||||
chain.wait.for_receipt(tx)
|
||||
events = contract_instance.pastEvents('EventV1').get()
|
||||
|
@ -197,7 +197,7 @@ def test_dispatcher(web3, chain):
|
|||
contract_instance = web3.eth.contract(
|
||||
contract2_lib.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
assert dispatcher.call().target().lower() == contract3_lib.address.lower()
|
||||
assert contract_instance.call().returnValue() == 20
|
||||
assert contract_instance.call().getStorageValue() == 5
|
||||
|
@ -237,7 +237,7 @@ def test_dispatcher(web3, chain):
|
|||
contract_instance = web3.eth.contract(
|
||||
contract1_lib.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
events = contract_instance.pastEvents('EventV1').get()
|
||||
assert 1 == len(events)
|
||||
assert 33 == events[0]['args']['value']
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
from ethereum.tester import TransactionFailed
|
||||
from populus.contracts.contract import PopulusContract
|
||||
from web3.contract import Contract
|
||||
|
||||
|
||||
NULL_ADDR = '0x' + '0' * 40
|
||||
|
@ -44,7 +44,7 @@ def escrow(web3, chain):
|
|||
escrow = web3.eth.contract(
|
||||
escrow_library.abi,
|
||||
escrow_dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
return escrow
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ def test_voting(web3, chain, escrow, policy_manager):
|
|||
government = web3.eth.contract(
|
||||
government_library.abi,
|
||||
government_dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Transfer ownership
|
||||
tx = government.transact({'from': creator}).transferOwnership(government.address)
|
||||
|
@ -250,7 +250,7 @@ def test_upgrade(web3, chain, escrow, policy_manager):
|
|||
government = web3.eth.contract(
|
||||
government_library_v1.abi,
|
||||
government_dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Deploy second version of the government contract
|
||||
government_library_v2, _ = chain.provider.deploy_contract(
|
||||
|
@ -450,7 +450,7 @@ def test_verifying_state(web3, chain):
|
|||
government = web3.eth.contract(
|
||||
government_library_v2.abi,
|
||||
government_dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Upgrade to the second version
|
||||
tx = government_dispatcher.transact({'from': creator}).upgrade(government_library_v2.address)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
from ethereum.tester import TransactionFailed
|
||||
from populus.contracts.contract import PopulusContract
|
||||
from web3.contract import Contract
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
@ -122,7 +122,7 @@ def test_verifying_state(web3, chain, token):
|
|||
contract = web3.eth.contract(
|
||||
contract_library_v2.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Give Miner tokens for reward and initialize contract
|
||||
tx = token.transact({'from': creator}).transfer(contract.address, 10000)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
from ethereum.tester import TransactionFailed
|
||||
import os
|
||||
from populus.contracts.contract import PopulusContract
|
||||
from web3.contract import Contract
|
||||
|
||||
|
||||
MINERS_LENGTH = 0
|
||||
|
@ -52,7 +52,7 @@ def escrow_contract(web3, chain, token, request):
|
|||
contract = web3.eth.contract(
|
||||
contract.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
return contract
|
||||
|
||||
return make_escrow
|
||||
|
@ -760,7 +760,7 @@ def test_verifying_state(web3, chain, token):
|
|||
contract = web3.eth.contract(
|
||||
contract_library_v2.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
assert 1500 == contract.call().maxAllowableLockedTokens()
|
||||
|
||||
# Initialize contract and miner
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
from ethereum.tester import TransactionFailed
|
||||
import os
|
||||
from populus.contracts.contract import PopulusContract
|
||||
from web3.contract import Contract
|
||||
|
||||
|
||||
CLIENT_FIELD = 0
|
||||
|
@ -58,7 +58,7 @@ def policy_manager(web3, chain, escrow, request):
|
|||
contract = web3.eth.contract(
|
||||
contract.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
tx = escrow.transact({'from': creator}).setPolicyManager(contract.address)
|
||||
chain.wait.for_receipt(tx)
|
||||
|
@ -606,7 +606,7 @@ def test_verifying_state(web3, chain):
|
|||
contract = web3.eth.contract(
|
||||
contract_library_v2.abi,
|
||||
dispatcher.address,
|
||||
ContractFactoryClass=PopulusContract)
|
||||
ContractFactoryClass=Contract)
|
||||
|
||||
# Upgrade to the second version
|
||||
assert address1 == contract.call().escrow().lower()
|
||||
|
|
Loading…
Reference in New Issue