Error: setUp() failed: ValueError: constructor failed, error=Unsupported cheat code: calldata = Concat(0xffa18649, sha3_64(0x6465706c6f796572)) returndata=None
C0D3O opened this issue · comments
Describe the bug
I have only one files in the test folder ( code below ) and I run halmos, and I get this error:
Error: setUp() failed: ValueError: constructor failed, error=Unsupported cheat code: calldata = Concat(0xffa18649, sha3_64(0x6465706c6f796572)) returndata=None
To Reproduce
I just pasted the example code from the 'getting started.md'
// SPDX-License-Identifier: MIT
import { ERC20 } from "openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SymTest } from "halmos-cheatcodes/SymTest.sol";
import { Test, console2 } from "forge-std/Test.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyToken", "MT") {
_mint(msg.sender, initialSupply);
}
}
contract MyTokenTest is Test, SymTest {
MyToken token;
function setUp() public {
uint256 initialSupply = svm.createUint256("initialSupply");
token = new MyToken(initialSupply);
}
function check_transfer(address sender, address receiver, uint256 amount) public {
// specify input conditions
vm.assume(receiver != address(0));
vm.assume(token.balanceOf(sender) >= amount);
// record the current balance of sender and receiver
uint256 balanceOfSender = token.balanceOf(sender);
uint256 balanceOfReceiver = token.balanceOf(receiver);
// call target contract
vm.prank(sender);
token.transfer(receiver, amount);
// check output state
assert(token.balanceOf(sender) == balanceOfSender - amount);
assert(token.balanceOf(receiver) == balanceOfReceiver + amount);
}
}
btw I guess you have a typo there, first it doesn't
import { Test } from "forge-std/Test.sol";
and here it should be balanceOf on the last line in the screenshot
https://github.com/a16z/halmos/blob/main/docs/getting-started.md#2-write-symbolic-tests
But even if I delete everything from the contract like this
// SPDX-License-Identifier: MIT
import { SymTest } from "halmos-cheatcodes/SymTest.sol";
contract MyTokenTest is SymTest {}
it will still throw the same error
and haha even if I will delete the file from the test folder.. it will still throw the same error....hm 🤔
Environment:
- Windows
- 3.12
- forge 0.2.0, halmos 0.1.9
Additional context
in WSL it returns the same error
ok, I did sth ( deleting all sol files, copying everything again, building again and many random things and now it seems to be working...
but now the test says
[FAIL] check_transfer(address,address,uint256) (paths: 1/8, time: 1.88s, bounds: [])
Counterexample:
halmos_initialSupply_uint256_01 = 0x0400000000000000000000000000000000000000000000000000000000000000 (1809251394333065553493296640760748560207343510400633813116524750123642650624)
p_amount_uint256 = 0x0400000000000000000000000000000000000000000000000000000000000000 (1809251394333065553493296640760748560207343510400633813116524750123642650624)
p_receiver_address = 0x00000000000000000000000000000000aaaa0001
p_sender_address = 0x00000000000000000000000000000000aaaa0001
WARNING:Halmos:Counterexample: unknown
--solver-timeout-assertion 0
flag doesn't help
or does it
I guess it did help so... idk seems to be working then:D
I am facing similar issue. Setup is failing each time. Although setUp was working fine with Foundry tests.
cheatcode 0xffa18649
is vm.addr(uint256)
, support has been added in https://github.com/a16z/halmos/releases/tag/v0.1.11
@shanzson please provide more details if you are still impacted