oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.94k stars 2.75k forks source link

bun test crashes on `revert` from Solidity contract #14716

Open volodymyrprokopyuk opened 5 days ago

volodymyrprokopyuk commented 5 days ago

Hi,

I'm using the bun test runner for testing Solidity contracts with the HardHat default provider. On each revert from the Solidity contract bun crashes with a segfault.

How can we reproduce the crash?

Install dependencies

bun install  hardhat @nomicfoundation/hardhat-toolbox

Configure HardHat in ./hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.27",
};

Create the minimal Solidity contract in ./contracts/Revert.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

contract Revert {
  error Oh();
  function doRevert() pure external {
    revert Oh();
  }
}

Compile the Solidity contract

bunx hardhat compile

Create the minimal JS test using the bun test runner in ./tests/Revert.test.js

import { ethers } from "hardhat"

test("Unconditional revert", async() => {
  const revert = await ethers.deployContract("Revert")
  await revert.doRevert()
})

Run the test with the bun test runner

bun test

The bun test runner crashes every time.

Thank you for doing the exceptional work!

Relevant log output

No response

Stack Trace (bun.report)

Bun v1.1.32 (fe8d007) on linux x86_64_baseline [TestCommand]

Segmentation fault at address 0x00000020

Features: jsc, no_avx2, transpiler_cache, tsconfig

Jarred-Sumner commented 15 hours ago

Thank you for the reproduction, that made this a lot easier to fix