Merge pull request #759 from cosmos/387-missing-block-meta-fields
Add missing block meta fields
This commit is contained in:
commit
fcdab9d6d5
@ -263,7 +263,7 @@ interface RpcBlockId {
|
||||
/** hex encoded */
|
||||
readonly hash: string;
|
||||
readonly parts: {
|
||||
readonly total: string;
|
||||
readonly total: number;
|
||||
/** hex encoded */
|
||||
readonly hash: string;
|
||||
};
|
||||
@ -273,7 +273,7 @@ function decodeBlockId(data: RpcBlockId): responses.BlockId {
|
||||
return {
|
||||
hash: fromHex(assertNotEmpty(data.hash)),
|
||||
parts: {
|
||||
total: Integer.parse(assertNotEmpty(data.parts.total)),
|
||||
total: assertNotEmpty(data.parts.total),
|
||||
hash: fromHex(assertNotEmpty(data.parts.hash)),
|
||||
},
|
||||
};
|
||||
@ -296,8 +296,6 @@ interface RpcHeader {
|
||||
readonly chain_id: string;
|
||||
readonly height: string;
|
||||
readonly time: string;
|
||||
readonly num_txs: string;
|
||||
readonly total_txs: string;
|
||||
|
||||
readonly last_block_id: RpcBlockId;
|
||||
|
||||
@ -348,13 +346,17 @@ function decodeHeader(data: RpcHeader): responses.Header {
|
||||
|
||||
interface RpcBlockMeta {
|
||||
readonly block_id: RpcBlockId;
|
||||
readonly block_size: string;
|
||||
readonly header: RpcHeader;
|
||||
readonly num_txs: string;
|
||||
}
|
||||
|
||||
function decodeBlockMeta(data: RpcBlockMeta): responses.BlockMeta {
|
||||
return {
|
||||
blockId: decodeBlockId(data.block_id),
|
||||
blockSize: Integer.parse(assertNotEmpty(data.block_size)),
|
||||
header: decodeHeader(data.header),
|
||||
numTxs: Integer.parse(assertNotEmpty(data.num_txs)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -195,9 +195,9 @@ export interface TxProof {
|
||||
|
||||
export interface BlockMeta {
|
||||
readonly blockId: BlockId;
|
||||
readonly blockSize: number;
|
||||
readonly header: Header;
|
||||
// TODO: Add blockSize (e.g "block_size": "471")
|
||||
// TODO: Add numTxs (e.g "num_txs": "0")
|
||||
readonly numTxs: number;
|
||||
}
|
||||
|
||||
export interface BlockId {
|
||||
|
||||
@ -275,19 +275,18 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
|
||||
expect(blockchain.blockMetas.length).toBeGreaterThanOrEqual(1);
|
||||
const meta = blockchain.blockMetas[0];
|
||||
|
||||
// TODO: check all the fields
|
||||
expect(meta).toEqual({
|
||||
blockId: jasmine.objectContaining({}),
|
||||
// block_size: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
// num_txs: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
header: jasmine.objectContaining({
|
||||
expect(meta.blockId).toEqual(jasmine.objectContaining({}));
|
||||
expect(meta.blockSize).toBeInstanceOf(Number);
|
||||
expect(meta.header).toEqual(
|
||||
jasmine.objectContaining({
|
||||
version: {
|
||||
block: expected.blockVersion,
|
||||
app: expected.appVersion,
|
||||
},
|
||||
chainId: jasmine.stringMatching(chainIdMatcher),
|
||||
}),
|
||||
});
|
||||
);
|
||||
expect(meta.numTxs).toBeInstanceOf(Number);
|
||||
|
||||
client.disconnect();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user