Skip to content

Hardhat Counter tests fail with Kurtosis ethereum-package (invariant was violated: receipt should not be null) #7952

@jaa2

Description

@jaa2

Version of Hardhat

3.1.8

What happened?

Basic Counter tests fail with Kurtosis. Seems like an issue with checking emits. Does not happen with other execution RPC clients.

Running Mocha tests


  Counter
    1) Should emit the Increment event when calling the inc() function
    2) The sum of the Increment events should match the current value


  0 passing (274ms)
  2 failing

  1) Counter
       Should emit the Increment event when calling the inc() function:
     HardhatError: HHE100: An internal invariant was violated: receipt should not be null
      at assertHardhatInvariant (node_modules/@nomicfoundation/hardhat-errors/src/errors.ts:237:11)
      at assertIsNotNull (node_modules/@nomicfoundation/hardhat-ethers-chai-matchers/src/internal/utils/asserts.ts:17:3)
      at <anonymous> (node_modules/@nomicfoundation/hardhat-ethers-chai-matchers/src/internal/matchers/emit.ts:134:13)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async Context.<anonymous> (file:///home/user/hh-test/test/Counter.ts:10:5)

  2) Counter
       The sum of the Increment events should match the current value:
     Error: could not decode result data (value="0x", info={ "method": "x", "signature": "x()" }, code=BAD_DATA, version=6.16.0)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:698:21)
      at assert (node_modules/ethers/src.ts/utils/errors.ts:719:25)
      at Interface.decodeFunctionResult (node_modules/ethers/src.ts/abi/interface.ts:916:9)
      at staticCallResult (node_modules/ethers/src.ts/contract/contract.ts:346:35)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async staticCall (node_modules/ethers/src.ts/contract/contract.ts:303:24)
      at async Proxy.x (node_modules/ethers/src.ts/contract/contract.ts:351:41)
      at async Context.<anonymous> (file:///home/user/hh-test/test/Counter.ts:34:12)

When I run more comprehensive tests, Hardhat fills up several blocks with transactions.

Minimal reproduction steps

  1. Initialize hardhat with
npx hardhat --init

(Choose Hardhat 3 Beta and ethers + mocha for testing.)

  1. Write network_params.yaml:
participants:
  - el_type: geth
    cl_type: lighthouse
    count: 1

network_params:
  prefunded_accounts: '{"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266": {"balance": "999999ETH"}}'
  1. Run Kurtosis:
kurtosis run github.com/ethpandaops/ethereum-package --args-file ./network_params.yaml --image-download always --enclave hh-test
  1. Add this network to hardhat.config.ts:
    kurtosis: {
      type: "http",
      chainType: "l1",
      url: "http://127.0.0.1:32003",
      accounts: [
        "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
      ],
    }
  1. Run tests:
npx hardhat test --network kurtosis

Output:

$ npx hardhat test --network kurtosis
No contracts to compile
No Solidity tests to compile

Running Solidity tests

  contracts/Counter.t.sol:CounterTest
    ✔ test_InitialValue()
    ✔ test_IncByZero()
    ✔ testFuzz_Inc(uint8) (runs: 256)

Running Mocha tests


  Counter
    1) Should emit the Increment event when calling the inc() function
    2) The sum of the Increment events should match the current value


  0 passing (274ms)
  2 failing

  1) Counter
       Should emit the Increment event when calling the inc() function:
     HardhatError: HHE100: An internal invariant was violated: receipt should not be null
      at assertHardhatInvariant (node_modules/@nomicfoundation/hardhat-errors/src/errors.ts:237:11)
      at assertIsNotNull (node_modules/@nomicfoundation/hardhat-ethers-chai-matchers/src/internal/utils/asserts.ts:17:3)
      at <anonymous> (node_modules/@nomicfoundation/hardhat-ethers-chai-matchers/src/internal/matchers/emit.ts:134:13)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async Context.<anonymous> (file:///home/user/hh-test/test/Counter.ts:10:5)

  2) Counter
       The sum of the Increment events should match the current value:
     Error: could not decode result data (value="0x", info={ "method": "x", "signature": "x()" }, code=BAD_DATA, version=6.16.0)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:698:21)
      at assert (node_modules/ethers/src.ts/utils/errors.ts:719:25)
      at Interface.decodeFunctionResult (node_modules/ethers/src.ts/abi/interface.ts:916:9)
      at staticCallResult (node_modules/ethers/src.ts/contract/contract.ts:346:35)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async staticCall (node_modules/ethers/src.ts/contract/contract.ts:303:24)
      at async Proxy.x (node_modules/ethers/src.ts/contract/contract.ts:351:41)
      at async Context.<anonymous> (file:///home/user/hh-test/test/Counter.ts:34:12)




3 passing (3 solidity)
2 failing (2 mocha)

Test run failed

Search terms

kurtosis, ethereum-package, ethpandaops, invariant, receipt should not be null

Metadata

Metadata

Assignees

Type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions