Add remaining fields to NodeInfoResponse

This commit is contained in:
Simon Warta 2020-03-07 11:23:17 +01:00
parent 28460cfc0f
commit 5309e460b8
4 changed files with 81 additions and 6 deletions

View File

@ -22,6 +22,7 @@ import {
tendermintAddressMatcher,
tendermintIdMatcher,
tendermintOptionalIdMatcher,
tendermintShortHashMatcher,
wasmdEnabled,
wasmdEndpoint,
} from "./testutils.spec";
@ -296,8 +297,32 @@ describe("RestClient", () => {
it("works", async () => {
pendingWithoutWasmd();
const client = new RestClient(wasmdEndpoint);
const info = await client.nodeInfo();
expect(info.node_info.network).toEqual(defaultNetworkId);
const { node_info, application_version } = await client.nodeInfo();
expect(node_info).toEqual(
jasmine.objectContaining({
protocol_version: { p2p: "7", block: "10", app: "0" },
listen_addr: "tcp://0.0.0.0:26656",
network: defaultNetworkId,
version: "0.33.0",
channels: "4020212223303800",
moniker: defaultNetworkId,
other: { tx_index: "on", rpc_address: "tcp://0.0.0.0:26657" },
}),
);
expect(node_info.id).toMatch(tendermintShortHashMatcher);
expect(application_version).toEqual(
jasmine.objectContaining({
name: "wasm",
server_name: "wasmd",
client_name: "wasmcli",
build_tags: "netgo,ledger",
}),
);
expect(application_version.version).toMatch(/^0\.7\.[0-9]+$/);
expect(application_version.commit).toMatch(tendermintShortHashMatcher);
expect(application_version.go).toMatch(/^go version go1\.[0-9]+\.[0-9]+ linux\/amd64$/);
});
});

View File

@ -15,12 +15,37 @@ export interface CosmosSdkAccount {
readonly sequence: number;
}
interface NodeInfo {
export interface NodeInfo {
readonly protocol_version: {
readonly p2p: string;
readonly block: string;
readonly app: string;
};
readonly id: string;
readonly listen_addr: string;
readonly network: string;
readonly version: string;
readonly channels: string;
readonly moniker: string;
readonly other: {
readonly tx_index: string;
readonly rpc_address: string;
};
}
interface NodeInfoResponse {
export interface ApplicationVersion {
readonly name: string;
readonly server_name: string;
readonly client_name: string;
readonly version: string;
readonly commit: string;
readonly build_tags: string;
readonly go: string;
}
export interface NodeInfoResponse {
readonly node_info: NodeInfo;
readonly application_version: ApplicationVersion;
}
export interface BlockId {

View File

@ -59,6 +59,7 @@ export function makeRandomAddress(): string {
export const tendermintIdMatcher = /^[0-9A-F]{64}$/;
export const tendermintOptionalIdMatcher = /^([0-9A-F]{64}|)$/;
export const tendermintAddressMatcher = /^[0-9A-F]{40}$/;
export const tendermintShortHashMatcher = /^[0-9a-f]{40}$/;
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
export const bech32AddressMatcher = /^[\x21-\x7e]{1,83}1[02-9ac-hj-np-z]{38}$/;

View File

@ -8,11 +8,35 @@ export interface CosmosSdkAccount {
readonly account_number: number;
readonly sequence: number;
}
interface NodeInfo {
export interface NodeInfo {
readonly protocol_version: {
readonly p2p: string;
readonly block: string;
readonly app: string;
};
readonly id: string;
readonly listen_addr: string;
readonly network: string;
readonly version: string;
readonly channels: string;
readonly moniker: string;
readonly other: {
readonly tx_index: string;
readonly rpc_address: string;
};
}
interface NodeInfoResponse {
export interface ApplicationVersion {
readonly name: string;
readonly server_name: string;
readonly client_name: string;
readonly version: string;
readonly commit: string;
readonly build_tags: string;
readonly go: string;
}
export interface NodeInfoResponse {
readonly node_info: NodeInfo;
readonly application_version: ApplicationVersion;
}
export interface BlockId {
readonly hash: string;