| 123456789101112131415161718192021222324252627282930313233343536373839 |
- set -e
- B=localhost:8787
- j(){ curl -s -b "$1" -c "$1" -H 'Content-Type: application/json' "${@:2}"; }
- # two members: anonymous sign-in, set names
- j /tmp/tom -X POST $B/api/auth/sign-in/anonymous -d '{}' >/dev/null; j /tmp/tom -X POST $B/api/me/name -d '{"name":"Tom"}' >/dev/null
- j /tmp/sam -X POST $B/api/auth/sign-in/anonymous -d '{}' >/dev/null; j /tmp/sam -X POST $B/api/me/name -d '{"name":"Sam"}' >/dev/null
- # phone OTP path smoke test
- j /tmp/phone -X POST $B/api/auth/phone-number/send-otp -d '{"phoneNumber":"+61400000000"}'; echo " <- send-otp"
- H=$(j /tmp/tom -X POST $B/api/hands -d '{"question":"Friday dinner","options":["Thai","Pizza","Ramen","Cook at home"],"constraints":["Sam is trying to spend less this month"]}' | python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])')
- echo "hand $H"
- A(){ j $1 -X POST $B/api/hands/$H/act -d "$2" >/dev/null; }
- A /tmp/tom '{"op":"join"}'; A /tmp/sam '{"op":"join"}'
- A /tmp/tom '{"op":"place","option":"o1","n":6}'; A /tmp/tom '{"op":"place","option":"o3","n":4}'
- A /tmp/sam '{"op":"place","option":"o2","n":8}'; A /tmp/sam '{"op":"place","option":"o4","n":2}'
- A /tmp/tom '{"op":"veto","option":"o2"}' # Tom vetoes pizza; Sam's 8 chips come back
- sleep 1.2
- curl -s $B/api/hands/$H | python3 -c '
- import sys,json; s=json.load(sys.stdin); r=s["round"]
- print("members",[m["name"] for m in s["members"]],"live",s["live"],"vetoed",r["vetoed"])
- print("chips",r["chips"])
- o=r["odds"]; print("odds", {k:round(v,2) for k,v in o["probabilities"].items()}, "conf",round(o["confidence"],2),"spice",round(o["spice"],2),"format",o["format"],"about",o["about"], o["ms"],"ms")'
- A /tmp/sam '{"op":"place","option":"o4","n":8}' # Sam goes all in on cooking
- sleep 0.6
- A /tmp/tom '{"op":"lock"}'; A /tmp/sam '{"op":"lock"}' # both locked -> lever pulls
- sleep 1.5
- curl -s $B/api/hands/$H | python3 -c '
- import sys,json; s=json.load(sys.stdin); r=s["round"]; p=r["pull"]
- lab=lambda i: next(o["label"] for o in r["options"] if o["id"]==i)
- print("status",s["status"]); print("odds at pull",{lab(k):round(v,2) for k,v in p["odds"].items()})
- print("WINNER",lab(p["winner"]),"| runner-up",lab(p["runnerUp"]),"| reel order",[lab(x) for x in p["order"]],"| seed",p["seed"])
- print("dealer:",p["dealer"])'
- A /tmp/tom '{"op":"again"}'; sleep 0.3
- A /tmp/tom '{"op":"place","option":"o1","n":10}'; A /tmp/sam '{"op":"place","option":"o1","n":10}'; sleep 1
- A /tmp/tom '{"op":"pull"}'; sleep 1.5
- A /tmp/tom '{"op":"accept"}'; A /tmp/sam '{"op":"accept"}'
- curl -s $B/api/hands/$H | python3 -c '
- import sys,json; s=json.load(sys.stdin); r=s["round"]; p=r["pull"]
- lab=lambda i: next(o["label"] for o in r["options"] if o["id"]==i)
- print("round",r["n"],"status",s["status"],"winner",lab(p["winner"]),{lab(k):round(v,2) for k,v in p["odds"].items()},"format",r["odds"]["format"]); print("dealer:",p["dealer"])'
|