/ model / chain / run.sh
run.sh
 1  #!/usr/bin/env bash
 2  # run.sh: run the model against a clean testnet, and clean up afterwards
 3  
 4  set -e
 5  
 6  # Have a function to kill off Ganache and clean up the database when we quit.
 7  function cleanup {
 8      echo "Clean Up..."
 9      rm *-approvals.json
10  }
11  
12  trap cleanup EXIT
13  
14  echo "Deploying contracts..."
15  time truffle migrate --reset -f 2 --to 2 --skip-dry-run --network=development | tee deploy_output.txt
16  #curl -X POST --data @q.txt -H "Content-Type: application/json" http://127.0.0.1:9545/ext/bc/evm/rpc | python -m json.tool
17  
18  
19  #'
20  if [[ ! -e venv ]] ; then
21      # Set up the virtual environment
22      echo "Preparing Virtual Environment..."
23      virtualenv --python python3 venv
24      . venv/bin/activate
25      pip3 install -r requirements.txt
26      time python -m py_compile model.py
27  else
28      # Just go into it
29      echo "Entering Virtual Environment..."
30      . venv/bin/activate
31      time python -m py_compile model.py
32  fi
33  
34  if [[ "${RUN_SHELL}" == "1" ]] ; then
35      # Run a shell so that you can run the model several times
36      echo "Running Interactive Shell..."
37      bash
38  else
39      # Run the model
40      echo "Running Model..."
41      ./model.py
42  fi
43  
44  # grep -P "^  Gas usage: .{6,}" ganache_output.txt | wc -l
45  # grep -P "^  Gas usage: .{0,}" ganache_output.txt | wc -l
46  
47