Zencode PROSUME Scenario. Business Logic to implement in the Zenroom VM.

run_booking.sh 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env zsh
  2. set -e
  3. set -u
  4. set -o pipefail
  5. # set -x
  6. # https://coderwall.com/p/fkfaqq/safer-bash-scripts-with-set-euxo-pipefail
  7. alias zenroom="${1:-../../src/zenroom}"
  8. echo "============================================"
  9. echo "TEST PROSUME SCENARIO FOR ASSET MARKET"
  10. echo "============================================"
  11. # Process: Check -> Booking -> Order -> Confirmation -> Settlement
  12. t=`mktemp -d`
  13. # Generate Alice's keypair
  14. cat <<EOF | zenroom -z | tee $t/alice_kp.json
  15. Scenario 'simple'
  16. Given that I am known as 'Alice'
  17. When I create the keypair
  18. Then print my data
  19. EOF
  20. # Publish Alice's public key
  21. cat <<EOF | zenroom -z -k $t/alice_kp.json | tee $t/alice_pub.json
  22. Scenario 'simple'
  23. Given that I am known as 'Alice'
  24. and I have my valid 'public key'
  25. Then print my data
  26. EOF
  27. cat <<EOF | tee $t/asset.json | json_pp
  28. { "asset":
  29. { "ID": "qPtMxufw84bkahCA",
  30. "time": "2020-2-6 05:12",
  31. "kind": "kWh",
  32. "quantity": 1000,
  33. "service_level": "renewable" } }
  34. EOF
  35. zenroom -z BOOK01.zen -a $t/asset.json -k $t/alice_kp.json | tee $t/booking.json
  36. cat <<EOF | zenroom -z -a $t/asset.json -k $t/booking.json | tee $t/asset-booking.json
  37. Scenario 'prosume'
  38. Scenario 'simple'
  39. Given I have a valid 'asset'
  40. and I have a valid 'booking'
  41. Then print all data
  42. EOF
  43. zenroom -z BOOK02.zen -a $t/asset-booking.json -k $t/alice_pub.json