Skip to content

vm.blobhashes does not work #11362

@StackOverflowExcept1on

Description

@StackOverflowExcept1on

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

1.3.1-stable

What version of Foundryup are you on?

1.3.0

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Counter {
    uint256 public number;

    function setNumber(uint256 newNumber) public {
        require(blobhash(0) != 0, "blob can't be found");
        number = newNumber;
    }

    function increment() public {
        number++;
    }
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";

contract CounterTest is Test {
    Counter public counter;

    function setUp() public {
        counter = new Counter();

        bytes32[] memory hashes = new bytes32[](1);
        hashes[0] = bytes32(uint256(1));
        vm.blobhashes(hashes);

        // vm.attachBlob("");

        counter.setNumber(0);
    }

    function test_Increment() public {
        counter.increment();
        assertEq(counter.number(), 1);
    }
}
[⠊] Compiling...
[⠒] Compiling 21 files with Solc 0.8.30
[⠑] Solc 0.8.30 finished in 550.75ms
Compiler run successful!

Ran 1 test for test/Counter.t.sol:CounterTest
[FAIL: blob can't be found] setUp() (gas: 0)
Traces:
  [177453] CounterTest::setUp()
    ├─ [134175] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
    │   └─ ← [Return] 670 bytes of code
    ├─ [0] VM::blobhashes([0x0000000000000000000000000000000000000000000000000000000000000001])
    │   └─ ← [Return]
    ├─ [0] VM::attachBlob(0x)
    │   └─ ← [Return]
    ├─ [690] Counter::setNumber(0)
    │   └─ ← [Revert] blob can't be found
    └─ ← [Revert] blob can't be found

Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 1.77s (0.00ns CPU time)

Ran 1 test suite in 1.77s (1.77s CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/Counter.t.sol:CounterTest
[FAIL: blob can't be found] setUp() (gas: 0)

Encountered a total of 1 failing tests, 0 tests succeeded

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bugType: bugT-needs-triageType: this issue needs to be labelled

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions