diff --git a/app/lib/dal/indexDAL/sqlite/SqliteTransactions.ts b/app/lib/dal/indexDAL/sqlite/SqliteTransactions.ts index 30bb5ca17bfb3391872623edf19de1d2c6b0ee1c..76ef91395337ece73f477f0ff4af0804d84eeeb1 100644 --- a/app/lib/dal/indexDAL/sqlite/SqliteTransactions.ts +++ b/app/lib/dal/indexDAL/sqlite/SqliteTransactions.ts @@ -87,6 +87,7 @@ export class SqliteTransactions extends SqliteTable<DBTx> implements TxsDAO { const theDBTx = DBTx.fromTransactionDTO(tx) theDBTx.written = true theDBTx.block_number = block_number + theDBTx.time = time if (!dbTx) { await this.insert(theDBTx) } diff --git a/test/integration/transactions/transactions-test.ts b/test/integration/transactions/transactions-test.ts index 3b04c54ea8d7105e90d210aabd97880fc2c677b6..c485b19227834c43f12e153e99fbafce7ea07241 100644 --- a/test/integration/transactions/transactions-test.ts +++ b/test/integration/transactions/transactions-test.ts @@ -22,6 +22,9 @@ const assert = require('assert'); describe("Testing transactions", function() { const now = 1490000000; + const yesterday = now - 86400; + const tomorrow = now + 86400; + const intwodays = now + (86400 * 2); let s1:TestingServer, tic:TestUser, toc:TestUser @@ -77,6 +80,27 @@ describe("Testing transactions", function() { ]) }) + describe("History by time", function(){ + it('should have a time not null', () => s1.expect('/tx/history/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo', (res:any) => { + res.should.have.property('pubkey').equal('DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo'); + res.should.have.property('history').property('received').length(1); + res.history.received[0].should.have.property('time').not.be.Null; + res.history.received[0].should.have.property('time').be.a.Number; + })); + + it('should return a received transaction between yesterday and tomorrow', () => s1.expect('/tx/history/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo/times/' + yesterday + '/' + tomorrow, (res:any) => { + res.should.have.property('pubkey').equal('DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo'); + res.should.have.property('history').property('received').length(1); + res.history.received[0].should.have.property('time').not.be.Null; + res.history.received[0].should.have.property('time').be.a.Number; + })); + + it('should not return a received transaction the day after tomorrow', () => s1.expect('/tx/history/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo/times/' + tomorrow + '/' + intwodays, (res:any) => { + res.should.have.property('pubkey').equal('DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo'); + res.should.have.property('history').property('received').length(0); + })); + }) + describe("Sources", function(){ it('it should exist block#2 with UD of 1200', () => s1.expect('/blockchain/block/2', (block:any) => {