Tests
- Added block search tests - Incremented v0.34 Tendermint version to 0.34.9
This commit is contained in:
parent
961b46d36e
commit
859b4ec19f
@ -204,6 +204,72 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
});
|
||||
});
|
||||
|
||||
describe("blockSearch", () => {
|
||||
const key = randomString();
|
||||
|
||||
beforeAll(async () => {
|
||||
if (tendermintEnabled()) {
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
async function sendTx(): Promise<void> {
|
||||
const me = randomString();
|
||||
const tx = buildKvTx(key, me);
|
||||
|
||||
const txRes = await client.broadcastTxCommit({ tx: tx });
|
||||
expect(responses.broadcastTxCommitSuccess(txRes)).toEqual(true);
|
||||
expect(txRes.height).toBeTruthy();
|
||||
expect(txRes.hash.length).not.toEqual(0);
|
||||
}
|
||||
|
||||
// send 3 txs
|
||||
await sendTx();
|
||||
await sendTx();
|
||||
await sendTx();
|
||||
|
||||
client.disconnect();
|
||||
|
||||
await tendermintSearchIndexUpdated();
|
||||
}
|
||||
});
|
||||
|
||||
it("can paginate over txSearch results", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 5" });
|
||||
|
||||
// expect one page of results
|
||||
const s1 = await client.blockSearch({ query: query, page: 1, per_page: 2 });
|
||||
expect(s1.totalCount).toEqual(5);
|
||||
expect(s1.blocks.length).toEqual(2);
|
||||
|
||||
// second page
|
||||
const s2 = await client.blockSearch({ query: query, page: 2, per_page: 2 });
|
||||
expect(s2.totalCount).toEqual(5);
|
||||
expect(s2.blocks.length).toEqual(2);
|
||||
|
||||
client.disconnect();
|
||||
});
|
||||
|
||||
it("can get all search results in one call", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Tendermint34Client.create(rpcFactory());
|
||||
|
||||
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
|
||||
|
||||
const sall = await client.blockSearchAll({ query: query, per_page: 2 });
|
||||
expect(sall.totalCount).toEqual(5);
|
||||
expect(sall.blocks.length).toEqual(5);
|
||||
// make sure there are in order from lowest to highest height
|
||||
const [b1, b2, b3] = sall.blocks;
|
||||
expect(b2.block.header.height).toEqual(b1.block.header.height + 1);
|
||||
expect(b3.block.header.height).toEqual(b2.block.header.height + 1);
|
||||
|
||||
client.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("blockchain", () => {
|
||||
it("returns latest in descending order by default", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user