That's the error that occurs when I try to test my contract.
Can someone tell me what the problem is?
That's the code for the test:
const assert = require('assert');
const fs = require('fs');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const compiledFactory = fs.readFileSync('./ethereum/build/LotteriaFactory.json', 'utf8');
const compiledLotteria = fs.readFileSync('./ethereum/build/Lotteria.json', 'utf8');
let accounts;
let factory;
let lotteriaAddress;
let lotteria;
beforeEach(async () => {
accounts = await web3.eth.getAccounts();
factory = await new web3.eth.Contract(JSON.parse(compiledFactory).interface)
.deploy({ data: (compiledFactory).bytecode })
.send({ from: accounts[0], gas: '1000000' });
await factory.methods.createNew('5').send({
from: accounts[0], //manager
gas: '1000000'
});
const addresses = await factory.methods.active().call();
lotteriaAddress = addresses[0]; //[LotteriaFactory]
lotteria = new web3.eth.Contract(
JSON.parse(compiledFactory).interface,
lotteriaAddress
);
});
describe('Lotteria', () => {
it('deploy a factory and a lottery', () => {
assert.ok(factory.options.address);
assert.ok(lotteria.options.address);
});
});
console.log(typeof JSON.parse(compiledFactory).interface)
and tell us what you get?interface
field in the JSON object which the stringcompiledFactory
is parsed into. Print it (or simply open the file which you read it from), and find out what fields you have there, and which one of them represents a legal ABI.