Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Updated block meta fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ayora authored and Vektrat committed Sep 24, 2020
1 parent 28c77fa commit 7a228b7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 21 deletions.
5 changes: 3 additions & 2 deletions catapult-sdk/src/model/ModelSchemaBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ class ModelSchemaBuilder {
generationHash: ModelType.binary,
totalFee: ModelType.uint64,
stateHashSubCacheMerkleRoots: { type: ModelType.array, schemaName: ModelType.binary },
numTransactions: ModelType.int,
numStatements: ModelType.int
totalTransactionsCount: ModelType.int,
transactionsCount: ModelType.int,
statementsCount: ModelType.int
},
blockHeaderWithMetadata: {
id: ModelType.objectId,
Expand Down
9 changes: 7 additions & 2 deletions catapult-sdk/test/model/ModelFormatterBuilder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ describe('model formatter builder', () => {
hash: 0,
generationHash: 0,
totalFee: 0,
numTransactions: 0,
totalTransactionsCount: 0,
transactionsCount: 0,
statementsCount: 0,
stateHashSubCacheMerkleRoots: [0]
},
block: {
Expand Down Expand Up @@ -146,7 +148,10 @@ describe('model formatter builder', () => {
hash: 'binary',
generationHash: 'binary',
totalFee: 'uint64',
numTransactions: 'int',
transactionsCount: 'int',
statementsCount: 'int',
totalTransactionsCount: 'int',

stateHashSubCacheMerkleRoots: ['binary']
},
block: {
Expand Down
5 changes: 3 additions & 2 deletions catapult-sdk/test/model/ModelSchemaBuilder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,9 @@ describe('model schema builder', () => {
'blockHeader.network',
'blockHeader.type',
'blockHeader.feeMultiplier',
'blockHeaderMetadata.numTransactions',
'blockHeaderMetadata.numStatements',
'blockHeaderMetadata.totalTransactionsCount',
'blockHeaderMetadata.transactionsCount',
'blockHeaderMetadata.statementsCount',

'transaction.size',
'transaction.version',
Expand Down
2 changes: 1 addition & 1 deletion rest/src/plugins/receipts/receiptsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {

server.get(
'/blocks/:height/statements/:hash/merkle',
routeUtils.blockRouteMerkleProcessor(db.catapultDb, 'numStatements', 'statementMerkleTree')
routeUtils.blockRouteMerkleProcessor(db.catapultDb, 'statementsCount', 'statementMerkleTree')
);
}
};
2 changes: 1 addition & 1 deletion rest/src/routes/blockRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {

server.get(
'/blocks/:height/transactions/:hash/merkle',
routeUtils.blockRouteMerkleProcessor(db, 'numTransactions', 'transactionMerkleTree')
routeUtils.blockRouteMerkleProcessor(db, 'transactionsCount', 'transactionMerkleTree')
);

const buildResponse = (packet, codec, resultType) => {
Expand Down
16 changes: 8 additions & 8 deletions rest/test/db/CatapultDb_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ describe('catapult db', () => {
_id: createObjectId(10),
meta: {
hash: 0x0100,
numTransactions: 10
transactionsCount: 10
},
block: {
version: 1,
Expand Down Expand Up @@ -1079,7 +1079,7 @@ describe('catapult db', () => {
_id: createObjectId(10),
meta: {
hash: 0x0100,
numTransactions: 10
transactionsCount: 10
},
block: {
version: 1,
Expand All @@ -1099,7 +1099,7 @@ describe('catapult db', () => {
expect(page.data.length).to.equal(1);
expect(page.data[0]).to.deep.equal({
id: createObjectId(10),
meta: { hash: 0x0100, numTransactions: 10 },
meta: { hash: 0x0100, transactionsCount: 10 },
block: { version: 1, type: 2 }
});
}
Expand All @@ -1117,7 +1117,7 @@ describe('catapult db', () => {
expect(page.data.length).to.equal(1);
expect(page.data[0]).to.deep.equal({
id: createObjectId(10),
meta: { numTransactions: 10 },
meta: { transactionsCount: 10 },
block: { type: 2 }
});
}
Expand All @@ -1128,9 +1128,9 @@ describe('catapult db', () => {
describe('respects sort conditions', () => {
// Arrange:
const blocks = () => ([
{ _id: createObjectId(10), meta: { numTransactions: 1 }, block: { version: 3, type: 2 } },
{ _id: createObjectId(20), meta: { numTransactions: 2 }, block: { version: 2, type: 1 } },
{ _id: createObjectId(30), meta: { numTransactions: 3 }, block: { version: 1, type: 3 } }
{ _id: createObjectId(10), meta: { transactionsCount: 1 }, block: { version: 3, type: 2 } },
{ _id: createObjectId(20), meta: { transactionsCount: 2 }, block: { version: 2, type: 1 } },
{ _id: createObjectId(30), meta: { transactionsCount: 3 }, block: { version: 1, type: 3 } }
]);

it('direction ascending', () =>
Expand Down Expand Up @@ -1176,7 +1176,7 @@ describe('catapult db', () => {
describe('uses provided collection', () => {
// Arrange:
const accounts = () => ([{ _id: createObjectId(10), account: { address: account1.address, addressHeight: 10 } }]);
const blocks = () => ([{ _id: createObjectId(20), meta: { numTransactions: 1 }, block: { version: 3, type: 2 } }]);
const blocks = () => ([{ _id: createObjectId(20), meta: { transactionsCount: 1 }, block: { version: 3, type: 2 } }]);
const transactions = () => ([{ _id: createObjectId(30), meta: { height: 1 }, transaction: { type: 3 } }]);

it('respects collection', () =>
Expand Down
4 changes: 2 additions & 2 deletions rest/test/db/utils/dbTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ const createDbBlock = height => {
hash: new Binary(test.random.hash()),
generationHash: new Binary(test.random.hash()),
totalFee: Long.fromNumber(12345),
numTransactions: 5,
numStatements: 5,
transactionsCount: 5,
statementsCount: 5,
transactionMerkleTree: [new Binary(test.random.hash()), new Binary(test.random.hash())],
statementMerkleTree: [new Binary(test.random.hash()), new Binary(test.random.hash())]
};
Expand Down
2 changes: 1 addition & 1 deletion rest/test/plugins/receipts/receiptsRoutes_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ describe('receipts routes', () => {

// Assert:
expect(blockRouteMerkleProcessorSpy.calledOnce).to.equal(true);
expect(blockRouteMerkleProcessorSpy.firstCall.args[1]).to.equal('numStatements');
expect(blockRouteMerkleProcessorSpy.firstCall.args[1]).to.equal('statementsCount');
expect(blockRouteMerkleProcessorSpy.firstCall.args[2]).to.equal('statementMerkleTree');
blockRouteMerkleProcessorSpy.restore();
});
Expand Down
4 changes: 2 additions & 2 deletions rest/test/routes/blockRoutes_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('block routes', () => {
const testAddressString = 'SBZ22LWA7GDZLPLQF7PXTMNLWSEZ7ZRVGRMWLXQ';
const testAddress = address.stringToAddress(testAddressString);

const fakeBlock = { id: 0, meta: { numTransactions: 0 }, block: { type: 33091 } };
const fakeBlock = { id: 0, meta: { transactionsCount: 0 }, block: { type: 33091 } };
const fakePaginatedBlock = {
data: [fakeBlock],
pagination: {
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('block routes', () => {

// Assert:
expect(blockRouteMerkleProcessorSpy.calledOnce).to.equal(true);
expect(blockRouteMerkleProcessorSpy.firstCall.args[1]).to.equal('numTransactions');
expect(blockRouteMerkleProcessorSpy.firstCall.args[1]).to.equal('transactionsCount');
expect(blockRouteMerkleProcessorSpy.firstCall.args[2]).to.equal('transactionMerkleTree');
blockRouteMerkleProcessorSpy.restore();
});
Expand Down

0 comments on commit 7a228b7

Please sign in to comment.