File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments