Skip to content

Commit 99f9d06

Browse files
committed
fix: tests for updated _extractIntent()
1 parent d499d47 commit 99f9d06

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

test/Account.t.sol

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

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

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

533539
console.log("Test 3: encodedPreCalls offset corruption");
534540
maliciousCalldata = _createIntentOnMainnet();
@@ -538,7 +544,10 @@ contract AccountTest is BaseTest {
538544
// encodedPreCalls offset (bytes 256-287 relative to start, or 224-255 in Intent struct)
539545
mstore(add(intentPtr, 224), 0x10000000000000002) // 2^64 + 2
540546
}
541-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
547+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
548+
(success, returnData) =
549+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
550+
assertEq(success, false);
542551

543552
console.log("Test 4: encodedFundTransfers offset corruption");
544553
maliciousCalldata = _createIntentOnMainnet();
@@ -548,7 +557,10 @@ contract AccountTest is BaseTest {
548557
// encodedFundTransfers offset (bytes 288-319 relative to start, or 256-287 in Intent struct)
549558
mstore(add(intentPtr, 256), 0x10000000000000003) // 2^64 + 3
550559
}
551-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
560+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
561+
(success, returnData) =
562+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
563+
assertEq(success, false);
552564

553565
console.log("Test 5: funderSignature offset corruption");
554566
maliciousCalldata = _createIntentOnMainnet();
@@ -558,7 +570,10 @@ contract AccountTest is BaseTest {
558570
// funderSignature offset (bytes 448-479 relative to start, or 416-447 in Intent struct)
559571
mstore(add(intentPtr, 416), 0x10000000000000004) // 2^64 + 4
560572
}
561-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
573+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
574+
(success, returnData) =
575+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
576+
assertEq(success, false);
562577

563578
console.log("Test 6: signature offset corruption");
564579
maliciousCalldata = _createIntentOnMainnet();
@@ -568,7 +583,9 @@ contract AccountTest is BaseTest {
568583
// signature offset (bytes 576-607 relative to start, or 544-575 in Intent struct)
569584
mstore(add(intentPtr, 544), 0x10000000000000005) // 2^64 + 5
570585
}
571-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
586+
(success, returnData) =
587+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
588+
assertEq(success, false);
572589
}
573590

574591
// modified from testCrossChainKeyPreCallsAuthorization()'s intent creation
@@ -697,9 +714,9 @@ contract AccountTest is BaseTest {
697714
mstore(add(intentPtr, 576), 0x10000000000000006) // 2^64 + 6
698715
}
699716

700-
// custom error 0x00000000: 00000000000000000000000070a08231000000000000000000000000, the
701-
// uncaught error in case of corrupted paymentSignature
702-
assertEq(oc.execute(maliciousCalldata), bytes4(0x00000000));
717+
(bool success, bytes memory returnData) =
718+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
719+
assertEq(success, false);
703720
}
704721

705722
Merkle merkleHelper;
@@ -917,7 +934,10 @@ contract AccountTest is BaseTest {
917934
mstore(add(intentPtr, 448), 0x10000000000000007) // 2^64 + 7
918935
}
919936

920-
assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
937+
// assertEq(oc.execute(maliciousCalldata), bytes4(keccak256("VerifiedCallError()")));
938+
(bool success, bytes memory returnData) =
939+
address(oc).call(abi.encodeWithSignature("execute(bytes)", maliciousCalldata));
940+
assertEq(success, false);
921941
}
922942

923943
function _computeMerkleData(_TestMultiChainIntentTemps memory t) internal {

0 commit comments

Comments
 (0)