Skip to content

Commit a8a21c8

Browse files
committed
tests, justfile: Add a target to recompile test contracts
Also extract their ABIs into a directory tests/contracts/abi/
1 parent c6f3327 commit a8a21c8

File tree

9 files changed

+251
-4
lines changed

9 files changed

+251
-4
lines changed

justfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,24 @@ test-integration *EXTRA_FLAGS:
8383
# Clean workspace (cargo clean)
8484
clean:
8585
cargo clean
86+
87+
compile-contracts:
88+
#!/usr/bin/env bash
89+
set -e # Exit on error
90+
91+
if ! command -v "forge" &> /dev/null; then
92+
echo "Error: forge must be on your path"
93+
exit 1
94+
fi
95+
96+
cd tests/contracts
97+
98+
forge build
99+
100+
mkdir -p abis
101+
for c in src/*.sol
102+
do
103+
contract=$(basename $c .sol)
104+
echo $contract
105+
forge inspect --json "$contract" abi > "abis/$contract.json"
106+
done
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"type": "constructor",
4+
"inputs": [],
5+
"stateMutability": "nonpayable"
6+
},
7+
{
8+
"type": "function",
9+
"name": "inc",
10+
"inputs": [
11+
{
12+
"name": "value",
13+
"type": "uint256",
14+
"internalType": "uint256"
15+
}
16+
],
17+
"outputs": [
18+
{
19+
"name": "",
20+
"type": "uint256",
21+
"internalType": "uint256"
22+
}
23+
],
24+
"stateMutability": "pure"
25+
},
26+
{
27+
"type": "event",
28+
"name": "Trigger",
29+
"inputs": [],
30+
"anonymous": false
31+
}
32+
]
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[
2+
{
3+
"type": "constructor",
4+
"inputs": [],
5+
"stateMutability": "nonpayable"
6+
},
7+
{
8+
"type": "function",
9+
"name": "exampleFunction",
10+
"inputs": [
11+
{
12+
"name": "",
13+
"type": "bytes32",
14+
"internalType": "bytes32"
15+
}
16+
],
17+
"outputs": [
18+
{
19+
"name": "",
20+
"type": "uint256",
21+
"internalType": "uint256"
22+
}
23+
],
24+
"stateMutability": "pure"
25+
},
26+
{
27+
"type": "function",
28+
"name": "exampleFunction",
29+
"inputs": [
30+
{
31+
"name": "",
32+
"type": "uint256",
33+
"internalType": "uint256"
34+
}
35+
],
36+
"outputs": [
37+
{
38+
"name": "",
39+
"type": "string",
40+
"internalType": "string"
41+
}
42+
],
43+
"stateMutability": "pure"
44+
},
45+
{
46+
"type": "function",
47+
"name": "exampleFunction",
48+
"inputs": [
49+
{
50+
"name": "",
51+
"type": "string",
52+
"internalType": "string"
53+
}
54+
],
55+
"outputs": [
56+
{
57+
"name": "",
58+
"type": "string",
59+
"internalType": "string"
60+
}
61+
],
62+
"stateMutability": "pure"
63+
},
64+
{
65+
"type": "event",
66+
"name": "Trigger",
67+
"inputs": [],
68+
"anonymous": false
69+
}
70+
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"type": "constructor",
4+
"inputs": [],
5+
"stateMutability": "nonpayable"
6+
},
7+
{
8+
"type": "function",
9+
"name": "inc",
10+
"inputs": [
11+
{
12+
"name": "value",
13+
"type": "uint256",
14+
"internalType": "uint256"
15+
}
16+
],
17+
"outputs": [
18+
{
19+
"name": "",
20+
"type": "uint256",
21+
"internalType": "uint256"
22+
}
23+
],
24+
"stateMutability": "pure"
25+
},
26+
{
27+
"type": "event",
28+
"name": "Trigger",
29+
"inputs": [],
30+
"anonymous": false
31+
}
32+
]
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[
2+
{
3+
"type": "constructor",
4+
"inputs": [],
5+
"stateMutability": "nonpayable"
6+
},
7+
{
8+
"type": "function",
9+
"name": "emitAnotherTrigger",
10+
"inputs": [
11+
{
12+
"name": "a",
13+
"type": "uint256",
14+
"internalType": "uint256"
15+
},
16+
{
17+
"name": "b",
18+
"type": "uint256",
19+
"internalType": "uint256"
20+
},
21+
{
22+
"name": "c",
23+
"type": "uint256",
24+
"internalType": "uint256"
25+
},
26+
{
27+
"name": "data",
28+
"type": "string",
29+
"internalType": "string"
30+
}
31+
],
32+
"outputs": [],
33+
"stateMutability": "nonpayable"
34+
},
35+
{
36+
"type": "function",
37+
"name": "emitTrigger",
38+
"inputs": [
39+
{
40+
"name": "x",
41+
"type": "uint16",
42+
"internalType": "uint16"
43+
}
44+
],
45+
"outputs": [],
46+
"stateMutability": "nonpayable"
47+
},
48+
{
49+
"type": "event",
50+
"name": "AnotherTrigger",
51+
"inputs": [
52+
{
53+
"name": "a",
54+
"type": "uint256",
55+
"indexed": true,
56+
"internalType": "uint256"
57+
},
58+
{
59+
"name": "b",
60+
"type": "uint256",
61+
"indexed": true,
62+
"internalType": "uint256"
63+
},
64+
{
65+
"name": "c",
66+
"type": "uint256",
67+
"indexed": true,
68+
"internalType": "uint256"
69+
},
70+
{
71+
"name": "data",
72+
"type": "string",
73+
"indexed": false,
74+
"internalType": "string"
75+
}
76+
],
77+
"anonymous": false
78+
},
79+
{
80+
"type": "event",
81+
"name": "Trigger",
82+
"inputs": [
83+
{
84+
"name": "x",
85+
"type": "uint16",
86+
"indexed": false,
87+
"internalType": "uint16"
88+
}
89+
],
90+
"anonymous": false
91+
}
92+
]

tests/contracts/out/LimitedContract.sol/LimitedContract.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/contracts/out/OverloadedContract.sol/OverloadedContract.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/contracts/out/RevertingContract.sol/RevertingContract.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/contracts/out/SimpleContract.sol/SimpleContract.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)