Truffle: Fail to port tests to v5.0.0-beta.0

Created on 18 Sep 2018  Â·  6Comments  Â·  Source: trufflesuite/truffle

  • [X] I've asked for help in the Truffle Gitter before filing this issue.

Issue

Running working v4.1.14 tests to v5.0.0-beta.0 – Chocolate Sushi fails without clear error description.

Steps to Reproduce

  • set up some test to a simple Contract that interacts with pretty much regular ERC20 OpenZeppelin contracts that work in v4.1.14
  • run them using v5.0.0-beta.0

Expected Behavior

test should work? Maybe I'm missing same adaptation guide here, but couldn't find a step by step checklist on things needed to be updated on test to port them to v5.

Actual Results

Got this error:

Error: while migrating MyContract: Invalid number of parameters for "undefined". Got 0 expected 1!
    at /node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:361:1
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
ps: unrecognized option: p
BusyBox v1.26.2 (2018-05-30 13:51:20 GMT) multi-call binary.

Usage: ps [-o COL1,COL2=HEADER]

Show list of processes

    -o COL1,COL2=HEADER Select columns for display
npm ERR! Test failed.  See above for more details.

Environment

  • Operating System: LInux Mint
  • Ethereum client: default ganache-cli
  • Truffle version (truffle version): v5.0.0-beta.0
  • node version (node --version): v8.12.0
  • npm version (npm --version): 6.4.1

DockerFile:

FROM mhart/alpine-node:8

RUN apk add --no-cache make gcc g++ python git bash

COPY ./ ./

RUN npm uninstall truffle
RUN npm install truffle@beta
stale

All 6 comments

@jmendiola222 The error you're getting is coming from the contract constructor and suggests that one of the constructor inputs you supplied to MyContract is undefined? Or missing?

If you can show the code around that deployment it might help with debugging.

Thanks @cgewecke, I can't yet share the complete code base, but here are the basics. Let me enforce once again that this test do work on v4.1.14, with almost 100% coverage.

import "./MyToken1.sol";
import "./MyToken2.sol";
import "./OtherContract.sol";

contract MyContract is Ownable {

  address internal myToken1Address;
  address internal myToken2Address;
  address internal myOtherContractAddress;

  constructor(uint256 arg0) Ownable() public {
    myToken1Address = new MyToken1();
    myToken2Address = new MyToken2();
    myOtherContractAddress = new OtherContract(arg0, 40);
    initializeConfig();
  }

Then in out tests we have something like:

const MyContract = artifacts.require('./contracts/MyContract.sol');

contract('MyContract', function([owner, userAccount, ...accounts]) {
  beforeEach(async function() {
    this.myContract = await MyContract.new(10000 * 100, { from: owner });

    [x, y, z] = await Promise.all([
      this.myContract.getX(),
      this.myContract.getY(),
      this.myContract.getZ()
    ]);

    await this.myContract.setParam(3 * x);
  });
  it('WHEN not init should reverts', async function() {
    const doing = this.myContract.doShomething(100000, {
        from: userAccount,
        value: 110
      });
      await assertRevert(doing);
   });
});

Hope this clarifies. Thanks!

Hi @jmendiola222 it looks like the error message is coming from a migrations file rather than a test. Truffle will run your migrations are run as part of the preparations for the test suite execution.

Error: while migrating MyContract

Could you look in the relevant file and see if there's something amiss in one of your deploy statements?

Thanks @cgewecke that was correct, on my migration file a had:

  await deployer.deploy(myLibrary);
  deployer.link(myLibrary, MyContract);
  await deployer.deploy(MyContract);

Where as we saw, MyContract contructor receives a uint256. Changing it to deployer.deploy(MyContract, 1000) solved this issue. Any clue on why this is not a problem in v4? Migrations are not runned on test for that version?

Thanks again!

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

There has been no new activity on this issue since it was marked as stale 7 days ago, so it is being automatically closed. If you'd like help with this or a different problem, please open a new issue. Thanks!

Was this page helpful?
0 / 5 - 0 ratings