foundry-rs/book

stdstore cannot update bool type parameter?

linghuccc opened this issue · 1 comments

I use stdstore to mock all kinds of value except for boolean type. I always get all kinds of errors when trying to mock boolean value.

Below is an example:

Test codes (it's supposed to update isSuccess from false to true):
...
stdstore
.target(addrContract)
.sig(contract.isSuccess.selector)
.checked_write(true);

  assertEq(contract.isSuccess(), true);

...

Traces:
[127785] ContractTest::test_adminWithdraw_Part2()
├─ [0] VM::record()
│ └─ ← ()
├─ [2356] Contract::isSuccess() [staticcall]
│ └─ ← false
├─ [0] VM::accesses(Contract: [0x1a94a1Ae151C8e66Fb3a2E8843144969Bd2efc28])
│ └─ ← [0x000000000000000000000000000000000000000000000000000000000000000d], []
├─ [0] VM::load(Contract: [0x1a94a1Ae151C8e66Fb3a2E8843144969Bd2efc28], 0x000000000000000000000000000000000000000000000000000000000000000d) [staticcall]
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ emit WARNING_UninitedSlot(who: Contract: [0x1a94a1Ae151C8e66Fb3a2E8843144969Bd2efc28], slot: 13)
├─ emit SlotFound(who: Contract: [0x1a94a1Ae151C8e66Fb3a2E8843144969Bd2efc28], fsig: 0x0b6c754b, keysHash: 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563, slot: 13)
├─ [356] Contract::isSuccess() [staticcall]
│ └─ ← false
├─ [0] VM::load(Contract: [0x1a94a1Ae151C8e66Fb3a2E8843144969Bd2efc28], 0x000000000000000000000000000000000000000000000000000000000000000d) [staticcall]
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ [0] VM::store(Contract: [0x1a94a1Ae151C8e66Fb3a2E8843144969Bd2efc28], 0x000000000000000000000000000000000000000000000000000000000000000d, 0x0000000000000000000000000000000000000000000000000000000000000001)
│ └─ ← ()
├─ [356] Contract::isSuccess() [staticcall]
│ └─ ← false
├─ emit log(: Error: a == b not satisfied [bool])
├─ emit log_named_string(key: Left, val: false)
├─ emit log_named_string(key: Right, val: true)
├─ [0] VM::store(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 0x6661696c65640000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000001)
│ └─ ← ()
└─ ← ()

From trace above, we can see, value in address 0x000000000000000000000000000000000000000000000000000000000000000d was originally 0x0000000000000000000000000000000000000000000000000000000000000000,VM::store has updated it to 0x0000000000000000000000000000000000000000000000000000000000000001,but later Contract::isSuccess's value is still false. Why is this so?

I think I asked question in a wrong place. But I have to point out: It's been months since I had this question and nobody answered me in Telegram group.