def test_transfer_statechange_operators(): # pylint: disable=unneeded-not block_hash = factories.make_transaction_hash() a = Block( block_number=2, gas_limit=1, block_hash=block_hash, ) b = Block( block_number=2, gas_limit=1, block_hash=block_hash, ) c = Block( block_number=3, gas_limit=1, block_hash=factories.make_transaction_hash(), ) assert a == b assert not a != b assert a != c assert not a == c a = ActionCancelPayment(2) b = ActionCancelPayment(2) c = ActionCancelPayment(3) assert a == b assert not a != b assert a != c assert not a == c
def test_transfer_statechange_operators(): # pylint: disable=unneeded-not block_hash = factories.make_transaction_hash() a = Block( block_number=2, gas_limit=1, block_hash=block_hash, ) b = Block( block_number=2, gas_limit=1, block_hash=block_hash, ) c = Block( block_number=3, gas_limit=1, block_hash=factories.make_transaction_hash(), ) assert a == b assert not a != b assert a != c assert not a == c a = ActionCancelPayment(2) b = ActionCancelPayment(2) c = ActionCancelPayment(3) assert a == b assert not a != b assert a != c assert not a == c token_network_identifier = factories.make_address() a = ActionTransferDirect( token_network_identifier, receiver_address=ADDRESS, payment_identifier=2, amount=2, ) b = ActionTransferDirect( token_network_identifier, receiver_address=ADDRESS, payment_identifier=2, amount=2, ) c = ActionTransferDirect( token_network_identifier, receiver_address=ADDRESS2, # different recipient payment_identifier=2, amount=2, ) assert a == b assert not a != b assert a != c assert not a == c
def test_transfer_statechange_operators(): # pylint: disable=unneeded-not a = Block(2) b = Block(2) c = Block(3) assert a == b assert not a != b assert a != c assert not a == c a = ActionCancelPayment(2) b = ActionCancelPayment(2) c = ActionCancelPayment(3) assert a == b assert not a != b assert a != c assert not a == c payment_network_identifier = factories.make_address() token_address = factories.make_address() a = ActionTransferDirect( payment_network_identifier, token_address, receiver_address=ADDRESS, payment_identifier=2, amount=2, ) b = ActionTransferDirect( payment_network_identifier, token_address, receiver_address=ADDRESS, payment_identifier=2, amount=2, ) c = ActionTransferDirect( payment_network_identifier, token_address, receiver_address=ADDRESS2, # different recipient payment_identifier=2, amount=2, ) assert a == b assert not a != b assert a != c assert not a == c
def test_transfer_statechange_operators(): # pylint: disable=unneeded-not a = Block(2) b = Block(2) c = Block(3) assert a == b assert not a != b assert a != c assert not a == c a = ActionCancelPayment(2) b = ActionCancelPayment(2) c = ActionCancelPayment(3) assert a == b assert not a != b assert a != c assert not a == c a = ActionTransferDirect( receiver_address=ADDRESS, identifier=2, amount=2, ) b = ActionTransferDirect( receiver_address=ADDRESS, identifier=2, amount=2, ) c = ActionTransferDirect( receiver_address=ADDRESS2, # different recipient identifier=2, amount=2, ) assert a == b assert not a != b assert a != c assert not a == c
def test_cancel_transfer(): amount = UNIT_TRANSFER_AMOUNT block_number = 1 pseudo_random_generator = random.Random() channel1 = factories.make_channel( our_balance=amount, our_address=UNIT_TRANSFER_INITIATOR, token_address=UNIT_TOKEN_ADDRESS, token_network_identifier=UNIT_TOKEN_NETWORK_ADDRESS, ) channelmap = {channel1.identifier: channel1} available_routes = [factories.route_from_channel(channel1)] current_state = make_initiator_state( available_routes, factories.UNIT_TRANSFER_DESCRIPTION, channelmap, pseudo_random_generator, block_number, ) state_change = ActionCancelPayment( payment_identifier=UNIT_TRANSFER_IDENTIFIER, ) iteration = initiator_manager.state_transition( current_state, state_change, channelmap, pseudo_random_generator, block_number, ) assert iteration.new_state is None assert len(iteration.events) == 2 unlocked_failed = next(e for e in iteration.events if isinstance(e, EventUnlockFailed)) sent_failed = next(e for e in iteration.events if isinstance(e, EventTransferSentFailed)) assert unlocked_failed assert sent_failed
def test_cancel_transfer(): setup = setup_initiator_tests() state_change = ActionCancelPayment( payment_identifier=UNIT_TRANSFER_IDENTIFIER, ) iteration = initiator_manager.state_transition( setup.current_state, state_change, setup.channel_map, setup.prng, setup.block_number, ) assert iteration.new_state is None assert len(iteration.events) == 2 unlocked_failed = next(e for e in iteration.events if isinstance(e, EventUnlockFailed)) sent_failed = next(e for e in iteration.events if isinstance(e, EventPaymentSentFailed)) assert unlocked_failed assert sent_failed