Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/stdlib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 19 additions & 1 deletion src/test/StdError.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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?
}

Expand All @@ -66,7 +76,8 @@ contract ErrorsTest {
T1
}

uint256[] someArr;
uint256[] public someArr;
bytes someBytes;

function assertionError() public pure {
assert(false);
Expand All @@ -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();
}
Expand Down