defi-wonderland / smock

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

fix: fix `padNumHexSlotValue` output when giving a `SHA3` hash input #115

Closed DavidCai1111 closed 1 year ago

DavidCai1111 commented 2 years ago

Description When giving padNumHexSlotValue a SHA3 hash value, like 0xc1a82511edc30899b6306d233aa7b486fccf85b7c19d075b994557efe2bbe150 , since bigNumberToHex will add leading zeros, bigNumberToHex(bn) will return 00c1a82511edc30899b6306d233aa7b486fccf85b7c19d075b994557efe2bbe150, which will lead to a wrong output(0x00c1a82511edc30899b6306d233aa7b486fccf85b7c19d075b994557efe2bbe150). This PR tries to fix this error by removing the leading zeros and then let padStart to do the padding job.

wei3erHase commented 2 years ago

ey @DavidCai1111 thank you very much for your contribution! what's the scope of this fix?

it'd be nice to add a test that would fail without this fix, so that if we remove that line we can see it fail, and we have already a playground to try different scenarios and how this feature would affect, would you be willing to add them to the PR?

wei3erHase commented 1 year ago

closing this issue in favour of #160