Skip to content

Commit

Permalink
Adapt testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Mar 1, 2023
1 parent a14c9eb commit 856d567
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,13 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)

const query = buildQuery({ tags: [{ key: "app.key", value: key }] });

const s = await client.txSearch({ query: query });
const result = await client.txSearch({ query: query });

expect(s.totalCount).toEqual(3);
s.txs.slice(1).reduce((lastHeight, { height }) => {
expect(result.totalCount).toEqual(3);
result.txs.slice(1).reduce((lastHeight, { height }) => {
expect(height).toBeGreaterThanOrEqual(lastHeight);
return height;
}, s.txs[0].height);
}, result.txs[0].height);

client.disconnect();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,14 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
}
});

it("returns transactions in descending order by default", async () => {
it("returns transactions in ascending order by default", async () => {
// NOTE: The Tendermint docs states the default ordering is "desc". Until
// 0.35 it was actually "asc" but from 0.35 on it is "desc".
// Then it was changed back to "asc" in 0.37.
// Docs: https://docs.tendermint.com/master/rpc/#/Info/tx_search
// Code 0.34: https://github.com/tendermint/tendermint/blob/v0.34.10/rpc/core/tx.go#L89
// 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());

Expand All @@ -508,7 +510,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)

expect(result.totalCount).toEqual(3);
result.txs.slice(1).reduce((lastHeight, { height }) => {
expect(height).toBeLessThanOrEqual(lastHeight);
expect(height).toBeGreaterThanOrEqual(lastHeight);
return height;
}, result.txs[0].height);

Expand Down Expand Up @@ -560,8 +562,8 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
expect(sall.txs.length).toEqual(3);
// make sure there are in order from highest to lowest height
const [tx1, tx2, tx3] = sall.txs;
expect(tx2.height).toBeLessThan(tx1.height);
expect(tx3.height).toBeLessThan(tx2.height);
expect(tx2.height).toBeGreaterThan(tx1.height);
expect(tx3.height).toBeGreaterThan(tx2.height);

client.disconnect();
});
Expand Down Expand Up @@ -821,7 +823,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
});
}

describe("Tendermint37Client", () => {
fdescribe("Tendermint37Client", () => {
const { url, expected } = tendermintInstances[37];

it("can connect to a given url", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tendermint-rpc/src/testutil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const tendermintInstances = {
blockTime: 500,
expected: {
chainId: /^dockerchain$/,
version: /^$/, // Unfortunately we don't get info here
version: /^0\.37\.0-alpha\.3$/, // Unfortunately we don't get info here
appCreator: "Cosmoshi Netowoko",
p2pVersion: 8,
blockVersion: 11,
Expand Down

0 comments on commit 856d567

Please sign in to comment.