Skip to content

Commit a80e993

Browse files
author
Stuart Popejoy
committed
accounts regression in server
1 parent ed0e8ce commit a80e993

File tree

7 files changed

+82
-1
lines changed

7 files changed

+82
-1
lines changed

‎examples/accounts/accounts.pact‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;; accounts module, admin keyset, and table
22

3-
(enforce-pact-version "2.2.4")
3+
(enforce-pact-version "2.3")
44

55
(define-keyset 'accounts-admin-keyset
66
(read-keyset "accounts-admin-keyset"))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Provides mock system module for 'accounts'
2+
code: |-
3+
(define-keyset 'k (read-keyset "accounts-admin-keyset"))
4+
(module system 'k
5+
(defun get-system-time ()
6+
(time "2017-10-31T12:00:00Z")))
7+
(get-system-time)
8+
data:
9+
accounts-admin-keyset: ["ba54b224d1924dd98403f5c751abdd10de6cd81b0121800bf7bdbdcfaec7388d"]
10+
keyPairs:
11+
- public: ba54b224d1924dd98403f5c751abdd10de6cd81b0121800bf7bdbdcfaec7388d
12+
secret: 8693e641ae2bbe9ea802c736f42027b03f86afe63cae315e7169c9c496c17332
13+
nonce: step01
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To use, first load mock system module, then load accounts.
2+
# Command line:
3+
# $ pact -a examples/accounts/mock-system.yaml | curl -d @- http://localhost:8080/api/v1/send
4+
# $ pact -a examples/accounts/accounts.yaml | curl -d @- http://localhost:8080/api/v1/send
5+
6+
7+
codeFile: ../accounts.pact
8+
data:
9+
accounts-admin-keyset: ["ba54b224d1924dd98403f5c751abdd10de6cd81b0121800bf7bdbdcfaec7388d"]
10+
keyPairs:
11+
- public: ba54b224d1924dd98403f5c751abdd10de6cd81b0121800bf7bdbdcfaec7388d
12+
secret: 8693e641ae2bbe9ea802c736f42027b03f86afe63cae315e7169c9c496c17332
13+
nonce: step02
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Provides mock system module for 'accounts'
2+
3+
code: |-
4+
(use 'accounts)
5+
(use 'system)
6+
(create-account "Alice" (read-keyset "alice-keyset") "USD" (get-system-time))
7+
(create-account "Bob" (read-keyset "bob-keyset") "USD" (get-system-time))
8+
(fund-account "Alice" 100.0 (get-system-time))
9+
(read-all)
10+
data:
11+
alice-keyset: ["7d0c9ba189927df85c8c54f8b5c8acd76c1d27e923abbf25a957afdf25550804"]
12+
bob-keyset: ["ac69d9856821f11b8e6ca5cdd84a98ec3086493fd6407e74ea9038407ec9eba9"]
13+
keyPairs:
14+
- public: ba54b224d1924dd98403f5c751abdd10de6cd81b0121800bf7bdbdcfaec7388d
15+
secret: 8693e641ae2bbe9ea802c736f42027b03f86afe63cae315e7169c9c496c17332
16+
nonce: step03
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
code: |-
2+
(use 'accounts)
3+
(transfer "Alice" "Bob" 12.50 (system.get-system-time))
4+
(read-account-user "Alice")
5+
keyPairs:
6+
- public: 7d0c9ba189927df85c8c54f8b5c8acd76c1d27e923abbf25a957afdf25550804
7+
secret: 2e8c91521479537221576a7c3c80c46d0fa3fc663804117f0c7011366dec35de
8+
nonce: step04
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
code: |-
3+
(let ((bob-bal (at 'balance (accounts.read-account-user "Bob"))))
4+
(enforce (= 12.50 bob-bal) "Bob got paid 12.50"))
5+
keyPairs:
6+
- public: ac69d9856821f11b8e6ca5cdd84a98ec3086493fd6407e74ea9038407ec9eba9
7+
secret: 756f0d270d3ed42594529817e89ffa311b4bd5359d76cbcbb135fb178071faaa
8+
nonce: step05

‎examples/accounts/scripts/run.sh‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
echo ""; echo "Step 1"; echo ""
6+
pact -a examples/accounts/scripts/01-system.yaml | curl -d @- http://localhost:8080/api/v1/send
7+
curl -d '{"requestKeys":["221b1ea8687ca43da7eacdedfffe5a590215c334482b1148d5166e9847ead25e4d3a9c711c85c0b5ab9b739f151b562f37e1e21f2c8bc1004a5765575069cd91"]}' -X POST http://localhost:8080/api/v1/poll
8+
9+
echo ""; echo "Step 2"; echo ""
10+
pact -a examples/accounts/scripts/02-accounts.yaml | curl -d @- http://localhost:8080/api/v1/send
11+
curl -d '{"requestKeys":["1d1d4043dc194c616573895a5ebec0d1ea9898a719651d30e6be5bff386b94e4703afaf998c295a5181ef2eee844a79bdd3466072c30eb4004adf5108addaeee"]}' -X POST http://localhost:8080/api/v1/poll
12+
13+
echo ""; echo "Step 3"; echo ""
14+
pact -a examples/accounts/scripts/03-create.yaml | curl -d @- http://localhost:8080/api/v1/send
15+
curl -d '{"requestKeys":["5f8f4c71413d1b112892c0ae45a72f47d87c0811b97acf244e61b1ee667e85d0a599506db5774364c6e7577e5f48faa2ae323d38749a650bf4f59e8222eaf83e"]}' -X POST http://localhost:8080/api/v1/poll
16+
17+
echo ""; echo "Step 4"; echo ""
18+
pact -a examples/accounts/scripts/04-alice.yaml | curl -d @- http://localhost:8080/api/v1/send
19+
curl -d '{"requestKeys":["e0e26fb33bb20ff48f2c7378ed1f22cbe775f16e67de5f4b6e91de9ce83d13010f1d1da6633d8c0dd7050d4960b2d04dc11f9375ece36f6e66c60f9af5c69ed5"]}' -X POST http://localhost:8080/api/v1/poll
20+
21+
echo ""; echo "Step 5"; echo ""
22+
pact -l -a examples/accounts/scripts/05-bob.yaml | curl -d @- http://localhost:8080/api/v1/local
23+
echo ""

0 commit comments

Comments
 (0)