From a181d90042fdbbdb8b891ee605c0070a0cf316c0 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 6 Oct 2023 12:31:24 +0200 Subject: [PATCH 1/2] feat: add init-simapp script --- Makefile | 7 +++++++ scripts/init-simapp.sh | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 scripts/init-simapp.sh diff --git a/Makefile b/Makefile index 4e883c8d8bb..f1ca818ce02 100644 --- a/Makefile +++ b/Makefile @@ -167,6 +167,13 @@ endif ### Tests & Simulation ### ############################################################################### +# make init-simapp initializes a single local node network +# it is useful for testing and development +# Usage: make install && make init-simapp && simd start +# Warning: make init-simapp will remove all data in simapp home directory +init-simapp: + ./scripts/init-simapp.sh + test: test-unit test-all: test-unit test-ledger-mock test-race test-cover diff --git a/scripts/init-simapp.sh b/scripts/init-simapp.sh new file mode 100755 index 00000000000..9225e9b1245 --- /dev/null +++ b/scripts/init-simapp.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)} + +if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi +echo "using $SIMD_BIN" +if [ -d "$($SIMD_BIN config home)" ]; then rm -r $($SIMD_BIN config home); fi +$SIMD_BIN config set client chain-id demo +$SIMD_BIN config set client keyring-backend test +$SIMD_BIN config set app api.enable true +$SIMD_BIN keys add alice +$SIMD_BIN keys add bob +$SIMD_BIN init test --chain-id demo +$SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test +$SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test +$SIMD_BIN genesis gentx alice 1000000stake --chain-id demo +$SIMD_BIN genesis collect-gentxs \ No newline at end of file From 39d173180e9e0a004258ffd38f76578da66c0b00 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 17 Oct 2023 11:48:59 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Damian Nolan --- scripts/init-simapp.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/init-simapp.sh b/scripts/init-simapp.sh index 9225e9b1245..722a86d2a52 100755 --- a/scripts/init-simapp.sh +++ b/scripts/init-simapp.sh @@ -5,13 +5,13 @@ SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)} if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi echo "using $SIMD_BIN" if [ -d "$($SIMD_BIN config home)" ]; then rm -r $($SIMD_BIN config home); fi -$SIMD_BIN config set client chain-id demo +$SIMD_BIN config set client chain-id simapp-1 $SIMD_BIN config set client keyring-backend test $SIMD_BIN config set app api.enable true $SIMD_BIN keys add alice $SIMD_BIN keys add bob -$SIMD_BIN init test --chain-id demo +$SIMD_BIN init test --chain-id simapp-1 $SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test $SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test -$SIMD_BIN genesis gentx alice 1000000stake --chain-id demo +$SIMD_BIN genesis gentx alice 1000000stake --chain-id simapp-1 $SIMD_BIN genesis collect-gentxs \ No newline at end of file