From f396cae2a572ab9ee0247ce48f829bf4da00d721 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Sun, 16 Feb 2020 11:52:13 +0100 Subject: [PATCH] Pull out tendermintIdMatcher --- packages/sdk/src/cosmwasmclient.spec.ts | 6 +++--- packages/sdk/src/testutils.spec.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/sdk/src/cosmwasmclient.spec.ts b/packages/sdk/src/cosmwasmclient.spec.ts index 72321a1b..b2098969 100644 --- a/packages/sdk/src/cosmwasmclient.spec.ts +++ b/packages/sdk/src/cosmwasmclient.spec.ts @@ -9,7 +9,7 @@ import { findAttribute } from "./logs"; import { Secp256k1Pen } from "./pen"; import { RestClient } from "./restclient"; import cosmoshub from "./testdata/cosmoshub.json"; -import { getRandomizedHackatom, makeRandomAddress } from "./testutils.spec"; +import { getRandomizedHackatom, makeRandomAddress, tendermintIdMatcher } from "./testutils.spec"; import { Coin, CosmosSdkTx, MsgSend, StdFee } from "./types"; const { fromAscii, fromUtf8, toAscii } = Encoding; @@ -82,7 +82,7 @@ describe("CosmWasmClient", () => { const response = await client.getBlock(); // id - expect(response.block_id.hash).toMatch(/^[0-9A-F]{64}$/); + expect(response.block_id.hash).toMatch(tendermintIdMatcher); // header expect(parseInt(response.block.header.height, 10)).toBeGreaterThanOrEqual(1); @@ -103,7 +103,7 @@ describe("CosmWasmClient", () => { const response = await client.getBlock(height - 1); // id - expect(response.block_id.hash).toMatch(/^[0-9A-F]{64}$/); + expect(response.block_id.hash).toMatch(tendermintIdMatcher); // header expect(response.block.header.height).toEqual(`${height - 1}`); diff --git a/packages/sdk/src/testutils.spec.ts b/packages/sdk/src/testutils.spec.ts index 5e099de6..b5e4ebc7 100644 --- a/packages/sdk/src/testutils.spec.ts +++ b/packages/sdk/src/testutils.spec.ts @@ -54,6 +54,8 @@ export function makeRandomAddress(): string { return Bech32.encode("cosmos", Random.getBytes(20)); } +export const tendermintIdMatcher = /^[0-9A-F]{64}$/; + describe("leb128", () => { describe("leb128Encode", () => { it("works for single byte values", () => {