mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 13:47:12 +00:00
Merge pull request #1501 from cosmos/more-cometclient2
More renamings and refactorings from Tendermint -> Comet (2)
This commit is contained in:
commit
660417efea
@ -170,8 +170,8 @@ export function fromOneElementArray<T>(elements: ArrayLike<T>): T {
|
||||
export async function makeWasmClient(
|
||||
endpoint: string,
|
||||
): Promise<QueryClient & AuthExtension & BankExtension & WasmExtension> {
|
||||
const tmClient = await Tendermint34Client.connect(endpoint);
|
||||
return QueryClient.withExtensions(tmClient, setupAuthExtension, setupBankExtension, setupWasmExtension);
|
||||
const cometClient = await Tendermint34Client.connect(endpoint);
|
||||
return QueryClient.withExtensions(cometClient, setupAuthExtension, setupBankExtension, setupWasmExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { encodePubkey } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { assert } from "@cosmjs/utils";
|
||||
import { BaseAccount } from "cosmjs-types/cosmos/auth/v1beta1/auth";
|
||||
import { Any } from "cosmjs-types/google/protobuf/any";
|
||||
@ -9,18 +9,16 @@ import { QueryClient } from "../../queryclient";
|
||||
import { nonExistentAddress, pendingWithoutSimapp, simapp, unused, validator } from "../../testutils.spec";
|
||||
import { AuthExtension, setupAuthExtension } from "./queries";
|
||||
|
||||
async function makeClientWithAuth(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & AuthExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupAuthExtension), tmClient];
|
||||
async function makeClientWithAuth(rpcUrl: string): Promise<[QueryClient & AuthExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupAuthExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("AuthExtension", () => {
|
||||
describe("account", () => {
|
||||
it("works for unused account", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithAuth(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrl);
|
||||
const account = await client.auth.account(unused.address);
|
||||
assert(account);
|
||||
|
||||
@ -33,12 +31,12 @@ describe("AuthExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works for account with pubkey and non-zero sequence", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithAuth(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrl);
|
||||
const account = await client.auth.account(validator.delegatorAddress);
|
||||
assert(account);
|
||||
|
||||
@ -50,18 +48,18 @@ describe("AuthExtension", () => {
|
||||
sequence: BigInt(validator.sequence),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("rejects for non-existent address", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithAuth(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrl);
|
||||
|
||||
await expectAsync(client.auth.account(nonExistentAddress)).toBeRejectedWithError(
|
||||
/account cosmos1p79apjaufyphcmsn4g07cynqf0wyjuezqu84hd not found/i,
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { makeCosmoshubPath } from "@cosmjs/amino";
|
||||
import { coins, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { assertDefined, sleep } from "@cosmjs/utils";
|
||||
import { GenericAuthorization } from "cosmjs-types/cosmos/authz/v1beta1/authz";
|
||||
|
||||
@ -18,11 +18,9 @@ import {
|
||||
} from "../../testutils.spec";
|
||||
import { AuthzExtension, setupAuthzExtension } from "./queries";
|
||||
|
||||
async function makeClientWithAuthz(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & AuthzExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupAuthzExtension), tmClient];
|
||||
async function makeClientWithAuthz(rpcUrl: string): Promise<[QueryClient & AuthzExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupAuthzExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("AuthzExtension", () => {
|
||||
@ -81,7 +79,7 @@ describe("AuthzExtension", () => {
|
||||
describe("grants", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithAuthz(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrl);
|
||||
const response = await client.authz.grants(granter1Address, grantee1Address, "");
|
||||
expect(response.grants.length).toEqual(1);
|
||||
const grant = response.grants[0];
|
||||
@ -98,14 +96,14 @@ describe("AuthzExtension", () => {
|
||||
// Check if it's the same one then we granted
|
||||
expect(msgDecoded).toEqual(grantedMsg);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("granter grants", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp46OrHigher();
|
||||
const [client, tmClient] = await makeClientWithAuthz(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrl);
|
||||
const response = await client.authz.granterGrants(granter1Address);
|
||||
expect(response.grants.length).toBeGreaterThanOrEqual(1);
|
||||
const grant = response.grants.find(
|
||||
@ -129,14 +127,14 @@ describe("AuthzExtension", () => {
|
||||
// Check if it's the same one then we granted
|
||||
expect(msgDecoded).toEqual(grantedMsg);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("grantee grants", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp46OrHigher();
|
||||
const [client, tmClient] = await makeClientWithAuthz(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithAuthz(simapp.tendermintUrl);
|
||||
const response = await client.authz.granteeGrants(grantee1Address);
|
||||
expect(response.grants.length).toEqual(1);
|
||||
const grant = response.grants[0];
|
||||
@ -157,7 +155,7 @@ describe("AuthzExtension", () => {
|
||||
// Check if it's the same one then we granted
|
||||
expect(msgDecoded).toEqual(grantedMsg);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
import { QueryClient } from "../../queryclient";
|
||||
import {
|
||||
@ -10,18 +10,16 @@ import {
|
||||
} from "../../testutils.spec";
|
||||
import { BankExtension, setupBankExtension } from "./queries";
|
||||
|
||||
async function makeClientWithBank(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & BankExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupBankExtension), tmClient];
|
||||
async function makeClientWithBank(rpcUrl: string): Promise<[QueryClient & BankExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupBankExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("BankExtension", () => {
|
||||
describe("balance", () => {
|
||||
it("works for different existing balances", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const response1 = await client.bank.balance(unused.address, simapp.denomFee);
|
||||
expect(response1).toEqual({
|
||||
@ -34,12 +32,12 @@ describe("BankExtension", () => {
|
||||
denom: simapp.denomStaking,
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("returns zero for non-existent balance", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.bank.balance(unused.address, "gintonic");
|
||||
expect(response).toEqual({
|
||||
@ -47,12 +45,12 @@ describe("BankExtension", () => {
|
||||
denom: "gintonic",
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("returns zero for non-existent address", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.bank.balance(nonExistentAddress, simapp.denomFee);
|
||||
expect(response).toEqual({
|
||||
@ -60,14 +58,14 @@ describe("BankExtension", () => {
|
||||
denom: simapp.denomFee,
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allBalances", () => {
|
||||
it("returns all balances for unused account", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const balances = await client.bank.allBalances(unused.address);
|
||||
expect(balances).toEqual([
|
||||
@ -81,24 +79,24 @@ describe("BankExtension", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("returns an empty list for non-existent account", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const balances = await client.bank.allBalances(nonExistentAddress);
|
||||
expect(balances).toEqual([]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("totalSupply", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const { supply } = await client.bank.totalSupply();
|
||||
expect(supply).toEqual([
|
||||
@ -112,14 +110,14 @@ describe("BankExtension", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("supplyOf", () => {
|
||||
it("works for existing denom", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.bank.supplyOf(simapp.denomFee);
|
||||
expect(response).toEqual({
|
||||
@ -127,12 +125,12 @@ describe("BankExtension", () => {
|
||||
denom: simapp.denomFee,
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("returns zero for non-existent denom", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.bank.supplyOf("gintonic");
|
||||
expect(response).toEqual({
|
||||
@ -140,14 +138,14 @@ describe("BankExtension", () => {
|
||||
denom: "gintonic",
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("denomMetadata", () => {
|
||||
it("works for existent denom", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const metadata = await client.bank.denomMetadata("ucosm");
|
||||
expect(metadata).toEqual(
|
||||
@ -172,23 +170,23 @@ describe("BankExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works for non-existent denom", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
await expectAsync(client.bank.denomMetadata("nothere")).toBeRejectedWithError(/code = NotFound/i);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("denomsMetadata", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrl);
|
||||
|
||||
const metadatas = await client.bank.denomsMetadata();
|
||||
expect(metadatas.length).toEqual(1);
|
||||
@ -214,7 +212,7 @@ describe("BankExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { coin, coins, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { sleep } from "@cosmjs/utils";
|
||||
import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
||||
|
||||
@ -20,9 +20,9 @@ import { DistributionExtension, setupDistributionExtension } from "./queries";
|
||||
|
||||
async function makeClientWithDistribution(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & DistributionExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupDistributionExtension), tmClient];
|
||||
): Promise<[QueryClient & DistributionExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupDistributionExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("DistributionExtension", () => {
|
||||
@ -60,20 +60,20 @@ describe("DistributionExtension", () => {
|
||||
describe("communityPool", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.communityPool();
|
||||
expect(response.pool).toBeDefined();
|
||||
expect(response.pool).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegationRewards", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.delegationRewards(
|
||||
faucet.address0,
|
||||
@ -82,98 +82,98 @@ describe("DistributionExtension", () => {
|
||||
expect(response.rewards).toBeDefined();
|
||||
expect(response.rewards).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegationTotalRewards", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.delegationTotalRewards(faucet.address0);
|
||||
expect(response.rewards).toBeDefined();
|
||||
expect(response.rewards).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegatorValidators", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.delegatorValidators(faucet.address0);
|
||||
expect(response.validators).toBeDefined();
|
||||
expect(response.validators).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegatorWithdrawAddress", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.delegatorWithdrawAddress(faucet.address0);
|
||||
expect(response.withdrawAddress).toBeDefined();
|
||||
expect(response.withdrawAddress).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("params", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.params();
|
||||
expect(response.params).toBeDefined();
|
||||
expect(response.params).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatorCommission", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.validatorCommission(validator.validatorAddress);
|
||||
expect(response.commission).toBeDefined();
|
||||
expect(response.commission).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatorOutstandingRewards", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.validatorOutstandingRewards(validator.validatorAddress);
|
||||
expect(response.rewards).toBeDefined();
|
||||
expect(response.rewards).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatorSlashes", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithDistribution(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.distribution.validatorSlashes(validator.validatorAddress, 1, 5);
|
||||
expect(response.slashes).toBeDefined();
|
||||
expect(response.slashes).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { coin, coins, makeCosmoshubPath } from "@cosmjs/amino";
|
||||
import { toAscii } from "@cosmjs/encoding";
|
||||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
import {
|
||||
ProposalStatus,
|
||||
@ -28,9 +28,9 @@ import {
|
||||
import { MsgDelegateEncodeObject, MsgSubmitProposalEncodeObject, MsgVoteEncodeObject } from "../";
|
||||
import { GovExtension, setupGovExtension } from "./queries";
|
||||
|
||||
async function makeClientWithGov(rpcUrl: string): Promise<[QueryClient & GovExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupGovExtension), tmClient];
|
||||
async function makeClientWithGov(rpcUrl: string): Promise<[QueryClient & GovExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupGovExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("GovExtension", () => {
|
||||
@ -152,7 +152,7 @@ describe("GovExtension", () => {
|
||||
describe("params", () => {
|
||||
it("works for deposit", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.params("deposit");
|
||||
expect(response).toEqual(
|
||||
@ -167,12 +167,12 @@ describe("GovExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works for tallying", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.params("tallying");
|
||||
expect(response).toEqual(
|
||||
@ -186,12 +186,12 @@ describe("GovExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works for voting", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.params("voting");
|
||||
expect(response).toEqual(
|
||||
@ -205,7 +205,7 @@ describe("GovExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -213,7 +213,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.proposals(
|
||||
ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD,
|
||||
@ -236,7 +236,7 @@ describe("GovExtension", () => {
|
||||
votingEndTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -244,7 +244,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.proposal(proposalId);
|
||||
expect(response.proposal).toEqual({
|
||||
@ -263,7 +263,7 @@ describe("GovExtension", () => {
|
||||
votingEndTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -271,7 +271,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.deposits(proposalId);
|
||||
expect(response.deposits).toEqual([
|
||||
@ -282,7 +282,7 @@ describe("GovExtension", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -290,7 +290,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.deposit(proposalId, voter1Address);
|
||||
expect(response.deposit).toEqual({
|
||||
@ -299,7 +299,7 @@ describe("GovExtension", () => {
|
||||
amount: initialDeposit,
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -307,7 +307,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.tally(proposalId);
|
||||
expect(response.tally).toEqual({
|
||||
@ -317,7 +317,7 @@ describe("GovExtension", () => {
|
||||
noWithVeto: delegationVoter2.amount,
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -325,7 +325,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.votes(proposalId);
|
||||
|
||||
@ -357,7 +357,7 @@ describe("GovExtension", () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -365,7 +365,7 @@ describe("GovExtension", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
assert(proposalId, "Missing proposal ID");
|
||||
const [client, tmClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithGov(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.gov.vote(proposalId, voter1Address);
|
||||
expect(response.vote).toEqual(
|
||||
@ -382,7 +382,7 @@ describe("GovExtension", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
import { QueryClient } from "../../queryclient";
|
||||
import { simapp } from "../../testutils.spec";
|
||||
import * as ibcTest from "./ibctestdata.spec";
|
||||
import { IbcExtension, setupIbcExtension } from "./queries";
|
||||
|
||||
async function makeClientWithIbc(rpcUrl: string): Promise<[QueryClient & IbcExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupIbcExtension), tmClient];
|
||||
async function makeClientWithIbc(rpcUrl: string): Promise<[QueryClient & IbcExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupIbcExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("IbcExtension", () => {
|
||||
@ -15,73 +15,73 @@ describe("IbcExtension", () => {
|
||||
describe("channel", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.channel(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.channel).toEqual(ibcTest.channel);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("channels", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.channels();
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allChannels", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.allChannels();
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("connectionChannels", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.connectionChannels(ibcTest.connectionId);
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allConnectionChannels", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.allConnectionChannels(ibcTest.connectionId);
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientState", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.clientState(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.identifiedClientState).toEqual({
|
||||
@ -92,14 +92,14 @@ describe("IbcExtension", () => {
|
||||
},
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusState", () => {
|
||||
xit("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.consensusState(
|
||||
ibcTest.portId,
|
||||
@ -114,14 +114,14 @@ describe("IbcExtension", () => {
|
||||
});
|
||||
expect(response.clientId).toEqual(ibcTest.clientId);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitment", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.packetCommitment(
|
||||
ibcTest.portId,
|
||||
@ -132,45 +132,45 @@ describe("IbcExtension", () => {
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitments", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.packetCommitments(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.commitments).toEqual([ibcTest.packetState]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allPacketCommitments", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.allPacketCommitments(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.commitments).toEqual([ibcTest.packetState]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetReceipt", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.packetReceipt(ibcTest.portId, ibcTest.channelId, 1);
|
||||
expect(response.received).toEqual(false);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -178,7 +178,7 @@ describe("IbcExtension", () => {
|
||||
it("works", async () => {
|
||||
pending("We don't have an acknowledgement for testing at the moment");
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.packetAcknowledgement(
|
||||
ibcTest.portId,
|
||||
@ -189,28 +189,28 @@ describe("IbcExtension", () => {
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgements", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.packetAcknowledgements(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.acknowledgements).toEqual(ibcTest.packetAcknowledgements);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allPacketAcknowledgements", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.allPacketAcknowledgements(
|
||||
ibcTest.portId,
|
||||
@ -218,14 +218,14 @@ describe("IbcExtension", () => {
|
||||
);
|
||||
expect(response.acknowledgements).toEqual(ibcTest.packetAcknowledgements);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedPackets", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.unreceivedPackets(
|
||||
ibcTest.portId,
|
||||
@ -235,14 +235,14 @@ describe("IbcExtension", () => {
|
||||
expect(response.sequences).toEqual([1, 2, 3].map((n) => BigInt(n)));
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedAcks", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.unreceivedAcks(
|
||||
ibcTest.portId,
|
||||
@ -252,21 +252,21 @@ describe("IbcExtension", () => {
|
||||
expect(response.sequences).toEqual([BigInt(ibcTest.commitment.sequence)]);
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextSequenceReceive", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.channel.nextSequenceReceive(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.nextSequenceReceive).toEqual(BigInt(1));
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -275,7 +275,7 @@ describe("IbcExtension", () => {
|
||||
describe("state", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.state(ibcTest.clientId);
|
||||
expect(response.clientState).toEqual({
|
||||
@ -283,14 +283,14 @@ describe("IbcExtension", () => {
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("states", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.states();
|
||||
expect(response.clientStates).toEqual([
|
||||
@ -304,14 +304,14 @@ describe("IbcExtension", () => {
|
||||
]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allStates", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.allStates();
|
||||
expect(response.clientStates).toEqual([
|
||||
@ -324,14 +324,14 @@ describe("IbcExtension", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusState", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.consensusState(ibcTest.clientId);
|
||||
expect(response.consensusState).toEqual({
|
||||
@ -339,14 +339,14 @@ describe("IbcExtension", () => {
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusStates", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.consensusStates(ibcTest.clientId);
|
||||
expect(response.consensusStates).toEqual(
|
||||
@ -361,14 +361,14 @@ describe("IbcExtension", () => {
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allConsensusStates", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.allConsensusStates(ibcTest.clientId);
|
||||
expect(response.consensusStates).toEqual(
|
||||
@ -383,41 +383,41 @@ describe("IbcExtension", () => {
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("params", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.params();
|
||||
expect(response.params).toEqual({
|
||||
allowedClients: ["06-solomachine", "07-tendermint"],
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("stateTm", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.stateTm(ibcTest.clientId);
|
||||
expect(response.chainId).toEqual("ibc-1");
|
||||
// TODO: Fill these expectations out
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("statesTm", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.statesTm();
|
||||
expect(response).toEqual(
|
||||
@ -428,14 +428,14 @@ describe("IbcExtension", () => {
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allStatesTm", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.allStatesTm();
|
||||
expect(response).toEqual(
|
||||
@ -446,20 +446,20 @@ describe("IbcExtension", () => {
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusStateTm", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.client.consensusStateTm(ibcTest.clientId);
|
||||
expect(response.nextValidatorsHash).toEqual(jasmine.any(Uint8Array));
|
||||
// TODO: Fill out these expectations
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -468,61 +468,61 @@ describe("IbcExtension", () => {
|
||||
describe("connection", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.connection.connection(ibcTest.connectionId);
|
||||
expect(response.connection).toEqual(ibcTest.connection);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("connections", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.connection.connections();
|
||||
expect(response.connections).toEqual([ibcTest.identifiedConnection]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allConnections", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.connection.allConnections();
|
||||
expect(response.connections).toEqual([ibcTest.identifiedConnection]);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientConnections", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.connection.clientConnections(ibcTest.clientId);
|
||||
expect(response.connectionPaths).toEqual([ibcTest.connectionId]);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientState", () => {
|
||||
it("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.connection.clientState(ibcTest.connectionId);
|
||||
expect(response.identifiedClientState).toEqual({
|
||||
@ -533,14 +533,14 @@ describe("IbcExtension", () => {
|
||||
},
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusState", () => {
|
||||
xit("works", async () => {
|
||||
pending("We cannot test this easily anymore since the IBC module was removed from simapp");
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
// TODO: Find valid values
|
||||
const response = await client.ibc.connection.consensusState(ibcTest.connectionId, 1, 1);
|
||||
@ -550,7 +550,7 @@ describe("IbcExtension", () => {
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,21 +1,19 @@
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
import { QueryClient } from "../../queryclient";
|
||||
import { pendingWithoutSimapp, simapp } from "../../testutils.spec";
|
||||
import { MintExtension, setupMintExtension } from "./queries";
|
||||
|
||||
async function makeClientWithMint(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & MintExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupMintExtension), tmClient];
|
||||
async function makeClientWithMint(rpcUrl: string): Promise<[QueryClient & MintExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupMintExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("MintExtension", () => {
|
||||
describe("params", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithMint(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithMint(simapp.tendermintUrl);
|
||||
|
||||
const params = await client.mint.params();
|
||||
expect(Number(params.blocksPerYear)).toBeGreaterThan(100_000);
|
||||
@ -26,33 +24,33 @@ describe("MintExtension", () => {
|
||||
expect(params.inflationRateChange.toString()).toEqual("0.13");
|
||||
expect(params.mintDenom).toEqual(simapp.denomStaking);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("inflation", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithMint(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithMint(simapp.tendermintUrl);
|
||||
|
||||
const inflation = await client.mint.inflation();
|
||||
expect(inflation.toFloatApproximation()).toBeGreaterThan(0.13);
|
||||
expect(inflation.toFloatApproximation()).toBeLessThan(0.1301);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("annualProvisions", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithMint(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithMint(simapp.tendermintUrl);
|
||||
|
||||
const annualProvisions = await client.mint.annualProvisions();
|
||||
expect(annualProvisions.toFloatApproximation()).toBeGreaterThan(5_400_000_000);
|
||||
expect(annualProvisions.toFloatApproximation()).toBeLessThan(5_500_000_000);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
import { QueryClient } from "../../queryclient";
|
||||
import { pendingWithoutSimapp, simapp } from "../../testutils.spec";
|
||||
@ -7,35 +7,35 @@ import { setupSlashingExtension, SlashingExtension } from "./queries";
|
||||
|
||||
async function makeClientWithSlashing(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & SlashingExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupSlashingExtension), tmClient];
|
||||
): Promise<[QueryClient & SlashingExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupSlashingExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("SlashingExtension", () => {
|
||||
describe("signingInfos", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithSlashing(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithSlashing(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.slashing.signingInfos();
|
||||
expect(response.info).toBeDefined();
|
||||
expect(response.info).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("params", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithSlashing(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithSlashing(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.slashing.params();
|
||||
expect(response.params).toBeDefined();
|
||||
expect(response.params).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { coin, coins, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { sleep } from "@cosmjs/utils";
|
||||
import { MsgDelegate, MsgUndelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
||||
|
||||
@ -18,11 +18,9 @@ import {
|
||||
import { MsgDelegateEncodeObject, MsgUndelegateEncodeObject } from "./messages";
|
||||
import { setupStakingExtension, StakingExtension } from "./queries";
|
||||
|
||||
async function makeClientWithStaking(
|
||||
rpcUrl: string,
|
||||
): Promise<[QueryClient & StakingExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupStakingExtension), tmClient];
|
||||
async function makeClientWithStaking(rpcUrl: string): Promise<[QueryClient & StakingExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupStakingExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("StakingExtension", () => {
|
||||
@ -76,104 +74,104 @@ describe("StakingExtension", () => {
|
||||
describe("delegation", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.delegation(faucet.address0, validator.validatorAddress);
|
||||
expect(response.delegationResponse).toBeDefined();
|
||||
expect(response.delegationResponse).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegatorDelegations", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.delegatorDelegations(faucet.address0);
|
||||
expect(response.delegationResponses).toBeDefined();
|
||||
expect(response.delegationResponses).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegatorUnbondingDelegations", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.delegatorUnbondingDelegations(faucet.address0);
|
||||
expect(response.unbondingResponses).toBeDefined();
|
||||
expect(response.unbondingResponses).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegatorValidator", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.delegatorValidator(faucet.address0, validator.validatorAddress);
|
||||
expect(response.validator).toBeDefined();
|
||||
expect(response.validator).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("delegatorValidators", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.delegatorValidators(faucet.address0);
|
||||
expect(response.validators).toBeDefined();
|
||||
expect(response.validators).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("historicalInfo", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.historicalInfo(5);
|
||||
expect(response.hist).toBeDefined();
|
||||
expect(response.hist).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("params", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.params();
|
||||
expect(response.params).toBeDefined();
|
||||
expect(response.params).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("pool", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.pool();
|
||||
expect(response.pool).toBeDefined();
|
||||
expect(response.pool).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -181,46 +179,46 @@ describe("StakingExtension", () => {
|
||||
it("works", async () => {
|
||||
// TODO: Set up a result for this test
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
await expectAsync(
|
||||
client.staking.redelegations(faucet.address0, validator.validatorAddress, validator.validatorAddress),
|
||||
).toBeRejectedWithError(/redelegation not found/i);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unbondingDelegation", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.unbondingDelegation(faucet.address0, validator.validatorAddress);
|
||||
expect(response.unbond).toBeDefined();
|
||||
expect(response.unbond).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validator", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.validator(validator.validatorAddress);
|
||||
expect(response.validator).toBeDefined();
|
||||
expect(response.validator).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatorDelegations", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.validatorDelegations(validator.validatorAddress);
|
||||
expect(response.delegationResponses.length).toBeGreaterThanOrEqual(2);
|
||||
@ -235,33 +233,33 @@ describe("StakingExtension", () => {
|
||||
});
|
||||
expect(Number(response.pagination!.total)).toBeGreaterThanOrEqual(2);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validators", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.validators("BOND_STATUS_BONDED");
|
||||
expect(response.validators).toBeDefined();
|
||||
expect(response.validators).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatorUnbondingDelegations", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithStaking(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.staking.validatorUnbondingDelegations(validator.validatorAddress);
|
||||
expect(response.unbondingResponses).toBeDefined();
|
||||
expect(response.unbondingResponses).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { coin, coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { assertDefined, sleep } from "@cosmjs/utils";
|
||||
import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
||||
|
||||
@ -18,9 +18,9 @@ import {
|
||||
} from "../../testutils.spec";
|
||||
import { setupTxExtension, TxExtension } from "./queries";
|
||||
|
||||
async function makeClientWithTx(rpcUrl: string): Promise<[QueryClient & TxExtension, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient, setupTxExtension), tmClient];
|
||||
async function makeClientWithTx(rpcUrl: string): Promise<[QueryClient & TxExtension, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient, setupTxExtension), cometClient];
|
||||
}
|
||||
|
||||
describe("TxExtension", () => {
|
||||
@ -63,12 +63,12 @@ describe("TxExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
assertDefined(txHash);
|
||||
assertDefined(memo);
|
||||
const [client, tmClient] = await makeClientWithTx(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithTx(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.tx.getTx(txHash);
|
||||
expect(response.tx?.body?.memo).toEqual(memo);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@ -77,7 +77,7 @@ describe("TxExtension", () => {
|
||||
pendingWithoutSimapp();
|
||||
assertDefined(txHash);
|
||||
assertDefined(memo);
|
||||
const [client, tmClient] = await makeClientWithTx(simapp.tendermintUrl);
|
||||
const [client, cometClient] = await makeClientWithTx(simapp.tendermintUrl);
|
||||
const sequenceClient = await StargateClient.connect(simapp.tendermintUrl);
|
||||
|
||||
const registry = new Registry(defaultRegistryTypes);
|
||||
@ -100,7 +100,7 @@ describe("TxExtension", () => {
|
||||
simapp44Enabled() ? BigInt(0) : BigInt("0xffffffffffffffff"),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { coin } from "@cosmjs/amino";
|
||||
import { toAscii } from "@cosmjs/encoding";
|
||||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { CometClient, Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { assert } from "@cosmjs/utils";
|
||||
import { Metadata } from "cosmjs-types/cosmos/bank/v1beta1/bank";
|
||||
import {
|
||||
@ -24,9 +24,9 @@ import {
|
||||
} from "../testutils.spec";
|
||||
import { QueryClient } from "./queryclient";
|
||||
|
||||
async function makeClient(rpcUrl: string): Promise<[QueryClient, Tendermint34Client]> {
|
||||
const tmClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(tmClient), tmClient];
|
||||
async function makeClient(rpcUrl: string): Promise<[QueryClient, CometClient]> {
|
||||
const cometClient = await Tendermint34Client.connect(rpcUrl);
|
||||
return [QueryClient.withExtensions(cometClient), cometClient];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ describe("QueryClient", () => {
|
||||
describe("queryStoreVerified", () => {
|
||||
it("works via WebSockets", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClient(simapp.tendermintUrlWs);
|
||||
const [client, cometClient] = await makeClient(simapp.tendermintUrlWs);
|
||||
|
||||
// "keys before 0.45 had denom two times in the key"
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/10ad61a4dd/x/bank/migrations/v045/store_test.go#L91
|
||||
@ -61,12 +61,12 @@ describe("QueryClient", () => {
|
||||
expect(response.base).toEqual(simapp.denomFee);
|
||||
expect(response.description).toEqual("The fee token of this test chain");
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works via http", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClient(simapp.tendermintUrlHttp);
|
||||
const [client, cometClient] = await makeClient(simapp.tendermintUrlHttp);
|
||||
|
||||
// "keys before 0.45 had denom two times in the key"
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/10ad61a4dd/x/bank/migrations/v045/store_test.go#L91
|
||||
@ -88,14 +88,14 @@ describe("QueryClient", () => {
|
||||
expect(response.base).toEqual(simapp.denomFee);
|
||||
expect(response.description).toEqual("The fee token of this test chain");
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("queryAbci", () => {
|
||||
it("works via WebSockets", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClient(simapp.tendermintUrlWs);
|
||||
const [client, cometClient] = await makeClient(simapp.tendermintUrlWs);
|
||||
|
||||
const requestData = Uint8Array.from(
|
||||
QueryAllBalancesRequest.encode(
|
||||
@ -106,12 +106,12 @@ describe("QueryClient", () => {
|
||||
const response = QueryAllBalancesResponse.decode(value);
|
||||
expect(response.balances.length).toEqual(2);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works via http", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClient(simapp.tendermintUrlHttp);
|
||||
const [client, cometClient] = await makeClient(simapp.tendermintUrlHttp);
|
||||
|
||||
const requestData = Uint8Array.from(
|
||||
QueryAllBalancesRequest.encode(
|
||||
@ -122,15 +122,15 @@ describe("QueryClient", () => {
|
||||
const response = QueryAllBalancesResponse.decode(value);
|
||||
expect(response.balances.length).toEqual(2);
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
|
||||
it("works for height", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [queryClient, tmClient] = await makeClient(simapp.tendermintUrlHttp);
|
||||
const [queryClient, cometClient] = await makeClient(simapp.tendermintUrlHttp);
|
||||
|
||||
const joe = makeRandomAddress();
|
||||
const h1 = (await tmClient.status()).syncInfo.latestBlockHeight;
|
||||
const h1 = (await cometClient.status()).syncInfo.latestBlockHeight;
|
||||
|
||||
// Send tokens to `recipient`
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
@ -142,7 +142,7 @@ describe("QueryClient", () => {
|
||||
const amount = coin(332211, simapp.denomFee);
|
||||
await client.sendTokens(faucet.address0, joe, [amount], "auto");
|
||||
|
||||
const h2 = (await tmClient.status()).syncInfo.latestBlockHeight;
|
||||
const h2 = (await cometClient.status()).syncInfo.latestBlockHeight;
|
||||
assert(h1 < h2);
|
||||
|
||||
// Query with no height
|
||||
@ -183,7 +183,7 @@ describe("QueryClient", () => {
|
||||
expect(height).toEqual(h1);
|
||||
}
|
||||
|
||||
tmClient.disconnect();
|
||||
cometClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -174,8 +174,8 @@ describe("SigningStargateClient", () => {
|
||||
defaultSigningClientOptions,
|
||||
);
|
||||
|
||||
const tmClient = await Tendermint34Client.connect(simapp.tendermintUrl);
|
||||
const queryClient = QueryClient.withExtensions(tmClient, setupFeegrantExtension);
|
||||
const cometClient = await Tendermint34Client.connect(simapp.tendermintUrl);
|
||||
const queryClient = QueryClient.withExtensions(cometClient, setupFeegrantExtension);
|
||||
let allowanceExists: boolean;
|
||||
try {
|
||||
const _existingAllowance = await queryClient.feegrant.allowance(payer, signer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user