Commit 055737a2 authored by Kelvin Fichter's avatar Kelvin Fichter

fix[smock]: add naive support for packed storage slots

parent 8e99c149
......@@ -98,10 +98,14 @@ export const getStorageSlots = (
ethers.BigNumber.from(slotHash).add(inputSlot.slot)
)
const slotValue = toHexString32(
`0x` + toHexString32(flat[key]).slice(2 + variableDef.offset * 2)
)
slots.push({
label: key,
hash: slotHash,
value: toHexString32(flat[key]),
value: slotValue,
})
}
......
......@@ -23,6 +23,11 @@ contract SimpleStorageGetter {
bool internal _packedA;
address internal _packedB;
// Regression for #1275.
uint256 internal __packingSpacerUnused1; // Spacer to avoid packing with the above two.
bool public booleanOne = true;
bool public booleanTwo = true;
constructor(
uint256 _inA
) {
......
......@@ -53,8 +53,7 @@ describe('smoddit', () => {
expect(await smod.getAddress()).to.equal(ret)
})
// TODO: Need to solve this with a rewrite.
it.skip('should be able to return an address in a packed storage slot', async () => {
it('should be able to return an address in a packed storage slot', async () => {
const ret = '0x558ba9b8d78713fbf768c1f8a584485B4003f43F'
await smod.smodify.put({
......@@ -170,6 +169,16 @@ describe('smoddit', () => {
expect(await smod.getAddressToAddressMapValue(key)).to.equal(val)
})
it('should be able to pack two booleans', async () => {
const ret = true
expect(await smod.booleanTwo()).to.equal(ret)
await smod.smodify.put({
booleanTwo: ret,
})
expect(await smod.booleanTwo()).to.equal(ret)
})
})
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment