def passive_channel_try_then_start(c: Config, ibc1: ChainId, ibc0: ChainId, ibc1_conn_id: ConnectionId, ibc0_conn_id: ConnectionId, port_id: PortId): # 1. create a channel in Try state ibc1_chan_id = chan_open_init(c, dst=ibc1, src=ibc0, dst_conn=ibc1_conn_id) sleep(2.0) ibc0_chan_id = chan_open_try(c, dst=ibc0, src=ibc1, dst_conn=ibc0_conn_id, src_port=port_id, dst_port=port_id, src_chan=ibc1_chan_id) sleep(2.0) # 2. start relaying proc = relayer.start(c) # 3. wait for channel handshake to finish and verify channel state on both chains verify_state(c, ibc1, ibc0, ibc1_chan_id, port_id) # 4. All good, stop the relayer proc.kill()
def passive_connection_init_then_start(c: Config, ibc1: ChainId, ibc0: ChainId, ibc1_client_id: ClientId, ibc0_client_id: ClientId ): # 1. create a connection in Init state ibc1_conn_id_a = conn_init(c, dst=ibc1, src=ibc0, dst_client=ibc1_client_id, src_client=ibc0_client_id) # 2. start hermes proc = relayer.start(c) sleep(10.0) # 3. wait for connection handshake to finish and verify connection state on both chains verify_state(c, ibc1, ibc0, ibc1_conn_id_a) # 4. All good, stop the relayer proc.kill()
def passive_packets(c: Config, ibc0: ChainId, ibc1: ChainId, port_id: PortId, ibc0_channel_id: ChannelId, ibc1_channel_id: ChannelId): # 1. create some unreceived acks # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 2 packet.packet_send(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id, amount=10000, height_offset=1000, number_msgs=2) # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 2 packet.packet_send(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id, amount=10000, height_offset=1000, number_msgs=2) sleep(5.0) # hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 packet.packet_recv(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id) # hermes tx raw packet-recv ibc-0 ibc-1 transfer channel-1 packet.packet_recv(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id) # 2. create some unreceived packets # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 3 packet.packet_send(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id, amount=10000, height_offset=1000, number_msgs=3) # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 4 packet.packet_send(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id, amount=10000, height_offset=1000, number_msgs=4) sleep(10.0) # 3. verify the expected number of unreceived packets and acks on each channel end # hermes query packet unreceived-packets ibc-0 transfer channel-0 unreceived = packet.query_unreceived_packets(c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 3), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-acks ibc-1 transfer channel-1 unreceived = packet.query_unreceived_acks(c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 2), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-packets ibc-1 transfer channel-1 unreceived = packet.query_unreceived_packets(c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 4), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-acks ibc-0 transfer channel-0 unreceived = packet.query_unreceived_acks(c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 2), (unreceived, "unreceived packet mismatch") # 4. start relaying - it should clear the unreceived packets proc = relayer.start(c) # 5. wait for the relayer to initialize and pick up pending packets sleep(10.0) # 6. verify that there are no pending packets # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 3 packet.packet_send(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id, amount=10000, height_offset=1000, number_msgs=3) # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 4 packet.packet_send(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id, amount=10000, height_offset=1000, number_msgs=4) sleep(10.0) # hermes query packet unreceived-packets ibc-1 transfer channel-1 unreceived = packet.query_unreceived_packets(c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)") # hermes query packet unreceived-acks ibc-1 transfer channel-1 unreceived = packet.query_unreceived_acks(c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived acks mismatch (expected 0)") # hermes query packet unreceived-packets ibc-0 transfer channel-0 unreceived = packet.query_unreceived_packets(c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)") # hermes query packet unreceived-acks ibc-0 transfer channel-0 unreceived = packet.query_unreceived_acks(c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived acks mismatch (expected 0)") # 7.Stop the relayer proc.kill()
def loop(c: Config): IBC_0 = ChainId('ibc-0') IBC_1 = ChainId('ibc-1') TRANSFER = PortId('transfer') IBC_0_CHANNEL = ChannelId('channel-0') IBC_1_CHANNEL = ChannelId('channel-1') # 1. create some unreceived acks # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 2 packet.packet_send(c, src=IBC_0, dst=IBC_1, src_port=TRANSFER, src_channel=IBC_0_CHANNEL, amount=10000, height_offset=1000, number_msgs=2) # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 2 packet.packet_send(c, src=IBC_1, dst=IBC_0, src_port=TRANSFER, src_channel=IBC_1_CHANNEL, amount=10000, height_offset=1000, number_msgs=2) sleep(5.0) # hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 packet.packet_recv(c, src=IBC_0, dst=IBC_1, src_port=TRANSFER, src_channel=IBC_0_CHANNEL) # hermes tx raw packet-recv ibc-0 ibc-1 transfer channel-1 packet.packet_recv(c, src=IBC_1, dst=IBC_0, src_port=TRANSFER, src_channel=IBC_1_CHANNEL) # 2. create some unreceived packets # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 3 packet.packet_send(c, src=IBC_1, dst=IBC_0, src_port=TRANSFER, src_channel=IBC_1_CHANNEL, amount=10000, height_offset=1000, number_msgs=3) # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 4 packet.packet_send(c, src=IBC_0, dst=IBC_1, src_port=TRANSFER, src_channel=IBC_0_CHANNEL, amount=10000, height_offset=1000, number_msgs=4) sleep(10.0) # 3. verify the expected number of unreceived packets and acks on each channel end # hermes query packet unreceived-packets ibc-0 transfer channel-0 unreceived = packet.query_unreceived_packets(c, chain=IBC_0, port=TRANSFER, channel=IBC_0_CHANNEL) assert (len(unreceived) == 3), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-acks ibc-1 transfer channel-1 unreceived = packet.query_unreceived_acks(c, chain=IBC_1, port=TRANSFER, channel=IBC_1_CHANNEL) assert (len(unreceived) == 2), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-packets ibc-1 transfer channel-1 unreceived = packet.query_unreceived_packets(c, chain=IBC_1, port=TRANSFER, channel=IBC_1_CHANNEL) assert (len(unreceived) == 4), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-acks ibc-0 transfer channel-0 unreceived = packet.query_unreceived_acks(c, chain=IBC_0, port=TRANSFER, channel=IBC_0_CHANNEL) assert (len(unreceived) == 2), (unreceived, "unreceived packet mismatch") sleep(5.0) # 4. start relaying - it should clear the unreceived packets proc = relayer.start(c) sleep(5.0) # 5. wait a bit and make sure there are no pending packets # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 3 packet.packet_send(c, src=IBC_1, dst=IBC_0, src_port=TRANSFER, src_channel=IBC_1_CHANNEL, amount=10000, height_offset=1000, number_msgs=3) # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 4 packet.packet_send(c, src=IBC_0, dst=IBC_1, src_port=TRANSFER, src_channel=IBC_0_CHANNEL, amount=10000, height_offset=1000, number_msgs=4) sleep(10.0) # hermes query packet unreceived-packets ibc-1 transfer channel-1 unreceived = packet.query_unreceived_packets(c, chain=IBC_1, port=TRANSFER, channel=IBC_1_CHANNEL) assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-acks ibc-1 transfer channel-1 unreceived = packet.query_unreceived_acks(c, chain=IBC_1, port=TRANSFER, channel=IBC_1_CHANNEL) assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-packets ibc-0 transfer channel-0 unreceived = packet.query_unreceived_packets(c, chain=IBC_0, port=TRANSFER, channel=IBC_0_CHANNEL) assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch") # hermes query packet unreceived-acks ibc-0 transfer channel-0 unreceived = packet.query_unreceived_acks(c, chain=IBC_0, port=TRANSFER, channel=IBC_0_CHANNEL) assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch") # 6. All good, stop the relayer proc.kill()