From 9c240a70bb2ac98fd9f32356a5eaa26fd7f68acb Mon Sep 17 00:00:00 2001
From: Spencer Brown <spencer@privategrity.com>
Date: Fri, 25 May 2018 14:22:19 -0700
Subject: [PATCH] Run a batch through the gateway

---
 basice2e/clients.goldoutput/client12.out |  2 +
 basice2e/clients.goldoutput/client23.out |  2 +
 basice2e/clients.goldoutput/client34.out |  2 +
 basice2e/clients.goldoutput/client41.out |  2 +
 basice2e/gateway.yaml                    | 36 +++++++++++++++++
 basice2e/run.sh                          | 17 +++++++-
 build.sh                                 |  7 ++++
 update.sh                                | 49 ++++++++++++++++--------
 8 files changed, 100 insertions(+), 17 deletions(-)
 create mode 100644 basice2e/gateway.yaml

diff --git a/basice2e/clients.goldoutput/client12.out b/basice2e/clients.goldoutput/client12.out
index 71f22f1..5bdaeeb 100755
--- a/basice2e/clients.goldoutput/client12.out
+++ b/basice2e/clients.goldoutput/client12.out
@@ -2,3 +2,5 @@ Sending Message to 2, Jim: Hello, 2
 Message from 31, #General Received: Channel, Hello
 Sending Message to 2, Jim: Hello, 2
 Message from 4, Rick Received: Hello, 1
+Sending Message to 2, Jim: Hello, 2
+Message from 4, Rick Received: Hello, 1
diff --git a/basice2e/clients.goldoutput/client23.out b/basice2e/clients.goldoutput/client23.out
index 97b0607..48ab196 100755
--- a/basice2e/clients.goldoutput/client23.out
+++ b/basice2e/clients.goldoutput/client23.out
@@ -2,3 +2,5 @@ Sending Message to 3, Ben: Hello, 3
 Message from 31, #General Received: Channel, Hello
 Sending Message to 3, Ben: Hello, 3
 Message from 1, David Received: Hello, 2
+Sending Message to 3, Ben: Hello, 3
+Message from 1, David Received: Hello, 2
diff --git a/basice2e/clients.goldoutput/client34.out b/basice2e/clients.goldoutput/client34.out
index ec71365..840020e 100755
--- a/basice2e/clients.goldoutput/client34.out
+++ b/basice2e/clients.goldoutput/client34.out
@@ -2,3 +2,5 @@ Sending Message to 4, Rick: Hello, 4
 Message from 31, #General Received: Channel, Hello
 Sending Message to 4, Rick: Hello, 4
 Message from 2, Jim Received: Hello, 3
+Sending Message to 4, Rick: Hello, 4
+Message from 2, Jim Received: Hello, 3
diff --git a/basice2e/clients.goldoutput/client41.out b/basice2e/clients.goldoutput/client41.out
index e1b6109..1b1ce0f 100755
--- a/basice2e/clients.goldoutput/client41.out
+++ b/basice2e/clients.goldoutput/client41.out
@@ -2,3 +2,5 @@ Sending Message to 1, David: Hello, 1
 Message from 31, #General Received: Channel, Hello
 Sending Message to 1, David: Hello, 1
 Message from 3, Ben Received: Hello, 4
+Sending Message to 1, David: Hello, 1
+Message from 3, Ben Received: Hello, 4
diff --git a/basice2e/gateway.yaml b/basice2e/gateway.yaml
new file mode 100644
index 0000000..6681b96
--- /dev/null
+++ b/basice2e/gateway.yaml
@@ -0,0 +1,36 @@
+################################################################################
+## Copyright © 2018 Privategrity Corporation                                   #
+##                                                                             #
+## All rights reserved.                                                        #
+################################################################################
+
+##
+# Sample Gateway Configuration
+##
+
+# Output log file
+log: "results/gateway.log"
+
+# The cMix nodes in the network
+cMixNodes:
+ - "localhost:50000"
+ - "localhost:50001"
+ - "localhost:50002"
+ - "localhost:50003"
+ - "localhost:50004"
+# The index to which this Gateway is attached in the cMixNodes list
+GatewayNodeIndex: 4
+
+# The listening address of this gateway
+GatewayAddress: "localhost:8443"
+
+# The number of seconds a message should remain in the globals before being
+# deleted from the user's message queue
+MessageTimeout: 60
+
+### Anything below this line is to be deprecated ###
+
+# Number of nodes in the cMix Network
+
+# Batch size of the cMix Network (to be deprecated)
+batchSize: 4
diff --git a/basice2e/run.sh b/basice2e/run.sh
index 35f2291..b407fc5 100755
--- a/basice2e/run.sh
+++ b/basice2e/run.sh
@@ -12,6 +12,7 @@ CLIENTOUT=results/clients
 CHANNELOUT=results/channelbot.console
 DUMMYOUT=results/dummy.console
 UDBOUT=results/udb.console
