Skip to content

Commit 561cdda

Browse files
committed
test: add griefing test
1 parent ea55689 commit 561cdda

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/helpers/WrappedTokenGateway.t.sol

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,45 @@ contract WrappedTokenGatewayTests is TestnetProcedures {
227227
assertEq(alice.balance, userEthBalanceBefore + userATokenBalance);
228228
}
229229

230+
function test_withdrawEth_permit_frontrunRegression() public {
231+
test_depositNativeEthInPool();
232+
233+
uint256 withdrawAmount = 0.6e18;
234+
235+
EIP712SigUtils.Permit memory permit = EIP712SigUtils.Permit({
236+
owner: alice,
237+
spender: address(wrappedTokenGatewayV3),
238+
value: withdrawAmount,
239+
nonce: 0,
240+
deadline: block.timestamp + 1 days
241+
});
242+
bytes32 digest = EIP712SigUtils.getTypedDataHash(
243+
permit,
244+
bytes(aWEth.name()),
245+
bytes('1'),
246+
address(aWEth)
247+
);
248+
249+
(uint8 v, bytes32 r, bytes32 s) = vm.sign(alicePrivateKey, digest);
250+
251+
uint256 userEthBalanceBefore = alice.balance;
252+
253+
vm.prank(alice);
254+
aWEth.permit(permit.owner, permit.spender, permit.value, permit.deadline, v, r, s);
255+
256+
// should not revert if permit is already executed
257+
vm.prank(alice);
258+
wrappedTokenGatewayV3.withdrawETHWithPermit(
259+
report.poolProxy,
260+
withdrawAmount,
261+
alice,
262+
permit.deadline,
263+
v,
264+
r,
265+
s
266+
);
267+
}
268+
230269
function test_withdrawEth_full() public {
231270
uint256 fullWithdraw = depositSize;
232271

0 commit comments

Comments
 (0)