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
|
2019-03-05 02:50:11 +00:00
|
|
|
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
|
2019-03-05 02:50:11 +00:00
|
|
|
GNU Affero General Public License for more details.
|
2018-11-17 14:15:50 +00:00
|
|
|
|
2019-03-05 02:50:11 +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-12-18 11:06:36 +00:00
|
|
|
|
|
|
|
|
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):
|
2018-12-05 14:11:17 +00:00
|
|
|
escrow, _ = testerchain.interface.deploy_contract('MinersEscrowForMiningAdjudicatorMock')
|
2018-10-13 17:41:41 +00:00
|
|
|
return escrow
|
|
|
|
|
|
|
|
|
2018-12-05 17:03:18 +00:00
|
|
|
@pytest.fixture(params=[False, True])
|
2018-12-05 14:11:17 +00:00
|
|
|
def adjudicator_contract(testerchain, escrow, request):
|
2018-12-09 17:02:32 +00:00
|
|
|
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
|
|
|
|
2018-12-05 17:03:18 +00:00
|
|
|
if request.param:
|
2019-02-01 11:43:38 +00:00
|
|
|
secret_hash = testerchain.interface.w3.keccak(secret)
|
2018-12-05 17:03:18 +00:00
|
|
|
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
|