def test_settle_channel_event( web3, get_accounts, token_network, create_channel, channel_deposit, create_balance_proof, create_balance_proof_update_signature, event_handler, ): ev_handler = event_handler(token_network) (A, B) = get_accounts(2) deposit_A = 10 settle_timeout = SETTLE_TIMEOUT_MIN locksroot = fake_hex(32, '00') channel_identifier = create_channel(A, B)[0] channel_deposit(A, deposit_A, B) balance_proof_A = create_balance_proof(channel_identifier, A, 10, 0, 1, locksroot) balance_proof_B = create_balance_proof(channel_identifier, B, 5, 0, 3, locksroot) balance_proof_update_signature_B = create_balance_proof_update_signature( B, channel_identifier, *balance_proof_A, ) token_network.functions.closeChannel(B, *balance_proof_B).transact( {'from': A}) token_network.functions.updateNonClosingBalanceProof( A, B, *balance_proof_A, balance_proof_update_signature_B, ).transact({'from': B}) web3.testing.mine(settle_timeout) txn_hash = token_network.functions.settleChannel( B, 5, 0, locksroot, A, 10, 0, locksroot, ).transact({'from': A}) ev_handler.add(txn_hash, EVENT_CHANNEL_SETTLED, check_channel_settled( channel_identifier, 5, 5, )) ev_handler.check()
def test_verifyWithdrawSignatures( token_network_test, create_withdraw_signatures, get_accounts, ): (A, B) = get_accounts(2) fake_signature = fake_bytes(64) channel_identifier = fake_hex(32) (signature_A, signature_B) = create_withdraw_signatures( [A, B], channel_identifier, A, 1, token_network_test.address, ) token_network_test.functions.verifyWithdrawSignaturesPublic( channel_identifier, A, B, 1, signature_A, signature_B, ).call() with pytest.raises(TransactionFailed): token_network_test.functions.verifyWithdrawSignaturesPublic( channel_identifier, A, B, 3, signature_B, signature_A, ).call() with pytest.raises(TransactionFailed): token_network_test.functions.verifyWithdrawSignaturesPublic( channel_identifier, A, B, 3, signature_A, fake_signature, ).call() with pytest.raises(TransactionFailed): token_network_test.functions.verifyWithdrawSignaturesPublic( channel_identifier, A, B, 3, fake_signature, signature_B, ).call()