diff --git a/tests/README.md b/tests/README.md index 3d72d8123e..fa6f675a54 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,9 +1,6 @@ ## Binary init checker - -### WIP -A simple tool to ensure that all binaries init with the correct format, using the assert.sh library - +A simple tool to ensure that all binaries init with the correct format, using the `assert.sh` library Simply run `./build_and_run.sh $RELEASE_BRANCH` `$CURRENT_PRODUCTION_RELEASE_VERSION` @@ -11,10 +8,10 @@ For example: `./build_and_run.sh release/v1.1.11 v1.1.10` -This will run through all the binaries anc check the fields that we expect to be initialised when passing the parameters into nyms core binaries +Currently, this is run on linux based machines as the nym-core binaries are published via a linux build agent + + +This will run through all the binaries and check the fields that we expect to be initialised when passing the parameters into nyms core binaries ## TODO - - Introduce all binaries - - Sort paths and locations - - Tidy up - - Run in CI + - Create GH workflow and Run in CI diff --git a/tests/build_and_run.sh b/tests/build_and_run.sh index 765e053bf7..b86c74cced 100755 --- a/tests/build_and_run.sh +++ b/tests/build_and_run.sh @@ -4,6 +4,13 @@ PWD="../" GIT_BRANCH=$1 VERSION_NUMBER=$2 +# run the script from the correct location + +if [[ $(pwd) != */tests ]]; then + echo "Please run the script from the 'tests' directory." + exit 1 +fi + # lets make sure the branch is up to date # --------------------------------------- git checkout develop @@ -20,26 +27,26 @@ cargo build --release --all #here there should be the applicable binaries to test inits echo "running mixnode binary check" -./nym-mixnode-binary-check.sh "$VERSION_NUMBER" +./nym-mixnode-binary-check.sh sleep 2 echo "running gateway binary check" -./nym-gateway-binary-check.sh "$VERSION_NUMBER" +./nym-gateway-binary-check.sh sleep 2 echo "running socks-5 binary check" -./nym-socks-5-binary-check.sh "$VERSION_NUMBER" +./nym-socks-5-binary-check.sh sleep 2 echo "running network-requester binary check" -./nym-network-requester-binary-check.sh "$VERSION_NUMBER" +./nym-network-requester-binary-check.sh sleep 2 echo "running client binary check" -./nym-client-binary-check.sh "$VERSION_NUMBER" +./nym-client-binary-check.sh diff --git a/tests/nym-client-binary-check.sh b/tests/nym-client-binary-check.sh index ef22d439cd..ee23bccb64 100755 --- a/tests/nym-client-binary-check.sh +++ b/tests/nym-client-binary-check.sh @@ -6,19 +6,14 @@ set -e PWD="../" RELEASE_DIRECTORY="target/release" -VERSION_NUMBER=$1 OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${OUTPUT}" BINARY_NAME="nym-client" -echo "the version number is ${VERSION_NUMBER} to be installed from github" - -cd ${PWD}${RELEASE_DIRECTORY} - # install the current release binary # so this is dependant on running on a linux machine for the time being -curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME chmod u+x $BINARY_NAME #---------------------------------------------------------------------------------------------------------- @@ -41,12 +36,9 @@ check_nym_client_binary_build() if [ -f $BINARY_NAME ]; then VALUE=${VALUE#\"} VALUE=${VALUE%\"} - echo "${OUTPUT}" - sleep 2 - # do asserts here based upon the output on init - assert $(echo ${VALUE}) $(echo ${ID}) + assert "echo ${VALUE}" $(echo ${ID}) assert_end nym-client-tests else echo "exting test no binary found" @@ -62,7 +54,7 @@ fi check_nym_client_binary_build -first_init=$(cat /root/.nym/clients/${ID}/config/config.toml | grep -v "^version =") +first_init=$(cat ${HOME}/.nym/clients/${ID}/config/config.toml | grep -v "^version =") #---------------------------------------------------------------------------------------------------------- # lets remove the binary then navigate to the target/release directory for checking the latest version @@ -91,7 +83,7 @@ echo "-------------------------------------" check_nym_client_binary_build -second_init=$(cat /root/.nym/clients/${ID}/config/config.toml | grep -v "^version =") +second_init=$(cat ${HOME}/.nym/clients/${ID}/config/config.toml | grep -v "^version =") diff -w <(echo "$first_init") <(echo "$second_init") diff --git a/tests/nym-gateway-binary-check.sh b/tests/nym-gateway-binary-check.sh index 5c8df30fb8..9df6fd80f6 100755 --- a/tests/nym-gateway-binary-check.sh +++ b/tests/nym-gateway-binary-check.sh @@ -6,44 +6,41 @@ set -e PWD="../" RELEASE_DIRECTORY="target/release" -VERSION_NUMBER=$1 WALLET_ADDRESS_CONST=n1435n84se65tn7yv536am0sfvng4yyrwj7thhxr MOCK_HOST="1.2.3.4" RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${RANDOM_ID}" BINARY_NAME="nym-gateway" -echo "the version number is ${VERSION_NUMBER} to be installed from github" - -cd ${PWD}${RELEASE_DIRECTORY} - # install the current release binary # so this is dependant on running on a linux machine for the time being -curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME chmod u+x $BINARY_NAME #-------------------------------------- # functions #-------------------------------------- -check_gateway_binary_build() if [ -f nym-gateway ]; then +check_gateway_binary_build() if [ -f "$BINARY_NAME" ]; then echo "running init tests" # we wont use config env files for now # unless we want to use a specific environment - OUTPUT=$(./nym-gateway --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST}) >/dev/null 2>&1 + OUTPUT=$(./${BINARY_NAME} --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST}) >/dev/null 2>&1 # get jq values for things we can assert against - VALUE=$(echo ${OUTPUT} | jq .wallet_address) + VALUE=$(echo ${OUTPUT} | jq .data_store) VALUE=${VALUE#\"} VALUE=${VALUE%\"} - echo $OUTPUT - sleep 2 + #------------------------------------------------------ + DATA_STORE="${HOME}/.nym/gateways/${ID}/data/db.sqlite" + #------------------------------------------------------ - # do asserts here based upon the output on init + # do asserts here based upon the output + # check the data store path - assert $(echo ${VALUE}) $(echo ${WALLET_ADDRESS_CONST}) + assert "echo ${VALUE}" $(echo ${DATA_STORE}) assert_end nym-gateway-tests else echo "exting test no binary found" @@ -57,7 +54,7 @@ fi check_gateway_binary_build # whoami # this is dependant on where it runs on ci potentially, will need to tweak this in the future -first_init=$(cat /root/.nym/gateways/${ID}/config/config.toml | grep -v "^\[gateway\]$" | grep -v "^version =") +first_init=$(cat ${HOME}/.nym/gateways/${ID}/config/config.toml | grep -v "^\[gateway\]$" | grep -v "^version =" | grep -v "^cosmos_mnemonic =") #lets remove the binary then navigate to the target/release directory for checking the latest version if [ -f "$BINARY_NAME" ]; then @@ -83,7 +80,7 @@ check_gateway_binary_build echo "diff the config files after each init" echo "-------------------------------------" -second_init=$(cat /root/.nym/gateways/${ID}/config/config.toml | grep -v "^\[gateway\]$" | grep -v "^version =") +second_init=$(cat ${HOME}/.nym/gateways/${ID}/config/config.toml | grep -v "^\[gateway\]$" | grep -v "^version =" | grep -v "^cosmos_mnemonic =") diff -w <(echo "$first_init") <(echo "$second_init") diff --git a/tests/nym-mixnode-binary-check.sh b/tests/nym-mixnode-binary-check.sh index b670113c0d..cb47ed9b4b 100755 --- a/tests/nym-mixnode-binary-check.sh +++ b/tests/nym-mixnode-binary-check.sh @@ -4,19 +4,17 @@ PWD="../" RELEASE_DIRECTORY="target/release" -RELEASE_VERSION_NUMBER=$1 WALLET_ADDRESS_CONST=n1435n84se65tn7yv536am0sfvng4yyrwj7thhxr MOCK_HOST="1.2.3.4" -OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) -ID="test-${OUTPUT}" +RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) +ID="test-${RANDOM_ID}" BINARY_NAME="nym-mixnode" -echo "the version number is ${VERSION_NUMBER} to be installed from github" - # install the current release binary # so this is dependant on running on a linux machine for the time being -curl -L "https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/${BINARY_NAME}" -o nym-mixnode -chmod u+x "$BINARY_NAME" + +curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME +chmod u+x $BINARY_NAME #---------------------------------------------------------------------------------------------------------- # functions @@ -26,7 +24,7 @@ check_mixnode_binary_build() { if [ -f "$BINARY_NAME" ]; then echo "running init tests" # we wont use config env files for now - OUTPUT=$(./${BINARY_NAME} --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST} >/dev/null) + OUTPUT=$(./${BINARY_NAME} --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST}) >/dev/null # get jq values for things we can assert against # tidy this bit up - okay for first push @@ -48,7 +46,7 @@ check_mixnode_binary_build() { check_mixnode_binary_build # whoami # this is dependant on where it runs on ci potentially, will need to tweak this in the future -first_init=$(cat /root/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =") +first_init=$(cat ${HOME}/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =") #lets remove the binary then navigate to the target/release directory for checking the latest version if [ -f "$BINARY_NAME" ]; then @@ -74,7 +72,7 @@ check_mixnode_binary_build echo "diff the config files after each init" echo "-------------------------------------" -second_init=$(cat /root/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =") +second_init=$(cat ${HOME}/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =") diff -w <(echo "$first_init") <(echo "$second_init") diff --git a/tests/nym-network-requester-binary-check.sh b/tests/nym-network-requester-binary-check.sh index a82fe1284e..8f299cc042 100755 --- a/tests/nym-network-requester-binary-check.sh +++ b/tests/nym-network-requester-binary-check.sh @@ -6,18 +6,15 @@ set -e PWD="../" RELEASE_DIRECTORY="target/release" -VERSION_NUMBER=$1 RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${RANDOM_ID}" BINARY_NAME="nym-network-requester" -echo "the version number is ${VERSION_NUMBER} to be installed from github" - -cd ${PWD}${RELEASE_DIRECTORY} +echo "the version number is ${RELEASE_VERSION_NUMBER} to be installed from github" # we have now the bundled the client into the network requester, more a less the same output as the client -curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME chmod u+x $BINARY_NAME #---------------------------------------------------------------------------------------------------------- @@ -40,12 +37,9 @@ check_nym_network_requester_binary_build() if [ -f $BINARY_NAME ]; then VALUE=${VALUE#\"} VALUE=${VALUE%\"} - echo "${OUTPUT}" - sleep 2 - # do asserts here based upon the output on init - assert $(echo ${VALUE}) $(echo ${ID}) + assert "echo ${VALUE}" $(echo ${ID}) assert_end nym-network-requester-tests else echo "exting test no binary found" @@ -61,7 +55,7 @@ fi check_nym_network_requester_binary_build -first_init=$(cat /root/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =") +first_init=$(cat ${HOME}/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =") #---------------------------------------------------------------------------------------------------------- # lets remove the binary then navigate to the target/release directory for checking the latest version @@ -90,7 +84,7 @@ echo "-------------------------------------" check_nym_network_requester_binary_build -second_init=$(cat /root/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =") +second_init=$(cat ${HOME}/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =") diff -w <(echo "$first_init") <(echo "$second_init") diff --git a/tests/nym-socks-5-binary-check.sh b/tests/nym-socks-5-binary-check.sh index b818db3b9a..ebcfe85e14 100755 --- a/tests/nym-socks-5-binary-check.sh +++ b/tests/nym-socks-5-binary-check.sh @@ -6,20 +6,15 @@ set -e PWD="../" RELEASE_DIRECTORY="target/release" -VERSION_NUMBER=$1 MOCK_SERVICE_PROVIDER="36cUqdggtdXixZhmXfyZm3Dep3Q5QsKVPotMrVSmS4oY.ZCCAdFPwPNSTtUMYveA62ttEFe8FDiB3cdheWHtCytX@6Lnxj9vD2YMtSmfe8zp5RBtj1uZLYQAFRxY9q7ANwrZz" RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${RANDOM_ID}" BINARY_NAME="nym-socks5-client" -echo "the version number is ${VERSION_NUMBER} to be installed from github" - -cd ${PWD}${RELEASE_DIRECTORY} - # install the current release binary # so this is dependant on running on a linux machine for the time being -curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME chmod u+x $BINARY_NAME #---------------------------------------------------------------------------------------------------------- @@ -42,12 +37,9 @@ check_nym_socks5_client_binary_build() if [ -f $BINARY_NAME ]; then VALUE=${VALUE#\"} VALUE=${VALUE%\"} - echo "${OUTPUT}" - sleep 2 - # do asserts here based upon the output on init - assert $(echo ${VALUE}) $(echo ${ID}) + assert "echo ${VALUE}" $(echo ${ID}) assert_end nym-socks-5-client-tests else echo "exting test no binary found" @@ -63,7 +55,7 @@ fi check_nym_socks5_client_binary_build -first_init=$(cat /root/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =") +first_init=$(cat ${HOME}/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =") #---------------------------------------------------------------------------------------------------------- # lets remove the binary then navigate to the target/release directory for checking the latest version @@ -92,7 +84,7 @@ echo "-------------------------------------" check_nym_socks5_client_binary_build -second_init=$(cat /root/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =") +second_init=$(cat ${HOME}/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =") diff -w <(echo "$first_init") <(echo "$second_init")