def test_update_channel_event( get_accounts: Callable, token_network: Contract, create_channel: Callable, channel_deposit: Callable, create_balance_proof: Callable, create_balance_proof_countersignature: Callable, event_handler: Callable, ) -> None: """ Successful updateNonClosingBalanceProof() emit BALANCE_PROOF_UPDATED events """ ev_handler = event_handler(token_network) (A, B) = get_accounts(2) deposit_A = 10 deposit_B = 10 channel_identifier = create_channel(A, B)[0] channel_deposit(channel_identifier, A, deposit_A, B) channel_deposit(channel_identifier, B, deposit_B, A) balance_proof_B = create_balance_proof(channel_identifier, B, 5, 0, 3) closing_sig_A = create_balance_proof_countersignature( A, channel_identifier, MessageTypeId.BALANCE_PROOF, *balance_proof_B ) balance_proof_A = create_balance_proof(channel_identifier, A, 2, 0, 1) balance_proof_update_signature_B = create_balance_proof_countersignature( B, channel_identifier, MessageTypeId.BALANCE_PROOF_UPDATE, *balance_proof_A ) token_network.functions.closeChannel( channel_identifier, B, A, *balance_proof_B, closing_sig_A ).call_and_transact({"from": A}) txn_hash = token_network.functions.updateNonClosingBalanceProof( channel_identifier, A, B, *balance_proof_A, balance_proof_update_signature_B ).call_and_transact({"from": B}) ev_handler.add( txn_hash, ChannelEvent.BALANCE_PROOF_UPDATED, check_transfer_updated(channel_identifier, A, 1, balance_proof_A[0]), ) ev_handler.check() # Test event for second balance proof update balance_proof_A2 = create_balance_proof(channel_identifier, A, 4, 0, 2) balance_proof_update_signature_B2 = create_balance_proof_countersignature( B, channel_identifier, MessageTypeId.BALANCE_PROOF_UPDATE, *balance_proof_A2 ) txn_hash = token_network.functions.updateNonClosingBalanceProof( channel_identifier, A, B, *balance_proof_A2, balance_proof_update_signature_B2 ).call_and_transact({"from": B}) ev_handler.add( txn_hash, ChannelEvent.BALANCE_PROOF_UPDATED, check_transfer_updated(channel_identifier, A, 2, balance_proof_A2[0]), ) ev_handler.check()
def test_update_channel_event(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 deposit_B = 10 channel_identifier = create_channel(A, B)[0] channel_deposit(A, deposit_A, B) channel_deposit(B, deposit_B, A) balance_proof_B = create_balance_proof(channel_identifier, B, 5, 0, 3) balance_proof_A = create_balance_proof(channel_identifier, A, 2, 0, 1) 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}) txn_hash = token_network.functions.updateNonClosingBalanceProof( A, B, *balance_proof_A, balance_proof_update_signature_B).transact({'from': B}) ev_handler.add(txn_hash, EVENT_CHANNEL_BALANCE_PROOF_UPDATED, check_transfer_updated(channel_identifier, A)) ev_handler.check()
def test_update_channel_event(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 deposit_B = 10 channel_identifier = create_channel(A, B) channel_deposit(channel_identifier, A, deposit_A) channel_deposit(channel_identifier, B, deposit_B) balance_proof_B = create_balance_proof(channel_identifier, B, 5, 0, 3) balance_proof_A = create_balance_proof(channel_identifier, A, 2, 0, 1) balance_proof_update_signature_B = create_balance_proof_update_signature( B, *balance_proof_A) token_network.transact({'from': A}).closeChannel(*balance_proof_B) txn_hash = token_network.transact({ 'from': B }).updateNonClosingBalanceProof(*balance_proof_A, balance_proof_update_signature_B) ev_handler.add(txn_hash, E_TRANSFER_UPDATED, check_transfer_updated(channel_identifier, A)) ev_handler.check()
def test_update_channel_event( get_accounts, token_network, create_channel, channel_deposit, create_balance_proof, create_balance_proof_update_signature, event_handler, ): """ Successful updateNonClosingBalanceProof() emit BALANCE_PROOF_UPDATED events """ ev_handler = event_handler(token_network) (A, B) = get_accounts(2) deposit_A = 10 deposit_B = 10 channel_identifier = create_channel(A, B)[0] channel_deposit(channel_identifier, A, deposit_A, B) channel_deposit(channel_identifier, B, deposit_B, A) balance_proof_B = create_balance_proof(channel_identifier, B, 5, 0, 3) balance_proof_A = create_balance_proof(channel_identifier, A, 2, 0, 1) balance_proof_update_signature_B = create_balance_proof_update_signature( B, channel_identifier, *balance_proof_A, ) token_network.functions.closeChannel( channel_identifier, B, *balance_proof_B, ).transact({'from': A}) txn_hash = token_network.functions.updateNonClosingBalanceProof( channel_identifier, A, B, *balance_proof_A, balance_proof_update_signature_B, ).transact({'from': B}) ev_handler.add( txn_hash, ChannelEvent.BALANCE_PROOF_UPDATED, check_transfer_updated(channel_identifier, A, 1), ) ev_handler.check() # Test event for second balance proof update balance_proof_A2 = create_balance_proof(channel_identifier, A, 4, 0, 2) balance_proof_update_signature_B2 = create_balance_proof_update_signature( B, channel_identifier, *balance_proof_A2, ) txn_hash = token_network.functions.updateNonClosingBalanceProof( channel_identifier, A, B, *balance_proof_A2, balance_proof_update_signature_B2, ).transact({'from': B}) ev_handler.add( txn_hash, ChannelEvent.BALANCE_PROOF_UPDATED, check_transfer_updated(channel_identifier, A, 2), ) ev_handler.check()