Skip to content

Commit f3d07dd

Browse files
committed
fix: tests for updated _extractIntent()
1 parent 417fd85 commit f3d07dd

File tree

2 files changed

+75
-55
lines changed

2 files changed

+75
-55
lines changed

snapshots/BenchmarkTest.json

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
{
2-
"testERC20Transfer_AlchemyModularAccount": "159588",
3-
"testERC20Transfer_AlchemyModularAccount_AppSponsor": "134814",
4-
"testERC20Transfer_AlchemyModularAccount_ERC20SelfPay": "178364",
5-
"testERC20Transfer_Batch100_AlchemyModularAccount_AppSponsor": "7107081",
6-
"testERC20Transfer_Batch100_CoinbaseSmartWallet": "9854643",
7-
"testERC20Transfer_Batch100_CoinbaseSmartWallet_AppSponsor": "6537123",
8-
"testERC20Transfer_Batch100_CoinbaseSmartWallet_ERC20SelfPay": "8614329",
9-
"testERC20Transfer_Batch100_Safe4337": "11219000",
10-
"testERC20Transfer_Batch100_Safe4337_AppSponsor": "7579427",
11-
"testERC20Transfer_Batch100_Safe4337_ERC20SelfPay": "9667539",
12-
"testERC20Transfer_Batch100_ZerodevKernel_AppSponsor": "9010139",
13-
"testERC20Transfer_CoinbaseSmartWallet": "150669",
14-
"testERC20Transfer_CoinbaseSmartWallet_AppSponsor": "126545",
15-
"testERC20Transfer_CoinbaseSmartWallet_ERC20SelfPay": "168436",
16-
"testERC20Transfer_ERC4337MinimalAccount": "151131",
17-
"testERC20Transfer_ERC4337MinimalAccount_AppSponsor": "126393",
18-
"testERC20Transfer_ERC4337MinimalAccount_ERC20SelfPay": "169943",
19-
"testERC20Transfer_IthacaAccount": "117897",
20-
"testERC20Transfer_IthacaAccountWithSpendLimits": "175241",
21-
"testERC20Transfer_IthacaAccount_AppSponsor": "134058",
22-
"testERC20Transfer_IthacaAccount_ERC20SelfPay": "137105",
23-
"testERC20Transfer_Safe4337": "164211",
24-
"testERC20Transfer_Safe4337_AppSponsor": "136859",
25-
"testERC20Transfer_Safe4337_ERC20SelfPay": "178805",
26-
"testERC20Transfer_ZerodevKernel": "175983",
27-
"testERC20Transfer_ZerodevKernel_AppSponsor": "151270",
28-
"testERC20Transfer_ZerodevKernel_ERC20SelfPay": "194858",
29-
"testERC20Transfer_batch100_AlchemyModularAccount": "10491576",
30-
"testERC20Transfer_batch100_AlchemyModularAccount_ERC20SelfPay": "9348032",
31-
"testERC20Transfer_batch100_IthacaAccount": "8630993",
32-
"testERC20Transfer_batch100_IthacaAccount_AppSponsor": "9850193",
33-
"testERC20Transfer_batch100_IthacaAccount_ERC20SelfPay": "8631193",
34-
"testERC20Transfer_batch100_ZerodevKernel": "12386290",
35-
"testERC20Transfer_batch100_ZerodevKernel_ERC20SelfPay": "11261385",
2+
"testERC20Transfer_AlchemyModularAccount": "159052",
3+
"testERC20Transfer_AlchemyModularAccount_AppSponsor": "134278",
4+
"testERC20Transfer_AlchemyModularAccount_ERC20SelfPay": "177269",
5+
"testERC20Transfer_Batch100_AlchemyModularAccount_AppSponsor": "7053481",
6+
"testERC20Transfer_Batch100_CoinbaseSmartWallet": "9801043",
7+
"testERC20Transfer_Batch100_CoinbaseSmartWallet_AppSponsor": "6483523",
8+
"testERC20Transfer_Batch100_CoinbaseSmartWallet_ERC20SelfPay": "8504829",
9+
"testERC20Transfer_Batch100_Safe4337": "11165400",
10+
"testERC20Transfer_Batch100_Safe4337_AppSponsor": "7525827",
11+
"testERC20Transfer_Batch100_Safe4337_ERC20SelfPay": "9558039",
12+
"testERC20Transfer_Batch100_ZerodevKernel_AppSponsor": "8956539",
13+
"testERC20Transfer_CoinbaseSmartWallet": "150133",
14+
"testERC20Transfer_CoinbaseSmartWallet_AppSponsor": "126009",
15+
"testERC20Transfer_CoinbaseSmartWallet_ERC20SelfPay": "167341",
16+
"testERC20Transfer_ERC4337MinimalAccount": "148602",
17+
"testERC20Transfer_ERC4337MinimalAccount_AppSponsor": "123885",
18+
"testERC20Transfer_ERC4337MinimalAccount_ERC20SelfPay": "166876",
19+
"testERC20Transfer_IthacaAccount": "94212",
20+
"testERC20Transfer_IthacaAccountWithSpendLimits": "115653",
21+
"testERC20Transfer_IthacaAccount_AppSponsor": "101764",
22+
"testERC20Transfer_IthacaAccount_ERC20SelfPay": "111613",
23+
"testERC20Transfer_Safe4337": "163675",
24+
"testERC20Transfer_Safe4337_AppSponsor": "136323",
25+
"testERC20Transfer_Safe4337_ERC20SelfPay": "177710",
26+
"testERC20Transfer_ZerodevKernel": "175447",
27+
"testERC20Transfer_ZerodevKernel_AppSponsor": "150734",
28+
"testERC20Transfer_ZerodevKernel_ERC20SelfPay": "193763",
29+
"testERC20Transfer_batch100_AlchemyModularAccount": "10437976",
30+
"testERC20Transfer_batch100_AlchemyModularAccount_ERC20SelfPay": "9238532",
31+
"testERC20Transfer_batch100_IthacaAccount": "6252997",
32+
"testERC20Transfer_batch100_IthacaAccount_AppSponsor": "6809297",
33+
"testERC20Transfer_batch100_IthacaAccount_ERC20SelfPay": "6072497",
34+
"testERC20Transfer_batch100_ZerodevKernel": "12332690",
35+
"testERC20Transfer_batch100_ZerodevKernel_ERC20SelfPay": "11151885",
3636
"testNativeTransfer_AlchemyModularAccount": "168453",
3737
"testNativeTransfer_CoinbaseSmartWallet": "159248",
38-
"testNativeTransfer_IthacaAccount": "126759",
39-
"testNativeTransfer_IthacaAccount_AppSponsor": "142920",
40-
"testNativeTransfer_IthacaAccount_ERC20SelfPay": "145967",
38+
"testNativeTransfer_IthacaAccount": "103610",
39+
"testNativeTransfer_IthacaAccount_AppSponsor": "111181",
40+
"testNativeTransfer_IthacaAccount_ERC20SelfPay": "121011",
4141
"testNativeTransfer_Safe4337": "172763",
4242
"testNativeTransfer_ZerodevKernel": "184855",
43-
"testUniswapV2Swap_AlchemyModularAccount": "211952",
44-
"testUniswapV2Swap_CoinbaseSmartWallet": "203464",
45-
"testUniswapV2Swap_ERC4337MinimalAccount": "203524",
46-
"testUniswapV2Swap_IthacaAccount": "170264",
47-
"testUniswapV2Swap_IthacaAccount_AppSponsor": "186426",
48-
"testUniswapV2Swap_IthacaAccount_ERC20SelfPay": "189472",
49-
"testUniswapV2Swap_Safe4337": "217194",
50-
"testUniswapV2Swap_ZerodevKernel": "228432"
43+
"testUniswapV2Swap_AlchemyModularAccount": "210111",
44+
"testUniswapV2Swap_CoinbaseSmartWallet": "201623",
45+
"testUniswapV2Swap_ERC4337MinimalAccount": "199690",
46+
"testUniswapV2Swap_IthacaAccount": "145274",
47+
"testUniswapV2Swap_IthacaAccount_AppSponsor": "152790",
48+
"testUniswapV2Swap_IthacaAccount_ERC20SelfPay": "162675",
49+
"testUniswapV2Swap_Safe4337": "215353",
50+
"testUniswapV2Swap_ZerodevKernel": "226591"
5151
}

