stargate: Fill out IBC query tests
This commit is contained in:
parent
8fa28b2d0b
commit
a5f2033757
@ -1,7 +1,10 @@
|
||||
import { Client as TendermintClient } from "@cosmjs/tendermint-rpc";
|
||||
import Long from "long";
|
||||
|
||||
import { cosmos, ibc } from "../codec";
|
||||
import { pendingWithoutSimapp, simapp } from "../testutils.spec";
|
||||
import { IbcExtension, setupIbcExtension } from "./ibc";
|
||||
import * as ibcTest from "./ibctestdata.spec";
|
||||
import { QueryClient } from "./queryclient";
|
||||
|
||||
async function makeClientWithIbc(rpcUrl: string): Promise<[QueryClient & IbcExtension, TendermintClient]> {
|
||||
@ -12,116 +15,130 @@ async function makeClientWithIbc(rpcUrl: string): Promise<[QueryClient & IbcExte
|
||||
describe("IbcExtension", () => {
|
||||
describe("unverified", () => {
|
||||
describe("channel", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel("foo", "bar");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.channel(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.channel).toEqual(ibcTest.channel);
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("channels", () => {
|
||||
it("can be called", async () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channels();
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeInstanceOf(cosmos.base.query.v1beta1.PageResponse);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("connectionChannels", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connectionChannels("foo");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.connectionChannels(ibcTest.connectionId);
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeInstanceOf(cosmos.base.query.v1beta1.PageResponse);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitment", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetCommitment("foo", "bar", 0);
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.packetCommitment(ibcTest.portId, ibcTest.channelId, 4);
|
||||
expect(response.commitment).toEqual(ibcTest.commitmentData);
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitments", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetCommitments("foo", "bar");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.packetCommitments(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.commitments).toEqual([ibcTest.packetState]);
|
||||
expect(response.pagination).toBeInstanceOf(cosmos.base.query.v1beta1.PageResponse);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgement", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetAcknowledgement("foo", "bar", 1);
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.packetAcknowledgement(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
1,
|
||||
);
|
||||
expect(response.acknowledgement).toEqual(ibcTest.acknowledgement);
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedPackets", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.unreceivedPackets("foo", "bar", [0, 1]);
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.unreceivedPackets(ibcTest.portId, ibcTest.channelId, [
|
||||
4,
|
||||
5,
|
||||
]);
|
||||
expect(response.sequences).toEqual([Long.fromInt(4, true), Long.fromInt(5, true)]);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedAcks", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.unreceivedAcks("foo", "bar", [0, 1]);
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.unreceivedAcks(ibcTest.portId, ibcTest.channelId, [
|
||||
4,
|
||||
5,
|
||||
]);
|
||||
expect(response.sequences).toEqual([Long.fromInt(4, true)]);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextSequenceReceive", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.nextSequenceReceive("foo", "bar");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.nextSequenceReceive(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.nextSequenceReceive).toEqual(Long.fromInt(1, true));
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
@ -130,38 +147,40 @@ describe("IbcExtension", () => {
|
||||
// Queries for ibc.connection
|
||||
|
||||
describe("connection", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connection("foo");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.connection(ibcTest.connectionId);
|
||||
expect(response.connection).toEqual(ibcTest.connection);
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("connections", () => {
|
||||
it("can be called", async () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connections();
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
expect(response.connections).toEqual([ibcTest.identifiedConnection]);
|
||||
expect(response.pagination).toBeInstanceOf(cosmos.base.query.v1beta1.PageResponse);
|
||||
expect(response.height).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientConnections", () => {
|
||||
it("can be called", async () => {
|
||||
pending("Fails with 'Query failed with (1): internal'. Make it work.");
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.clientConnections("foo");
|
||||
expect(response).toBeTruthy(); // TODO: implement checks
|
||||
const response = await client.ibc.unverified.clientConnections(ibcTest.clientId);
|
||||
expect(response.connectionPaths).toEqual([ibcTest.connectionId]);
|
||||
expect(response.proofHeight).toBeInstanceOf(ibc.core.client.v1.Height);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
|
||||
82
packages/stargate/src/queries/ibctestdata.spec.ts
Normal file
82
packages/stargate/src/queries/ibctestdata.spec.ts
Normal file
@ -0,0 +1,82 @@
|
||||
import { fromBase64 } from "@cosmjs/encoding";
|
||||
import Long from "long";
|
||||
|
||||
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 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",
|
||||
}),
|
||||
connectionHops: [connectionId],
|
||||
version: "pong",
|
||||
});
|
||||
|
||||
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",
|
||||
}),
|
||||
connectionHops: [connectionId],
|
||||
version: "pong",
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
});
|
||||
|
||||
export const commitmentData = fromBase64("DIuspQzH8GooFceqNxkTsiZXBn9qoWWJMUqsAIB1G5c=");
|
||||
|
||||
export const packetState = ibc.core.channel.v1.PacketState.create({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromInt(4, true),
|
||||
data: commitmentData,
|
||||
});
|
||||
export const acknowledgement = fromBase64("9RKC5OuTvBsFMtD79dHHvb9qCxw08IKsSJlAwmiw8tI=");
|
||||
|
||||
export const connection = ibc.core.connection.v1.ConnectionEnd.create({
|
||||
clientId: clientId,
|
||||
versions: [
|
||||
ibc.core.connection.v1.Version.create({
|
||||
identifier: "1",
|
||||
features: ["ORDER_ORDERED", "ORDER_UNORDERED"],
|
||||
}),
|
||||
],
|
||||
state: ibc.core.connection.v1.State.STATE_OPEN,
|
||||
counterparty: ibc.core.connection.v1.Counterparty.create({
|
||||
clientId: "client0Fortestchain0",
|
||||
connectionId: "testchain1-conn0",
|
||||
prefix: ibc.core.commitment.v1.MerklePrefix.create({
|
||||
keyPrefix: fromBase64("aWJj"),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const identifiedConnection = ibc.core.connection.v1.IdentifiedConnection.create({
|
||||
id: connectionId,
|
||||
clientId: clientId,
|
||||
versions: [
|
||||
ibc.core.connection.v1.Version.create({
|
||||
identifier: "1",
|
||||
features: ["ORDER_ORDERED", "ORDER_UNORDERED"],
|
||||
}),
|
||||
],
|
||||
state: ibc.core.connection.v1.State.STATE_OPEN,
|
||||
counterparty: ibc.core.connection.v1.Counterparty.create({
|
||||
clientId: "client0Fortestchain0",
|
||||
connectionId: "testchain1-conn0",
|
||||
prefix: ibc.core.commitment.v1.MerklePrefix.create({
|
||||
keyPrefix: fromBase64("aWJj"),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user