mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 13:47:12 +00:00
Make .create constructors non-async
This is a braking follow-up to https://github.com/cosmos/cosmjs/pull/1380
This commit is contained in:
parent
e819a1fc0e
commit
e51d6558bf
@ -105,7 +105,7 @@ export class CosmWasmClient {
|
||||
* Creates an instance from a manually created Comet client.
|
||||
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
|
||||
*/
|
||||
public static async create(cometClient: CometClient): Promise<CosmWasmClient> {
|
||||
public static create(cometClient: CometClient): CosmWasmClient {
|
||||
return new CosmWasmClient(cometClient);
|
||||
}
|
||||
|
||||
|
@ -221,10 +221,7 @@ export class StargateClient {
|
||||
* Creates an instance from a manually created Comet client.
|
||||
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
|
||||
*/
|
||||
public static async create(
|
||||
cometClient: CometClient,
|
||||
options: StargateClientOptions = {},
|
||||
): Promise<StargateClient> {
|
||||
public static create(cometClient: CometClient, options: StargateClientOptions = {}): StargateClient {
|
||||
return new StargateClient(cometClient, options);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("create", () => {
|
||||
it("can auto-discover Tendermint version and communicate", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const info = await client.abciInfo();
|
||||
expect(info).toBeTruthy();
|
||||
client.disconnect();
|
||||
@ -33,7 +33,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can connect to Tendermint with known version", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
expect(await client.abciInfo()).toBeTruthy();
|
||||
client.disconnect();
|
||||
});
|
||||
@ -41,7 +41,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get genesis", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const genesis = await client.genesis();
|
||||
expect(genesis).toBeTruthy();
|
||||
client.disconnect();
|
||||
@ -50,7 +50,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxCommit", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxCommit({ tx: tx });
|
||||
@ -70,7 +70,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxSync", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxSync({ tx: tx });
|
||||
@ -86,7 +86,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxAsync", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxAsync({ tx: tx });
|
||||
@ -98,7 +98,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("gets the same tx hash from backend as calculated locally", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
const calculatedTxHash = hashTx(tx);
|
||||
|
||||
@ -111,7 +111,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("abciQuery", () => {
|
||||
it("can query the state", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const key = randomString();
|
||||
const value = randomString();
|
||||
@ -137,7 +137,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get a commit", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const response = await client.commit(4);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -152,7 +152,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const response = await client.validators({});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -170,7 +170,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const response = await client.validatorsAll();
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -188,7 +188,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can call a bunch of methods", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
expect(await client.block()).toBeTruthy();
|
||||
expect(await client.genesis()).toBeTruthy();
|
||||
@ -200,7 +200,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("status", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const status = await client.status();
|
||||
|
||||
@ -241,7 +241,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("numUnconfirmedTxs", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const response = await client.numUnconfirmedTxs();
|
||||
|
||||
@ -255,7 +255,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockResults", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const height = 3;
|
||||
const results = await client.blockResults(height);
|
||||
@ -271,7 +271,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockSearch", () => {
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<void> {
|
||||
@ -296,7 +296,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can paginate over blockSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
@ -315,7 +315,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
@ -334,7 +334,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockchain", () => {
|
||||
it("returns latest in descending order by default", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
// Run in parallel to increase chance there is no block between the calls
|
||||
const [status, blockchain] = await Promise.all([client.status(), client.blockchain()]);
|
||||
@ -351,7 +351,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can limit by maxHeight", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(undefined, height - 1);
|
||||
@ -365,7 +365,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("works with maxHeight in the future", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(undefined, height + 20);
|
||||
@ -380,7 +380,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can limit by minHeight and maxHeight", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(height - 2, height - 1);
|
||||
@ -394,7 +394,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("contains all the info", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(height - 1, height - 1);
|
||||
@ -423,7 +423,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("tx", () => {
|
||||
it("can query a tx properly", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const find = randomString();
|
||||
const me = randomString();
|
||||
@ -463,7 +463,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> {
|
||||
@ -491,7 +491,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
it("finds a single tx by hash", async () => {
|
||||
pendingWithoutTendermint();
|
||||
assert(tx1 && broadcast1);
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const result = await client.txSearch({ query: `tx.hash='${toHex(broadcast1.hash)}'` });
|
||||
expect(result.totalCount).toEqual(1);
|
||||
@ -509,7 +509,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("finds a single tx by tags", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const txKey2 = randomString();
|
||||
const txValue2 = randomString();
|
||||
@ -559,7 +559,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
// Code 0.35: https://github.com/tendermint/tendermint/blob/v0.35.6/internal/rpc/core/tx.go#L93
|
||||
// Code 0.37: https://github.com/cometbft/cometbft/blob/v0.37.0-rc3/rpc/core/tx.go#L87
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -576,7 +576,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can set the order", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -591,7 +591,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can paginate over txSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -610,7 +610,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -634,7 +634,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
|
||||
(async () => {
|
||||
const events: responses.NewBlockHeaderEvent[] = [];
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlockHeader();
|
||||
expect(stream).toBeTruthy();
|
||||
const subscription = stream.subscribe({
|
||||
@ -693,7 +693,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
const transactionData2 = buildKvTx(randomString(), randomString());
|
||||
|
||||
const events: responses.NewBlockEvent[] = [];
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlock();
|
||||
const subscription = stream.subscribe({
|
||||
next: (event) => {
|
||||
@ -752,7 +752,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const events: responses.TxEvent[] = [];
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const stream = client.subscribeTx();
|
||||
const subscription = stream.subscribe({
|
||||
next: (event) => {
|
||||
@ -796,7 +796,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
const transactionData2 = buildKvTx(randomString(), randomString());
|
||||
|
||||
const events: responses.TxEvent[] = [];
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const query = buildQuery({ tags: [{ key: "app.creator", value: expected.appCreator }] });
|
||||
const stream = client.subscribeTx(query);
|
||||
expect(stream).toBeTruthy();
|
||||
@ -834,7 +834,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
it("can unsubscribe and re-subscribe to the same stream", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlockHeader();
|
||||
|
||||
const event1 = await firstEvent(stream);
|
||||
@ -867,7 +867,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
it("can subscribe twice", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const client = await Comet38Client.create(rpcFactory());
|
||||
const client = Comet38Client.create(rpcFactory());
|
||||
const stream1 = client.subscribeNewBlockHeader();
|
||||
const stream2 = client.subscribeNewBlockHeader();
|
||||
|
||||
|
@ -47,7 +47,7 @@ export class Comet38Client {
|
||||
/**
|
||||
* Creates a new Tendermint client given an RPC client.
|
||||
*/
|
||||
public static async create(rpcClient: RpcClient): Promise<Comet38Client> {
|
||||
public static create(rpcClient: RpcClient): Comet38Client {
|
||||
return new Comet38Client(rpcClient);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("create", () => {
|
||||
it("can auto-discover Tendermint version and communicate", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const info = await client.abciInfo();
|
||||
expect(info).toBeTruthy();
|
||||
client.disconnect();
|
||||
@ -33,7 +33,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can connect to Tendermint with known version", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
expect(await client.abciInfo()).toBeTruthy();
|
||||
client.disconnect();
|
||||
});
|
||||
@ -41,7 +41,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get genesis", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const genesis = await client.genesis();
|
||||
expect(genesis).toBeTruthy();
|
||||
client.disconnect();
|
||||
@ -50,7 +50,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxCommit", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxCommit({ tx: tx });
|
||||
@ -70,7 +70,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxSync", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxSync({ tx: tx });
|
||||
@ -86,7 +86,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxAsync", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxAsync({ tx: tx });
|
||||
@ -98,7 +98,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("gets the same tx hash from backend as calculated locally", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
const calculatedTxHash = hashTx(tx);
|
||||
|
||||
@ -111,7 +111,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("abciQuery", () => {
|
||||
it("can query the state", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const key = randomString();
|
||||
const value = randomString();
|
||||
@ -137,7 +137,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get a commit", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const response = await client.commit(4);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -152,7 +152,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const response = await client.validators({});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -170,7 +170,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const response = await client.validatorsAll();
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -188,7 +188,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can call a bunch of methods", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
expect(await client.block()).toBeTruthy();
|
||||
expect(await client.genesis()).toBeTruthy();
|
||||
@ -200,7 +200,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("status", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const status = await client.status();
|
||||
|
||||
@ -241,7 +241,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("numUnconfirmedTxs", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const response = await client.numUnconfirmedTxs();
|
||||
|
||||
@ -255,7 +255,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockResults", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const height = 3;
|
||||
const results = await client.blockResults(height);
|
||||
@ -271,7 +271,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockSearch", () => {
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<void> {
|
||||
@ -296,7 +296,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can paginate over blockSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
@ -315,7 +315,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
@ -334,7 +334,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockchain", () => {
|
||||
it("returns latest in descending order by default", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
// Run in parallel to increase chance there is no block between the calls
|
||||
const [status, blockchain] = await Promise.all([client.status(), client.blockchain()]);
|
||||
@ -351,7 +351,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can limit by maxHeight", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(undefined, height - 1);
|
||||
@ -365,7 +365,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("works with maxHeight in the future", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(undefined, height + 20);
|
||||
@ -379,7 +379,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can limit by minHeight and maxHeight", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(height - 2, height - 1);
|
||||
@ -393,7 +393,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("contains all the info", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(height - 1, height - 1);
|
||||
@ -422,7 +422,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("tx", () => {
|
||||
it("can query a tx properly", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const find = randomString();
|
||||
const me = randomString();
|
||||
@ -462,7 +462,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> {
|
||||
@ -490,7 +490,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
it("finds a single tx by hash", async () => {
|
||||
pendingWithoutTendermint();
|
||||
assert(tx1 && broadcast1);
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const result = await client.txSearch({ query: `tx.hash='${toHex(broadcast1.hash)}'` });
|
||||
expect(result.totalCount).toEqual(1);
|
||||
@ -508,7 +508,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("finds a single tx by tags", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const txKey2 = randomString();
|
||||
const txValue2 = randomString();
|
||||
@ -554,7 +554,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
// Docs: https://docs.tendermint.com/master/rpc/#/Info/tx_search
|
||||
// Code: https://github.com/tendermint/tendermint/blob/v0.34.10/rpc/core/tx.go#L89
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -571,7 +571,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can set the order", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -586,7 +586,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can paginate over txSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -605,7 +605,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -629,7 +629,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
|
||||
(async () => {
|
||||
const events: responses.NewBlockHeaderEvent[] = [];
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlockHeader();
|
||||
expect(stream).toBeTruthy();
|
||||
const subscription = stream.subscribe({
|
||||
@ -687,7 +687,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
const transactionData2 = buildKvTx(randomString(), randomString());
|
||||
|
||||
const events: responses.NewBlockEvent[] = [];
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlock();
|
||||
const subscription = stream.subscribe({
|
||||
next: (event) => {
|
||||
@ -743,7 +743,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const events: responses.TxEvent[] = [];
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const stream = client.subscribeTx();
|
||||
const subscription = stream.subscribe({
|
||||
next: (event) => {
|
||||
@ -787,7 +787,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
const transactionData2 = buildKvTx(randomString(), randomString());
|
||||
|
||||
const events: responses.TxEvent[] = [];
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const query = buildQuery({ tags: [{ key: "app.creator", value: expected.appCreator }] });
|
||||
const stream = client.subscribeTx(query);
|
||||
expect(stream).toBeTruthy();
|
||||
@ -825,7 +825,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
it("can unsubscribe and re-subscribe to the same stream", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlockHeader();
|
||||
|
||||
const event1 = await firstEvent(stream);
|
||||
@ -858,7 +858,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
it("can subscribe twice", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
const client = Tendermint34Client.create(rpcFactory());
|
||||
const stream1 = client.subscribeNewBlockHeader();
|
||||
const stream2 = client.subscribeNewBlockHeader();
|
||||
|
||||
|
@ -47,7 +47,7 @@ export class Tendermint34Client {
|
||||
/**
|
||||
* Creates a new Tendermint client given an RPC client.
|
||||
*/
|
||||
public static async create(rpcClient: RpcClient): Promise<Tendermint34Client> {
|
||||
public static create(rpcClient: RpcClient): Tendermint34Client {
|
||||
return new Tendermint34Client(rpcClient);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("create", () => {
|
||||
it("can auto-discover Tendermint version and communicate", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const info = await client.abciInfo();
|
||||
expect(info).toBeTruthy();
|
||||
client.disconnect();
|
||||
@ -33,7 +33,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can connect to Tendermint with known version", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
expect(await client.abciInfo()).toBeTruthy();
|
||||
client.disconnect();
|
||||
});
|
||||
@ -41,7 +41,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get genesis", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const genesis = await client.genesis();
|
||||
expect(genesis).toBeTruthy();
|
||||
client.disconnect();
|
||||
@ -50,7 +50,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxCommit", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxCommit({ tx: tx });
|
||||
@ -70,7 +70,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxSync", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxSync({ tx: tx });
|
||||
@ -86,7 +86,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("broadcastTxAsync", () => {
|
||||
it("can broadcast a transaction", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
|
||||
const response = await client.broadcastTxAsync({ tx: tx });
|
||||
@ -98,7 +98,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("gets the same tx hash from backend as calculated locally", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const tx = buildKvTx(randomString(), randomString());
|
||||
const calculatedTxHash = hashTx(tx);
|
||||
|
||||
@ -111,7 +111,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("abciQuery", () => {
|
||||
it("can query the state", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const key = randomString();
|
||||
const value = randomString();
|
||||
@ -137,7 +137,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get a commit", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const response = await client.commit(4);
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -152,7 +152,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const response = await client.validators({});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -170,7 +170,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const response = await client.validatorsAll();
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
@ -188,7 +188,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can call a bunch of methods", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
expect(await client.block()).toBeTruthy();
|
||||
expect(await client.genesis()).toBeTruthy();
|
||||
@ -200,7 +200,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("status", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const status = await client.status();
|
||||
|
||||
@ -241,7 +241,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("numUnconfirmedTxs", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const response = await client.numUnconfirmedTxs();
|
||||
|
||||
@ -255,7 +255,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockResults", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const height = 3;
|
||||
const results = await client.blockResults(height);
|
||||
@ -271,7 +271,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockSearch", () => {
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<void> {
|
||||
@ -296,7 +296,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can paginate over blockSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
@ -315,7 +315,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
@ -334,7 +334,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("blockchain", () => {
|
||||
it("returns latest in descending order by default", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
// Run in parallel to increase chance there is no block between the calls
|
||||
const [status, blockchain] = await Promise.all([client.status(), client.blockchain()]);
|
||||
@ -351,7 +351,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can limit by maxHeight", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(undefined, height - 1);
|
||||
@ -365,7 +365,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("works with maxHeight in the future", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(undefined, height + 20);
|
||||
@ -380,7 +380,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can limit by minHeight and maxHeight", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(height - 2, height - 1);
|
||||
@ -394,7 +394,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("contains all the info", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const height = (await client.status()).syncInfo.latestBlockHeight;
|
||||
const blockchain = await client.blockchain(height - 1, height - 1);
|
||||
@ -423,7 +423,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
describe("tx", () => {
|
||||
it("can query a tx properly", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const find = randomString();
|
||||
const me = randomString();
|
||||
@ -463,7 +463,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> {
|
||||
@ -491,7 +491,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
it("finds a single tx by hash", async () => {
|
||||
pendingWithoutTendermint();
|
||||
assert(tx1 && broadcast1);
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const result = await client.txSearch({ query: `tx.hash='${toHex(broadcast1.hash)}'` });
|
||||
expect(result.totalCount).toEqual(1);
|
||||
@ -509,7 +509,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("finds a single tx by tags", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const txKey2 = randomString();
|
||||
const txValue2 = randomString();
|
||||
@ -559,7 +559,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
// Code 0.35: https://github.com/tendermint/tendermint/blob/v0.35.6/internal/rpc/core/tx.go#L93
|
||||
// Code 0.37: https://github.com/cometbft/cometbft/blob/v0.37.0-rc3/rpc/core/tx.go#L87
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -576,7 +576,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can set the order", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -591,7 +591,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can paginate over txSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -610,7 +610,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
|
||||
|
||||
@ -634,7 +634,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
|
||||
(async () => {
|
||||
const events: responses.NewBlockHeaderEvent[] = [];
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlockHeader();
|
||||
expect(stream).toBeTruthy();
|
||||
const subscription = stream.subscribe({
|
||||
@ -693,7 +693,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
const transactionData2 = buildKvTx(randomString(), randomString());
|
||||
|
||||
const events: responses.NewBlockEvent[] = [];
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlock();
|
||||
const subscription = stream.subscribe({
|
||||
next: (event) => {
|
||||
@ -752,7 +752,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const events: responses.TxEvent[] = [];
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const stream = client.subscribeTx();
|
||||
const subscription = stream.subscribe({
|
||||
next: (event) => {
|
||||
@ -796,7 +796,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
const transactionData2 = buildKvTx(randomString(), randomString());
|
||||
|
||||
const events: responses.TxEvent[] = [];
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const query = buildQuery({ tags: [{ key: "app.creator", value: expected.appCreator }] });
|
||||
const stream = client.subscribeTx(query);
|
||||
expect(stream).toBeTruthy();
|
||||
@ -834,7 +834,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
it("can unsubscribe and re-subscribe to the same stream", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const stream = client.subscribeNewBlockHeader();
|
||||
|
||||
const event1 = await firstEvent(stream);
|
||||
@ -867,7 +867,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
|
||||
it("can subscribe twice", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const client = await Tendermint37Client.create(rpcFactory());
|
||||
const client = Tendermint37Client.create(rpcFactory());
|
||||
const stream1 = client.subscribeNewBlockHeader();
|
||||
const stream2 = client.subscribeNewBlockHeader();
|
||||
|
||||
|
@ -47,7 +47,7 @@ export class Tendermint37Client {
|
||||
/**
|
||||
* Creates a new Tendermint client given an RPC client.
|
||||
*/
|
||||
public static async create(rpcClient: RpcClient): Promise<Tendermint37Client> {
|
||||
public static create(rpcClient: RpcClient): Tendermint37Client {
|
||||
return new Tendermint37Client(rpcClient);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user