def test_deposit_wrong_channel( get_accounts: Callable, token_network: Contract, create_channel: Callable, assign_tokens: Callable, ) -> None: """setTotalDeposit() with a wrong channelID fails""" (A, B, C) = get_accounts(3) channel_identifier = create_channel(A, B)[0] channel_identifier2 = create_channel(A, C)[0] assign_tokens(A, 10) with pytest.raises(TransactionFailed, match="TN/deposit: channel id mismatch"): token_network.functions.setTotalDeposit(channel_identifier2, A, 10, B).call({"from": A}) with pytest.raises(TransactionFailed, match="TN/deposit: channel id mismatch"): token_network.functions.setTotalDeposit(channel_identifier, A, 10, C).call({"from": A}) call_and_transact( token_network.functions.setTotalDeposit(channel_identifier, A, 10, B), {"from": A}, ) assert (10 == token_network.functions.getChannelParticipantInfo( channel_identifier, A, B).call()[0])
def test_withdraw_wrong_signers( token_network: Contract, create_channel_and_deposit: Callable, get_accounts: Callable, create_withdraw_signatures: Callable, ) -> None: (A, B, C) = get_accounts(3) deposit_A = 15 deposit_B = 13 withdraw_A = 5 channel_identifier = create_channel_and_deposit(A, B, deposit_A, deposit_B) (signature_A_for_A, signature_B_for_A, signature_C_for_A) = create_withdraw_signatures([A, B, C], channel_identifier, A, withdraw_A, UINT256_MAX) with pytest.raises(TransactionFailed): token_network.functions.setTotalWithdraw( channel_identifier, A, withdraw_A, UINT256_MAX, signature_C_for_A, signature_B_for_A).call({"from": C}) with pytest.raises(TransactionFailed): token_network.functions.setTotalWithdraw( channel_identifier, A, withdraw_A, UINT256_MAX, signature_A_for_A, signature_C_for_A).call({"from": C}) call_and_transact( token_network.functions.setTotalWithdraw(channel_identifier, A, withdraw_A, UINT256_MAX, signature_A_for_A, signature_B_for_A), {"from": C}, )
def test_changing_duration(service_registry: Contract, get_accounts: Callable, custom_token: Contract) -> None: """The controller can change the registration period of ServiceRegistry""" new_duration = 90 * SECONDS_PER_DAY call_and_transact( service_registry.functions.changeParameters( _price_bump_numerator=DEFAULT_BUMP_NUMERATOR, _price_bump_denominator=DEFAULT_BUMP_DENOMINATOR, _decay_constant=DEFAULT_DECAY_CONSTANT, _min_price=DEFAULT_MIN_PRICE, _registration_duration=new_duration, ), {"from": DEPLOYER_ADDRESS}, ) # make sure that the duration has changed. assert service_registry.functions.registration_duration().call( ) == new_duration (A, ) = get_accounts(1) call_and_transact(custom_token.functions.mint(2 * SERVICE_DEPOSIT), {"from": A}) call_and_transact( custom_token.functions.approve(service_registry.address, 2 * SERVICE_DEPOSIT), {"from": A}, ) call_and_transact(service_registry.functions.deposit(SERVICE_DEPOSIT), {"from": A}) first_expiration = service_registry.functions.service_valid_till(A).call() call_and_transact(service_registry.functions.deposit(SERVICE_DEPOSIT), {"from": A}) second_expiration = service_registry.functions.service_valid_till(A).call() assert second_expiration == first_expiration + new_duration
def test_close_second_participant_can_close( token_network: Contract, create_channel: Callable, get_accounts: Callable, create_close_signature_for_no_balance_proof: Callable, ) -> None: """Simplest successful closeChannel by the second participant""" (A, B) = get_accounts(2) channel_identifier = create_channel(A, B)[0] closing_sig = create_close_signature_for_no_balance_proof( B, channel_identifier) call_and_transact( token_network.functions.closeChannel( channel_identifier=channel_identifier, non_closing_participant=A, closing_participant=B, balance_hash=EMPTY_BALANCE_HASH, nonce=0, additional_hash=EMPTY_ADDITIONAL_HASH, non_closing_signature=EMPTY_SIGNATURE, closing_signature=closing_sig, ), {"from": B}, )
def test_internal_min_price(service_registry: Contract) -> None: """Calling the internal setMinPrice() must fail""" with pytest.raises(MismatchedABI): call_and_transact( service_registry.functions.setMinPrice(DEFAULT_MIN_PRICE * 2), {"from": DEPLOYER_ADDRESS}, )
def test_unauthorized_deprecation_switch( service_registry: Contract, get_accounts: Callable ) -> None: """A random account cannot turn on the deprecation switch""" (A,) = get_accounts(1) with pytest.raises(TransactionFailed, match="caller is not the controller"): call_and_transact(service_registry.functions.setDeprecationSwitch(), {"from": A})
def test_monitor_on_wrong_token_network_registry( token_network_in_another_token_network_registry: Contract, monitoring_service_external: Contract, monitor_data: Dict, ms_address: HexAddress, web3: Web3, ) -> None: A, B = monitor_data["participants"] # wait until MS is allowed to monitor mine_blocks(web3, monitor_data["first_allowed"] - web3.eth.block_number) # monitor() call fails because the TokenNetwork is not registered on the # supposed TokenNetworkRegistry with pytest.raises(TransactionFailed, match="Unknown TokenNetwork"): call_and_transact( monitoring_service_external.functions.monitor( A, B, *monitor_data["balance_proof_B"]._asdict().values(), monitor_data["non_closing_signature"], REWARD_AMOUNT, token_network_in_another_token_network_registry.address, monitor_data["reward_proof_signature"], ), {"from": ms_address}, )
def test_internal_set_decay_constant(service_registry: Contract) -> None: """Calling the internal setDecayConstant() must fail""" with pytest.raises(MismatchedABI): call_and_transact( service_registry.functions.setDecayConstant(DEFAULT_DECAY_CONSTANT + 100), {"from": DEPLOYER_ADDRESS}, )
def test_withdraw_call_near_expiration( token_network: Contract, create_channel_and_deposit: Callable, get_accounts: Callable, create_withdraw_signatures: Callable, web3: Web3, ) -> None: """setTotalWithdraw() succeeds when expiration_block is one block in the future""" (A, B) = get_accounts(2) withdraw_A = 3 channel_identifier = create_channel_and_deposit(A, B, 10, 1) # The block must still be one block in the future when the transaction is # processed, so we have to choose an expiration two block in the future expiration = web3.eth.block_number + 2 (signature_A_for_A, signature_B_for_A) = create_withdraw_signatures([A, B], channel_identifier, A, withdraw_A, expiration) call_and_transact( token_network.functions.setTotalWithdraw( channel_identifier=channel_identifier, participant=A, total_withdraw=withdraw_A, expiration_block=expiration, participant_signature=signature_A_for_A, partner_signature=signature_B_for_A, ), {"from": A}, )
def test_deprecation_switch( get_accounts: Callable, token_network: Contract, create_channel: Callable, channel_deposit: Callable, ) -> None: """Test the effects of the deprecation switch on deposits and channel opening""" controller = token_network.functions.controller().call() (A, B, C, D) = get_accounts(4) deposit = 100 bigger_deposit = 200 channel_identifier = create_channel(A, B)[0] channel_deposit(channel_identifier, A, deposit, B) channel_deposit(channel_identifier, B, deposit, A) call_and_transact(token_network.functions.deprecate(), {"from": controller}) assert token_network.functions.safety_deprecation_switch().call() is True # Now we cannot deposit in existent channels with pytest.raises(TransactionFailed, match="TN: network is deprecated"): channel_deposit(channel_identifier, A, bigger_deposit, B) with pytest.raises(TransactionFailed, match="TN: network is deprecated"): channel_deposit(channel_identifier, B, bigger_deposit, A) # Now we cannot open channels anymore with pytest.raises(TransactionFailed, match="TN: network is deprecated"): channel_identifier = create_channel(C, D)[0]
def test_cooperative_settle_channel_state_withdraw( custom_token: Contract, token_network: Contract, create_channel_and_deposit: Callable, withdraw_channel: Callable, get_accounts: Callable, create_withdraw_signatures: Callable, cooperative_settle_state_tests: Callable, ) -> None: (A, B, C) = get_accounts(3) deposit_A = 20 deposit_B = 10 withdraw_A = 3 withdraw_B = 7 balance_A = 5 balance_B = 15 assert deposit_A + deposit_B == withdraw_A + withdraw_B + balance_A + balance_B channel_identifier = create_channel_and_deposit(A, B, deposit_A, deposit_B) withdraw_channel(channel_identifier, A, withdraw_A, EXPIRATION, B) withdraw_channel(channel_identifier, B, withdraw_B, EXPIRATION, A) # We need to add the already withdrawn amount to the balance as `withdraw_amount` # is a monotonic value (signature_A1, signature_B1) = create_withdraw_signatures([A, B], channel_identifier, A, balance_A + withdraw_A, EXPIRATION) (signature_A2, signature_B2) = create_withdraw_signatures([A, B], channel_identifier, B, balance_B + withdraw_B, EXPIRATION) pre_account_balance_A = custom_token.functions.balanceOf(A).call() pre_account_balance_B = custom_token.functions.balanceOf(B).call() pre_balance_contract = custom_token.functions.balanceOf( token_network.address).call() call_and_transact( token_network.functions.cooperativeSettle( channel_identifier, (A, balance_A + withdraw_A, EXPIRATION, signature_A1, signature_B1), (B, balance_B + withdraw_B, EXPIRATION, signature_B2, signature_A2), ), {"from": C}, ) cooperative_settle_state_tests( channel_identifier, A, balance_A, B, balance_B, pre_account_balance_A, pre_account_balance_B, pre_balance_contract, )
def test_settle2_no_bp_success( web3: Web3, custom_token: Contract, token_network: Contract, create_channel_and_deposit: Callable, get_accounts: Callable, create_close_signature_for_no_balance_proof: Callable, ) -> None: """The simplest settlement, tested against the V2 ABI settle""" (A, B) = get_accounts(2) deposit_A = 10 deposit_B = 6 settle_timeout = TEST_SETTLE_TIMEOUT_MIN channel_identifier = create_channel_and_deposit(A, B, deposit_A, deposit_B) closing_sig = create_close_signature_for_no_balance_proof( A, channel_identifier) # Close channel with no balance proof call_and_transact( token_network.functions.closeChannel( channel_identifier, B, A, EMPTY_BALANCE_HASH, 0, EMPTY_ADDITIONAL_HASH, EMPTY_SIGNATURE, closing_sig, ), {"from": A}, ) # Do not call updateNonClosingBalanceProof # Settlement window must be over before settling the channel mine_blocks(web3, settle_timeout + 1) # Settling the channel should work with no balance proofs call_and_transact( token_network.functions.settleChannel2( channel_identifier=channel_identifier, participant1_settlement=dict( participant=A, transferred_amount=0, locked_amount=0, locksroot=LOCKSROOT_OF_NO_LOCKS, ), participant2_settlement=dict( participant=B, transferred_amount=0, locked_amount=0, locksroot=LOCKSROOT_OF_NO_LOCKS, ), ), {"from": A}, ) assert custom_token.functions.balanceOf(A).call() == deposit_A assert custom_token.functions.balanceOf(B).call() == deposit_B
def test_call_and_transact_does_not_mine(web3: Web3, custom_token: Contract) -> None: """ See call_and_transact() does not mine a block """ before = web3.eth.blockNumber call_and_transact(custom_token.functions.multiplier()) after = web3.eth.blockNumber assert before + 1 == after
def test_update_channel_fail_no_offchain_transfers( get_accounts: Callable, token_network: Contract, create_channel: Callable, create_balance_proof: Callable, create_balance_proof_countersignature: Callable, create_close_signature_for_no_balance_proof: Callable, ) -> None: """Calls to updateNonClosingBalanceProof() fail with the zero nonce""" (A, B) = get_accounts(2) channel_identifier = create_channel(A, B)[0] balance_proof_A = create_balance_proof(channel_identifier, A, 0, 0, 0) balance_proof_update_signature_B = create_balance_proof_countersignature( participant=B, channel_identifier=channel_identifier, msg_type=MessageTypeId.BALANCE_PROOF_UPDATE, **balance_proof_A._asdict(), ) closing_sig = create_close_signature_for_no_balance_proof( A, channel_identifier) call_and_transact( token_network.functions.closeChannel( channel_identifier, B, A, EMPTY_BALANCE_HASH, 0, EMPTY_ADDITIONAL_HASH, EMPTY_SIGNATURE, closing_sig, ), {"from": A}, ) with pytest.raises(TransactionFailed, match="TN/update: balance hash is zero"): token_network.functions.updateNonClosingBalanceProof( channel_identifier, A, B, EMPTY_BALANCE_HASH, 0, EMPTY_ADDITIONAL_HASH, EMPTY_SIGNATURE, EMPTY_SIGNATURE, ).call({"from": B}) with pytest.raises(TransactionFailed, match="TN/update: nonce is zero"): token_network.functions.updateNonClosingBalanceProof( channel_identifier, A, B, *balance_proof_A._asdict().values(), balance_proof_update_signature_B, ).call({"from": B})
def get(tx_from: HexAddress, transfers: List[Tuple]) -> None: for (expiration, _, secrethash, secret) in transfers: assert web3.eth.blockNumber < expiration call_and_transact( secret_registry_contract.functions.registerSecret(secret), {"from": tx_from}) assert ( secret_registry_contract.functions.getSecretRevealBlockHeight( secrethash).call() == web3.eth.blockNumber)
def test_calling_internal_bump_paramter_change( service_registry: Contract) -> None: """Calling an internal function setPriceBumpParameters() must fail""" with pytest.raises(MismatchedABI): call_and_transact( service_registry.functions.setPriceBumpParameters( DEFAULT_BUMP_NUMERATOR + 1, DEFAULT_BUMP_DENOMINATOR), {"from": DEPLOYER_ADDRESS}, )
def user_deposit_contract( uninitialized_user_deposit_contract: Contract, monitoring_service_external: Contract, one_to_n_contract: Contract, ) -> Contract: call_and_transact( uninitialized_user_deposit_contract.functions.init( monitoring_service_external.address, one_to_n_contract.address)) return uninitialized_user_deposit_contract
def test_cooperative_settle_channel_wrong_balances( token_network: Contract, create_channel_and_deposit: Callable, get_accounts: Callable, create_cooperative_settle_signatures: Callable, ) -> None: (A, B, C) = get_accounts(3) deposit_A = 20 deposit_B = 10 balance_A = 7 balance_B = 23 balance_A_fail1 = 20 balance_B_fail1 = 11 balance_A_fail2 = 6 balance_B_fail2 = 8 channel_identifier = create_channel_and_deposit(A, B, deposit_A, deposit_B) (signature_A, signature_B) = create_cooperative_settle_signatures( [A, B], channel_identifier, A, balance_A, B, balance_B ) (signature_A_fail1, signature_B_fail1) = create_cooperative_settle_signatures( [A, B], channel_identifier, A, balance_A_fail1, B, balance_B_fail1 ) (signature_A_fail2, signature_B_fail2) = create_cooperative_settle_signatures( [A, B], channel_identifier, A, balance_A_fail2, B, balance_B_fail2 ) with pytest.raises(TransactionFailed): token_network.functions.cooperativeSettle( channel_identifier, A, balance_A_fail1, B, balance_B_fail1, signature_A_fail1, signature_B_fail1, ).call({"from": C}) with pytest.raises(TransactionFailed): token_network.functions.cooperativeSettle( channel_identifier, A, balance_A_fail2, B, balance_B_fail2, signature_A_fail2, signature_B_fail2, ).call({"from": C}) call_and_transact( token_network.functions.cooperativeSettle( channel_identifier, A, balance_A, B, balance_B, signature_A, signature_B ), {"from": C}, )
def print_gas_secret_registry(secret_registry_contract: Contract, print_gas: Callable) -> None: """ Abusing pytest to print gas cost of SecretRegistry's registerSecret() """ secret = b"secretsecretsecretsecretsecretse" txn_hash = call_and_transact(secret_registry_contract.functions.registerSecret(secret)) print_gas(txn_hash, CONTRACT_SECRET_REGISTRY + ".registerSecret") for batch_size in (1, 2, 3): batch = [bytes([batch_size, i] + [0] * 30) for i in range(batch_size)] txn_hash = call_and_transact(secret_registry_contract.functions.registerSecretBatch(batch)) print_gas(txn_hash, CONTRACT_SECRET_REGISTRY + ".registerSecretBatch" + str(batch_size))
def print_gas_token(get_accounts: Callable, custom_token: Contract, print_gas: Callable) -> None: (A, B) = get_accounts(2) tx_hash = call_and_transact(custom_token.functions.mint(100), {"from": A}) print_gas(tx_hash, "CustomToken.mint") tx_hash = call_and_transact(custom_token.functions.transfer(B, 100), {"from": A}) print_gas(tx_hash, "CustomToken.transfer") tx_hash = call_and_transact(custom_token.functions.approve(A, 100), {"from": B}) print_gas(tx_hash, "CustomToken.approve") tx_hash = call_and_transact(custom_token.functions.transferFrom(B, A, 100), {"from": A}) print_gas(tx_hash, "CustomToken.transferFrom")
def test_deprecation_immediate_payout(create_account: Callable, custom_token: Contract, service_registry: Contract, web3: Web3) -> None: """When the deprecation switch is on, deposits can be withdrawn immediately.""" # A user makes a deposit A = create_account() minted = service_registry.functions.currentPrice().call() call_and_transact(custom_token.functions.mint(minted), {"from": A}) call_and_transact( custom_token.functions.approve(service_registry.address, minted), {"from": A}) deposit_tx = call_and_transact(service_registry.functions.deposit(minted), {"from": A}) # The user obtains the deposit address deposit_tx_receipt = web3.eth.get_transaction_receipt(deposit_tx) contract_manager = ContractManager( contracts_precompiled_path(version=None)) event_abi = contract_manager.get_event_abi(CONTRACT_SERVICE_REGISTRY, EVENT_REGISTERED_SERVICE) event_data = get_event_data(web3.codec, event_abi, deposit_tx_receipt["logs"][-1]) deposit_address = event_data["args"]["deposit_contract"] # And obtains the Deposit contract instance deposit_abi = contract_manager.get_contract_abi(CONTRACT_DEPOSIT) deposit = web3.eth.contract(abi=deposit_abi, address=deposit_address) # The controller turns on the deprecation switch call_and_transact(service_registry.functions.setDeprecationSwitch(), {"from": DEPLOYER_ADDRESS}) # The user successfully withdraws the deposit call_and_transact(deposit.functions.withdraw(A), {"from": A}) # The user has all the balance it has minted assert minted == custom_token.functions.balanceOf(A).call() # The Deposit contract has destroyed itself assert web3.eth.get_code(deposit.address) == HexBytes("0x")
def test_setURL(custom_token: Contract, service_registry: Contract, get_accounts: Callable, web3: Web3) -> None: """A ServiceRegistry allows registered service providers to set their URLs""" (A, ) = get_accounts(1) url1 = "http://example.com" url2 = "http://raiden.example.com" call_and_transact(custom_token.functions.mint(SERVICE_DEPOSIT), {"from": A}) call_and_transact( custom_token.functions.approve(service_registry.address, SERVICE_DEPOSIT), {"from": A}, ) tx = call_and_transact(service_registry.functions.deposit(SERVICE_DEPOSIT), {"from": A}) tx_receipt = web3.eth.get_transaction_receipt(tx) contract_manager = ContractManager( contracts_precompiled_path(version=None)) event_abi = contract_manager.get_event_abi(CONTRACT_SERVICE_REGISTRY, EVENT_REGISTERED_SERVICE) event_data = get_event_data(web3.codec, event_abi, tx_receipt["logs"][-1]) assert event_data["args"]["service"] == A assert event_data["args"]["deposit_contract"] != EMPTY_ADDRESS call_and_transact(service_registry.functions.setURL(url1), {"from": A}) assert service_registry.functions.urls(A).call() == url1 call_and_transact(service_registry.functions.setURL(url2), {"from": A}) assert service_registry.functions.urls(A).call() == url2
def f(target: str) -> None: assert is_address(target) ethereum_tester.send_transaction({ "from": FAUCET_ADDRESS, "to": target, "gas": 21000, "value": 1 * int(units["ether"]) }) call_and_transact( custom_token.functions.transfer(_to=target, _value=10000), {"from": FAUCET_ADDRESS})
def test_withdraw_to_beneficiary( user_deposit_contract: Contract, deposit_to_udc: Callable, get_accounts: Callable, web3: Web3, event_handler: Callable, custom_token: Contract, ) -> None: """Test the interaction between planWithdraw, withdrawToBeneficiary and effectiveBalance""" ev_handler = event_handler(user_deposit_contract) (A, B) = get_accounts(2) deposit_to_udc(A, 30) assert user_deposit_contract.functions.balances(A).call() == 30 assert user_deposit_contract.functions.effectiveBalance(A).call() == 30 # plan withdraw of 20 tokens tx_hash = call_and_transact( user_deposit_contract.functions.planWithdraw(20), {"from": A}) ev_handler.assert_event( tx_hash, UserDepositEvent.WITHDRAW_PLANNED, dict(withdrawer=A, plannedBalance=10), ) assert user_deposit_contract.functions.balances(A).call() == 30 assert user_deposit_contract.functions.effectiveBalance(A).call() == 10 # beneficiary can not be zero address with pytest.raises(TransactionFailed, match="beneficiary is zero"): user_deposit_contract.functions.withdrawToBeneficiary( 18, ZERO_ADDRESS).call({"from": A}) # withdraw won't work before withdraw_delay elapsed withdraw_delay = user_deposit_contract.functions.withdraw_delay().call() mine_blocks(web3, withdraw_delay - 1) with pytest.raises(TransactionFailed, match="withdrawing too early"): user_deposit_contract.functions.withdrawToBeneficiary(18, B).call( {"from": A}) # can't withdraw more then planned mine_blocks(web3, 1) # now withdraw_delay is over with pytest.raises(TransactionFailed, match="withdrawing more than planned"): user_deposit_contract.functions.withdrawToBeneficiary(21, B).call( {"from": A}) # actually withdraw 18 tokens assert custom_token.functions.balanceOf(B).call() == 0 call_and_transact( user_deposit_contract.functions.withdrawToBeneficiary(18, B), {"from": A}) assert user_deposit_contract.functions.balances(A).call() == 12 assert user_deposit_contract.functions.effectiveBalance(A).call() == 12 assert custom_token.functions.balanceOf(B).call() == 18
def send_remaining( channel_identifier: int, participant1: HexAddress, participant2: HexAddress ) -> None: remaining_to_reach_limit = remaining() assign_tokens(participant1, remaining_to_reach_limit) call_and_transact( token_network.functions.setTotalDeposit( channel_identifier, participant1, remaining_to_reach_limit, participant2 ), {"from": participant1}, )
def test_very_big_decay_cosntant(service_registry: Contract) -> None: """set a very big decay constant and see very slow price decay""" call_and_transact( service_registry.functions.changeParameters( _price_bump_numerator=DEFAULT_BUMP_NUMERATOR, _price_bump_denominator=DEFAULT_BUMP_DENOMINATOR, _decay_constant=2 ** 40 - 1, _min_price=DEFAULT_MIN_PRICE, _registration_duration=DEFAULT_REGISTRATION_DURATION, ), {"from": DEPLOYER_ADDRESS}, ) assert service_registry.functions.decayedPrice(100000, 11990300).call() == 99998
def test_changing_min_price(service_registry: Contract) -> None: """The controller can change the min_price""" call_and_transact( service_registry.functions.changeParameters( _price_bump_numerator=DEFAULT_BUMP_NUMERATOR, _price_bump_denominator=DEFAULT_BUMP_DENOMINATOR, _decay_constant=DEFAULT_DECAY_CONSTANT, _min_price=DEFAULT_MIN_PRICE * 2, _registration_duration=DEFAULT_REGISTRATION_DURATION, ), {"from": DEPLOYER_ADDRESS}, ) assert service_registry.functions.min_price().call() == DEFAULT_MIN_PRICE * 2
def test_zero_denominator_fail(service_registry: Contract) -> None: """changeParameters() fails if the new bump denominator is zero""" with pytest.raises(TransactionFailed, match="divide by zero"): call_and_transact( service_registry.functions.changeParameters( _price_bump_numerator=DEFAULT_BUMP_NUMERATOR, _price_bump_denominator=0, _decay_constant=DEFAULT_DECAY_CONSTANT, _min_price=DEFAULT_MIN_PRICE, _registration_duration=DEFAULT_REGISTRATION_DURATION, ), {"from": DEPLOYER_ADDRESS}, )
def test_too_high_decay_constant_fail(service_registry: Contract) -> None: """changeParameters() fails if the new decay constant is too high""" with pytest.raises(TransactionFailed, match="too big decay constant"): call_and_transact( service_registry.functions.changeParameters( _price_bump_numerator=DEFAULT_BUMP_NUMERATOR, _price_bump_denominator=DEFAULT_BUMP_DENOMINATOR, _decay_constant=2**40, _min_price=DEFAULT_MIN_PRICE, _registration_duration=DEFAULT_REGISTRATION_DURATION, ), {"from": DEPLOYER_ADDRESS}, )
def test_changing_too_low_bump_parameter_fail(service_registry: Contract) -> None: """changeParameters() fails if the bump numerator is smaller than the bump denominator""" with pytest.raises(TransactionFailed, match="price dump instead of bump"): call_and_transact( service_registry.functions.changeParameters( _price_bump_numerator=DEFAULT_BUMP_NUMERATOR, _price_bump_denominator=DEFAULT_BUMP_NUMERATOR + 1, _decay_constant=DEFAULT_DECAY_CONSTANT, _min_price=DEFAULT_MIN_PRICE, _registration_duration=DEFAULT_REGISTRATION_DURATION, ), {"from": DEPLOYER_ADDRESS}, )