working-groups-test.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. export AUTO_CONFIRM=true
  6. export OCLIF_TS_NODE=0
  7. yarn workspace @joystream/cli build
  8. CLI=../bin/run
  9. # Use storage working group as default group
  10. TEST_LEAD_SURI="//testing//worker//Storage//0"
  11. # Init lead
  12. GROUP="storageWorkingGroup" yarn workspace api-scripts initialize-lead
  13. # CLI commands group
  14. GROUP="storageProviders"
  15. # Add integration tests lead key (in case the script is executed after ./start.sh)
  16. ${CLI} account:forget --name "Test wg lead key" || true
  17. ${CLI} account:import --suri ${TEST_LEAD_SURI} --name "Test wg lead key" --password "" || true
  18. # Set/update working group metadata
  19. ${CLI} working-groups:updateGroupMetadata --group ${GROUP} -i ../examples/working-groups/UpdateMetadata.json
  20. # Create upcoming opening
  21. UPCOMING_OPENING_ID=`${CLI} working-groups:createOpening \
  22. --group ${GROUP} \
  23. --input ../examples/working-groups/CreateOpening.json \
  24. --upcoming \
  25. --startsAt 2030-01-01`
  26. # Delete upcoming opening
  27. ${CLI} working-groups:removeUpcomingOpening --group ${GROUP} --id ${UPCOMING_OPENING_ID}
  28. # Create opening
  29. OPENING_ID=`${CLI} working-groups:createOpening \
  30. --group ${GROUP} \
  31. --input ../examples/working-groups/CreateOpening.json \
  32. --stakeTopUpSource 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY`
  33. # Setup a staking account (//Alice//worker-stake)
  34. ${CLI} account:forget --name "Test worker staking key" || true
  35. ${CLI} account:import --suri //Alice//worker-stake --name "Test worker staking key" --password "" || true
  36. ${CLI} membership:addStakingAccount \
  37. --address 5Dyzr3jNj1JngvJPDf4dpjsgZqZaUSrhFMdmKJMYkziv74qt \
  38. --withBalance 2000 \
  39. --fundsSource 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
  40. # Apply
  41. APPLICATION_ID=`${CLI} working-groups:apply \
  42. --group ${GROUP} \
  43. --openingId ${OPENING_ID} \
  44. --roleAccount 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
  45. --rewardAccount 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
  46. --stakingAccount 5Dyzr3jNj1JngvJPDf4dpjsgZqZaUSrhFMdmKJMYkziv74qt \
  47. --answers "Alice" "30" "I'm the best!"`
  48. # Fill opening
  49. ${CLI} working-groups:fillOpening \
  50. --group ${GROUP} \
  51. --openingId ${OPENING_ID} \
  52. --applicationIds ${APPLICATION_ID}
  53. # Forget test lead account and test worker staking account
  54. ${CLI} account:forget --name "Test wg lead key"
  55. ${CLI} account:forget --name "Test worker staking key"