nucypher/tests/blockchain/eth/contracts/main/mining_adjudicator/conftest.py

60 lines
1.8 KiB
Python
Raw Normal View History

2018-11-17 14:15:50 +00:00
"""
This file is part of nucypher.
nucypher is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
2018-11-17 14:15:50 +00:00
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
nucypher is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
2018-11-17 14:15:50 +00:00
You should have received a copy of the GNU Affero General Public License
2018-11-17 14:15:50 +00:00
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
2018-10-13 17:41:41 +00:00
import pytest
from web3.contract import Contract
ALGORITHM_SHA256 = 1
2019-02-08 13:44:06 +00:00
BASE_PENALTY = 100
PENALTY_HISTORY_COEFFICIENT = 10
PERCENTAGE_PENALTY_COEFFICIENT = 8
REWARD_COEFFICIENT = 2
2018-10-13 17:41:41 +00:00
secret = (123456).to_bytes(32, byteorder='big')
@pytest.fixture()
def escrow(testerchain):
escrow, _ = testerchain.interface.deploy_contract('MinersEscrowForMiningAdjudicatorMock')
2018-10-13 17:41:41 +00:00
return escrow
@pytest.fixture(params=[False, True])
def adjudicator_contract(testerchain, escrow, request):
contract, _ = testerchain.interface.deploy_contract(
2019-02-08 13:44:06 +00:00
'MiningAdjudicator',
escrow.address,
ALGORITHM_SHA256,
BASE_PENALTY,
PENALTY_HISTORY_COEFFICIENT,
PERCENTAGE_PENALTY_COEFFICIENT,
REWARD_COEFFICIENT)
2018-10-13 17:41:41 +00:00
if request.param:
secret_hash = testerchain.interface.w3.keccak(secret)
dispatcher, _ = testerchain.interface.deploy_contract('Dispatcher', contract.address, secret_hash)
# Deploy second version of the government contract
contract = testerchain.interface.w3.eth.contract(
abi=contract.abi,
address=dispatcher.address,
ContractFactoryClass=Contract)
2018-10-13 17:41:41 +00:00
return contract