Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bun test crashes on revert from Solidity contract #14716

Closed
volodymyrprokopyuk opened this issue Oct 21, 2024 · 1 comment · Fixed by #14834
Closed

bun test crashes on revert from Solidity contract #14716

volodymyrprokopyuk opened this issue Oct 21, 2024 · 1 comment · Fixed by #14834
Labels
crash An issue that could cause a crash linux An issue that occurs on Linux

Comments

@volodymyrprokopyuk
Copy link

volodymyrprokopyuk commented Oct 21, 2024

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

@volodymyrprokopyuk volodymyrprokopyuk added the crash An issue that could cause a crash label Oct 21, 2024
@github-actions github-actions bot added the linux An issue that occurs on Linux label Oct 21, 2024
@volodymyrprokopyuk volodymyrprokopyuk changed the title Segfault when using try/catch in a test bun test crashes on revert from Solidity contract Oct 24, 2024
Jarred-Sumner added a commit that referenced this issue Oct 26, 2024
@Jarred-Sumner
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash linux An issue that occurs on Linux
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants