Skip to content

Commit 938fa36

Browse files
committed
Fix timstamp conversion in block header, add test
1 parent cebd78f commit 938fa36

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/node/src/algorand/utils.algorand.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { INestApplication } from '@nestjs/common';
55
import { AlgorandBlock } from '@subql/types-algorand';
66
import { prepareApiService } from './algorand.spec';
77
import { AlgorandApiService } from './api.service.algorand';
8-
import { filterTransaction } from './utils.algorand';
8+
import { algorandBlockToHeader, filterTransaction } from './utils.algorand';
99

1010
describe('Algorand Filters', () => {
1111
describe('Transaction Filters', () => {
@@ -94,5 +94,11 @@ describe('Algorand Filters', () => {
9494
}),
9595
).toBeTruthy();
9696
});
97+
98+
it('can correctly get a block timestamp date', () => {
99+
const header = algorandBlockToHeader(block);
100+
101+
expect(header.timestamp).toEqual(new Date('2023-07-13T10:44:35.000Z'));
102+
});
97103
});
98104
});

packages/node/src/algorand/utils.algorand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function algorandBlockToHeader(block: BlockContent): Header {
1818
blockHeight: block.round,
1919
blockHash: block.hash,
2020
parentHash: block.previousBlockHash,
21-
timestamp: new Date(block.timestamp),
21+
timestamp: new Date(block.timestamp * 1000), // Add MS
2222
};
2323
}
2424

0 commit comments

Comments
 (0)