0

I am currently creating a test for signatures, and it runs fine with truffle, but with solidity-coverage I get the following error...

ECDSA: invalid signature 'v' value

I checked the ethereum-js version and found that v7.1.0 is used by Ganache in truffle and v2.13.1 is used by solidity-coverage. However, ganache 7.0 does not work in solidity-coverage. Thank you in advance.

https://github.com/sc-forks/solidity-coverage/issues/694 https://github.com/trufflesuite/ganache/issues/972

Code: Solidity

contract Member {
  using ECDSAUpgradeable for bytes32;

...

  function join(
    bytes memory signature,
  ) public returns (uint256) {
    bytes32 _hash = _getHash(msg.sender);
    address inviter = ECDSAUpgradeable.recover(_hash, signature);
    require(msg.sender != inviter, "Cannot invite yourself");

  function _getHash(address invited) private view returns (bytes32) {
    uint256 _timeStamp = _getTimeStamp();
    return toEthSignedMessageHash(
      abi.encodePacked(
        StringsUpgradeable.toString(_timeStamp),
        ",",
        StringsUpgradeable.toHexString(uint160(invited), 20)
      )
    );
  }
...

Code: test(js)

it("join OK", async() => {
        const str = `${timestamp},${accounts[1].toLowerCase()}`;
        const sign = await web3.eth.sign(str, accounts[0]);
        const data = await memberInstance.join.call(
            sign, {from: accounts[1]}
        ); // get error
...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.