-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (131 loc) · 4.92 KB
/
ci.yml
File metadata and controls
161 lines (131 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Go vet
run: go vet ./...
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build
run: make build
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Go tests (race detector)
run: go test -race -count=1 ./...
js-parity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: MiMC parity
run: |
node --experimental-vm-modules -e "
import('./public/mimc.js').then(({ mimcHash }) => {
const tests = [
[42n, 100n, '13603062797811675188639909697080538913826685491246923374232736861692843824956'],
[1n, 100n, '2108862887778322224540152968033371138921907848559177206190676617530753041980'],
[2n, 200n, '12104544101572163940166299184207267496585694752863501697795764603195813619670'],
[3n, 300n, '14050062093042685743601673262179176428971353750296441969316735981035391690629'],
];
let ok = true;
for (const [a, b, expected] of tests) {
const got = mimcHash(a, b).toString();
if (got !== expected) { console.error('FAIL: mimcHash(' + a + ',' + b + ')'); ok = false; }
}
const leaf1 = mimcHash(1n, 100n);
const leaf2 = mimcHash(2n, 200n);
const internal = mimcHash(leaf1, leaf2);
if (internal.toString() !== '10001607114380327872427237512814332051665707940309726398903659001061123407361') {
console.error('FAIL: hash-of-hashes'); ok = false;
}
if (!ok) process.exit(1);
console.log('MiMC parity: all tests passed');
});
"
- name: Merkle parity
run: |
node --experimental-vm-modules -e "
Promise.all([
import('./public/mimc.js'),
import('./public/merkle.js')
]).then(([{ mimcHash }, { MerkleTree }]) => {
let ok = true;
const tree2 = MerkleTree.fromEntries([[1n,100n],[2n,200n],[3n,300n]], 2);
if (tree2.root.toString() !== '12130528498295607510169328491562967273325478064319458189868958806658912023584') {
console.error('FAIL: depth-2 root'); ok = false;
}
const leaf0 = mimcHash(1n, 100n);
const proof0 = tree2.getProof(0);
if (!MerkleTree.verifyProof(leaf0, tree2.root, proof0.pathElements, proof0.pathIndices)) {
console.error('FAIL: depth-2 proof'); ok = false;
}
const tree20 = MerkleTree.fromEntries([[1n,100n],[2n,200n]], 20);
if (tree20.root.toString() !== '13775778477642284888777307564811980032757405543704598195813203538944140930097') {
console.error('FAIL: depth-20 root'); ok = false;
}
const proof20 = tree20.getProof(0);
if (!MerkleTree.verifyProof(mimcHash(1n,100n), tree20.root, proof20.pathElements, proof20.pathIndices)) {
console.error('FAIL: depth-20 proof'); ok = false;
}
if (!ok) process.exit(1);
console.log('Merkle parity: all tests passed');
});
"
- name: Petri net execution parity
run: |
node --experimental-vm-modules public/parity_test.mjs
- name: JS syntax check
run: |
for f in public/mimc.js public/merkle.js public/witness-builder.js public/safemath.js public/model.js public/state.js public/bridge.js public/bitwrap.js; do
node --check "$f" || exit 1
done
echo "All JS files pass syntax check"
playwright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build server
run: make build
- name: Install Playwright
run: cd e2e && npm install && npx playwright install chromium --with-deps
- name: Start server
run: ./bitwrap -port 8088 -dev -no-prover &
- name: Wait for server
run: |
for i in $(seq 1 30); do
curl -s http://localhost:8088/api/templates > /dev/null && break
sleep 1
done
- name: Run Playwright tests
run: cd e2e && npx playwright test
- name: Stop server
if: always()
run: pkill -f './bitwrap -port' || true