From 385bf139c12a9411b49f65bd65fe86936186ea30 Mon Sep 17 00:00:00 2001 From: ZeroEkkusu <94782988+ZeroEkkusu@users.noreply.github.com> Date: Mon, 28 Feb 2022 13:38:57 +0100 Subject: [PATCH 1/2] feat(stdError): add `lowLevelError` --- src/stdlib.sol | 1 + src/test/StdError.t.sol | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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..511b8227 100644 --- a/src/test/StdError.t.sol +++ b/src/test/StdError.t.sol @@ -58,6 +58,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 +71,7 @@ contract ErrorsTest { T1 } - uint256[] someArr; + uint256[] public someArr; function assertionError() public pure { assert(false); From cfa392508df12bcedbd5face0e41dde26cc9f4d7 Mon Sep 17 00:00:00 2001 From: ZeroEkkusu <94782988+ZeroEkkusu@users.noreply.github.com> Date: Wed, 2 Mar 2022 17:21:02 +0100 Subject: [PATCH 2/2] test(stdError): add `testExpectEncodeStg` --- src/test/StdError.t.sol | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/StdError.t.sol b/src/test/StdError.t.sol index 511b8227..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(); @@ -72,6 +77,7 @@ contract ErrorsTest { } uint256[] public someArr; + bytes someBytes; function assertionError() public pure { assert(false); @@ -93,6 +99,13 @@ contract ErrorsTest { T(a); } + function encodeStgError() public { + assembly { + sstore(someBytes.slot, 1) + } + bytes memory b = someBytes; + } + function pop() public { someArr.pop(); }