@@ -10,63 +10,47 @@ import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
10
10
import {ERC20Burnable } from "openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Burnable.sol " ;
11
11
import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol " ;
12
12
import {Test, console2} from "forge-std/Test.sol " ;
13
+ import {SignetStdTest} from "./SignetStdTest.t.sol " ;
14
+ import {IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol " ;
13
15
14
- contract PassageTest is Test {
16
+ contract PassageTest is SignetStdTest {
15
17
using Address for address payable ;
16
18
17
19
Passage public target;
18
20
address token;
19
21
address newToken;
20
- uint256 chainId = 3 ;
21
22
address recipient = address (0x123 );
22
23
uint256 amount = 200 ;
23
24
24
- address to = address (0x01 );
25
- bytes data = abi.encodeWithSelector (ERC20 .transfer.selector , recipient, amount);
26
- uint256 value = 100 ;
27
- uint256 gas = 10_000_000 ;
28
- uint256 maxFeePerGas = 50 ;
29
-
30
25
event Enter (uint256 indexed rollupChainId , address indexed rollupRecipient , uint256 amount );
31
26
32
27
event EnterToken (
33
28
uint256 indexed rollupChainId , address indexed rollupRecipient , address indexed token , uint256 amount
34
29
);
35
30
36
- event Transact (
37
- uint256 indexed rollupChainId ,
38
- address indexed sender ,
39
- address indexed to ,
40
- bytes data ,
41
- uint256 value ,
42
- uint256 gas ,
43
- uint256 maxFeePerGas
44
- );
31
+ event EnterConfigured (address indexed token , bool indexed canEnter );
45
32
46
33
event Withdrawal (address indexed token , address indexed recipient , uint256 amount );
47
34
48
- event EnterConfigured (address indexed token , bool indexed canEnter );
49
-
50
35
function setUp () public {
51
- // deploy token one, configured at deploy time
52
- token = address (new TestERC20 ("hi " , "HI " ));
53
- TestERC20 (token).mint (address (this ), amount * 10000 );
54
-
55
36
// deploy target
56
- address [] memory initialEnterTokens = new address [](1 );
57
- initialEnterTokens[0 ] = token;
58
- target = new Passage (block .chainid + 1 , address (this ), initialEnterTokens, address (0 ));
37
+ target = HOST_PASSAGE;
38
+
39
+ // setup token
40
+ token = address (HOST_WETH);
41
+ // mint WETH by sending ETH
42
+ payable (token).sendValue (amount * 10000 );
59
43
TestERC20 (token).approve (address (target), amount * 10000 );
60
44
61
- // deploy token two, don't configure
62
- newToken = address (new TestERC20 ("bye " , "BYE " ));
45
+ // deploy new token that's not configured on Passage
46
+ newToken = address (new TestERC20 ("bye " , "BYE " , 18 ));
63
47
TestERC20 (newToken).mint (address (this ), amount * 10000 );
64
48
TestERC20 (newToken).approve (address (target), amount * 10000 );
65
49
}
66
50
67
51
function test_setUp () public {
68
- assertEq (target.defaultRollupChainId (), block . chainid + 1 );
69
- assertEq (target.tokenAdmin (), address ( this ) );
52
+ assertEq (target.defaultRollupChainId (), ROLLUP_CHAIN_ID );
53
+ assertEq (target.tokenAdmin (), TOKEN_ADMIN );
70
54
assertTrue (target.canEnter (token));
71
55
assertFalse (target.canEnter (newToken));
72
56
}
@@ -89,28 +73,32 @@ contract PassageTest is Test {
89
73
// enter not allowed by default
90
74
assertFalse (target.canEnter (newToken));
91
75
vm.expectRevert (abi.encodeWithSelector (Passage.DisallowedEnter.selector , newToken));
92
- target.enterToken (chainId , recipient, newToken, amount);
76
+ target.enterToken (ROLLUP_CHAIN_ID , recipient, newToken, amount);
93
77
94
78
// allow enter
79
+ vm.startPrank (TOKEN_ADMIN);
95
80
vm.expectEmit ();
96
81
emit EnterConfigured (newToken, true );
97
82
target.configureEnter (newToken, true );
83
+ vm.stopPrank ();
98
84
99
85
// enter is allowed
100
86
assertTrue (target.canEnter (newToken));
101
87
vm.expectEmit ();
102
- emit EnterToken (chainId , recipient, newToken, amount);
103
- target.enterToken (chainId , recipient, newToken, amount);
88
+ emit EnterToken (ROLLUP_CHAIN_ID , recipient, newToken, amount);
89
+ target.enterToken (ROLLUP_CHAIN_ID , recipient, newToken, amount);
104
90
105
91
// disallow enter
92
+ vm.startPrank (TOKEN_ADMIN);
106
93
vm.expectEmit ();
107
94
emit EnterConfigured (newToken, false );
108
95
target.configureEnter (newToken, false );
96
+ vm.stopPrank ();
109
97
110
98
// enter not allowed again
111
99
assertFalse (target.canEnter (newToken));
112
100
vm.expectRevert (abi.encodeWithSelector (Passage.DisallowedEnter.selector , newToken));
113
- target.enterToken (chainId , recipient, newToken, amount);
101
+ target.enterToken (ROLLUP_CHAIN_ID , recipient, newToken, amount);
114
102
}
115
103
116
104
function test_receive () public {
@@ -127,8 +115,8 @@ contract PassageTest is Test {
127
115
128
116
function test_enter () public {
129
117
vm.expectEmit ();
130
- emit Enter (chainId , recipient, amount);
131
- target.enter {value: amount}(chainId , recipient);
118
+ emit Enter (ROLLUP_CHAIN_ID , recipient, amount);
119
+ target.enter {value: amount}(ROLLUP_CHAIN_ID , recipient);
132
120
}
133
121
134
122
function test_enter_defaultChain () public {
@@ -139,11 +127,11 @@ contract PassageTest is Test {
139
127
140
128
function test_enterToken () public {
141
129
vm.expectEmit ();
142
- emit EnterToken (chainId , recipient, token, amount);
130
+ emit EnterToken (ROLLUP_CHAIN_ID , recipient, token, amount);
143
131
vm.expectCall (
144
132
token, abi.encodeWithSelector (ERC20 .transferFrom.selector , address (this ), address (target), amount)
145
133
);
146
- target.enterToken (chainId , recipient, token, amount);
134
+ target.enterToken (ROLLUP_CHAIN_ID , recipient, token, amount);
147
135
}
148
136
149
137
function test_enterToken_defaultChain () public {
@@ -156,16 +144,17 @@ contract PassageTest is Test {
156
144
}
157
145
158
146
function test_withdraw () public {
159
- TestERC20 (token).mint (address (target), amount);
147
+ IERC20 (token).transfer (address (target), amount);
160
148
149
+ vm.startPrank (TOKEN_ADMIN);
161
150
vm.expectEmit ();
162
151
emit Withdrawal (token, recipient, amount);
163
152
vm.expectCall (token, abi.encodeWithSelector (ERC20 .transfer.selector , recipient, amount));
164
153
target.withdraw (token, recipient, amount);
165
154
}
166
155
}
167
156
168
- contract RollupPassageTest is Test {
157
+ contract RollupPassageTest is SignetStdTest {
169
158
using Address for address payable ;
170
159
171
160
RollupPassage public target;
@@ -178,11 +167,12 @@ contract RollupPassageTest is Test {
178
167
event ExitToken (address indexed hostRecipient , address indexed token , uint256 amount );
179
168
180
169
function setUp () public virtual {
181
- // deploy target
182
- target = new RollupPassage ( address ( 0 )) ;
170
+ // setup target
171
+ target = ROLLUP_PASSAGE ;
183
172
184
- // deploy token
185
- token = address (new TestERC20 ("hi " , "HI " ));
173
+ // setup token
174
+ token = address (ROLLUP_WETH);
175
+ vm.prank (ROLLUP_MINTER);
186
176
TestERC20 (token).mint (address (this ), amount * 10000 );
187
177
TestERC20 (token).approve (address (target), amount * 10000 );
188
178
}
0 commit comments