test/Account.t.sol

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,17 @@ contract AccountTest is BaseTest {
511511
}
512512

513513
function testPayWithFiveCorruptedFieldOffsetsOfIntent() public {
514+
bool success;
515+
bytes memory returnData;
516+
514517
console.log("Test 1: Main Intent struct offset corruption");
515518
bytes memory maliciousCalldata = _createIntentOnMainnet();
516519
assembly {
517520
let dataPtr := add(maliciousCalldata, 0x20) // Skip bytes length prefix
518521
// CORRUPT MAIN OFFSET (Bytes 0-31) - Points to Intent struct start
519522
mstore(dataPtr, 0x10000000000000000) // 2^64 (strictly greater than 2^64-1)
520523
}
521-
(bool success, bytes memory returnData) =
524+
(success, returnData) =
522525
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
523526
assertEq(success, false);
524527

@@ -530,7 +533,10 @@ contract AccountTest is BaseTest {
530533
// executionData offset (bytes 64-95 relative to start, or 32-63 in Intent struct)
531534
mstore(add(intentPtr, 32), 0x10000000000000001) // 2^64 + 1
532535
}
533-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
536+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
537+
(success, returnData) =
538+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
539+
assertEq(success, false);
534540

535541
console.log("Test 3: encodedPreCalls offset corruption");
536542
maliciousCalldata = _createIntentOnMainnet();
@@ -540,7 +546,10 @@ contract AccountTest is BaseTest {
540546
// encodedPreCalls offset (bytes 256-287 relative to start, or 224-255 in Intent struct)
541547
mstore(add(intentPtr, 224), 0x10000000000000002) // 2^64 + 2
542548
}
543-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
549+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
550+
(success, returnData) =
551+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
552+
assertEq(success, false);
544553

545554
console.log("Test 4: encodedFundTransfers offset corruption");
546555
maliciousCalldata = _createIntentOnMainnet();
@@ -550,7 +559,10 @@ contract AccountTest is BaseTest {
550559
// encodedFundTransfers offset (bytes 288-319 relative to start, or 256-287 in Intent struct)
551560
mstore(add(intentPtr, 256), 0x10000000000000003) // 2^64 + 3
552561
}
553-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
562+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
563+
(success, returnData) =
564+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
565+
assertEq(success, false);
554566

555567
console.log("Test 5: funderSignature offset corruption");
556568
maliciousCalldata = _createIntentOnMainnet();
@@ -560,7 +572,10 @@ contract AccountTest is BaseTest {
560572
// funderSignature offset (bytes 448-479 relative to start, or 416-447 in Intent struct)
561573
mstore(add(intentPtr, 416), 0x10000000000000004) // 2^64 + 4
562574
}
563-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
575+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
576+
(success, returnData) =
577+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
578+
assertEq(success, false);
564579

565580
console.log("Test 6: signature offset corruption");
566581
maliciousCalldata = _createIntentOnMainnet();
@@ -570,7 +585,9 @@ contract AccountTest is BaseTest {
570585
// signature offset (bytes 576-607 relative to start, or 544-575 in Intent struct)
571586
mstore(add(intentPtr, 544), 0x10000000000000005) // 2^64 + 5
572587
}
573-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
588+
(success, returnData) =
589+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
590+
assertEq(success, false);
574591
}
575592

576593
// modified from testCrossChainKeyPreCallsAuthorization()'s intent creation
@@ -699,9 +716,9 @@ contract AccountTest is BaseTest {
699716
mstore(add(intentPtr, 576), 0x10000000000000006) // 2^64 + 6
700717
}
701718

702-
// custom error 0x00000000: 00000000000000000000000070a08231000000000000000000000000, the
703-
// uncaught error in case of corrupted paymentSignature
704-
assertEq(oc.execute(maliciousCalldata), bytes4(0x00000000));
719+
(bool success, bytes memory returnData) =
720+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
721+
assertEq(success, false);
705722
}
706723

707724
Merkle merkleHelper;
@@ -919,7 +936,10 @@ contract AccountTest is BaseTest {
919936
mstore(add(intentPtr, 448), 0x10000000000000007) // 2^64 + 7
920937
}
921938

922-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
939+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
940+
(bool success, bytes memory returnData) =
941+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
942+
assertEq(success, false);
923943
}
924944

925945
function _computeMerkleData(_TestMultiChainIntentTemps memory t) internal {

0 commit comments

Comments
 (0)