diff --git a/src/stdlib.sol b/src/stdlib.sol index d895915e..24262d46 100644 --- a/src/stdlib.sol +++ b/src/stdlib.sol @@ -109,6 +109,7 @@ library stdError { bytes public constant indexOOBError = abi.encodeWithSignature("Panic(uint256)", 0x32); bytes public constant memOverflowError = abi.encodeWithSignature("Panic(uint256)", 0x41); bytes public constant zeroVarError = abi.encodeWithSignature("Panic(uint256)", 0x51); + bytes public constant lowLevelError = bytes(""); // `0x` } struct StdStorage { diff --git a/src/test/StdError.t.sol b/src/test/StdError.t.sol index 46014d94..f55fff1e 100644 --- a/src/test/StdError.t.sol +++ b/src/test/StdError.t.sol @@ -38,6 +38,11 @@ contract StdErrorsTest is DSTest { test.enumConversion(1); } + function testExpectEncodeStg() public { + vm.expectRevert(stdError.encodeStorageError); + test.encodeStgError(); + } + function testExpectPop() public { vm.expectRevert(stdError.popError); test.pop(); @@ -58,6 +63,11 @@ contract StdErrorsTest is DSTest { test.intern(); } + function testExpectLowLvl() public { + vm.expectRevert(stdError.lowLevelError); + test.someArr(0); + } + // TODO: figure out how to trigger encodeStorageError? } @@ -66,7 +76,8 @@ contract ErrorsTest { T1 } - uint256[] someArr; + uint256[] public someArr; + bytes someBytes; function assertionError() public pure { assert(false); @@ -88,6 +99,13 @@ contract ErrorsTest { T(a); } + function encodeStgError() public { + assembly { + sstore(someBytes.slot, 1) + } + bytes memory b = someBytes; + } + function pop() public { someArr.pop(); }