Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Tendermint version in tests to 0.34.10 and adapt code #813

Merged
merged 1 commit into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions packages/tendermint-rpc/src/legacy/adaptors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,15 @@ export const adaptor33 = v0_33;
*/
export const adaptor34 = v0_33; // With this alias we can swap out the implementation without affecting caller code.

const hashes = {
v0_34: [
"ca2c9df", // v0.34.0-rc6
"182fa32", // v0.34.0
],
};

/**
* Returns an Adaptor implementation for a given tendermint version.
* Throws when version is not supported.
*
* @param version full Tendermint version string, e.g. "0.20.1"
*/
export function adaptorForVersion(version: string): Adaptor {
if (version.startsWith("0.33.") || version.startsWith("0.34.") || hashes.v0_34.includes(version)) {
return v0_33;
} else {
throw new Error(`Unsupported tendermint version: ${version}`);
}
export function adaptorForVersion(_version: string): Adaptor {
// Note: In some cases, Tendermint 0.34 returns an empty version value.
// This supports 0.33 and 0.34 now, no matter which version you provide.
// Very soon this function becomes obsolete (https://github.com/cosmos/cosmjs/issues/789).
return v0_33;
}
2 changes: 1 addition & 1 deletion packages/tendermint-rpc/src/legacy/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, adaptor: Adaptor, expecte
const status = await client.status();

// node info
expect(status.nodeInfo.version).toEqual(expected.version);
expect(status.nodeInfo.version).toMatch(expected.version);
expect(status.nodeInfo.protocolVersion).toEqual({
p2p: expected.p2pVersion,
block: expected.blockVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
const status = await client.status();

// node info
expect(status.nodeInfo.version).toEqual(expected.version);
expect(status.nodeInfo.version).toMatch(expected.version);
expect(status.nodeInfo.protocolVersion).toEqual({
p2p: expected.p2pVersion,
block: expected.blockVersion,
Expand Down
9 changes: 5 additions & 4 deletions packages/tendermint-rpc/src/testutil.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { toAscii } from "@cosmjs/encoding";
import { sleep } from "@cosmjs/utils";

export const chainIdMatcher = /^[-a-zA-Z0-9]{3,30}$/;
export const anyMatcher = /^.*$/; // Any string, including empty. Does not do more than a type check.

export interface ExpectedValues {
/** The Tendermint version as reported by Tendermint itself */
readonly version: string;
readonly version: string | RegExp;
readonly appCreator: string;
readonly p2pVersion: number;
readonly blockVersion: number;
Expand Down Expand Up @@ -49,7 +52,7 @@ export const tendermintInstances: readonly TendermintInstance[] = [
version: "0.34.x",
blockTime: 500,
expected: {
version: "182fa32", // srsly?
version: anyMatcher,
appCreator: "Cosmoshi Netowoko",
p2pVersion: 8,
blockVersion: 11,
Expand All @@ -60,8 +63,6 @@ export const tendermintInstances: readonly TendermintInstance[] = [

export const defaultInstance: TendermintInstance = tendermintInstances[0];

export const chainIdMatcher = /^[-a-zA-Z0-9]{3,30}$/;

export function tendermintEnabled(): boolean {
return !!process.env.TENDERMINT_ENABLED;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/tendermint/all_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ command -v shellcheck >/dev/null && shellcheck "$0"
# Find latest patch releases at https://hub.docker.com/r/tendermint/tendermint/tags/
declare -a TM_VERSIONS
TM_VERSIONS[33]=v0.33.8
TM_VERSIONS[34]=v0.34.0
TM_VERSIONS[34]=v0.34.10

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

Expand Down
2 changes: 1 addition & 1 deletion scripts/tendermint/all_stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ command -v shellcheck >/dev/null && shellcheck "$0"

declare -a TM_VERSIONS
TM_VERSIONS[33]=v0.33.8
TM_VERSIONS[34]=v0.34.0
TM_VERSIONS[34]=v0.34.10

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

Expand Down