Skip to content

Commit 60b2792

Browse files
committed
coverage
1 parent 04a2424 commit 60b2792

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/utils/AbiDecode.t.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ contract AbiDecodeTest is Test {
4040
}
4141
}
4242

43+
function testDecodeOffsetToNowhere() public view {
44+
bytes memory buffer = abi.encodePacked(uint256(0x20));
45+
46+
(bool success, Memory.Slice output) = buffer.tryDecodeBytes();
47+
assertFalse(success);
48+
assertEq(output.toBytes(), new bytes(0));
49+
50+
(bool successCalldata, bytes memory outputCalldata) = this.__tryDecodeBytesCalldata(buffer);
51+
assertFalse(successCalldata);
52+
assertEq(outputCalldata, new bytes(0));
53+
}
54+
55+
function testDecodeLengthExceedsBuffer() public view {
56+
bytes memory buffer = abi.encodePacked(uint256(0x20), uint256(0x40));
57+
58+
(bool success, Memory.Slice output) = buffer.tryDecodeBytes();
59+
assertFalse(success);
60+
assertEq(output.toBytes(), new bytes(0));
61+
62+
(bool successCalldata, bytes memory outputCalldata) = this.__tryDecodeBytesCalldata(buffer);
63+
assertFalse(successCalldata);
64+
assertEq(outputCalldata, new bytes(0));
65+
}
66+
4367
function __tryDecodeBytesCalldata(
4468
bytes calldata buffer
4569
) external pure returns (bool success, bytes calldata output) {

0 commit comments

Comments
 (0)