问题描述
无法从 javascript 中的单元测试访问智能合约的变量和方法。 我怎么解决这个问题? 如果我尝试调用它的每个方法或字段返回 undefiend 我在 js 中的单元测试:
const ERC721 = artifacts.require('../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol');
contract("MultiSig",function () {
let instance
beforeEach('deploying',async() => {
instance = await MultiSig.new();
token_1 = await ERC721.new("token_1","TKN1");
token_2 = await ERC721.new("token_2","TKN2");
token_3 = await ERC721.new("token_3","TKN3");
});
it('adding',async function () {
let accounts = await web3.eth.getAccounts();
instance.addOwner(accounts[0]);
let first = instance.owners[0];
console.log(accounts[0]);
console.log(first);
})
})
用solidity编写的智能合约包含这个字段
address[] public owners;
它返回下一个输出(字段未定义): enter image description here
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)