def handle_secretreveal(payment_state, state_change, channelidentifiers_to_channels): channel_identifier = payment_state.initiator.channel_identifier channel_state = channelidentifiers_to_channels[channel_identifier] sub_iteration = initiator.handle_secretreveal( payment_state.initiator, state_change, channel_state, ) iteration = iteration_from_sub(payment_state, sub_iteration) return iteration
def handle_secretreveal( payment_state: InitiatorPaymentState, state_change: ReceiveSecretReveal, channelidentifiers_to_channels: initiator.ChannelMap, pseudo_random_generator: random.Random, ) -> TransitionResult: channel_identifier = payment_state.initiator.channel_identifier channel_state = channelidentifiers_to_channels[channel_identifier] sub_iteration = initiator.handle_secretreveal( payment_state.initiator, state_change, channel_state, pseudo_random_generator, ) iteration = iteration_from_sub(payment_state, sub_iteration) return iteration
def test_handle_secretreveal(): channel1 = factories.make_channel( our_balance=UNIT_TRANSFER_AMOUNT, token_address=UNIT_TOKEN_ADDRESS, token_network_identifier=UNIT_TOKEN_NETWORK_ADDRESS, ) channel_map = {channel1.identifier: channel1} available_routes = [factories.route_from_channel(channel1)] pseudo_random_generator = random.Random() block_number = 10 manager_state = make_initiator_manager_state( available_routes, factories.UNIT_TRANSFER_DESCRIPTION, channel_map, pseudo_random_generator, block_number, ) secret_reveal = ReceiveSecretReveal( secret=UNIT_SECRET, sender=channel1.partner_state.address, ) message_identifier = message_identifier_from_prng( deepcopy(pseudo_random_generator)) iteration = initiator.handle_secretreveal( initiator_state=manager_state.initiator, state_change=secret_reveal, channel_state=channel1, pseudo_random_generator=pseudo_random_generator, ) assert events.must_contain_entry( iteration.events, SendBalanceProof, { 'message_identifier': message_identifier, 'payment_identifier': manager_state.initiator.transfer_description.payment_identifier, })