From d8a2a543538cebc1222a441d83f8a524f08df656 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Thu, 21 Sep 2017 11:13:30 +0200
Subject: [PATCH] [enh] Make WS2P tests run faster

---
 test/integration/ws2p_client_limitations.ts |  4 ++++
 test/integration/ws2p_cluster.ts            |  4 ++++
 test/integration/ws2p_connection.ts         |  4 ++++
 test/integration/ws2p_doc_sharing.ts        |  4 ++++
 test/integration/ws2p_docpool.ts            |  4 ++++
 test/integration/ws2p_exchange.ts           |  4 ++++
 test/integration/ws2p_heads.ts              |  4 ++++
 test/integration/ws2p_network.ts            | 10 +++++-----
 test/integration/ws2p_pulling.ts            |  4 ++++
 test/integration/ws2p_server_limitations.ts |  4 ++++
 10 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/test/integration/ws2p_client_limitations.ts b/test/integration/ws2p_client_limitations.ts
index 20a27bdba..b9224e86d 100644
--- a/test/integration/ws2p_client_limitations.ts
+++ b/test/integration/ws2p_client_limitations.ts
@@ -8,11 +8,15 @@ import {
   waitForkWS2PDisconnection
 } from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P client limitations", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer, s3:TestingServer, s4:TestingServer
   let cluster1:WS2PCluster, cluster2:WS2PCluster, cluster3:WS2PCluster, cluster4:WS2PCluster
diff --git a/test/integration/ws2p_cluster.ts b/test/integration/ws2p_cluster.ts
index 1b53dade9..05da7330a 100644
--- a/test/integration/ws2p_cluster.ts
+++ b/test/integration/ws2p_cluster.ts
@@ -7,11 +7,15 @@ import {
   waitForkWS2PConnection
 } from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P cluster", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer, s3:TestingServer
   let cat:any, tac:any, toc:any
diff --git a/test/integration/ws2p_connection.ts b/test/integration/ws2p_connection.ts
index 6708ac753..ea4de591a 100644
--- a/test/integration/ws2p_connection.ts
+++ b/test/integration/ws2p_connection.ts
@@ -9,6 +9,7 @@ import {Key, verify} from "../../app/lib/common-libs/crypto/keyring"
 import {assertThrows, getNewTestingPort} from "./tools/toolbox"
 import {WS2PMessageHandler} from "../../app/modules/ws2p/lib/impl/WS2PMessageHandler"
 import {WS2PResponse} from "../../app/modules/ws2p/lib/impl/WS2PResponse"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 const assert = require('assert');
 const WebSocketServer = require('ws').Server
 const logger = require('../../app/lib/logger').NewLogger('ws2p')
@@ -16,6 +17,9 @@ const gtest = "gtest"
 
 describe('WS2P', () => {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   describe("WS2P client connection", function() {
 
     describe("no auth", () => {
diff --git a/test/integration/ws2p_doc_sharing.ts b/test/integration/ws2p_doc_sharing.ts
index 68d43e13f..9bf604335 100644
--- a/test/integration/ws2p_doc_sharing.ts
+++ b/test/integration/ws2p_doc_sharing.ts
@@ -1,9 +1,13 @@
 import {simpleTestingConf, simpleTestingServer, simpleUser, simpleWS2PNetwork, TestingServer} from "./tools/toolbox"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P doc sharing", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer, wss:any
   let cat:any, tac:any, toc:any
diff --git a/test/integration/ws2p_docpool.ts b/test/integration/ws2p_docpool.ts
index 90cc54ec5..fed1b20a9 100644
--- a/test/integration/ws2p_docpool.ts
+++ b/test/integration/ws2p_docpool.ts
@@ -1,11 +1,15 @@
 import {simpleTestingConf, simpleTestingServer, simpleUser, simpleWS2PNetwork, TestingServer} from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
 import {ProverDependency} from "../../app/modules/prover/index"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P docpool pulling", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer, wss:any
   let cluster2:WS2PCluster
diff --git a/test/integration/ws2p_exchange.ts b/test/integration/ws2p_exchange.ts
index ad94beb03..731769fd0 100644
--- a/test/integration/ws2p_exchange.ts
+++ b/test/integration/ws2p_exchange.ts
@@ -5,10 +5,14 @@ import {WS2PRequester} from "../../app/modules/ws2p/lib/WS2PRequester"
 import {BlockDTO} from "../../app/lib/dto/BlockDTO"
 import {WS2PMessageHandler} from "../../app/modules/ws2p/lib/impl/WS2PMessageHandler"
 import {WS2PResponse} from "../../app/modules/ws2p/lib/impl/WS2PResponse"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 const assert = require('assert');
 
 describe('WS2P exchange', () => {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   let wss:any
   let c1:WS2PConnection, s1:WS2PConnection
 
diff --git a/test/integration/ws2p_heads.ts b/test/integration/ws2p_heads.ts
index 1f3b894c2..d116b90a9 100644
--- a/test/integration/ws2p_heads.ts
+++ b/test/integration/ws2p_heads.ts
@@ -1,11 +1,15 @@
 import {getNewTestingPort, simpleTestingConf, simpleTestingServer, simpleUser, TestingServer} from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 const should = require('should')
 
 describe("WS2P heads propagation", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer
   let cluster1:WS2PCluster, cluster2:WS2PCluster
diff --git a/test/integration/ws2p_network.ts b/test/integration/ws2p_network.ts
index 2f450fe80..96cc0dc56 100644
--- a/test/integration/ws2p_network.ts
+++ b/test/integration/ws2p_network.ts
@@ -1,14 +1,14 @@
-import {
-  getNewTestingPort, simpleTestingConf, simpleTestingServer, simpleUser, simpleWS2PNetwork,
-  TestingServer
-} from "./tools/toolbox"
+import {getNewTestingPort, simpleTestingConf, simpleTestingServer, simpleUser, TestingServer} from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
-import {ProverDependency} from "../../app/modules/prover/index"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P network", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer
   let cat:any, tac:any, toc:any
diff --git a/test/integration/ws2p_pulling.ts b/test/integration/ws2p_pulling.ts
index 39d8e8e3b..31a050311 100644
--- a/test/integration/ws2p_pulling.ts
+++ b/test/integration/ws2p_pulling.ts
@@ -1,10 +1,14 @@
 import {simpleTestingConf, simpleTestingServer, simpleUser, simpleWS2PNetwork, TestingServer} from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P block pulling", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer, wss:any
   let cluster2:WS2PCluster
diff --git a/test/integration/ws2p_server_limitations.ts b/test/integration/ws2p_server_limitations.ts
index c903ec535..cade31717 100644
--- a/test/integration/ws2p_server_limitations.ts
+++ b/test/integration/ws2p_server_limitations.ts
@@ -8,11 +8,15 @@ import {
   waitForkWS2PDisconnection
 } from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
+import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
 
 const assert = require('assert')
 
 describe("WS2P server limitations", function() {
 
+  WS2PConstants.CONNEXION_TIMEOUT = 100
+  WS2PConstants.REQUEST_TIMEOUT= 100
+
   const now = 1500000000
   let s1:TestingServer, s2:TestingServer, s3:TestingServer, s4:TestingServer
   let cluster1:WS2PCluster, cluster2:WS2PCluster, cluster3:WS2PCluster, cluster4:WS2PCluster
-- 
GitLab