Sdk testing getting Invalid number of parameters

When running the below I get Error: Invalid number of parameters for “symbol”. Got 0 expected 1!

it works perfectly for name()

I can see the result from console.log(this.proxy.methods)
But I’m guessing this is not the correct way to test the StandaloneERC20.sol

any help would be very much appreciated.

const { TestHelper } = require('@openzeppelin/cli');
const { Contracts, ZWeb3 } = require('@openzeppelin/upgrades');

ZWeb3.initialize(web3.currentProvider);

const StandaloneERC20 = Contracts.getFromNodeModules('@openzeppelin/contracts-ethereum-package', 'StandaloneERC20');

require('chai').should();

contract('tokenTest', function () {

  beforeEach(async function () {
    this.project = await TestHelper();
    this.proxy = await this.project.createProxy(StandaloneERC20, { initMethod: 'initialize', initArgs: ["Test", "TST", 18]});
  })

  it('should return the name', async function () {
    const name = await this.proxy.methods.name().call();

    name.should.eq('Test');
  })

  it('should return the symbol', async function () {
    const symbol = await this.proxy.methods.symbol().call();

    symbol.should.eq('TST');
  })
  
})
1 Like

I changed the sample.sol and use truffle compile and use normal truffle test with artifacts. Not sure if it is a hack or the correct way but it works…

const token = artifacts.require('Test.sol');

pragma solidity ^0.5.0;

import "../node_modules/@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/StandaloneERC20.sol";

contract Test is StandaloneERC20 {
  function greet() public pure returns (string memory) {
    return "A Test";
  }
}

Now I want to upgrade the function greet in a separate testUpgrade.js file but I have no idea where to start… any help?

1 Like

Hi @CIX,

console.log(this.proxy.methods); is showing 'symbol(address)' which doesn’t look right. It should be 'symbol()'

I downgraded @openzeppelin/contracts-ethereum-package to the previous version 2.2.3 and the test works as expected.

npm uninstall @openzeppelin/contracts-ethereum-package 
oz link @openzeppelin/contracts-ethereum-package@2.2.3

I have created an Issue: https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/issues/70

1 Like

Hi @CIX,

There is an issue with symbol (see above).
Your work around is testing the logic contract on it’s own, just like any other non-upgradeable contract.

I have answered this in a new topic: Test upgrading a function

1 Like

@abcoathup thanks it works perfectly now :slight_smile:

1 Like