From 6b8195ef3ed6a8b3490c9e6a303ae6a41d070868 Mon Sep 17 00:00:00 2001
From: Bertrand PRESLES <bertrand@presles.fr>
Date: Mon, 1 Apr 2019 10:27:08 +0200
Subject: [PATCH] Added integration tests for transaction history and
 transaction history with times filters

---
 .../transactions/transactions-test.ts         | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/integration/transactions/transactions-test.ts b/test/integration/transactions/transactions-test.ts
index 3b04c54ea..c485b1922 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) => {
-- 
GitLab