+GATEWAYOUT=results/gateway.console
 
 mkdir -p $SERVERLOGS
 mkdir -p $CLIENTOUT
@@ -68,7 +69,7 @@ runclients() {
             nid=$((($cid % 4) + 1))
             eval NICK=\${NICK${cid}}
             # Send a regular message
-            CLIENTCMD="timeout 60s ../bin/client -f blob$cid --numnodes 5 -s $LASTNODE -i $cid -d $nid -m \"Hello, $nid\" --noratchet"
+            CLIENTCMD="timeout 60s ../bin/client -f blob$cid --numnodes 5 $GATEWAY -s $LASTNODE -i $cid -d $nid -m \"Hello, $nid\" --noratchet"
             eval $CLIENTCMD >> $CLIENTOUT/client$cid$nid.out 2>&1 &
             PIDVAL=$!
             eval CLIENTS${CTR}=$PIDVAL
@@ -106,6 +107,13 @@ PIDVAL=$!
 echo $PIDVAL >> results/serverpids
 echo "$DUMMYCMD -- $PIDVAL"
 
+# Start a gateway
+GATEWAYCMD="../bin/gateway --config gateway.yaml"
+$GATEWAYCMD >> $GATEWAYOUT 2>&1 &
+PIDVAL=$!
+echo $PIDVAL >> results/serverpids
+echo "$GATEWAYCMD -- $PIDVAL"
+
 # Send a registration command
 cat registration-commands.txt | while read LINE
 do
@@ -129,6 +137,9 @@ echo "RUNNING CLIENTS..."
 runclients
 echo "RUNNING CLIENTS (2nd time)..."
 runclients
+echo "RUNNING CLIENTS THROUGH GATEWAY..."
+GATEWAY="-g localhost:8443"
+runclients
 
 # HACK HACK HACK: Remove the ratchet warning from client output
 for F in $(find results/clients -type f)
@@ -148,6 +159,10 @@ diff -ruN results/channel-errors.txt noerrors.txt
 cat $DUMMYOUT | grep "ERROR" > results/dummy-errors.txt || true
 cat $DUMMYOUT | grep "FATAL" >> results/dummy-errors.txt || true
 diff -ruN results/dummy-errors.txt noerrors.txt
+cat $GATEWAYOUT | grep "ERROR" > results/gateway-errors.txt || true
+cat $GATEWAYOUT | grep "FATAL" >> results/gateway-errors.txt || true
+diff -ruN results/gateway-errors.txt noerrors.txt
+
 
 
 echo "SUCCESS!"
diff --git a/build.sh b/build.sh
index c9c9f71..3faffc8 100755
--- a/build.sh
+++ b/build.sh
@@ -4,6 +4,8 @@
 # and assumes that you've cloned the Go repos to your GOPATH and updated them
 # with Glide.
 
+mkdir -p bin
+
 pushd $GOPATH/src/gitlab.com/privategrity/client
 go generate cmd/version.go
 go build
@@ -29,3 +31,8 @@ popd
 go build -o udb $UDBPATH
 mv ./udb bin
 
+pushd $GOPATH/src/gitlab.com/privategrity/gateway
+go generate cmd/version.go
+go build
+popd
+mv $GOPATH/src/gitlab.com/privategrity/gateway/gateway bin
diff --git a/update.sh b/update.sh
index 32db2e7..d173a60 100755
--- a/update.sh
+++ b/update.sh
@@ -6,30 +6,47 @@
 git pull
 rm -fr ~/.glide
 
+update() {
+    git clean -ffdx
+#    git checkout master
+    git pull
+    glide cc
+    glide up
+}
+
 pushd $GOPATH/src/gitlab.com/privategrity/client
-git clean -ffdx
-git pull
-glide cc
-glide up
+update
 popd
 
 pushd $GOPATH/src/gitlab.com/privategrity/server
-git clean -ffdx
-git pull
-glide cc
-glide up
+update
 popd
 
 pushd $GOPATH/src/gitlab.com/privategrity/channelbot
-git clean -ffdx
-git pull
-glide cc
-glide up
+update
 popd
 
 pushd $GOPATH/src/gitlab.com/privategrity/user-discovery-bot
-git clean -ffdx
-git pull
-glide cc
-glide up
+update
+popd
+
+pushd $GOPATH/src/gitlab.com/privategrity/gateway
+update
 popd
+
+#pushd $GOPATH/src/gitlab.com/privategrity/comms
+#update
+#popd
+
+#pushd $GOPATH/src/gitlab.com/privategrity/crypto
+#update
+#popd
+
+#pushd $GOPATH/src/gitlab.com/privategrity/client-consoleUI
+#update
+#popd
+
+pushd ..
+go test ./...
+popd
+
-- 
GitLab