Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Aug 1, 2023
1 parent f49b93c commit 7fe435c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
36 changes: 18 additions & 18 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
MulticallerTest:testMultiCallerWithSignerIncrementNonceSalt(uint256) (runs: 256, μ: 79117, ~: 81170)
MulticallerTest:testMultiCallerWithSignerIncrementNonceSaltWithERC1271(uint256) (runs: 256, μ: 579599, ~: 579578)
MulticallerTest:testMulticallerCdFallback(string) (runs: 256, μ: 307142, ~: 301941)
MulticallerTest:testMultiCallerWithSignerIncrementNonceSalt(uint256) (runs: 256, μ: 77967, ~: 78971)
MulticallerTest:testMultiCallerWithSignerIncrementNonceSaltWithERC1271(uint256) (runs: 256, μ: 579597, ~: 579501)
MulticallerTest:testMulticallerCdFallback(string) (runs: 256, μ: 307420, ~: 301901)
MulticallerTest:testMulticallerForwardsMessageValue() (gas: 213836)
MulticallerTest:testMulticallerGetNames() (gas: 147569)
MulticallerTest:testMulticallerReentrancyGuard() (gas: 18370)
MulticallerTest:testMulticallerRefund(uint256) (runs: 256, μ: 169958, ~: 171973)
MulticallerTest:testMulticallerRefund(uint256) (runs: 256, μ: 169441, ~: 171973)
MulticallerTest:testMulticallerReturnDataIsProperlyEncoded() (gas: 122104)
MulticallerTest:testMulticallerReturnDataIsProperlyEncoded(string,string,uint256) (runs: 256, μ: 523865, ~: 513971)
MulticallerTest:testMulticallerReturnDataIsProperlyEncoded(string,string,uint256) (runs: 256, μ: 512999, ~: 485451)
MulticallerTest:testMulticallerReturnDataIsProperlyEncoded(uint256,uint256,uint256,uint256) (runs: 256, μ: 122228, ~: 122228)
MulticallerTest:testMulticallerRevertWithCustomError() (gas: 32024)
MulticallerTest:testMulticallerRevertWithMessage() (gas: 34819)
MulticallerTest:testMulticallerRevertWithMessage(string) (runs: 256, μ: 35689, ~: 35751)
MulticallerTest:testMulticallerRevertWithMessage() (gas: 34841)
MulticallerTest:testMulticallerRevertWithMessage(string) (runs: 256, μ: 35700, ~: 35751)
MulticallerTest:testMulticallerRevertWithNothing() (gas: 31867)
MulticallerTest:testMulticallerSenderDoesNotRevertWithoutMulticallerDeployed() (gas: 3408)
MulticallerTest:testMulticallerTargetGetMulticallerSender() (gas: 27451)
MulticallerTest:testMulticallerWithNoData() (gas: 16181)
MulticallerTest:testMulticallerWithSigner(uint256) (runs: 256, μ: 129847, ~: 122128)
MulticallerTest:testMulticallerWithSigner(uint256) (runs: 256, μ: 129657, ~: 121930)
MulticallerTest:testMulticallerWithSignerEIP712Domain() (gas: 12442)
MulticallerTest:testMulticallerWithSignerGetMulticallerSigner() (gas: 139939)
MulticallerTest:testMulticallerWithSignerInvalidateNonces(uint256) (runs: 256, μ: 82230, ~: 80039)
MulticallerTest:testMulticallerWithSignerInvalidateNoncesWithERC1271(uint256) (runs: 256, μ: 585512, ~: 584949)
MulticallerTest:testMulticallerWithSignerNonPayableFunctions() (gas: 48928)
MulticallerTest:testMulticallerWithSignerReentrancyGuard() (gas: 127316)
MulticallerTest:testMulticallerWithSignerRevert() (gas: 211551)
MulticallerTest:testMulticallerWithSignerGetMulticallerSigner() (gas: 139951)
MulticallerTest:testMulticallerWithSignerInvalidateNonces(uint256) (runs: 256, μ: 81467, ~: 80060)
MulticallerTest:testMulticallerWithSignerInvalidateNoncesWithERC1271(uint256) (runs: 256, μ: 586511, ~: 584950)
MulticallerTest:testMulticallerWithSignerNonPayableFunctions() (gas: 48950)
MulticallerTest:testMulticallerWithSignerReentrancyGuard() (gas: 127328)
MulticallerTest:testMulticallerWithSignerRevert() (gas: 211569)
MulticallerTest:testMulticallerWithSignerRevertsWithNastyArrayLength() (gas: 9297)
MulticallerTest:testMulticallerWithSignerWithERC1271(uint256) (runs: 256, μ: 630394, ~: 606221)
MulticallerTest:testMulticallerWithSignerWithNoData() (gas: 131563)
MulticallerTest:testNastyCalldataRevert() (gas: 30788)
MulticallerTest:testMulticallerWithSignerWithERC1271(uint256) (runs: 256, μ: 626599, ~: 606086)
MulticallerTest:testMulticallerWithSignerWithNoData() (gas: 131569)
MulticallerTest:testNastyCalldataRevert() (gas: 3388)
MulticallerTest:testOffsetTrick(uint256,uint256,uint256) (runs: 256, μ: 571, ~: 571)
MulticallerTest:test__codesize() (gas: 50447)
MulticallerTest:test__codesize() (gas: 50734)
TestPlus:test__codesize() (gas: 1102)
30 changes: 21 additions & 9 deletions test/Multicaller.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1049,24 +1049,36 @@ contract MulticallerTest is TestPlus {
}
}

function revertsOnNastyCalldata(address[] calldata a) public pure returns (bytes32) {
return keccak256(abi.encodePacked(a));
}

function testNastyCalldataRevert() public {
assembly {
let m := mload(0x40)
mstore(m, 0x2eb48a80)

mstore(m, 0xcf74109c)
mstore(add(m, 0x20), 0x20)
mstore(add(m, 0x40), 1)
mstore(add(m, 0x60), 0x112233)
if iszero(
call(gas(), sload(multicallerWithSigner.slot), 0, add(m, 0x1c), 0x80, 0x00, 0x00)
) { revert(0x00, 0x00) }
mstore(add(m, 0x40), 2)
if call(gas(), sload(multicallerWithSigner.slot), 0, add(m, 0x1c), 0x80, 0x00, 0x00) {

// Check does not revert with valid calldata.
if iszero(call(gas(), address(), 0, add(m, 0x1c), 0x80, 0x00, 0x00)) {
revert(0x00, 0x00)
}

// Check reverts if address has dirty upper bits.
mstore(add(m, 0x60), not(0))
if call(gas(), address(), 0, add(m, 0x1c), 0x80, 0x00, 0x00) { revert(0x00, 0x00) }
mstore(add(m, 0x60), 0x112233)

// Check reverts if length of array is excessive.
mstore(add(m, 0x40), 2)
if call(gas(), address(), 0, add(m, 0x1c), 0x80, 0x00, 0x00) { revert(0x00, 0x00) }

// Check reverts if length of array is excessive.
mstore(add(m, 0x40), shl(255, 1))
if call(gas(), sload(multicallerWithSigner.slot), 0, add(m, 0x1c), 0x80, 0x00, 0x00) {
revert(0x00, 0x00)
}
if call(gas(), address(), 0, add(m, 0x1c), 0x80, 0x00, 0x00) { revert(0x00, 0x00) }
}
}

Expand Down

0 comments on commit 7fe435c

Please sign in to comment.