From d87e6b08ddc97109d63365e890e3a45d9aedde8b Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Wed, 26 Feb 2020 13:22:01 +0000 Subject: [PATCH] Fixed #464 - Added numStatements --- e2e/infrastructure/BlockHttp.spec.ts | 1 + src/infrastructure/BlockHttp.ts | 1 + src/model/blockchain/BlockInfo.ts | 7 ++++++- test/model/blockchain/BlockInfo.spec.ts | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e/infrastructure/BlockHttp.spec.ts b/e2e/infrastructure/BlockHttp.spec.ts index 1c11f5b77b..d0a3b6fadb 100644 --- a/e2e/infrastructure/BlockHttp.spec.ts +++ b/e2e/infrastructure/BlockHttp.spec.ts @@ -96,6 +96,7 @@ describe('BlockHttp', () => { expect(blockInfo.timestamp.lower).to.be.equal(0); expect(blockInfo.timestamp.higher).to.be.equal(0); expect(blockInfo.beneficiaryPublicKey).not.to.be.undefined; + expect(blockInfo.numStatements).not.to.be.undefined; }); }); diff --git a/src/infrastructure/BlockHttp.ts b/src/infrastructure/BlockHttp.ts index 96dc39dd7b..be209da207 100644 --- a/src/infrastructure/BlockHttp.ts +++ b/src/infrastructure/BlockHttp.ts @@ -123,6 +123,7 @@ export class BlockHttp extends Http implements BlockRepository { dto.block.receiptsHash, dto.block.stateHash, dto.block.beneficiaryPublicKey ? PublicAccount.createFromPublicKey(dto.block.beneficiaryPublicKey, networkType) : undefined, + dto.meta.numStatements, ); } diff --git a/src/model/blockchain/BlockInfo.ts b/src/model/blockchain/BlockInfo.ts index 6bf9061a8a..67dc6c3e58 100644 --- a/src/model/blockchain/BlockInfo.ts +++ b/src/model/blockchain/BlockInfo.ts @@ -42,6 +42,7 @@ export class BlockInfo { * @param blockReceiptsHash * @param blockStateHash * @param beneficiaryPublicKey + * @param numStatements */ constructor(/** * The block hash. @@ -117,7 +118,11 @@ export class BlockInfo { /** * The beneficiary public key. */ - public readonly beneficiaryPublicKey?: PublicAccount | undefined) { + public readonly beneficiaryPublicKey?: PublicAccount | undefined, + /** + * The number of statements included. + */ + public readonly numStatements?: number) { } } diff --git a/test/model/blockchain/BlockInfo.spec.ts b/test/model/blockchain/BlockInfo.spec.ts index aaa03b9352..c4839653eb 100644 --- a/test/model/blockchain/BlockInfo.spec.ts +++ b/test/model/blockchain/BlockInfo.spec.ts @@ -45,6 +45,7 @@ describe('BlockInfo', () => { generationHash: '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6', hash: '24E92B511B54EDB48A4850F9B42485FDD1A30589D92C775632DDDD71D7D1D691', numTransactions: 25, + numStatements: 1, totalFee: new UInt64([ 0, 0 ]), }, }; @@ -68,6 +69,7 @@ describe('BlockInfo', () => { blockDTO.block.blockReceiptsHash, blockDTO.block.stateHash, PublicAccount.createFromPublicKey(blockDTO.block.beneficiaryPublicKey, blockDTO.block.network), + blockDTO.meta.numStatements, ); expect(blockInfo.hash).to.be.equal(blockDTO.meta.hash); @@ -88,6 +90,7 @@ describe('BlockInfo', () => { expect(blockInfo.blockReceiptsHash).to.be.equal(blockDTO.block.blockReceiptsHash); expect(blockInfo.stateHash).to.be.equal(blockDTO.block.stateHash); expect((blockInfo.beneficiaryPublicKey as PublicAccount).publicKey).to.be.equal(blockDTO.block.beneficiaryPublicKey); + expect(blockInfo.numStatements).to.be.equal(blockDTO.meta.numStatements); }); });