diff --git a/scripts/README.md b/scripts/README.md index 80ef9ba2..37d5d172 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,6 +1,7 @@ # Scripts for running D-voting locally -The following scripts are available to configure and run D-voting locally. They should be called in this order: +The following scripts are available to configure and run D-voting locally. +They should be called in this order: - `run_local.sh` - sets up a complete system with 4 nodes, the db, the authentication-server, and the frontend. @@ -13,6 +14,14 @@ The following scripts are available to configure and run D-voting locally. They - `local_votes.sh` casts the given number of votes. THE ENCRYPTION IS WRONG AND WILL NOT WORK. But it allows to test missing votes +Every script must be called from the root of the repository: + +```bash +./scripts/run_local.sh +./scripts/local_proxies.sh +./scripts/local_proxies.sh +``` + The following script is only called by the other scripts: - `local_login.sh` logs into the frontend and stores the cookie diff --git a/scripts/local_forms.sh b/scripts/local_forms.sh index df8e98b5..9388bb91 100755 --- a/scripts/local_forms.sh +++ b/scripts/local_forms.sh @@ -4,7 +4,8 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) . "$SCRIPT_DIR/local_login.sh" echo "add form" -RESP=$(curl -sk "$FRONTEND_URL/api/evoting/forms" -X POST -H 'Content-Type: application/json' -b cookies.txt --data-raw '{"Title":{"En":"Something","Fr":"","De":""},"Scaffold":[{"ID":"99hYV4uy","Title":{"En":"More stuff","Fr":"","De":""},"Order":["0c7RSRKs"],"Ranks":[],"Selects":[{"ID":"0c7RSRKs","Title":{"En":"Choose","Fr":"","De":""},"MaxN":3,"MinN":1,"Choices":[{"Choice":"{\"en\":\"First\"}","URL":""},{"Choice":"{\"en\":\"Second\"}","URL":""},{"Choice":"{\"en\":\"Third\"}","URL":""}],"Hint":{"En":"","Fr":"","De":""}}],"Texts":[],"Subjects":[]}]}') +FORMJSON='{"Configuration":{"Title":{"En":"title","Fr":"","De":"","URL":""},"Scaffold":[{"ID":"ozCI7gKv","Title":{"En":"subtitle","Fr":"","De":"","URL":""},"Order":["nVjQ0jMK"],"Ranks":[],"Selects":[{"ID":"nVjQ0jMK","Title":{"En":"vote","Fr":"","De":"","URL":""},"MaxN":3,"MinN":1,"Choices":[{"Choice":"{\"en\":\"one\"}","URL":""},{"Choice":"{\"en\":\"two\"}","URL":""},{"Choice":"{\"en\":\"three\"}","URL":""}],"Hint":{"En":"","Fr":"","De":""}}],"Texts":[],"Subjects":[]}],"AdditionalInfo":""}}' +RESP=$(curl -sk "$FRONTEND_URL/api/evoting/forms" -X POST -H 'Content-Type: application/json' -b cookies.txt --data-raw "$FORMJSON") FORMID=$(echo "$RESP" | jq -r .FormID) echo "FORMID=$FORMID" > "$SCRIPT_DIR/formid.env" diff --git a/scripts/local_votes.sh b/scripts/local_votes.sh index c48a90d0..416d2b90 100755 --- a/scripts/local_votes.sh +++ b/scripts/local_votes.sh @@ -1,14 +1,19 @@ #!/bin/bash -if ! [[ "$1" && "$2" ]]; then - echo "Syntax is: $0 #votes FORMID" +if ! [[ "$1" ]]; then + echo "Syntax is: $0 #votes [FORMID]" exit 1 fi SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) . "$SCRIPT_DIR/local_login.sh" -FORMID=$2 +if [ -f $SCRIPT_DIR/formid.env ]; then + . $SCRIPT_DIR/formid.env + FORMID_ENV=$FORMID +fi + +FORMID=${2:-$FORMID_ENV} echo "Casting $1 votes to form $FORMID" for i in $(seq $1); do echo "Casting vote #$i" diff --git a/scripts/run_local.sh b/scripts/run_local.sh index c185e5e4..0154cb89 100755 --- a/scripts/run_local.sh +++ b/scripts/run_local.sh @@ -94,13 +94,6 @@ function init_nodes() { function init_dela() { echo "Initializing dela" - echo " Share the certificate" - for n in $(seq 2 4); do - TOKEN_ARGS=$(dvoting --config ./nodes/node-1 minogrpc token) - NODEDIR=./nodes/node-$n - dvoting --config $NODEDIR minogrpc join --address grpc://localhost:2000 $TOKEN_ARGS - done - echo " Create a new chain with the nodes" for n in $(seq 4); do NODEDIR=./nodes/node-$n