瀏覽代碼

tests: can fund and customize sudo and treasury accounts

Mokhtar Naamani 3 年之前
父節點
當前提交
40d38283a2

+ 1 - 0
tests/network-tests/run-migration-tests.sh

@@ -16,6 +16,7 @@ TARGET_RUNTIME=${TARGET_RUNTIME:=latest}
 # Prevent joystream cli from prompting
 export AUTO_CONFIRM=true
 
+# Create chainspec with Alice (sudo) as member so we can use her in joystream-cli
 CONTAINER_ID=`MAKE_SUDO_MEMBER=true ./run-test-node-docker.sh`
 
 function cleanup() {

+ 13 - 2
tests/network-tests/run-test-node-docker.sh

@@ -4,28 +4,39 @@ set -e
 SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
 cd $SCRIPT_PATH
 
+# Log only to stderr
+# Only output from this script should be the container id of the node at the very end
+
 # Location that will be mounted as the /data volume in containers
 # This is where the initial members and balances files and generated chainspec files will be located.
 DATA_PATH=${DATA_PATH:=$(pwd)/data}
 mkdir -p ${DATA_PATH}
 
 # Initial account balance for sudo account
-# Will be the source of funds for all new accounts that are created in the tests.
 SUDO_INITIAL_BALANCE=${SUDO_INITIAL_BALANCE:=100000000}
 SUDO_ACCOUNT_URI=${SUDO_ACCOUNT_URI:="//Alice"}
 SUDO_ACCOUNT=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${SUDO_ACCOUNT_URI} --output-type json | jq .ss58Address -r)
 
+# Source of funds for all new accounts that are created in the tests.
+TREASURY_INITIAL_BALANCE=${TREASURY_INITIAL_BALANCE:=100000000}
+TREASURY_ACCOUNT_URI=${TREASURY_ACCOUNT_URI:=$SUDO_ACCOUNT_URI}
+TREASURY_ACCOUNT=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${TREASURY_ACCOUNT_URI} --output-type json | jq .ss58Address -r)
+
 >&2 echo "sudo account from suri: ${SUDO_ACCOUNT}"
+>&2 echo "treasury account from suri: ${TREASURY_ACCOUNT}"
 
 # The docker image tag to use for joystream/node
 RUNTIME=${RUNTIME:=latest}
 
 echo "{
   \"balances\":[
-    [\"$SUDO_ACCOUNT\", $SUDO_INITIAL_BALANCE]
+    [\"$SUDO_ACCOUNT\", $SUDO_INITIAL_BALANCE],
+    [\"$TREASURY_ACCOUNT\", $TREASURY_INITIAL_BALANCE]
   ]
 }" > ${DATA_PATH}/initial-balances.json
 
+# Remember if there are initial members at genesis query-node needs to be bootstrapped
+# or any events processed for this member will cause processor to fail.
 if [ "${MAKE_SUDO_MEMBER}" == true ]
 then
   echo "

+ 8 - 1
tests/network-tests/test-setup-new-chain.sh

@@ -4,7 +4,14 @@ set -e
 SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
 cd $SCRIPT_PATH
 
-CONTAINER_ID=`./run-test-node-docker.sh`
+# Custom sudo and treasury accounts - export them before start new chain
+# will be used to configre chainspec and override test framework defaults.
+export SUDO_ACCOUNT_URI=//Bob
+export SUDO_INITIAL_BALANCE=5000
+export TREASURY_ACCOUNT_URI=//Charlie
+export TREASURY_INITIAL_BALANCE=1000000000
+
+CONTAINER_ID=$(./run-test-node-docker.sh)
 
 function cleanup() {
     docker logs ${CONTAINER_ID} --tail 15