Merge pull request #5743 from nymtech/tommy/remove-old-tests
Remove old test directory - Update validator docker
This commit is contained in:
+119
-25
@@ -1,45 +1,139 @@
|
||||
## Build with Docker & Docker Compose
|
||||
## Nym Validator
|
||||
|
||||
Currently you can build and run locally in a Docker containers the following components of the Nym Privacy Platform:
|
||||
This contains the configuration needed to run a Nym validator using Docker
|
||||
|
||||
* One genesis validator
|
||||
* Any number of secondary validators
|
||||
* A contract uploader, that uploads the contract built from the local sources
|
||||
* The web wallet application, accessible on port 3000
|
||||
* The block explorer application, accessible on port 3080
|
||||
* The network explorer application, accessible on port 3040, for registered users
|
||||
> **SECURITY**: This runs the validator as the root user inside the container for simplicity and development purposes. This setup should NOT be used in any other fashion.
|
||||
|
||||
### Running
|
||||
### Initial Setup
|
||||
|
||||
The following commands need to be run from the root of the Nym git project.
|
||||
|
||||
To build the entire dockerized environment, run the following command:
|
||||
Before building and running the validator, you'll need to create the required directories:
|
||||
|
||||
```
|
||||
PERSONAL_TOKEN=[network explorer token] docker-compose build
|
||||
# Create required directories
|
||||
mkdir -p data/validator data/addresses
|
||||
chmod -R 777 data
|
||||
```
|
||||
|
||||
or build each service separately, as changes are made to their relevant source code.
|
||||
**Note** network-explorer build time is currently very high, so building it more than once is not advisable.
|
||||
### Running on Apple (Mx) Macs with Colima
|
||||
|
||||
To start the dockerized environment, run the following command:
|
||||
When running on Apple Silicon Macs, we are using Colima with x86_64 emulation to properly run the validator:
|
||||
|
||||
1. Install Colima
|
||||
```
|
||||
METEOR_SETTINGS=$(cat docker/block_explorer/settings.json) docker-compose up -d --scale=secondary_validator=3
|
||||
brew install colima
|
||||
```
|
||||
|
||||
**Note**: The `secondary_validator=3` can take any other number as value, depending on the desired setup.
|
||||
|
||||
The web wallet interface will become available at `localhost:3000`.
|
||||
|
||||
The mnemonic needed to connect to the admin user, which also has a pre-added number of tokens, can be obtained by running:
|
||||
|
||||
2. Set up a Colima VM with x86_64 architecture and Rosetta support:
|
||||
```
|
||||
docker logs nym_mnemonic_echo_1
|
||||
# Create a Colima VM with x86_64 architecture
|
||||
colima start nym-validator --arch x86_64 --cpu 4 --memory 8 --disk 20 --vm-type=vz --vz-rosetta --mount-type=virtiofs
|
||||
```
|
||||
|
||||
To stop the dockerized environment, run:
|
||||
3. Build and start the validator:
|
||||
```
|
||||
# Make sure you're using the Colima context
|
||||
docker context use colima-nym-validator
|
||||
|
||||
# Build the validator
|
||||
docker-compose build validator
|
||||
|
||||
# Start the validator
|
||||
docker-compose up -d validator
|
||||
```
|
||||
|
||||
### Standard Operation (Intel/AMD x86_64 Systems)
|
||||
|
||||
For standard x86_64 systems:
|
||||
|
||||
```
|
||||
# Build the validator
|
||||
docker-compose build validator
|
||||
|
||||
# Start the validator
|
||||
docker-compose up -d validator
|
||||
```
|
||||
|
||||
The genesis validator will be initialized with the network configuration defined in the `docker-compose.yml` file.
|
||||
|
||||
### Managing the Validator
|
||||
|
||||
To check the validator logs:
|
||||
|
||||
```
|
||||
docker logs -f validator
|
||||
```
|
||||
|
||||
To get the admin mnemonic:
|
||||
|
||||
```
|
||||
docker exec validator cat /root/output/node_admin_mnemonic
|
||||
```
|
||||
|
||||
To stop the validator:
|
||||
|
||||
```
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### Terminating and Cleaning Up Validator Data
|
||||
|
||||
If you need to completely terminate your validator and remove all associated data:
|
||||
|
||||
```
|
||||
# Stop the containers
|
||||
docker-compose down
|
||||
|
||||
# Remove the volumes
|
||||
docker-compose down -v
|
||||
|
||||
# Delete the data directories
|
||||
rm -rf data
|
||||
|
||||
# If you want to start fresh, recreate the directories
|
||||
mkdir -p data/validator/config data/addresses
|
||||
chmod -R 777 data
|
||||
```
|
||||
|
||||
This will completely remove all blockchain state, keys, and configuration, allowing you to start with a clean validator instance
|
||||
|
||||
### Using nym-cli for Smart Contract Operations
|
||||
|
||||
The nym-cli utility can be used to manage and execute WASM smart contracts. You can access the CLI from within the validator container:
|
||||
|
||||
```
|
||||
docker exec -it validator ./nym-cli cosmwasm --help
|
||||
```
|
||||
|
||||
#### Available Commands:
|
||||
|
||||
- **upload**: Upload a smart contract WASM blob
|
||||
- **init**: Init a WASM smart contract
|
||||
- **generate-init-message**: Generate an instantiate message
|
||||
- **migrate**: Migrate a WASM smart contract
|
||||
- **execute**: Execute a WASM smart contract method
|
||||
- **raw-contract-state**: Obtain raw contract state of a cosmwasm smart contract
|
||||
|
||||
#### Example Usage:
|
||||
|
||||
To upload a contract:
|
||||
|
||||
```
|
||||
docker exec -it validator ./nym-cli cosmwasm upload \
|
||||
--mnemonic $(cat /root/output/node_admin_mnemonic) \
|
||||
--wasm-file /path/to/contract.wasm
|
||||
```
|
||||
|
||||
To initialize a contract:
|
||||
|
||||
```
|
||||
docker exec -it validator ./nym-cli cosmwasm init \
|
||||
--mnemonic $(cat /root/output/node_admin_mnemonic) \
|
||||
--code-id <CODE_ID> \
|
||||
--init-msg '{"key": "value"}'
|
||||
```
|
||||
|
||||
For more detailed options, use the help command:
|
||||
|
||||
```
|
||||
docker exec -it validator ./nym-cli cosmwasm <COMMAND> --help
|
||||
```
|
||||
@@ -1,69 +0,0 @@
|
||||
{
|
||||
"public":{
|
||||
"chainName": "Nym",
|
||||
"chainId": "nymnet",
|
||||
"slashingWindow": 10000,
|
||||
"uptimeWindow": 250,
|
||||
"initialPageSize": 30,
|
||||
"secp256k1": false,
|
||||
"bech32PrefixAccAddr": "punk",
|
||||
"bech32PrefixAccPub": "punkpub",
|
||||
"bech32PrefixValAddr": "punkvaloper",
|
||||
"bech32PrefixValPub": "punkvaloperpub",
|
||||
"bech32PrefixConsAddr": "punkvalcons",
|
||||
"bech32PrefixConsPub": "punkvalconspub",
|
||||
"bondDenom": "punk",
|
||||
"powerReduction": 1000000,
|
||||
"coins": [
|
||||
{
|
||||
"denom": "upunk",
|
||||
"displayName": "PUNK",
|
||||
"fraction": 1000000
|
||||
},
|
||||
{
|
||||
"denom": "punk",
|
||||
"displayName": "PUNK",
|
||||
"fraction": 1000000
|
||||
}
|
||||
],
|
||||
"ledger":{
|
||||
"coinType": 118,
|
||||
"appName": "punk",
|
||||
"appVersion": "2.16.0",
|
||||
"gasPrice": 0.025
|
||||
},
|
||||
"modules": {
|
||||
"bank": true,
|
||||
"supply": true,
|
||||
"minting": false,
|
||||
"gov": true,
|
||||
"distribution": false
|
||||
},
|
||||
"coingeckoId": "punk",
|
||||
"networks": "https://gist.githubusercontent.com/kwunyeung/8be4598c77c61e497dfc7220a678b3ee/raw/bd-networks.json",
|
||||
"banners": false
|
||||
},
|
||||
"remote":{
|
||||
"rpc":"http://genesis_validator:26657",
|
||||
"api":"http://genesis_validator:1317"
|
||||
},
|
||||
"debug": {
|
||||
"startTimer": true
|
||||
},
|
||||
"params":{
|
||||
"startHeight": 0,
|
||||
"defaultBlockTime": 5000,
|
||||
"validatorUpdateWindow": 300,
|
||||
"blockInterval": 15000,
|
||||
"transactionsInterval": 18000,
|
||||
"keybaseFetchingInterval": 18000000,
|
||||
"consensusInterval": 1000,
|
||||
"statusInterval":7500,
|
||||
"signingInfoInterval": 1800000,
|
||||
"proposalInterval": 5000,
|
||||
"missedBlocksInterval": 60000,
|
||||
"delegationInterval": 900000
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
FROM node:16
|
||||
|
||||
COPY ./setup.sh /setup.sh
|
||||
CMD /setup.sh
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
git clone https://github.com/nymtech/nym.git
|
||||
|
||||
mkdir /explorer-copy
|
||||
cp -r nym/explorer/* /explorer-copy
|
||||
|
||||
cd /explorer-copy
|
||||
|
||||
npm install
|
||||
#baseUrl
|
||||
sed -i 's/https:\/\/testnet-milhon-explorer.nymtech.net\//http:\/\/localhost:3080/' ./src/api/constants.ts
|
||||
|
||||
#master validator
|
||||
sed -i 's/https:\/\/testnet-milhon-validator1.nymtech.net/http:\/\/localhost:26657/' ./src/api/constants.ts
|
||||
|
||||
#big dipper url
|
||||
sed -i 's/https:\/\/testnet-milhon-blocks.nymtech.net\//http:\/\/localhost:3080/' ./src/api/constants.ts
|
||||
|
||||
nohup npm run start
|
||||
@@ -1,4 +0,0 @@
|
||||
FROM rust
|
||||
RUN rustup target add wasm32-unknown-unknown
|
||||
CMD cd nym/contracts/mixnet && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM alpine
|
||||
COPY ./entrypoint.sh /entrypoint.sh
|
||||
CMD /entrypoint.sh
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Wait for the mnemonic(s) to be generated
|
||||
while ! [ -s /genesis_volume/genesis_mnemonic ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
while ! [ -s /genesis_volume/secondary_mnemonic ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "This is the current genesis mnemonic:"
|
||||
cat /genesis_volume/genesis_mnemonic
|
||||
|
||||
echo "This is the current secondary mnemonic:"
|
||||
cat /genesis_volume/secondary_mnemonic
|
||||
@@ -1,4 +0,0 @@
|
||||
FROM node
|
||||
RUN apt update && apt install -y netcat
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
CMD /entrypoint.sh
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd /nym/clients/validator
|
||||
yarn install
|
||||
yarn build
|
||||
|
||||
cd /nym/docker/typescript_client/upload_contract
|
||||
npm install
|
||||
|
||||
# Wait until the mnemonic is created
|
||||
while ! [ -s /genesis_volume/genesis_mnemonic ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Wait until the validator opens its port
|
||||
while ! nc -z genesis_validator 26657; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
chmod 777 /contract_volume
|
||||
npx ts-node upload-wasm.ts
|
||||
-2116
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "nym-driver-example",
|
||||
"version": "1.0.0",
|
||||
"main": "./dist/index.js",
|
||||
"author": "Dave Hrycyszyn",
|
||||
"license": "MIT",
|
||||
"description": "The simplest cosmjs typescript client to work as an example driver program",
|
||||
"repository": "https://github.com/nymtech/nym",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/recommended": "^1.0.1",
|
||||
"prettier": "^2.8.7",
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^14.14.22",
|
||||
"nodemon": "^2.0.20",
|
||||
"@nymproject/nym-validator-client" : "0.18.0",
|
||||
"save-dev": "0.0.1-security",
|
||||
"tasktimer": "^3.0.0",
|
||||
"ts-node": "^9.1.1"
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// npx ts-node upload-wasm.ts
|
||||
|
||||
import ValidatorClient from "@nymproject/nym-validator-client";
|
||||
import * as fs from 'fs';
|
||||
|
||||
async function newClient(): Promise<ValidatorClient> {
|
||||
let contract = "fakeContractAddress"; // we don't have one yet
|
||||
let mnemonic = fs.readFileSync("/genesis_volume/genesis_mnemonic", "utf8").slice(0, -1);
|
||||
let admin = ValidatorClient.connect(contract, mnemonic, "http://genesis_validator:26657", process.env["BECH32_PREFIX"]);
|
||||
return admin;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let admin = await newClient();
|
||||
console.log(`admin address: ${admin.address}`);
|
||||
|
||||
// check that we have actually connected to an account, query it to test
|
||||
let balance = await admin.getBalance(admin.address);
|
||||
console.log(`balance of admin account is: ${balance.amount}${balance.denom}`);
|
||||
|
||||
let wasm = fs.readFileSync("/nym/contracts/mixnet/target/wasm32-unknown-unknown/release/mixnet_contracts.wasm");
|
||||
console.log("wasm loaded");
|
||||
|
||||
// dave can upload (note: nobody else can)
|
||||
const uploadResult = await admin.upload(admin.address, wasm, undefined, "mixnet contract");//.then((uploadResult) => console.log("Upload from dave succeeded, codeId is: " + uploadResult.codeId)).catch((err) => console.log(err));
|
||||
|
||||
//todo
|
||||
//add vesting contract?
|
||||
|
||||
// Instantiate the copy of the option contract
|
||||
const { codeId } = uploadResult;
|
||||
console.log("code id is", codeId)
|
||||
const initMsg = {};
|
||||
const options = { memo: "v0.1.0", transferAmount: [{ denom: "u" + process.env["BECH32_PREFIX"], amount: "1000000" }], admin: admin.address }
|
||||
let instantiateResult = await admin.instantiate(admin.address, codeId, initMsg, "mixnet contract", options);
|
||||
let contractAddress = instantiateResult.contractAddress;
|
||||
console.log(`mixnet contract ${contractAddress} instantiated successfully`)
|
||||
fs.writeFileSync("/contract_volume/contract_address", contractAddress);
|
||||
}
|
||||
|
||||
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,25 @@
|
||||
CONFIGURED=true
|
||||
|
||||
NETWORK_NAME=nymtestnetwork
|
||||
|
||||
RUST_LOG=info
|
||||
RUST_BACKTRACE=1
|
||||
|
||||
BECH32_PREFIX=n
|
||||
MIX_DENOM=unym
|
||||
MIX_DENOM_DISPLAY=nym
|
||||
STAKE_DENOM=unyx
|
||||
STAKE_DENOM_DISPLAY=nyx
|
||||
DENOMS_EXPONENT=6
|
||||
|
||||
MIXNET_CONTRACT_ADDRESS=
|
||||
VESTING_CONTRACT_ADDRESS=
|
||||
GROUP_CONTRACT_ADDRESS=
|
||||
ECASH_CONTRACT_ADDRESS=
|
||||
MULTISIG_CONTRACT_ADDRESS=
|
||||
COCONUT_DKG_CONTRACT_ADDRESS=
|
||||
|
||||
REWARDING_VALIDATOR_ADDRESS=
|
||||
NYXD="https://localhost:26656"
|
||||
NYM_API="https://insertvalues.io"
|
||||
NYXD_WS="wss://insertvalues.io"
|
||||
@@ -0,0 +1,15 @@
|
||||
# data
|
||||
|
||||
data/
|
||||
data/validator/
|
||||
data/addresses/
|
||||
|
||||
secrets/
|
||||
|
||||
# docker
|
||||
.docker/
|
||||
|
||||
# access
|
||||
*_mnemonic
|
||||
*.key
|
||||
genesis_mnemonic
|
||||
+41
-11
@@ -1,12 +1,42 @@
|
||||
FROM golang:buster as go_builder
|
||||
ARG BECH32_PREFIX
|
||||
ARG WASMD_VERSION
|
||||
RUN apt update && apt install -y git build-essential
|
||||
COPY setup.sh .
|
||||
RUN ./setup.sh
|
||||
FROM ubuntu:24.04
|
||||
|
||||
FROM ubuntu:20.04
|
||||
COPY --from=go_builder /go/wasmd/build/nymd /root/nymd
|
||||
COPY --from=go_builder /go/wasmd/build/libwasmvm*.so /root
|
||||
COPY init_and_start.sh .
|
||||
ENTRYPOINT ["./init_and_start.sh"]
|
||||
ARG WASMD_VERSION
|
||||
ARG NYM_CLI_GIT_TAG
|
||||
ARG RETAIN_BLOCKS
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
jq \
|
||||
curl \
|
||||
wget \
|
||||
vim \
|
||||
openssl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
RUN wget -O nym-cli "https://github.com/nymtech/nym/releases/download/nym-binaries-v${NYM_CLI_GIT_TAG:-2025.8-tourist}/nym-cli" && \
|
||||
chmod 755 nym-cli || echo "nym-cli not available"
|
||||
|
||||
RUN wget "https://github.com/nymtech/nyxd/releases/download/${WASMD_VERSION:-v0.54.3}/nyxd-ubuntu-22.04.tar.gz" && \
|
||||
tar -zxvf nyxd-ubuntu-22.04.tar.gz && \
|
||||
mv libwasmvm.x86_64.so /lib/x86_64-linux-gnu/ && \
|
||||
chmod 755 nyxd && \
|
||||
rm nyxd-ubuntu-22.04.tar.gz
|
||||
|
||||
RUN mkdir -p "/root/.nyxd/config" "/root/output"
|
||||
RUN chmod 755 "/root/.nyxd" "/root/.nyxd/config" "/root/output"
|
||||
|
||||
VOLUME /root/.nyxd
|
||||
VOLUME /root/output
|
||||
|
||||
RUN touch .env
|
||||
|
||||
COPY start.sh .
|
||||
RUN chmod 755 *.sh
|
||||
|
||||
ENV RETAIN_BLOCKS=${RETAIN_BLOCKS}
|
||||
|
||||
ENTRYPOINT ["./start.sh"]
|
||||
CMD ["genesis"]
|
||||
@@ -0,0 +1,30 @@
|
||||
services:
|
||||
validator:
|
||||
build:
|
||||
context: ./
|
||||
args:
|
||||
NYM_CLI_GIT_TAG: "2025.8-tourist"
|
||||
WASMD_VERSION: "v0.54.3"
|
||||
image: validator:latest
|
||||
container_name: validator
|
||||
ports:
|
||||
- "127.0.0.1:26657:26657"
|
||||
- "127.0.0.1:26656:26656"
|
||||
- "127.0.0.1:1317:1317"
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2'
|
||||
memory: 4G
|
||||
volumes:
|
||||
- ./data/addresses:/root/output
|
||||
- ./data/validator:/root/.nyxd
|
||||
environment:
|
||||
BECH32_PREFIX: "n"
|
||||
DENOM: "nym"
|
||||
STAKE_DENOM: "nyx"
|
||||
WASMD_VERSION: "v0.54.3"
|
||||
CHAIN_ID: "nymtestnetwork"
|
||||
NYM_CLI_GIT_TAG: "2025.8-tourist"
|
||||
RETAIN_BLOCKS: "no"
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root
|
||||
PASSPHRASE=passphrase
|
||||
|
||||
cd /root
|
||||
|
||||
if [ "$1" = "genesis" ]; then
|
||||
if [ ! -f "/root/.nymd/config/genesis.json" ]; then
|
||||
./nyxd init nymnet --chain-id nymnet 2> /dev/null
|
||||
# staking/governance token is hardcoded in config, change this
|
||||
sed -i "s/\"stake\"/\"u${STAKE_DENOM}\"/" /root/.nyxd/config/genesis.json
|
||||
sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.025u'"${DENOM}"'"/' /root/.nyxd/config/app.toml
|
||||
sed -i '0,/enable = false/s//enable = true/g' /root/.nyxd/config/app.toml
|
||||
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/' /root/.nyxd/config/config.toml
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/' /root/.nyxd/config/config.toml
|
||||
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/' /root/.nyxd/config/config.toml
|
||||
|
||||
# create accounts
|
||||
yes "${PASSPHRASE}" | ./nyxd keys add node_admin 2>&1 >/dev/null | tail -n 1 > /root/.nyxd/mnemonic
|
||||
yes "${PASSPHRASE}" | ./nyxd keys add secondary 2>&1 >/dev/null | tail -n 1 > /root/.nyxd/secondary_mnemonic
|
||||
cp /root/.nyxd/mnemonic /genesis_volume/genesis_mnemonic
|
||||
cp /root/.nyxd/secondary_mnemonic /genesis_volume/secondary_mnemonic
|
||||
|
||||
# add genesis accounts with some initial tokens
|
||||
GENESIS_ADDRESS=$(yes "${PASSPHRASE}" | ./nyxd keys show node_admin -a)
|
||||
SECONDARY_ADDRESS=$(yes "${PASSPHRASE}" | ./nyxd keys show secondary -a)
|
||||
yes "${PASSPHRASE}" | ./nyxd add-genesis-account "${GENESIS_ADDRESS}" 1000000000000000u"${DENOM}",1000000000000000u"${STAKE_DENOM}"
|
||||
yes "${PASSPHRASE}" | ./nyxd add-genesis-account "${SECONDARY_ADDRESS}" 1000000000000000u"${DENOM}",1000000000000000u"${STAKE_DENOM}"
|
||||
|
||||
yes "${PASSPHRASE}" | ./nyxd gentx node_admin 1000000000u"${STAKE_DENOM}" --chain-id nymnet 2> /dev/null
|
||||
./nyxd collect-gentxs 2> /dev/null
|
||||
./nyxd validate-genesis > /dev/null
|
||||
cp /root/.nyxd/config/genesis.json /genesis_volume/genesis.json
|
||||
else
|
||||
echo "Validator already initialized, starting with the existing configuration."
|
||||
echo "If you want to re-init the validator, destroy the existing container"
|
||||
fi
|
||||
./nyxd start
|
||||
elif [ "$1" = "secondary" ]; then
|
||||
if [ ! -f "/root/.nymd/config/genesis.json" ]; then
|
||||
./nyxd init nymnet --chain-id nym-secondary 2> /dev/null
|
||||
|
||||
# Wait until the genesis node writes the genesis.json to the shared volume
|
||||
while ! [ -s /genesis_volume/genesis.json ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# wait for the actual validator to start up
|
||||
sleep 5
|
||||
|
||||
cp /genesis_volume/genesis.json /root/.nyxd/config/genesis.json
|
||||
GENESIS_PEER=$(cat /root/.nyxd/config/genesis.json | grep '"memo"' | cut -d'"' -f 4)
|
||||
GENESIS_IP=$(cat /root/.nyxd/config/genesis.json | grep '"memo"' | cut -d'@' -f2 | cut -d: -f1)
|
||||
sed -i 's/persistent_peers = ""/persistent_peers = "'"${GENESIS_PEER}"'"/' /root/.nyxd/config/config.toml
|
||||
sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.025u'"${BECH32_PREFIX}"'"/' /root/.nyxd/config/app.toml
|
||||
sed -i '0,/enable = false/s//enable = true/g' /root/.nyxd/config/app.toml
|
||||
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/' /root/.nyxd/config/config.toml
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/' /root/.nyxd/config/config.toml
|
||||
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/' /root/.nyxd/config/config.toml
|
||||
|
||||
# import mnemonic generated by the genesis validator (have a local copy for ease of use)
|
||||
cp /genesis_volume/secondary_mnemonic /root/.nyxd/mnemonic
|
||||
{ cat /root/.nyxd/mnemonic; echo "${PASSPHRASE}"; echo "${PASSPHRASE}"; } | ./nyxd keys add node_admin --recover #> /dev/null
|
||||
./nyxd validate-genesis > /dev/null
|
||||
|
||||
# create validator
|
||||
# don't even ask about those sleeps...
|
||||
{ echo "${PASSPHRASE}"; sleep 10; yes; sleep 10; } | ./nyxd tx staking create-validator --amount=10000000u"${STAKE_DENOM}" --fees 100000u"${DENOM}" --pubkey="$(./nyxd tendermint show-validator)" --moniker="secondary" --commission-rate="0.10" --commission-max-rate="0.20" --commission-max-change-rate="0.01" --min-self-delegation="1" --chain-id=nymnet --from=node_admin -b async --node http://"${GENESIS_IP}":26657
|
||||
else
|
||||
echo "Validator already initialized, starting with the existing configuration."
|
||||
echo "If you want to re-init the validator, destroy the existing container"
|
||||
fi
|
||||
./nyxd start
|
||||
else
|
||||
echo "Wrong command. Usage: ./$0 [genesis/secondary]"
|
||||
fi
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ue
|
||||
|
||||
git clone https://github.com/CosmWasm/wasmd.git
|
||||
cd wasmd
|
||||
git checkout "${WASMD_VERSION}"
|
||||
WASMD_COMMIT_HASH=$(git rev-parse HEAD)
|
||||
mkdir build
|
||||
go build \
|
||||
-o build/nyxd -mod=readonly -tags "netgo,ledger" \
|
||||
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=nymd \
|
||||
-X github.com/cosmos/cosmos-sdk/version.AppName=nymd \
|
||||
-X github.com/CosmWasm/wasmd/app.NodeDir=.nymd \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Version=${WASMD_VERSION} \
|
||||
-X github.com/cosmos/cosmos-sdk/version.Commit=${WASMD_COMMIT_HASH} \
|
||||
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=${BECH32_PREFIX} \
|
||||
-X 'github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger'" \
|
||||
-trimpath ./cmd/wasmd
|
||||
find .. -type f -name 'libwasm*.so' -exec cp {} build \;
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/root
|
||||
PASSPHRASE=passphrase
|
||||
APP_NAME=nyxd
|
||||
OUTPUT_DIRECTORY="/root/output"
|
||||
VALIDATOR_DATA_DIRECTORY="/root/.${APP_NAME}"
|
||||
|
||||
mkdir -p "${VALIDATOR_DATA_DIRECTORY}/config"
|
||||
mkdir -p "${OUTPUT_DIRECTORY}"
|
||||
|
||||
if [ ! -f "${VALIDATOR_DATA_DIRECTORY}/config/genesis.json" ]; then
|
||||
# initialise the validator
|
||||
./${APP_NAME} init "${CHAIN_ID}" --chain-id "${CHAIN_ID}" 2>/dev/null
|
||||
|
||||
echo "init chain successful"
|
||||
sleep 5
|
||||
|
||||
echo "checking config files:"
|
||||
ls -la ${VALIDATOR_DATA_DIRECTORY}/config/
|
||||
|
||||
echo "changing params"
|
||||
sed -i "s/\"stake\"/\"u${STAKE_DENOM}\"/" "${VALIDATOR_DATA_DIRECTORY}/config/genesis.json"
|
||||
sed -i 's/minimum-gas-prices = "0stake"/minimum-gas-prices = "0.025u'"${DENOM}"'"/' "${VALIDATOR_DATA_DIRECTORY}/config/app.toml"
|
||||
sed -i '0,/enable = false/s//enable = true/g' "${VALIDATOR_DATA_DIRECTORY}/config/app.toml"
|
||||
if [ "$RETAIN_BLOCKS" = "no" ]; then
|
||||
# amending to say if min retain blocks should be set yes or no...
|
||||
sed -i 's/min-retain-blocks = 0/min-retain-blocks = 70000/' "${VALIDATOR_DATA_DIRECTORY}/config/app.toml"
|
||||
fi
|
||||
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/' "${VALIDATOR_DATA_DIRECTORY}/config/config.toml"
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/' "${VALIDATOR_DATA_DIRECTORY}/config/config.toml"
|
||||
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/' "${VALIDATOR_DATA_DIRECTORY}/config/config.toml"
|
||||
sed -i 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/' "${VALIDATOR_DATA_DIRECTORY}/config/app.toml"
|
||||
|
||||
echo "params changed"
|
||||
|
||||
echo "adding parent mnemonic account details"
|
||||
yes "${PASSPHRASE}" | ./${APP_NAME} keys add node_admin 2>&1 >/dev/null | tail -n 1 >${OUTPUT_DIRECTORY}/node_admin_mnemonic
|
||||
|
||||
# add genesis accounts with some initial tokens
|
||||
echo "adding genesis account details"
|
||||
GENESIS_ADDRESS=$(yes "${PASSPHRASE}" | ./${APP_NAME} keys show node_admin -a)
|
||||
yes "${PASSPHRASE}" | ./${APP_NAME} genesis add-genesis-account "${GENESIS_ADDRESS}" 1000000000000000u"${DENOM}",1000000000000000u"${STAKE_DENOM}"
|
||||
|
||||
echo "adding gentx time :)"
|
||||
yes "${PASSPHRASE}" | ./${APP_NAME} genesis gentx node_admin 100000000000u"${STAKE_DENOM}" --chain-id "${CHAIN_ID}" 2>/dev/null
|
||||
./${APP_NAME} genesis collect-gentxs 2>/dev/null
|
||||
./${APP_NAME} genesis validate-genesis >/dev/null
|
||||
|
||||
# make a copy of the genesis file to the output directory
|
||||
cp "${VALIDATOR_DATA_DIRECTORY}/config/genesis.json" "${OUTPUT_DIRECTORY}/genesis.json"
|
||||
fi
|
||||
|
||||
./${APP_NAME} start &
|
||||
sleep 10
|
||||
|
||||
sleep infinity
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM rust
|
||||
RUN rustup target add wasm32-unknown-unknown
|
||||
CMD cd nym/contracts/vesting && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown
|
||||
@@ -1,13 +0,0 @@
|
||||
## Binary init checker
|
||||
|
||||
A simple tool to ensure that all binaries init with the correct format, using the `assert.sh` library
|
||||
|
||||
Simply run `./build_and_run.sh $WORKING_BRANCH`
|
||||
For example:
|
||||
|
||||
`./build_and_run.sh release/v1.1.11`
|
||||
|
||||
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
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
#!/bin/bash
|
||||
# assert.sh 1.1 - bash unit testing framework
|
||||
# Copyright (C) 2009-2015 Robert Lehmann
|
||||
#
|
||||
# http://github.com/lehmannro/assert.sh
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
export DISCOVERONLY=${DISCOVERONLY:-}
|
||||
export DEBUG=${DEBUG:-}
|
||||
export STOP=${STOP:-}
|
||||
export INVARIANT=${INVARIANT:-}
|
||||
export CONTINUE=${CONTINUE:-}
|
||||
|
||||
args="$(getopt -n "$0" -l \
|
||||
verbose,help,stop,discover,invariant,continue vhxdic $*)" \
|
||||
|| exit -1
|
||||
for arg in $args; do
|
||||
case "$arg" in
|
||||
-h)
|
||||
echo "$0 [-vxidc]" \
|
||||
"[--verbose] [--stop] [--invariant] [--discover] [--continue]"
|
||||
echo "`sed 's/./ /g' <<< "$0"` [-h] [--help]"
|
||||
exit 0;;
|
||||
--help)
|
||||
cat <<EOF
|
||||
Usage: $0 [options]
|
||||
Language-agnostic unit tests for subprocesses.
|
||||
|
||||
Options:
|
||||
-v, --verbose generate output for every individual test case
|
||||
-x, --stop stop running tests after the first failure
|
||||
-i, --invariant do not measure timings to remain invariant between runs
|
||||
-d, --discover collect test suites only, do not run any tests
|
||||
-c, --continue do not modify exit code to test suite status
|
||||
-h show brief usage information and exit
|
||||
--help show this help message and exit
|
||||
EOF
|
||||
exit 0;;
|
||||
-v|--verbose)
|
||||
DEBUG=1;;
|
||||
-x|--stop)
|
||||
STOP=1;;
|
||||
-i|--invariant)
|
||||
INVARIANT=1;;
|
||||
-d|--discover)
|
||||
DISCOVERONLY=1;;
|
||||
-c|--continue)
|
||||
CONTINUE=1;;
|
||||
esac
|
||||
done
|
||||
|
||||
_indent=$'\n\t' # local format helper
|
||||
|
||||
_assert_reset() {
|
||||
tests_ran=0
|
||||
tests_failed=0
|
||||
tests_errors=()
|
||||
tests_starttime="$(date +%s%N)" # nanoseconds_since_epoch
|
||||
}
|
||||
|
||||
assert_end() {
|
||||
# assert_end [suite ..]
|
||||
tests_endtime="$(date +%s%N)"
|
||||
# required visible decimal place for seconds (leading zeros if needed)
|
||||
local tests_time="$( \
|
||||
printf "%010d" "$(( ${tests_endtime/%N/000000000}
|
||||
- ${tests_starttime/%N/000000000} ))")" # in ns
|
||||
tests="$tests_ran ${*:+$* }tests"
|
||||
[[ -n "$DISCOVERONLY" ]] && echo "collected $tests." && _assert_reset && return
|
||||
[[ -n "$DEBUG" ]] && echo
|
||||
# to get report_time split tests_time on 2 substrings:
|
||||
# ${tests_time:0:${#tests_time}-9} - seconds
|
||||
# ${tests_time:${#tests_time}-9:3} - milliseconds
|
||||
[[ -z "$INVARIANT" ]] \
|
||||
&& report_time=" in ${tests_time:0:${#tests_time}-9}.${tests_time:${#tests_time}-9:3}s" \
|
||||
|| report_time=
|
||||
|
||||
if [[ "$tests_failed" -eq 0 ]]; then
|
||||
echo "all $tests passed$report_time."
|
||||
else
|
||||
for error in "${tests_errors[@]}"; do echo "$error"; done
|
||||
echo "$tests_failed of $tests failed$report_time."
|
||||
fi
|
||||
tests_failed_previous=$tests_failed
|
||||
[[ $tests_failed -gt 0 ]] && tests_suite_status=1
|
||||
_assert_reset
|
||||
}
|
||||
|
||||
assert() {
|
||||
# assert <command> <expected stdout> [stdin]
|
||||
(( tests_ran++ )) || :
|
||||
[[ -z "$DISCOVERONLY" ]] || return
|
||||
expected=$(echo -ne "${2:-}")
|
||||
result="$(eval 2>/dev/null $1 <<< ${3:-})" || true
|
||||
if [[ "$result" == "$expected" ]]; then
|
||||
[[ -z "$DEBUG" ]] || echo -n .
|
||||
return
|
||||
fi
|
||||
result="$(sed -e :a -e '$!N;s/\n/\\n/;ta' <<< "$result")"
|
||||
[[ -z "$result" ]] && result="nothing" || result="\"$result\""
|
||||
[[ -z "$2" ]] && expected="nothing" || expected="\"$2\""
|
||||
_assert_fail "expected $expected${_indent}got $result" "$1" "$3"
|
||||
}
|
||||
|
||||
assert_raises() {
|
||||
# assert_raises <command> <expected code> [stdin]
|
||||
(( tests_ran++ )) || :
|
||||
[[ -z "$DISCOVERONLY" ]] || return
|
||||
status=0
|
||||
(eval $1 <<< ${3:-}) > /dev/null 2>&1 || status=$?
|
||||
expected=${2:-0}
|
||||
if [[ "$status" -eq "$expected" ]]; then
|
||||
[[ -z "$DEBUG" ]] || echo -n .
|
||||
return
|
||||
fi
|
||||
_assert_fail "program terminated with code $status instead of $expected" "$1" "$3"
|
||||
}
|
||||
|
||||
_assert_fail() {
|
||||
# _assert_fail <failure> <command> <stdin>
|
||||
[[ -n "$DEBUG" ]] && echo -n X
|
||||
report="test #$tests_ran \"$2${3:+ <<< $3}\" failed:${_indent}$1"
|
||||
if [[ -n "$STOP" ]]; then
|
||||
[[ -n "$DEBUG" ]] && echo
|
||||
echo "$report"
|
||||
exit 1
|
||||
fi
|
||||
tests_errors[$tests_failed]="$report"
|
||||
(( tests_failed++ )) || :
|
||||
}
|
||||
|
||||
skip_if() {
|
||||
# skip_if <command ..>
|
||||
(eval $@) > /dev/null 2>&1 && status=0 || status=$?
|
||||
[[ "$status" -eq 0 ]] || return
|
||||
skip
|
||||
}
|
||||
|
||||
skip() {
|
||||
# skip (no arguments)
|
||||
shopt -q extdebug && tests_extdebug=0 || tests_extdebug=1
|
||||
shopt -q -o errexit && tests_errexit=0 || tests_errexit=1
|
||||
# enable extdebug so returning 1 in a DEBUG trap handler skips next command
|
||||
shopt -s extdebug
|
||||
# disable errexit (set -e) so we can safely return 1 without causing exit
|
||||
set +o errexit
|
||||
tests_trapped=0
|
||||
trap _skip DEBUG
|
||||
}
|
||||
_skip() {
|
||||
if [[ $tests_trapped -eq 0 ]]; then
|
||||
# DEBUG trap for command we want to skip. Do not remove the handler
|
||||
# yet because *after* the command we need to reset extdebug/errexit (in
|
||||
# another DEBUG trap.)
|
||||
tests_trapped=1
|
||||
[[ -z "$DEBUG" ]] || echo -n s
|
||||
return 1
|
||||
else
|
||||
trap - DEBUG
|
||||
[[ $tests_extdebug -eq 0 ]] || shopt -u extdebug
|
||||
[[ $tests_errexit -eq 1 ]] || set -o errexit
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_assert_reset
|
||||
: ${tests_suite_status:=0} # remember if any of the tests failed so far
|
||||
_assert_cleanup() {
|
||||
local status=$?
|
||||
# modify exit code if it's not already non-zero
|
||||
[[ $status -eq 0 && -z $CONTINUE ]] && exit $tests_suite_status
|
||||
}
|
||||
trap _assert_cleanup EXIT
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
PWD="../"
|
||||
GIT_BRANCH=$1
|
||||
|
||||
# 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
|
||||
git fetch origin
|
||||
git checkout $GIT_BRANCH
|
||||
git pull origin $GIT_BRANCH
|
||||
# ---------------------------------------
|
||||
|
||||
echo "working directory ${PWD}"
|
||||
|
||||
#build all binaries...
|
||||
#expect the cargo tool chain to be installed on the machine
|
||||
cargo build --release --all
|
||||
|
||||
#here there should be the applicable binaries to test inits
|
||||
echo "running mixnode binary check"
|
||||
./nym-mixnode-binary-check.sh
|
||||
|
||||
sleep 2
|
||||
|
||||
echo "running gateway binary check"
|
||||
./nym-gateway-binary-check.sh
|
||||
|
||||
sleep 2
|
||||
|
||||
echo "running socks-5 binary check"
|
||||
./nym-socks-5-binary-check.sh
|
||||
|
||||
sleep 2
|
||||
|
||||
echo "running network-requester binary check"
|
||||
./nym-network-requester-binary-check.sh
|
||||
|
||||
sleep 2
|
||||
|
||||
echo "running client binary check"
|
||||
./nym-client-binary-check.sh
|
||||
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
. assert.sh -v -x
|
||||
|
||||
PWD="../"
|
||||
RELEASE_DIRECTORY="target/release"
|
||||
OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done)
|
||||
ID="test-${OUTPUT}"
|
||||
BINARY_NAME="nym-client"
|
||||
|
||||
# install the current release binary
|
||||
# so this is dependant on running on a linux machine for the time being
|
||||
|
||||
curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME
|
||||
chmod u+x $BINARY_NAME
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# functions
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
check_nym_client_binary_build() if [ -f $BINARY_NAME ]; then
|
||||
echo "running init tests"
|
||||
./${BINARY_NAME} init --id ${ID} --output-json >/dev/null 2>&1
|
||||
|
||||
# currently this outputs to a file name name
|
||||
# we currently store the output in a file in the same directory
|
||||
|
||||
if [ -f client_init_results.json ]; then
|
||||
OUTPUT=$(cat client_init_results.json)
|
||||
|
||||
# get jq values for things we can assert against
|
||||
# until the service provider is provided in the output we can validate the id is correct on init
|
||||
VALUE=$(echo ${OUTPUT} | jq .id)
|
||||
VALUE=${VALUE#\"}
|
||||
VALUE=${VALUE%\"}
|
||||
|
||||
# do asserts here based upon the output on init
|
||||
|
||||
assert "echo ${VALUE}" $(echo ${ID})
|
||||
assert_end nym-client-tests
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# tests
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we run the release version first
|
||||
|
||||
check_nym_client_binary_build
|
||||
|
||||
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
|
||||
# expect to have successful output and configuration
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ -f $BINARY_NAME ]; then
|
||||
echo "removing client binary"
|
||||
rm -rf $BINARY_NAME
|
||||
else
|
||||
echo "no binary found exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
# this should be caught at testing stage - navigate to latest binary build
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${PWD}${RELEASE_DIRECTORY}
|
||||
|
||||
# re-run against the current binary built locally
|
||||
|
||||
echo "diff the config files after each init"
|
||||
echo "-------------------------------------"
|
||||
|
||||
check_nym_client_binary_build
|
||||
|
||||
second_init=$(cat ${HOME}/.nym/clients/${ID}/config/config.toml | grep -v "^version =")
|
||||
|
||||
diff -w <(echo "$first_init") <(echo "$second_init")
|
||||
|
||||
# check the status of the diff
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "no differences in config files, exiting script"
|
||||
exit 0
|
||||
else
|
||||
echo "there are differences in the config files, it may require a fresh init on the binary"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
@@ -1,94 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
. assert.sh -v -x
|
||||
|
||||
PWD="../"
|
||||
RELEASE_DIRECTORY="target/release"
|
||||
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"
|
||||
|
||||
# install the current release binary
|
||||
# so this is dependant on running on a linux machine for the time being
|
||||
|
||||
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 "$BINARY_NAME" ]; then
|
||||
echo "running init tests"
|
||||
# we wont use config env files for now
|
||||
# unless we want to use a specific environment
|
||||
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 .data_store)
|
||||
VALUE=${VALUE#\"}
|
||||
VALUE=${VALUE%\"}
|
||||
|
||||
#------------------------------------------------------
|
||||
DATA_STORE="${HOME}/.nym/gateways/${ID}/data/db.sqlite"
|
||||
#------------------------------------------------------
|
||||
|
||||
# do asserts here based upon the output
|
||||
# check the data store path
|
||||
|
||||
assert "echo ${VALUE}" $(echo ${DATA_STORE})
|
||||
assert_end nym-gateway-tests
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# tests
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
# we run the release version first
|
||||
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 ${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
|
||||
echo "removing nym-gateway"
|
||||
rm -rf "$BINARY_NAME"
|
||||
echo "successfully removed nym-gateway"
|
||||
else
|
||||
echo "no binary found exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
# this should be caught at testing stage - navigate to latest binary build
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${PWD}${RELEASE_DIRECTORY}
|
||||
|
||||
#re run against the current binary built locally
|
||||
|
||||
check_gateway_binary_build
|
||||
|
||||
echo "diff the config files after each init"
|
||||
echo "-------------------------------------"
|
||||
|
||||
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")
|
||||
|
||||
# check the status of the diff
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "no differences in config files, exiting script"
|
||||
exit 0
|
||||
else
|
||||
echo "there are differences in the config files, it may require a fresh init on the binary"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,86 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
. assert.sh -v -x
|
||||
|
||||
PWD="../"
|
||||
RELEASE_DIRECTORY="target/release"
|
||||
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-mixnode"
|
||||
|
||||
# install the current release binary
|
||||
# so this is dependant on running on a linux machine for the time being
|
||||
|
||||
curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME
|
||||
chmod u+x $BINARY_NAME
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# functions
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
# get jq values for things we can assert against
|
||||
# tidy this bit up - okay for first push
|
||||
|
||||
VALUE="$(echo ${OUTPUT} | jq .wallet_address | tr -d '"')"
|
||||
|
||||
# do asserts here based upon the output on init
|
||||
assert "echo ${VALUE}" $(echo ${WALLET_ADDRESS_CONST})
|
||||
assert_end nym-mixnode-tests
|
||||
else
|
||||
echo "exiting test no binary found"
|
||||
fi
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# tests
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
# we run the release version first
|
||||
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 ${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
|
||||
echo "removing nym-mixnode"
|
||||
rm -rf "$BINARY_NAME"
|
||||
echo "successfully removed nym-mixnode"
|
||||
else
|
||||
echo "no binary found exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
# this should be caught at testing stage - navigate to latest binary build
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${PWD}${RELEASE_DIRECTORY}
|
||||
|
||||
#re run against the current binary built locally
|
||||
|
||||
check_mixnode_binary_build
|
||||
|
||||
echo "diff the config files after each init"
|
||||
echo "-------------------------------------"
|
||||
|
||||
second_init=$(cat ${HOME}/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =")
|
||||
|
||||
diff -w <(echo "$first_init") <(echo "$second_init")
|
||||
|
||||
# check the status of the diff
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "no differences in config files, exiting script"
|
||||
exit 0
|
||||
else
|
||||
echo "there are differences in the config files, it may require a fresh init on the binary"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
. assert.sh -v -x
|
||||
|
||||
PWD="../"
|
||||
RELEASE_DIRECTORY="target/release"
|
||||
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 ${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://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME
|
||||
chmod u+x $BINARY_NAME
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# functions
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
check_nym_network_requester_binary_build() if [ -f $BINARY_NAME ]; then
|
||||
echo "running init tests"
|
||||
./${BINARY_NAME} init --id ${ID} --output-json >/dev/null 2>&1
|
||||
|
||||
# currently this outputs to a file name name
|
||||
# we currently store the output in a file in the same directory
|
||||
|
||||
if [ -f "client_init_results.json" ]; then
|
||||
OUTPUT=$(cat client_init_results.json)
|
||||
|
||||
# get jq values for things we can assert against
|
||||
# until the service provider is provided in the output we can validate the id is correct on init
|
||||
VALUE=$(echo ${OUTPUT} | jq .id)
|
||||
VALUE=${VALUE#\"}
|
||||
VALUE=${VALUE%\"}
|
||||
|
||||
# do asserts here based upon the output on init
|
||||
|
||||
assert "echo ${VALUE}" $(echo ${ID})
|
||||
assert_end nym-network-requester-tests
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# tests
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we run the release version first
|
||||
|
||||
check_nym_network_requester_binary_build
|
||||
|
||||
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
|
||||
# expect to have successful output and configuration
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ -f $BINARY_NAME ]; then
|
||||
echo "removing nym-network-requester binary"
|
||||
rm -rf $BINARY_NAME
|
||||
else
|
||||
echo "no binary found exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
# this should be caught at testing stage - navigate to latest binary build
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${PWD}${RELEASE_DIRECTORY}
|
||||
|
||||
# re-run against the current binary built locally
|
||||
|
||||
echo "diff the config files after each init"
|
||||
echo "-------------------------------------"
|
||||
|
||||
check_nym_network_requester_binary_build
|
||||
|
||||
second_init=$(cat ${HOME}/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =")
|
||||
|
||||
diff -w <(echo "$first_init") <(echo "$second_init")
|
||||
|
||||
# check the status of the diff
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "no differences in config files, exiting script"
|
||||
exit 0
|
||||
else
|
||||
echo "there are differences in the config files, it may require a fresh init on the binary"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
. assert.sh -v -x
|
||||
|
||||
PWD="../"
|
||||
RELEASE_DIRECTORY="target/release"
|
||||
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"
|
||||
|
||||
# install the current release binary
|
||||
# so this is dependant on running on a linux machine for the time being
|
||||
|
||||
curl -L "https://builds.ci.nymte.ch/master/${BINARY_NAME}" -o $BINARY_NAME
|
||||
chmod u+x $BINARY_NAME
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# functions
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
check_nym_socks5_client_binary_build() if [ -f $BINARY_NAME ]; then
|
||||
echo "running init tests"
|
||||
./${BINARY_NAME} init --id ${ID} --provider ${MOCK_SERVICE_PROVIDER} --output-json >/dev/null 2>&1
|
||||
|
||||
# currently this outputs to a file name name
|
||||
# we currently store the output in a file in the same directory
|
||||
|
||||
if [ -f "socks5_client_init_results.json" ]; then
|
||||
OUTPUT=$(cat socks5_client_init_results.json)
|
||||
|
||||
# get jq values for things we can assert against
|
||||
# until the service provider is provided in the output we can validate the id is correct on init
|
||||
VALUE=$(echo ${OUTPUT} | jq .id)
|
||||
VALUE=${VALUE#\"}
|
||||
VALUE=${VALUE%\"}
|
||||
|
||||
# do asserts here based upon the output on init
|
||||
|
||||
assert "echo ${VALUE}" $(echo ${ID})
|
||||
assert_end nym-socks-5-client-tests
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
else
|
||||
echo "exting test no binary found"
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# tests
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we run the release version first
|
||||
|
||||
check_nym_socks5_client_binary_build
|
||||
|
||||
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
|
||||
# expect to have successful output and configuration
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ -f $BINARY_NAME ]; then
|
||||
echo "removing socks-5-client binary"
|
||||
rm -rf $BINARY_NAME
|
||||
else
|
||||
echo "no binary found exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
# this should be caught at testing stage - navigate to latest binary build
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${PWD}${RELEASE_DIRECTORY}
|
||||
|
||||
# re-run against the current binary built locally
|
||||
|
||||
echo "diff the config files after each init"
|
||||
echo "-------------------------------------"
|
||||
|
||||
check_nym_socks5_client_binary_build
|
||||
|
||||
second_init=$(cat ${HOME}/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =")
|
||||
|
||||
diff -w <(echo "$first_init") <(echo "$second_init")
|
||||
|
||||
# check the status of the diff
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "no differences in config files, exiting script"
|
||||
exit 0
|
||||
else
|
||||
echo "there are differences in the config files, it may require a fresh init on the binary"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we should expect it to pass because no errors should be presented when performing the upgrade of an init
|
||||
Reference in New Issue
Block a user