run-test-node-docker.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. # Log only to stderr
  6. # Only output from this script should be the container id of the node at the very end
  7. # Location that will be mounted to /spec in containers
  8. # This is where the initial members and balances files and generated chainspec files will be located.
  9. DATA_PATH=$PWD/data
  10. mkdir -p ${DATA_PATH}
  11. # Initial account balance for sudo account
  12. SUDO_INITIAL_BALANCE=${SUDO_INITIAL_BALANCE:=100000000}
  13. SUDO_ACCOUNT_URI=${SUDO_ACCOUNT_URI:="//Alice"}
  14. SUDO_ACCOUNT=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${SUDO_ACCOUNT_URI} --output-type json | jq .ss58Address -r)
  15. # Source of funds for all new accounts that are created in the tests.
  16. TREASURY_INITIAL_BALANCE=${TREASURY_INITIAL_BALANCE:=100000000}
  17. TREASURY_ACCOUNT_URI=${TREASURY_ACCOUNT_URI:=$SUDO_ACCOUNT_URI}
  18. TREASURY_ACCOUNT=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${TREASURY_ACCOUNT_URI} --output-type json | jq .ss58Address -r)
  19. >&2 echo "sudo account from suri: ${SUDO_ACCOUNT}"
  20. >&2 echo "treasury account from suri: ${TREASURY_ACCOUNT}"
  21. # The docker image tag to use for joystream/node
  22. RUNTIME=${RUNTIME:=$(RUNTIME_PROFILE=TESTING ../../scripts/runtime-code-shasum.sh)}
  23. echo "{
  24. \"balances\":[
  25. [\"$SUDO_ACCOUNT\", $SUDO_INITIAL_BALANCE],
  26. [\"$TREASURY_ACCOUNT\", $TREASURY_INITIAL_BALANCE]
  27. ]
  28. }" > ${DATA_PATH}/initial-balances.json
  29. # Remember if there are initial members at genesis query-node needs to be bootstrapped
  30. # or any events processed for this member will cause processor to fail.
  31. if [ "${MAKE_SUDO_MEMBER}" == true ]
  32. then
  33. echo "
  34. [{
  35. \"member_id\":0,
  36. \"root_account\":\"$SUDO_ACCOUNT\",
  37. \"controller_account\":\"$SUDO_ACCOUNT\",
  38. \"handle\":\"sudosudo\",
  39. \"avatar_uri\":\"https://sudo.com/avatar.png\",
  40. \"about\":\"Sudo\",
  41. \"registered_at_time\":0
  42. }]
  43. " > ${DATA_PATH}/initial-members.json
  44. else
  45. echo "[]" > ${DATA_PATH}/initial-members.json
  46. fi
  47. # Create a chain spec file
  48. docker run --rm -v ${DATA_PATH}:/spec --entrypoint ./chain-spec-builder joystream/node:${RUNTIME} \
  49. new \
  50. --authority-seeds Alice \
  51. --sudo-account ${SUDO_ACCOUNT} \
  52. --deployment dev \
  53. --chain-spec-path /spec/chain-spec.json \
  54. --initial-balances-path /spec/initial-balances.json \
  55. --initial-members-path /spec/initial-members.json
  56. # Convert the chain spec file to a raw chainspec file
  57. docker run --rm -v ${DATA_PATH}:/spec joystream/node:${RUNTIME} build-spec \
  58. --raw --disable-default-bootnode \
  59. --chain /spec/chain-spec.json > ${DATA_PATH}/chain-spec-raw.json
  60. # Start a chain with generated chain spec
  61. export JOYSTREAM_NODE_TAG=${RUNTIME}
  62. docker-compose -f ../../docker-compose.yml run -d -v ${DATA_PATH}:/spec --name joystream-node \
  63. -p 9944:9944 -p 9933:9933 joystream-node \
  64. --alice --validator --unsafe-ws-external --unsafe-rpc-external \
  65. --rpc-methods Unsafe --rpc-cors=all -l runtime \
  66. --chain /spec/chain-spec-raw.json