run-tests.sh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env bash
  2. set -e
  3. # Location that will be mounted as the /data volume in containers
  4. # This is how we access the initial members and balances files from
  5. # the containers and where generated chainspec files will be located.
  6. DATA_PATH=${DATA_PATH:=~/tmp}
  7. # Initial account balance for Alice
  8. # Alice is the source of funds for all new accounts that are created in the tests.
  9. ALICE_INITIAL_BALANCE=${ALICE_INITIAL_BALANCE:=100000000}
  10. # The docker image tag to use for joystream/node as the starting chain
  11. # that will be upgraded to the latest runtime.
  12. RUNTIME=${RUNTIME:=alexandria}
  13. TARGET_RUNTIME=${TARGET_RUNTIME:=latest}
  14. mkdir -p ${DATA_PATH}
  15. echo "{
  16. \"balances\":[
  17. [\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\", ${ALICE_INITIAL_BALANCE}]
  18. ]
  19. }" > ${DATA_PATH}/initial-balances.json
  20. # Make Alice a member
  21. echo '
  22. [{
  23. "member_id":0,
  24. "root_account":"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
  25. "controller_account":"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
  26. "handle":"alice",
  27. "avatar_uri":"https://alice.com/avatar.png",
  28. "about":"Alice",
  29. "registered_at_time":0
  30. }]
  31. ' > ${DATA_PATH}/initial-members.json
  32. # Create a chain spec file
  33. docker run --rm -v ${DATA_PATH}:/data --entrypoint ./chain-spec-builder joystream/node:${RUNTIME} \
  34. new \
  35. --authority-seeds Alice \
  36. --sudo-account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
  37. --deployment dev \
  38. --chain-spec-path /data/chain-spec.json \
  39. --initial-balances-path /data/initial-balances.json \
  40. --initial-members-path /data/initial-members.json
  41. # Convert the chain spec file to a raw chainspec file
  42. docker run --rm -v ${DATA_PATH}:/data joystream/node:${RUNTIME} build-spec \
  43. --raw --disable-default-bootnode \
  44. --chain /data/chain-spec.json > ~/tmp/chain-spec-raw.json
  45. # Start a chain with generated chain spec
  46. # Add "-l ws=trace,ws::handler=info" to get websocket trace logs
  47. CONTAINER_ID=`docker run -d -v ${DATA_PATH}:/data -p 9944:9944 joystream/node:${RUNTIME} \
  48. --validator --alice --unsafe-ws-external --rpc-cors=all -l runtime \
  49. --chain /data/chain-spec-raw.json`
  50. function cleanup() {
  51. docker logs ${CONTAINER_ID} --tail 15
  52. docker stop ${CONTAINER_ID}
  53. docker rm ${CONTAINER_ID}
  54. }
  55. trap cleanup EXIT
  56. if [ "$TARGET_RUNIME" == "$RUNTIME" ]; then
  57. echo "Not Performing a runtime upgrade."
  58. else
  59. # Copy new runtime wasm file from target joystream/node image
  60. echo "Extracting wasm blob from target joystream/node image."
  61. id=`docker create joystream/node:${TARGET_RUNTIME}`
  62. docker cp $id:/joystream/runtime.compact.wasm .tmp/
  63. docker rm $id
  64. # Display runtime version before runtime upgrade
  65. yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime
  66. echo "Performing runtime upgrade."
  67. DEBUG=* yarn workspace api-scripts tsnode-strict \
  68. src/dev-set-runtime-code.ts -- `pwd`/.tmp/runtime.compact.wasm
  69. echo "Runtime upgraded."
  70. fi
  71. # Display runtime version
  72. yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime
  73. # Execute the tests
  74. time DEBUG=* yarn workspace network-tests test-run src/scenarios/full.ts