test.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. # Executes cleanup function at script exit.
  3. trap cleanup EXIT
  4. cleanup() {
  5. # Kill the testrpc instance that we started (if we started one and if it's still running).
  6. if [ -n "$testrpc_pid" ] && ps -p $testrpc_pid > /dev/null; then
  7. kill -9 $testrpc_pid
  8. fi
  9. }
  10. testrpc_running() {
  11. nc -z localhost 8545
  12. }
  13. if testrpc_running; then
  14. echo "Using existing testrpc instance"
  15. else
  16. echo "Starting our own testrpc instance"
  17. # We define 10 accounts with balance 1M ether, needed for high-value tests.
  18. testrpc \
  19. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000" \
  20. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000" \
  21. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000" \
  22. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000" \
  23. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000" \
  24. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000" \
  25. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000" \
  26. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000" \
  27. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" \
  28. --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" \
  29. > /dev/null &
  30. testrpc_pid=$!
  31. fi
  32. node_modules/.bin/truffle test "$@"