You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I upgraded hardhat from 2.0.6 to 2.2.0 and ran into a problem where transaction that triggers a contract to selfdestruct succeeded (receipt.status == 1) but querying the dead contract's code still shows that the contract contains code (ethers.provider.getCode(CONTRACT_ADDRESS)).
Contract balance can be correctly updated however, but not the contract code.
To reproduce:
contract code (modified from Greeter example)
//SPDX-License-Identifier: Unlicensepragma solidity^0.7.0;
contractGreeter {
constructor() payable {}
function kill() public {
selfdestruct(msg.sender);
}
}
test
const{ expect }=require("chai");describe("Greeter",function(){it("Should successfully update contract state after selfdestruct",asyncfunction(){constGreeter=awaitethers.getContractFactory("Greeter");constgreeter=awaitGreeter.deploy({value: 1000});awaitgreeter.deployed();expect(awaitethers.provider.getBalance(greeter.address)).to.equal(1000)expect(awaitethers.provider.getCode(greeter.address)).to.not.equal("0x")awaitgreeter.kill();expect(awaitethers.provider.getBalance(greeter.address)).to.equal(0)expect(awaitethers.provider.getCode(greeter.address)).to.equal("0x")});});
Then install different versions of hardhat and run the test. So far I've tried 2.0.6, 2.0.10, 2.1.0, 2.1.2 and they all work fine. Only 2.2.0 fail.
The text was updated successfully, but these errors were encountered:
Hey @NIC619, thanks for reporting this bug and trying it with different versions! It was really helpful to understand what's going on. We are now working on a fix.
Update hardhat version and fix unit tests
Due to an error in Hardhat 2.2.0 (NomicFoundation/hardhat#1415)
we decided to update Hardhat version and fix errors in unit and system tests.
The errors in tests were caused by functions like isOpen, takeOffer, earlyClose
being called on auctions that self destructed (the previously used version of Hardhat
seemed to tolerate such calls).
I upgraded
hardhat
from2.0.6
to2.2.0
and ran into a problem where transaction that triggers a contract toselfdestruct
succeeded (receipt.status == 1
) but querying the dead contract's code still shows that the contract contains code (ethers.provider.getCode(CONTRACT_ADDRESS)
).Contract balance can be correctly updated however, but not the contract code.
To reproduce:
Greeter
example)Then install different versions of
hardhat
and run the test. So far I've tried2.0.6
,2.0.10
,2.1.0
,2.1.2
and they all work fine. Only2.2.0
fail.The text was updated successfully, but these errors were encountered: