From 4aba11ba606b0512df884558cfacbcfe8ffd2dd4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 11 Jan 2021 15:27:52 +0100 Subject: [PATCH] Adapt tests to new IBC data --- packages/stargate/src/queries/ibc.spec.ts | 19 ++--- .../stargate/src/queries/ibctestdata.spec.ts | 70 +++++++++---------- packages/stargate/src/testutils.spec.ts | 30 ++++++-- 3 files changed, 67 insertions(+), 52 deletions(-) diff --git a/packages/stargate/src/queries/ibc.spec.ts b/packages/stargate/src/queries/ibc.spec.ts index 75bdba1f..16c46057 100644 --- a/packages/stargate/src/queries/ibc.spec.ts +++ b/packages/stargate/src/queries/ibc.spec.ts @@ -60,8 +60,12 @@ describe("IbcExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); - const response = await client.ibc.unverified.packetCommitment(ibcTest.portId, ibcTest.channelId, 4); - expect(response.commitment).toEqual(ibcTest.commitmentData); + const response = await client.ibc.unverified.packetCommitment( + ibcTest.portId, + ibcTest.channelId, + ibcTest.commitment.sequence, + ); + expect(response.commitment).toEqual(ibcTest.commitment.data); expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height); tmClient.disconnect(); @@ -84,13 +88,14 @@ describe("IbcExtension", () => { describe("packetAcknowledgement", () => { it("works", async () => { + pending("We don't have an acknowledgement for testing at the moment"); pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); const response = await client.ibc.unverified.packetAcknowledgement( ibcTest.portId, ibcTest.channelId, - 1, + ibcTest.commitment.sequence, ); expect(response.acknowledgement).toEqual(ibcTest.packetAcknowledgements[0].data); expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height); @@ -125,12 +130,8 @@ describe("IbcExtension", () => { 1, 2, 3, - 4, - 5, - 6, - 7, ]); - expect(response.sequences).toEqual([4, 5, 6, 7].map((n) => Long.fromInt(n, true))); + expect(response.sequences).toEqual([1, 2, 3].map((n) => Long.fromInt(n, true))); expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height); tmClient.disconnect(); @@ -151,7 +152,7 @@ describe("IbcExtension", () => { 6, 7, ]); - expect(response.sequences).toEqual([Long.fromInt(4, true)]); + expect(response.sequences).toEqual([Long.fromInt(ibcTest.commitment.sequence, true)]); expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height); tmClient.disconnect(); diff --git a/packages/stargate/src/queries/ibctestdata.spec.ts b/packages/stargate/src/queries/ibctestdata.spec.ts index d6fe2fac..1e3c48eb 100644 --- a/packages/stargate/src/queries/ibctestdata.spec.ts +++ b/packages/stargate/src/queries/ibctestdata.spec.ts @@ -5,64 +5,60 @@ import { ibc } from "../codec"; // From scripts/simapp/genesis-ibc.json -export const portId = "wasm.cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5"; -export const channelId = "testchain0-conn00"; -export const connectionId = "testchain0-conn0"; -export const clientId = "client0Fortestchain1"; +export const portId = "transfer"; +export const channelId = "channel-0"; +export const connectionId = "connection-0"; +export const clientId = "07-tendermint-0"; export const channel = ibc.core.channel.v1.Channel.create({ state: ibc.core.channel.v1.State.STATE_OPEN, ordering: ibc.core.channel.v1.Order.ORDER_UNORDERED, counterparty: ibc.core.channel.v1.Counterparty.create({ - portId: "wasm.cosmos10pyejy66429refv3g35g2t7am0was7yacjc2l4", - channelId: "testchain1-conn00", + portId: portId, + channelId: channelId, }), connectionHops: [connectionId], - version: "pong", + version: "ics20-1", }); export const identifiedChannel = ibc.core.channel.v1.IdentifiedChannel.create({ state: ibc.core.channel.v1.State.STATE_OPEN, ordering: ibc.core.channel.v1.Order.ORDER_UNORDERED, counterparty: ibc.core.channel.v1.Counterparty.create({ - portId: "wasm.cosmos10pyejy66429refv3g35g2t7am0was7yacjc2l4", - channelId: "testchain1-conn00", + portId: portId, + channelId: "channel-0", }), connectionHops: [connectionId], - version: "pong", + version: "ics20-1", portId: portId, channelId: channelId, }); -export const commitmentData = fromBase64("DIuspQzH8GooFceqNxkTsiZXBn9qoWWJMUqsAIB1G5c="); +/** + * ``` + * jq ".channel_genesis.commitments[0]" scripts/simapp/genesis-ibc.json + * ``` + */ +export const commitment = { + sequence: 1, + data: fromBase64("hYz5Dx6o09DcSEWZR6xlJYwLgYUnLithsXMGtujic4I="), +}; export const packetState = ibc.core.channel.v1.PacketState.create({ portId: portId, channelId: channelId, - sequence: Long.fromInt(4, true), - data: commitmentData, + sequence: Long.fromInt(commitment.sequence, true), + data: commitment.data, }); -export const packetAcknowledgements = [ - ibc.core.channel.v1.PacketState.create({ - portId: portId, - channelId: channelId, - sequence: Long.fromInt(1, true), - data: fromBase64("9RKC5OuTvBsFMtD79dHHvb9qCxw08IKsSJlAwmiw8tI="), - }), - ibc.core.channel.v1.PacketState.create({ - portId: portId, - channelId: channelId, - sequence: Long.fromInt(2, true), - data: fromBase64("Nj784gGVOFk2mdt+wAk/LOoPdUOo+5+0JfYs0yAubZU="), - }), - ibc.core.channel.v1.PacketState.create({ - portId: portId, - channelId: channelId, - sequence: Long.fromInt(3, true), - data: fromBase64("+lLTGP1dlSD6MBpJgBIvx98Psd3U2xo500K7JyMkya8="), - }), -]; +/** + * Unfortunatly empty right now + * + * ``` + * jq ".channel_genesis.acknowledgements" scripts/simapp/genesis-ibc.json + * ``` + */ +export const packetAcknowledgements: ibc.core.channel.v1.PacketState[] = []; export const connection = ibc.core.connection.v1.ConnectionEnd.create({ clientId: clientId, @@ -74,8 +70,8 @@ export const connection = ibc.core.connection.v1.ConnectionEnd.create({ ], state: ibc.core.connection.v1.State.STATE_OPEN, counterparty: ibc.core.connection.v1.Counterparty.create({ - clientId: "client0Fortestchain0", - connectionId: "testchain1-conn0", + clientId: "07-tendermint-0", + connectionId: "connection-0", prefix: ibc.core.commitment.v1.MerklePrefix.create({ keyPrefix: fromBase64("aWJj"), }), @@ -93,8 +89,8 @@ export const identifiedConnection = ibc.core.connection.v1.IdentifiedConnection. ], state: ibc.core.connection.v1.State.STATE_OPEN, counterparty: ibc.core.connection.v1.Counterparty.create({ - clientId: "client0Fortestchain0", - connectionId: "testchain1-conn0", + clientId: "07-tendermint-0", + connectionId: "connection-0", prefix: ibc.core.commitment.v1.MerklePrefix.create({ keyPrefix: fromBase64("aWJj"), }), diff --git a/packages/stargate/src/testutils.spec.ts b/packages/stargate/src/testutils.spec.ts index 9d2f4f14..3cc83f6c 100644 --- a/packages/stargate/src/testutils.spec.ts +++ b/packages/stargate/src/testutils.spec.ts @@ -72,15 +72,33 @@ export const unused = { }; export const validator = { - /** From first gentx's auth_info.signer_infos in scripts/simapp/template/.simapp/config/genesis.json */ + /** + * From first gentx's auth_info.signer_infos in scripts/simapp/template/.simapp/config/genesis.json + * + * ``` + * jq ".app_state.genutil.gen_txs[0].auth_info.signer_infos[0].public_key" scripts/simapp/template/.simapp/config/genesis.json + * ``` + */ pubkey: { type: "tendermint/PubKeySecp256k1", - value: "AiRHwaEnXTLekByvbz4VnCW1TW2Pelp/mb4tK8ple1Xq", + value: "Ap1EN+TjP611NX0PicqFJXknbLmxBbhgoCgGtRF7SLQk", }, - /** delegator_address from /cosmos.staking.v1beta1.MsgCreateValidator in scripts/simapp/template/.simapp/config/genesis.json */ - delegatorAddress: "cosmos10083dys7qlzn663wcusq6hkr8wp7k2mm0sk4u9", - /** validator_address from /cosmos.staking.v1beta1.MsgCreateValidator in scripts/simapp/template/.simapp/config/genesis.json */ - validatorAddress: "cosmosvaloper10083dys7qlzn663wcusq6hkr8wp7k2mm2yzqsk", + /** + * delegator_address from /cosmos.staking.v1beta1.MsgCreateValidator in scripts/simapp/template/.simapp/config/genesis.json + * + * ``` + * jq ".app_state.genutil.gen_txs[0].body.messages[0].delegator_address" scripts/simapp/template/.simapp/config/genesis.json + * ``` + */ + delegatorAddress: "cosmos1acf9m2d35rqsk2e7kcgsmkh5ekdjcjh5n86vyq", + /** + * validator_address from /cosmos.staking.v1beta1.MsgCreateValidator in scripts/simapp/template/.simapp/config/genesis.json + * + * ``` + * jq ".app_state.genutil.gen_txs[0].body.messages[0].validator_address" scripts/simapp/template/.simapp/config/genesis.json + * ``` + */ + validatorAddress: "cosmosvaloper1acf9m2d35rqsk2e7kcgsmkh5ekdjcjh5knwegn", accountNumber: 0, sequence: 1, };