Skip to content

Commit

Permalink
Remove last usage of deploy_contract and remove it
Browse files Browse the repository at this point in the history
  • Loading branch information
palango committed Mar 1, 2021
1 parent 7dfd1c0 commit e268bd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
34 changes: 12 additions & 22 deletions raiden_contracts/tests/fixtures/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
log = logging.getLogger(__name__)


@pytest.fixture(scope="session")
def deploy_tester_contract(
web3: Web3, contracts_manager: ContractManager, deploy_contract: Callable
) -> Callable:
"""Returns a function that can be used to deploy a named contract,
using conract manager to compile the bytecode and get the ABI"""

def f(contract_name: str, **kwargs: Dict) -> Contract:
json_contract = contracts_manager.get_contract(contract_name)
contract = deploy_contract(
web3, DEPLOYER_ADDRESS, json_contract["abi"], json_contract["bin"], **kwargs
)
return contract

return f


@pytest.fixture(scope="session")
def deploy_contract_txhash() -> Callable[..., str]:
"""Returns a function that deploys a compiled contract, returning a txhash"""
Expand All @@ -46,12 +29,19 @@ def fn(


@pytest.fixture(scope="session")
def deploy_contract(deploy_contract_txhash: Callable) -> Callable:
"""Returns a function that deploys a compiled contract"""
def deploy_tester_contract(
web3: Web3, contracts_manager: ContractManager, deploy_contract_txhash: Callable
) -> Callable:
"""Returns a function that can be used to deploy a named contract,
using conract manager to compile the bytecode and get the ABI"""

def fn(
web3: Web3, deployer_address: HexAddress, abi: List, bytecode: str, **kwargs: Dict
def f(
contract_name: str, deployer_address: HexAddress = DEPLOYER_ADDRESS, **kwargs: Dict
) -> Contract:
json_contract = contracts_manager.get_contract(contract_name)
abi = json_contract["abi"]
bytecode = json_contract["bin"]

contract = web3.eth.contract(abi=abi, bytecode=bytecode)
txhash = deploy_contract_txhash(web3, deployer_address, abi, bytecode, **kwargs)
contract_address = web3.eth.getTransactionReceipt(txhash)["contractAddress"]
Expand All @@ -62,7 +52,7 @@ def fn(

return contract(contract_address)

return fn
return f


@pytest.fixture
Expand Down
9 changes: 3 additions & 6 deletions raiden_contracts/tests/test_deprecation_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def test_deprecation_executor(
web3: Web3,
contracts_manager: ContractManager,
deploy_contract: Callable,
deploy_tester_contract: Callable,
secret_registry_contract: Contract,
custom_token: Contract,
channel_participant_deposit_limit: int,
Expand All @@ -42,12 +42,9 @@ def test_deprecation_executor(
"""
(deprecation_executor, B) = get_accounts(2)

json_contract = contracts_manager.get_contract(CONTRACT_TOKEN_NETWORK_REGISTRY)
token_network_registry = deploy_contract(
web3,
token_network_registry = deploy_tester_contract(
CONTRACT_TOKEN_NETWORK_REGISTRY,
deprecation_executor,
json_contract["abi"],
json_contract["bin"],
_secret_registry_address=secret_registry_contract.address,
_chain_id=web3.eth.chain_id,
_settlement_timeout_min=TEST_SETTLE_TIMEOUT_MIN,
Expand Down

0 comments on commit e268bd7

Please sign in to comment.