Skip to content

Commit 6948754

Browse files
committed
chaincheck: Adds chaincheck integration test
1 parent 702dae1 commit 6948754

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

remappings.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
chronicle-std/=lib/chronicle-std/src
21
ds-test/=lib/forge-std/lib/ds-test/src/
32
forge-std/=lib/forge-std/src/
3+
4+
chronicle-std/=lib/chronicle-std/src
5+
@script/chronicle-std/=lib/chronicle-std/script/

script/IGreenhouseChaincheck.sol

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.16;
3+
4+
import {stdJson} from "forge-std/StdJson.sol";
5+
import {StdStyle} from "forge-std/StdStyle.sol";
6+
7+
import {Chaincheck} from "@script/chronicle-std/Chaincheck.sol";
8+
import {IAuthChaincheck} from "@script/chronicle-std/IAuthChaincheck.sol";
9+
import {ITollChaincheck} from "@script/chronicle-std/ITollChaincheck.sol";
10+
11+
import {IGreenhouse} from "src/IGreenhouse.sol";
12+
13+
/**
14+
* @notice IGreenhouse's `chaincheck` Integration Test
15+
*
16+
* @dev Config Definition:
17+
* ```json
18+
* {
19+
* "IGreenhouse": { },
20+
* "IAuth": {
21+
* "legacy": bool,
22+
* "authed": [
23+
* "<Ethereum address>",
24+
* ...
25+
* ]
26+
* },
27+
* "IToll": {
28+
* "legacy": bool,
29+
* "tolled": [
30+
* "<Ethereum address>",
31+
* ...
32+
* ]
33+
* }
34+
* }
35+
* ```
36+
*/
37+
contract IGreenhouseChaincheck is Chaincheck {
38+
using stdJson for string;
39+
40+
IGreenhouse self;
41+
string config;
42+
43+
string[] _logs;
44+
45+
function setUp(address self_, string memory config_)
46+
external
47+
override(Chaincheck)
48+
returns (Chaincheck)
49+
{
50+
self = IGreenhouse(self_);
51+
config = config_;
52+
53+
return Chaincheck(address(this));
54+
}
55+
56+
function run()
57+
external
58+
override(Chaincheck)
59+
returns (bool, string[] memory)
60+
{
61+
check_IAuth();
62+
check_IToll();
63+
64+
// Fail run if non-zero number of logs.
65+
return (_logs.length == 0, _logs);
66+
}
67+
68+
/// @dev Checks the IAuth module dependency.
69+
function check_IAuth() internal {
70+
// Run IAuth chaincheck.
71+
string[] memory authLogs;
72+
(, authLogs) = new IAuthChaincheck()
73+
.setUp(address(self), config)
74+
.run();
75+
76+
// Add logs to own logs.
77+
for (uint i; i < authLogs.length; i++) {
78+
_logs.push(authLogs[i]);
79+
}
80+
}
81+
82+
/// @dev Checks the IToll module dependency.
83+
function check_IToll() internal {
84+
// Run IToll chaincheck.
85+
string[] memory authLogs;
86+
(, authLogs) = new ITollChaincheck()
87+
.setUp(address(self), config)
88+
.run();
89+
90+
// Add logs to own logs.
91+
for (uint i; i < authLogs.length; i++) {
92+
_logs.push(authLogs[i]);
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)