Getting error when trying to run mocha tests on erc777 upgradable.
Any ideas?
Error Message:
testContract
"before each" hook for "returns the name":
Error: Returned error: VM Exception while processing transaction: revert
at Context.<anonymous> (test/testContract.test.js:22:41)
at processImmediate (internal/timers.js:456:21)
testContract.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.9;
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC777/ERC777.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/utils/Pausable.sol";
contract testContract is Initializable, ContextUpgradeSafe, ERC777UpgradeSafe {
function initialize(
address initialHolder,
uint256 initialBalance,
string memory name,
string memory symbol,
address[] memory defaultOperators
) public initializer {
__Context_init_unchained();
__ERC777_init_unchained(name, symbol, defaultOperators);
__ERC777Mock_init_unchained(initialHolder, initialBalance, name, symbol, defaultOperators);
}
function __ERC777Mock_init_unchained(
address initialHolder,
uint256 initialBalance,
string memory name,
string memory symbol,
address[] memory defaultOperators
) internal initializer {
_mint(initialHolder, initialBalance, "", "");
}
}
testContract.test.sol
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { BN, expectEvent, expectRevert, singletons } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
// Load compiled artifacts
const myContract = contract.fromArtifact('testContract');
// Start test block
describe('testContract', function () {
const [ owner, registryFunder, holder, defaultOperatorA, defaultOperatorB, newOperator, anyone ] = accounts;
const initialSupply = new BN('10000');
const name = 'testToken';
const symbol = '777TE';
// const data = web3.utils.sha3('OZ777TestData');
// const operatorData = web3.utils.sha3('OZ777TestOperatorData');
const defaultOperators = [defaultOperatorA, defaultOperatorB];
beforeEach(async function () {
this.contract = await myContract.new(holder, initialSupply, name, symbol, defaultOperators, {from: owner});
await this.contract.initialize(holder, initialSupply, name, symbol, defaultOperators, {from: owner});
});
it('returns the name', async function () {
expect(await this.contract.name({from: owner})).to.equal(name);
});
it('returns the symbol', async function () {
try {
var temp = await this.contract.symbol();
expect(temp).to.equal(symbol);
}
catch (e){
console.log("e", e);
}
});
});
cc @abcoathup