Skip to content

Commit

Permalink
Merge pull request #5 from FinBook/minor
Browse files Browse the repository at this point in the history
minor change
  • Loading branch information
yizhoucao committed Mar 5, 2019
2 parents 3300219 + 76e959c commit 4ec3ac3
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 29 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@finbook/duo-market-data",
"version": "1.0.3",
"version": "1.0.4",
"description": "DUO Market Data",
"author": "FinBook Pte Ltd",
"main": "dist/index.js",
Expand Down Expand Up @@ -41,7 +41,7 @@
"typescript": "^3.1.6"
},
"dependencies": {
"@finbook/duo-contract-wrapper": "^1.2.3",
"@finbook/duo-contract-wrapper": "^1.3.2",
"aws-sdk": "^2.407.0",
"moment": "^2.24.0"
},
Expand Down
20 changes: 10 additions & 10 deletions src/DynamoUtil.test.ts
Expand Up @@ -923,6 +923,12 @@ test('convertEventToDynamo', () =>
expect(dynamoUtil.convertEventToDynamo(event, 9876543210)).toMatchSnapshot()
));

test('convertEventToDynamo, no logStatus', () =>
events.forEach(event => {
event.logStatus = '';
expect(dynamoUtil.convertEventToDynamo(event, 9876543210)).toMatchSnapshot();
}));

