File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,10 @@ library stdStorage {
239239 checked_write (self, bytes32 (amt));
240240 }
241241
242+ function checked_write_int (StdStorage storage self , int256 val ) internal {
243+ checked_write (self, bytes32 (uint256 (val)));
244+ }
245+
242246 function checked_write (StdStorage storage self , bool write ) internal {
243247 bytes32 t;
244248 /// @solidity memory-safe-assembly
Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ contract StdStorageTest is Test {
3131 assertEq (test.exists (), 100 );
3232 }
3333
34+ function testStorageCheckedWriteSignedIntegerHidden () public {
35+ stdstore.target (address (test)).sig (test.hidden.selector ).checked_write_int (- 100 );
36+ assertEq (int256 (uint256 (test.hidden ())), - 100 );
37+ }
38+
39+ function testStorageCheckedWriteSignedIntegerObvious () public {
40+ stdstore.target (address (test)).sig (test.tG.selector ).checked_write_int (- 100 );
41+ assertEq (test.tG (), - 100 );
42+ }
43+
3444 function testStorageMapStructA () public {
3545 uint256 slot =
3646 stdstore.target (address (test)).sig (test.map_struct.selector ).with_key (address (this )).depth (0 ).find ();
You can’t perform that action at this time.
0 commit comments