# NOS Tests ## Prerequisites - Have a VM setup ([guide](https://hackmd.io/@LwMsxe3-SFmNXxugAXOKgg/HkAoasnIo)) ## Basic Packages Installation - `sudo apt update && sudo apt upgrade` - `sudo apt install make -y` - `sudo apt install git` - install `yarn` ``` curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update && sudo apt install yarn ``` - install `docker-compose` ([resource](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04)) - [OPTIONAL] Install [jq](https://stedolan.github.io/jq/) in case you would like to see the json responses in a more user friendly format in your terminal [from the `curl` commands returned from sidecar]. ## Install NOS - `git clone https://github.com/paritytech/nos` - `cd nos` - `yarn` - Follow instructions from the [README](https://github.com/paritytech/nos#nos----node--sidecar) of the NOS repository - Make a copy of the .env file : `cp .env.example .env` - `vim .env` - Changed polkadot version to the latest found [here](https://github.com/paritytech/polkadot) - Save your changes and exit with combination of keys : `ESC` and `:wq!` - `cat .env` should show something like ``` POLKADOT_VERSION=v0.9.36 POLKADOT_PARACHAIN_VERSION=v0.9.320-rc2-9f68ff77 RELAYCHAIN="polkadot" PARACHAIN="statemint" SIDECAR_VERSION=latest CONTAINER_UID="10000" UID=10000 ``` ## Tests ### Test1 - Start & Sync Relay/Para & Query through Sidecar - Connect through `ssh` to my server - `cd nos` - vim `.env` - Change Relay and Parachain to "westend" and "westmint" respectively. - Save and exit editor. - [OPTIONAL]`docker-compose -f sync-state.yml up` - It starts syncing ``` WARN[0000] Found orphan containers ([collator nos-202cc787e-sidecar-1 nos-202cc787e-chain-data-1]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Running 1/0 ⠿ Container chain Created 0.0s Attaching to chain chain | Relaychain: westend chain | Parachain: westmint chain | Syncing location: gs://westend-blockstore-backups/westmint-rocksdb-archive chain | /root/google-cloud-sdk/bin cp -r gs://westend-blockstore-backups/westmint-rocksdb-archive/20230118-112213/* /polkadot/chains/westmint/db/ chain | Syncing location: gs://westend-blockstore-backups/westend-rocksdb-prune chain | /root/google-cloud-sdk/bin cp -r gs://westend-blockstore-backups/westend-rocksdb-prune/20230118-110912/* /polkadot/chains/westend2/db/ chain | done syncing location chain | setting permissions on /chains/westmint/db/ chain | done syncing location chain | setting permissions on /chains/westend2/db/ chain exited with code 0 ``` - Exit Code 0 it means it is all good. - `docker-compose up -d` ``` [+] Running 3/3 ⠿ Container nos-202cc787e-sidecar-1 Started 0.8s ⠿ Container nos-202cc787e-chain-data-1 Started 0.9s ⠿ Container collator Started 1.5s ``` - Check with `docker ps` which containers are running ``` CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eb9d2261c3e9 paritypr/polkadot-parachain-debug:polkadot-v0.9.36-afe528af "/usr/local/bin/polk…" 14 minutes ago Up 1 second 9933/tcp, 30333/tcp, 0.0.0.0:9944->9944/tcp collator e791c23bd7dd parity/substrate-api-sidecar:latest "docker-entrypoint.s…" 8 hours ago Up 2 seconds 0.0.0.0:8080->8080/tcp nos-202cc787e-sidecar-1 ``` - Then you can do some queries through Sidecar to see if everything works correctly like : - `curl -s http://0.0.0.0:8080/runtime/spec | jq` ``` { "at": { "height": "3779285", "hash": "0x70b07ed0024181228a7ba30ceed1dcdb39e78e28e01170efb9e39b4c04e5beff" }, "authoringVersion": "1", "transactionVersion": "11", "implVersion": "0", "specName": "westmint", "specVersion": "9360", "chainType": { "live": null }, "properties": { "ss58Format": null, "tokenDecimals": [ "12" ], "tokenSymbol": [ "WND" ] } } ``` - For more endpoints check [Sidecar Docs](https://paritytech.github.io/substrate-api-sidecar/dist/) ### Check/Stop Containers - Check the containers that are running: `docker ps` - Stop containers: `docker stop <CONTAINER ID>` ### Run another combination of Relay/Parachain - Edit your env file and update the corresponding values - `vim .env` - examples are given in the README - for example if you want to run Kusama / Statemine you can use this [configuration](https://github.com/paritytech/nos#statemine-example-1) - Save & Exit the editor - `docker-compose up -d` or `docker-compose -f sync-state.yml up` ### Where is the data saved ? In folder `./chain-data/chains/` you can find the chain data.