test('insertTradeData', async () => {
dynamoUtil.insertData = jest.fn(() => Promise.resolve());
await dynamoUtil.insertTradeData(trade, true);
Expand All @@ -948,19 +954,15 @@ test('insertTradeData insertStatus', async () => {
test('insertEventsData', async () => {
dynamoUtil.insertData = jest.fn(() => Promise.resolve());
await dynamoUtil.insertEventsData(events);
expect((dynamoUtil.insertData as jest.Mock).mock.calls.length).toBe(
events.length
);
expect((dynamoUtil.insertData as jest.Mock).mock.calls.length).toBe(events.length);
expect((dynamoUtil.insertData as jest.Mock).mock.calls).toMatchSnapshot();
});

test('insertEventsData live', async () => {
dynamoUtil.insertData = jest.fn(() => Promise.resolve());
dynamoUtil.live = true;
await dynamoUtil.insertEventsData(events);
expect((dynamoUtil.insertData as jest.Mock).mock.calls.length).toBe(
events.length
);
expect((dynamoUtil.insertData as jest.Mock).mock.calls.length).toBe(events.length);
expect((dynamoUtil.insertData as jest.Mock).mock.calls).toMatchSnapshot();
});

Expand Down Expand Up @@ -1200,7 +1202,7 @@ test('getSingleKeyPeriodPrices, period = 60', async () => {
});

test('getSingleKeyPeriodPrices, period > 60', async () => {
dynamoUtil.getPriceKeyField = jest.fn(() => 'key' as any);
dynamoUtil.getPriceKeyField = jest.fn(() => 'key' as any);
dynamoUtil.queryData = jest.fn(() =>
Promise.resolve({
Items: [{}]
Expand Down Expand Up @@ -1559,9 +1561,7 @@ test('getPrices', async () => {
await dynamoUtil.getPrices('anySrc', 1, start, end);
await dynamoUtil.getPrices('anySrc', 1, start, end, 'ETH|USD');
await dynamoUtil.getPrices('anySrc', 60, start, end);
expect(
(dynamoUtil.getSingleKeyPeriodPrices as jest.Mock).mock.calls
).toMatchSnapshot();
expect((dynamoUtil.getSingleKeyPeriodPrices as jest.Mock).mock.calls).toMatchSnapshot();
});

const price = {
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoUtil.ts
Expand Up @@ -98,7 +98,7 @@ export class DynamoUtil {
[CST.DB_EV_BLOCK_HASH]: { S: event.blockHash },
[CST.DB_EV_BLOCK_NO]: { N: event.blockNumber + '' },
[CST.DB_EV_TX_HASH]: { S: event.transactionHash },
[CST.DB_EV_LOG_STATUS]: { S: event.logStatus }
[CST.DB_EV_LOG_STATUS]: { S: event.logStatus || 'mined'}
};
for (const key in event.parameters)
dbInput[key] = {
Expand Down
198 changes: 186 additions & 12 deletions src/__snapshots__/DynamoUtil.test.ts.snap
Expand Up @@ -423,6 +423,180 @@ Object {
}
`;

exports[`convertEventToDynamo, no logStatus 1`] = `
Object {
"blockHash": Object {
"S": "blockHash",
},
"blockNumber": Object {
"N": "123",
},
"eventKey": Object {
"S": "contractAddress|type|1970-01-15",
},
"logStatus": Object {
"S": "mined",
},
"systime": Object {
"N": "9876543210",
},
"test": Object {
"S": "test",
},
"timestampId": Object {
"S": "1234567890|id",
},
"transactionHash": Object {
"S": "txHash",
},
}
`;

exports[`convertEventToDynamo, no logStatus 2`] = `
Object {
"blockHash": Object {
"S": "blockHash",
},
"blockNumber": Object {
"N": "123",
},
"eventKey": Object {
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|CommitPrice|1970-01-15",
},
"logStatus": Object {
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"systime": Object {
"N": "9876543210",
},
"timestampId": Object {
"S": "1234567890|id",
},
"transactionHash": Object {
"S": "txHash",
},
}
`;

exports[`convertEventToDynamo, no logStatus 3`] = `
Object {
"blockHash": Object {
"S": "blockHash",
},
"blockNumber": Object {
"N": "123",
},
"eventKey": Object {
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Create|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"systime": Object {
"N": "9876543210",
},
"timestampId": Object {
"S": "1234567890|id",
},
"transactionHash": Object {
"S": "txHash",
},
}
`;

exports[`convertEventToDynamo, no logStatus 4`] = `
Object {
"blockHash": Object {
"S": "blockHash",
},
"blockNumber": Object {
"N": "123",
},
"eventKey": Object {
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Transfer|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"from": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "mined",
},
"systime": Object {
"N": "9876543210",
},
"timestampId": Object {
"S": "1234567890|id",
},
"transactionHash": Object {
"S": "txHash",
},
}
`;

exports[`convertEventToDynamo, no logStatus 5`] = `
Object {
"blockHash": Object {
"S": "blockHash",
},
"blockNumber": Object {
"N": "123",
},
"eventKey": Object {
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Approval|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "mined",
},
"systime": Object {
"N": "9876543210",
},
"timestampId": Object {
"S": "1234567890|id",
},
"tokenOwner": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"transactionHash": Object {
"S": "txHash",
},
}
`;

exports[`convertEventToDynamo, no logStatus 6`] = `
Object {
"blockHash": Object {
"S": "blockHash",
},
"blockNumber": Object {
"N": "123",
},
"eventKey": Object {
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|TotalSupply|1970-01-06",
},
"logStatus": Object {
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"systime": Object {
"N": "9876543210",
},
"timestampId": Object {
"S": "1234567890|id",
},
"transactionHash": Object {
"S": "txHash",
},
}
`;

exports[`convertTradeToDynamo 1`] = `
Object {
"amount": Object {
Expand Down Expand Up @@ -972,7 +1146,7 @@ Array [
"S": "contractAddress|type|1970-01-15",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"systime": Object {
"N": "1234567890",
Expand Down Expand Up @@ -1003,7 +1177,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|CommitPrice|1970-01-15",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
Expand Down Expand Up @@ -1034,7 +1208,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Create|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
Expand Down Expand Up @@ -1068,7 +1242,7 @@ Array [
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"systime": Object {
"N": "1234567890",
Expand Down Expand Up @@ -1096,7 +1270,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Approval|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"systime": Object {
"N": "1234567890",
Expand Down Expand Up @@ -1127,7 +1301,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|TotalSupply|1970-01-06",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
Expand Down Expand Up @@ -1163,7 +1337,7 @@ Array [
"S": "contractAddress|type|1970-01-15",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"systime": Object {
"N": "1234567890",
Expand Down Expand Up @@ -1194,7 +1368,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|CommitPrice|1970-01-15",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
Expand Down Expand Up @@ -1225,7 +1399,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Create|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
Expand Down Expand Up @@ -1259,7 +1433,7 @@ Array [
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"systime": Object {
"N": "1234567890",
Expand Down Expand Up @@ -1287,7 +1461,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|Approval|1970-01-15|0x00D8d0660b243452fC2f996A892D3083A903576F",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"systime": Object {
"N": "1234567890",
Expand Down Expand Up @@ -1318,7 +1492,7 @@ Array [
"S": "0x0f80F055c7482b919183EcD06e0dd5FD7991D309|TotalSupply|1970-01-06",
},
"logStatus": Object {
"S": "logStatus",
"S": "mined",
},
"sender": Object {
"S": "0x00D8d0660b243452fC2f996A892D3083A903576F",
Expand Down

0 comments on commit 4ec3ac3

Please sign in to comment.