test.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # Write a keypair for program deploy
  3. mkdir -p target/deploy
  4. cp keypairs/idl_commands_one-keypair.json target/deploy
  5. # Generate over 20kb bytes of random data (base64 encoded), surround it with quotes, and store it in a variable
  6. RANDOM_DATA=$(openssl rand -base64 $((10*1680)) | sed 's/.*/"&",/')
  7. # Create the JSON object with the "docs" field containing random data
  8. echo '{
  9. "version": "0.1.0",
  10. "name": "idl_commands_one",
  11. "instructions": [
  12. {
  13. "name": "initialize",
  14. "docs" : [
  15. '"$RANDOM_DATA"'
  16. "trailing comma begone"
  17. ],
  18. "accounts": [],
  19. "args": []
  20. }
  21. ]
  22. }' > testLargeIdl.json
  23. echo "Building programs"
  24. anchor build
  25. echo "Starting local validator for test"
  26. solana-test-validator --reset \
  27. -q \
  28. --mint tgyXxAhCkpgtKCEi4W6xWJSzqwVGs3uk2RodbZP2J49 \
  29. --bpf-program 2uA3amp95zsEHUpo8qnLMhcFAUsiKVEcKHXS1JetFjU5 target/deploy/idl_commands_one.so \
  30. --bpf-program DE4UbHnAcT6Kfh1fVTPRPwpiA3vipmQ4xR3gcLwX3wwS target/deploy/idl_commands_one.so \
  31. &
  32. sleep 10
  33. echo "Running tests"
  34. anchor test --skip-deploy --skip-local-validator
  35. trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT