20 Foundry Test: stdstore 无法改变 bool 类型参数的值?

我在写 foundry project 的 test script,其中一个 function 用 stdstore 把 isSuccess 的值从 false 改成 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) 
    │   └─ ← ()
    └─ ← ()

从上面的 Trace 可以看到,0x000000000000000000000000000000000000000000000000000000000000000d 这个地址的值,一开始是 0x0000000000000000000000000000000000000000000000000000000000000000,通过 VM::store, 改成了 0x0000000000000000000000000000000000000000000000000000000000000001,可是为什么 Contract::isSuccess 的值,还是 false 呢?

请先 登录 后评论

最佳答案 2023-09-28 14:34

这可能是 foundry 的一个bug,我先关闭这个问题了

请先 登录 后评论

其它 1 个回答

影无双
请先 登录 后评论
  • 1 关注
  • 0 收藏,1398 浏览
  • NPC.李括 提出于 2023-09-16 10:33