run-test-node-docker.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. # Location that will be mounted as the /data volume in containers
  6. # This is where the initial members and balances files and generated chainspec files will be located.
  7. DATA_PATH=${DATA_PATH:=$(pwd)/data}
  8. mkdir -p ${DATA_PATH}
  9. # Initial account balance for sudo account
  10. # Will be the source of funds for all new accounts that are created in the tests.
  11. SUDO_INITIAL_BALANCE=${SUDO_INITIAL_BALANCE:=100000000}
  12. SUDO_ACCOUNT_URI=${SUDO_ACCOUNT_URI:="//Alice"}
  13. SUDO_ACCOUNT=$(docker run -it --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${SUDO_ACCOUNT_URI} --output-type json | jq .ss58Address -r)
  14. # The docker image tag to use for joystream/node
  15. RUNTIME=${RUNTIME:=latest}
  16. echo "{
  17. \"balances\":[
  18. [\"$SUDO_ACCOUNT\", $SUDO_INITIAL_BALANCE]
  19. ]
  20. }" > ${DATA_PATH}/initial-balances.json
  21. if [ "${MAKE_SUDO_MEMBER}" == true ]
  22. then
  23. echo "
  24. [{
  25. \"member_id\":0,
  26. \"root_account\":\"$SUDO_ACCOUNT\",
  27. \"controller_account\":\"$SUDO_ACCOUNT\",
  28. \"handle\":\"sudosudo\",
  29. \"avatar_uri\":\"https://sudo.com/avatar.png\",
  30. \"about\":\"Sudo\",
  31. \"registered_at_time\":0
  32. }]
  33. " > ${DATA_PATH}/initial-members.json
  34. else
  35. echo "[]" > ${DATA_PATH}/initial-members.json
  36. fi
  37. # Create a chain spec file
  38. docker run --rm -v ${DATA_PATH}:/data --entrypoint ./chain-spec-builder joystream/node:${RUNTIME} \
  39. new \
  40. --authority-seeds Alice \
  41. --sudo-account ${SUDO_ACCOUNT} \
  42. --deployment dev \
  43. --chain-spec-path /data/chain-spec.json \
  44. --initial-balances-path /data/initial-balances.json \
  45. --initial-members-path /data/initial-members.json
  46. # Convert the chain spec file to a raw chainspec file
  47. docker run --rm -v ${DATA_PATH}:/data joystream/node:${RUNTIME} build-spec \
  48. --raw --disable-default-bootnode \
  49. --chain /data/chain-spec.json > ${DATA_PATH}/chain-spec-raw.json
  50. # Start a chain with generated chain spec
  51. export JOYSTREAM_NODE_TAG=${RUNTIME}
  52. docker-compose -f ../../docker-compose.yml run -d -v ${DATA_PATH}:/data --name joystream-node \
  53. -p 9944:9944 -p 9933:9933 joystream-node \
  54. --alice --validator --unsafe-ws-external --unsafe-rpc-external \
  55. --rpc-methods Unsafe --rpc-cors=all -l runtime \
  56. --chain /data/chain-spec-raw.json