membership-test.sh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. # Remove accounts added by previous test runs if needed
  10. ${CLI} account:forget --name test_alice_member_controller_1 || true
  11. ${CLI} account:forget --name test_alice_member_root_1 || true
  12. ${CLI} account:forget --name test_alice_member_controller_2 || true
  13. ${CLI} account:forget --name test_alice_member_staking || true
  14. # Create membership (controller: //Alice//controller, root: //Alice//root, sender: //Alice)
  15. MEMBER_HANDLE="alice-$(date +%s)"
  16. MEMBER_ID=`${CLI} membership:buy\
  17. --about="Test about text"\
  18. --avatarUri="http://example.com/example.jpg"\
  19. --controllerKey="5FnEMwYzo9PRGkGV4CtFNaCNSEZWA3AxbpbxcxamxdvMkD19"\
  20. --handle="$MEMBER_HANDLE"\
  21. --name="Alice"\
  22. --rootKey="5CVGusS1N7brUBqfVE1XgUeowHMD8o9xpk2mMXdFrrnLmM1v"\
  23. --senderKey="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"`
  24. # Import //Alice//controller key
  25. ${CLI} account:import\
  26. --suri //Alice//controller\
  27. --name test_alice_member_controller_1\
  28. --password=""
  29. # Transfer some funds to //Alice//controller key
  30. ${CLI} account:transferTokens\
  31. --amount 10000\
  32. --from 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\
  33. --to 5FnEMwYzo9PRGkGV4CtFNaCNSEZWA3AxbpbxcxamxdvMkD19
  34. # Update membership
  35. ${CLI} membership:update\
  36. --useMemberId="$MEMBER_ID"\
  37. --newHandle="$MEMBER_HANDLE-updated"\
  38. --newName="Alice Updated"\
  39. --newAvatarUri="http://example.com/updated.jpg"\
  40. --newAbout="Test about text updated"
  41. # Import //Alice//root key
  42. ${CLI} account:import\
  43. --suri //Alice//root\
  44. --name test_alice_member_root_1\
  45. --password=""
  46. # Transfer some funds to //Alice//root key
  47. ${CLI} account:transferTokens\
  48. --amount 10000\
  49. --from 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\
  50. --to 5CVGusS1N7brUBqfVE1XgUeowHMD8o9xpk2mMXdFrrnLmM1v
  51. # Update accounts (//Alice//controller//0, //Alice//root//0)
  52. ${CLI} membership:updateAccounts\
  53. --useMemberId="$MEMBER_ID"\
  54. --newControllerAccount="5E5JemkFX48JMRFraGZrjPwKL1HnhLkPrMQxaBvoSXPmzKab"\
  55. --newRootAccount="5HBBGjABKMczXYGmGZe9un3VYia1BmedLsoXJFWAtBtGVahv"
  56. # Import //Alice//controller//0 key
  57. ${CLI} account:import\
  58. --suri //Alice//controller//0\
  59. --name test_alice_member_controller_2\
  60. --password=""
  61. # Transfer some funds to //Alice//controller//0 key
  62. ${CLI} account:transferTokens\
  63. --amount 10000\
  64. --from 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\
  65. --to 5E5JemkFX48JMRFraGZrjPwKL1HnhLkPrMQxaBvoSXPmzKab
  66. # Import //Alice//staking key
  67. ${CLI} account:import\
  68. --suri //Alice//staking\
  69. --name test_alice_member_staking\
  70. --password=""
  71. # Add staking account (//Alice//staking)
  72. ${CLI} membership:addStakingAccount\
  73. --useMemberId="$MEMBER_ID"\
  74. --address="5EheygkSi4q4QCN12d2Vy65EnoEtdJy6yw6o7XZpPRcaVJCS"\
  75. --fundsSource="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"\
  76. --withBalance="10000"
  77. # Remove imported accounts
  78. ${CLI} account:forget --name test_alice_member_controller_1
  79. ${CLI} account:forget --name test_alice_member_root_1
  80. ${CLI} account:forget --name test_alice_member_controller_2
  81. ${CLI} account:forget --name test_alice_member_staking