From a21ed389059215fda774fdbec6a9705f6c4707b8 Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Thu, 2 Nov 2017 20:57:29 +0100
Subject: [PATCH] [fix] ws2p integrations test : use different uuidfor each
 testing server

---
 test/integration/ws2p_client_limitations.ts | 7 ++++---
 test/integration/ws2p_cluster.ts            | 7 ++++---
 test/integration/ws2p_heads.ts              | 7 ++++---
 test/integration/ws2p_server_limitations.ts | 7 ++++---
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/test/integration/ws2p_client_limitations.ts b/test/integration/ws2p_client_limitations.ts
index 1da2eabea..7f5bc868d 100644
--- a/test/integration/ws2p_client_limitations.ts
+++ b/test/integration/ws2p_client_limitations.ts
@@ -9,6 +9,7 @@ import {
 } from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
 import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
+import {hashf} from "../../app/lib/common";
 
 const assert = require('assert')
 
@@ -112,7 +113,7 @@ describe("WS2P client limitations", function() {
     const p1 = await s1.getPeer()
     assert.deepEqual(p1.endpoints, [
       'BASIC_MERKLED_API 127.0.0.1 ' + portBMA1,
-      'WS2P 11111111 127.0.0.1 ' + portWS1
+      'WS2P '+hashf(catKeyring.pub).slice(0, 8).toUpperCase()+' 127.0.0.1 ' + portWS1
     ])
     await s2.writePeer(p1)
     await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
@@ -231,7 +232,7 @@ describe("WS2P client limitations", function() {
     // A server
     conf1.ws2p = {
       upnp: false,
-      uuid: '11111111',
+      uuid: hashf(keyring.pub).slice(0, 8).toUpperCase(),
       host: '127.0.0.1',
       port: portWS,
       remotehost: '127.0.0.1',
@@ -239,7 +240,7 @@ describe("WS2P client limitations", function() {
       privilegedNodes: []
     }
     const server = simpleTestingServer(conf1)
-    server._server.addEndpointsDefinitions(async () => 'WS2P 11111111 127.0.0.1 ' + portWS)
+    server._server.addEndpointsDefinitions(async () => 'WS2P '+conf1.ws2p.uuid+' 127.0.0.1 ' + portWS)
     return { server, portWS, portBMA }
   }
 })
diff --git a/test/integration/ws2p_cluster.ts b/test/integration/ws2p_cluster.ts
index 08c976f75..50cc2c1d9 100644
--- a/test/integration/ws2p_cluster.ts
+++ b/test/integration/ws2p_cluster.ts
@@ -8,6 +8,7 @@ import {
 } from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
 import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
+import {hashf} from "../../app/lib/common";
 
 const assert = require('assert')
 
@@ -89,7 +90,7 @@ describe("WS2P cluster", function() {
     const p1 = await s1.getPeer()
     assert.deepEqual(p1.endpoints, [
       'BASIC_MERKLED_API 127.0.0.1 ' + portBMA1,
-      'WS2P 11111111 127.0.0.1 ' + portWS1
+      'WS2P '+hashf(catKeyring.pub).slice(0, 8).toUpperCase()+' 127.0.0.1 ' + portWS1
     ])
     await s2.writePeer(p1)
     WS2PCluster.plugOn(s2._server);
@@ -144,14 +145,14 @@ describe("WS2P cluster", function() {
     // A server
     conf1.ws2p = {
       upnp: false,
-      uuid: '11111111',
+      uuid: hashf(keyring.pub).slice(0, 8).toUpperCase(),
       host: '127.0.0.1',
       port: portWS,
       remotehost: '127.0.0.1',
       remoteport: portWS
     }
     const server = simpleTestingServer(conf1)
-    server._server.addEndpointsDefinitions(async () => 'WS2P 11111111 127.0.0.1 ' + portWS)
+    server._server.addEndpointsDefinitions(async () => 'WS2P '+conf1.ws2p.uuid+' 127.0.0.1 ' + portWS)
     return { server, portWS, portBMA }
   }
 })
diff --git a/test/integration/ws2p_heads.ts b/test/integration/ws2p_heads.ts
index 7f0e78e50..143670f37 100644
--- a/test/integration/ws2p_heads.ts
+++ b/test/integration/ws2p_heads.ts
@@ -1,6 +1,7 @@
 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"
+import {hashf} from "../../app/lib/common";
 
 const assert = require('assert')
 const should = require('should')
@@ -67,7 +68,7 @@ describe("WS2P heads propagation", function() {
     const p1 = await s1.getPeer()
     assert.deepEqual(p1.endpoints, [
       'BASIC_MERKLED_API 127.0.0.1 ' + portBMA1,
-      'WS2P 11111111 127.0.0.1 ' + portWS1
+      'WS2P '+hashf(catKeyring.pub).slice(0, 8).toUpperCase()+' 127.0.0.1 ' + portWS1
     ])
     await s2.writePeer(p1)
     await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
@@ -110,7 +111,7 @@ describe("WS2P heads propagation", function() {
     // A server
     conf1.ws2p = {
       upnp: false,
-      uuid: '11111111',
+      uuid:  hashf(keyring.pub).slice(0, 8).toUpperCase(),
       host: '127.0.0.1',
       port: portWS,
       remotehost: '127.0.0.1',
@@ -118,7 +119,7 @@ describe("WS2P heads propagation", function() {
       privilegedNodes: []
     }
     const server = simpleTestingServer(conf1)
-    server._server.addEndpointsDefinitions(async () => 'WS2P 11111111 127.0.0.1 ' + portWS)
+    server._server.addEndpointsDefinitions(async () => 'WS2P '+conf1.ws2p.uuid+' 127.0.0.1 ' + portWS)
     return { server, portWS, portBMA }
   }
 })
diff --git a/test/integration/ws2p_server_limitations.ts b/test/integration/ws2p_server_limitations.ts
index 8130d1862..515a2347d 100644
--- a/test/integration/ws2p_server_limitations.ts
+++ b/test/integration/ws2p_server_limitations.ts
@@ -9,6 +9,7 @@ import {
 } from "./tools/toolbox"
 import {WS2PCluster} from "../../app/modules/ws2p/lib/WS2PCluster"
 import {WS2PConstants} from "../../app/modules/ws2p/lib/constants"
+import {hashf} from "../../app/lib/common";
 
 const assert = require('assert')
 
@@ -115,7 +116,7 @@ describe("WS2P server limitations", function() {
     const p1 = await s1.getPeer()
     assert.deepEqual(p1.endpoints, [
       'BASIC_MERKLED_API 127.0.0.1 ' + portBMA1,
-      'WS2P 11111111 127.0.0.1 ' + portWS1
+      'WS2P '+hashf(catKeyring.pub).slice(0, 8).toUpperCase()+' 127.0.0.1 ' + portWS1
     ])
     await s2.writePeer(p1)
     await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
@@ -208,7 +209,7 @@ describe("WS2P server limitations", function() {
     // A server
     conf1.ws2p = {
       upnp: false,
-      uuid: '11111111',
+      uuid:  hashf(keyring.pub).slice(0, 8).toUpperCase(),
       host: '127.0.0.1',
       port: portWS,
       remotehost: '127.0.0.1',
@@ -216,7 +217,7 @@ describe("WS2P server limitations", function() {
       privilegedNodes: []
     }
     const server = simpleTestingServer(conf1)
-    server._server.addEndpointsDefinitions(async () => 'WS2P 11111111 127.0.0.1 ' + portWS)
+    server._server.addEndpointsDefinitions(async () => 'WS2P '+conf1.ws2p.uuid+' 127.0.0.1 ' + portWS)
     return { server, portWS, portBMA }
   }
 })
-- 
GitLab