ethereum - 松露测试是否支持 ABIEncoderV2?
问题描述
我想测试一个返回数组结构的函数。
这是示例代码。
struct Hoge {
uint id;
string text;
}
・・・
constructor() public {
hoges.push(Hoge(1, "Hogehoge"));
}
・・・
function hogehoge() external view returns(Hoge memory) {
return hoges[0];
}
我的测试是这样的。
var Sample = artifacts.require('./Sample.sol');
contract('sample', function(accounts) {
it('facilitates number of place and check-in', function() {
return Sample.deployed().then(function(instance) {
sampleInstance = instance;
return sampleInstance.hogehoge()
}).then(function(result) {
hoges = result;
assert.equal(hoges.id, 1);
})
})
})
但是,错误显示invalid solidity type!: tuple
。
返回数组结构的函数需要ABIEncoderV2
。
我听说 web3 正在尝试支持ABIEncoderV2
,但我不确定 web3ABIEncoderV2
现在是否支持。
我的版本是这样的。Truffle v4.1.15(核心:4.1.15) Solidity v0.4.25(solc-js)
你能给我任何建议如何测试我的代码吗?
解决方案
支持从 truffle v5 开始ABIEncoderV2
。我建议从您当前的版本升级到 v5。
推荐阅读
- asp.net-core - 如何处理多层1对多关系的DAL?
- c - 什么种族导致输出看起来不同?
- php - php图像上传并添加文本
- javascript - 如何将工具提示添加到 fullcalander
- ssl - SSL 握手在 NGinx 上游失败
- mysql - MySql 登录问题 - 未加载 auth_socket
- azure - 图标在 Azure DevOps 管道的发布任务目录中不可见。vss-extension.json 如下,
- javascript - axios里面的for循环
- python - psycopg2.OperationalError:致命:不支持的前端协议 1234.5679:服务器支持 2.0 到 3.0
- javascript - 如何在按钮的单击句柄中使用 mergeMap 订阅内部可观察对象