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

Error: Returned error: Returned error: invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Hash #160

Open
aress31 opened this issue May 6, 2021 · 4 comments

Comments

@aress31
Copy link

aress31 commented May 6, 2021

I am working on unit tests and the following one is failing:

  it("assigns the initial total supply to the owner", async () => {
    const [owner] = accounts;
    const totalSupply = await this.token.totalSupply();
    const ownerBalance = await this.token.balanceOf(owner);

    expect(ownerBalance).to.be.bignumber.equal(totalSupply);

    await expectEvent.inConstruction(this.token, "Transfer", {
      from: ZERO_ADDRESS,
      to: owner,
      value: totalSupply,
    });
  });

Here is the associated stack trace:

 1) Contract: Initial State
       assigns the initial total supply to the owner:
     Error: Returned error: Returned error: invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Hash
      at Object.ErrorResponse (node_modules\web3-core-helpers\lib\errors.js:28:19)
      at C:\Users\ateyar\Documents\GitHub\erc20-deflationary\node_modules\web3-core-requestmanager\lib\index.js:303:36
      at C:\Users\ateyar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\wrapper.js:107:1
      at XMLHttpRequest.request.onreadystatechange (C:\Users\ateyar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\web3\node_modules\web3-providers-http\lib\index.js:98:1)
      at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\ateyar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:1)
      at XMLHttpRequest.exports.modules.996763.XMLHttpRequest._setReadyState (C:\Users\ateyar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-request.js:208:1)
      at XMLHttpRequest.exports.modules.996763.XMLHttpRequest._onHttpResponseEnd (C:\Users\ateyar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-request.js:318:1)
      at IncomingMessage.<anonymous> (C:\Users\ateyar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\node_modules\xhr2-cookies\dist\xml-http-request.js:289:47)
      at endReadableNT (internal/streams/readable.js:1327:12)
      at processTicksAndRejections (internal/process/task_queues.js:80:21)

Anyone who can please make sense of this issue?

@frangio
Copy link
Contributor

frangio commented May 10, 2021

Please share details about your environment. In particular, what node are you running against?

@aress31
Copy link
Author

aress31 commented May 10, 2021

I hope this helps:

npx truffle version                  
Truffle v5.3.2 (core: 5.3.2)
Solidity - 0.8.4 (solc-js)
Node v14.16.0
Web3.js v1.3.5

@frangio
Copy link
Contributor

frangio commented May 10, 2021

How are you running your tests, is it just truffle test? What network are you running against? This is a weird error that I haven't seen before so as much data as you can provide to reproduce it, would help.

@aress31
Copy link
Author

aress31 commented May 10, 2021

Yeah, just using npx truffle test --network development and in local I run npx ganache-cli --fork https://ropsten.infura.io/v3/10cc02d0eec842c99af1653c011badc9.

This is my constructor:

    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_,
        uint256 totalSupply_,
        address router_,
        --- SNIP ---
    ) ERC20(name_, symbol_) {
        _decimals = decimals_;
        _totalSupply = totalSupply_ * (10**decimals_);

        --- SNIP ---

        //  Set DEX platform up
        _uniswapV2Router = IUniswapV2Router02(address(router_));

        address pair =
            IUniswapV2Factory(_uniswapV2Router.factory()).getPair(
                _uniswapV2Router.WETH(),
                address(this)
            );

        // Pair not yet created
        if (pair == address(0)) {
            _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
                .createPair(_uniswapV2Router.WETH(), address(this));
        } else {
            _uniswapV2Pair = pair;
        }

        --- SNIP ---

        emit Transfer(address(0), _msgSender(), _totalSupply);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants