defi-wonderland / smock

The Solidity mocking library
MIT License
319 stars 40 forks source link

Mocks: support large bytes (> 31 bytes) when using setVariable #30

Closed 0xGorilla closed 2 years ago

0xGorilla commented 3 years ago

Is your feature request related to a problem? Please describe. Currently, an error is thrown when using setVariable in a variable of type bytes and sending an string larger than 31 bytes

Describe the solution you'd like Bytes larger than 31 bytes do have an special handling in the storage, we need to adapt.

Additional context From Hardhat Docs:

For byte arrays that store data which is 32 or more bytes long, the main slot stores length * 2 + 1 and the data is stored as usual in keccak256(slot). This means that you can distinguish a short array from a long array by checking if the lowest bit is set: short (not set) and long (set).

There is an skipped test that should be unskipped as soon as this is working: Mock: Editable storage logic - should be able to set bytes