Truffle-Test
如何從單元測試中將函式指針傳遞給合約方法?
我收到此錯誤:
Error: invalid type (arg="type", value="function")
嘗試在合約上呼叫此方法時
IntOption
:function create( address target, string memory name, int initialValue, function (address, string memory, int) external view validate ) public {
從我的單元測試。我正在嘗試將定義的這個函式
Config4AccessControl
作為參數傳遞給validate
:function anyValue(address, string memory, int value) public pure { // any value is ok }
這是單元測試:
it("should not be defined after it's created", async () => { const intOptions = await IntOption.new(); const ac = await Config4AccessControl.new(); await intOptions.create(addr1, 'foo', 1, ac.anyValue.address);
web3 似乎不支持這一點(在撰寫本文時:1.2.4):https ://github.com/ethereum/web3.js/issues/2826