Running these tests I get an “Error: Returned error: VM Exception while processing transaction: revert” for the first test. What makes it happen is actually the “_owner = sender;” in “initialize” function in “Ownable”. If I comment that line it works. This is my first question, can anyone help me, please?
My second question is related to the “createProxy” method. If I try to initialize in the create proxy like
As for your first question, I have tested in the Remix, it looks like everything is in order, I can deploy the contract, and call the function initialize(address).
Today, following this tutorial https://docs.zeppelinos.org/docs/zos_lib.html I’m having problems at const proxy = await project.createProxy(MyContractV0, { initArgs: [42] }) step where I get a
Creating an upgradeable instance of V0...
Error: Returned error: VM Exception while processing transaction: out of gas
at Object.ErrorResponse (some-path/node_modules/web3-core-helpers/src/errors.js:29:16)
at some-path/node_modules/web3-core-requestmanager/src/index.js:140:36
at some-path/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:112:1
at XMLHttpRequest.request.onreadystatechange (some-path/node_modules/truffle/build/webpack:/~/web3/~/web3-providers-http/src/index.js:
96:1)
at XMLHttpRequestEventTarget.dispatchEvent (some-path/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request-event-t
arget.js:34:1)
at XMLHttpRequest._setReadyState (some-path/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:208:1)
at XMLHttpRequest._onHttpResponseEnd (some-path/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:318:1)
at IncomingMessage.<anonymous> (some-path/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:289:47)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Truffle v5.0.13 (core: 5.0.13)
Node v10.12.0
Can anybody help? Is it a known problem? Is there any workaround? Ive tried to do something like await proxy.methods.initialize(42) but then the value is zero.
So, I have a contract with the following method and when calling it from tests it always reverts. Althoug, if I remove the initializer modifier, it works well. Can anyone help me?
function initialize(address sender) public initializer {
Ownable.initialize(sender);
governors[sender] = true;
}
Sure, I’m following ZOS documentation https://docs.zeppelinos.org/docs/testing.html
and when trying to initialize using this.project.createProxy it reverts, and if I do only this.project.createProxy(Sample); and then I use proxy.methods.initialize(myValue).call({from:user}); it kinda works. Kinda meaning that, it does if it does not have the initializer modifier.
Since you asked, here’s the code
So, this actually works, if the initialize method in Whitelist is not an initializer. Another alternative was to comment the line owner = _owner in Ownable.sol in initialize method.
So, I think that it might happen when an initializer calls another initializer and tries to set a variable value.
Hello @obernardovieira! This is kind of a wild guess, but maybe the problem is that your initialize() function is overloaded and the test doesn't know which one to pick? (Or is picking the wrong one) IE: there is an initialize() in Ownable.sol and there is an initialize() in Whitelist, but maybe the test is calling the Ownable initialize() but not Whitelist? Again, wild guess.
I just wrote up a little mini-tip regarding testing for overloaded functions. I haven't tried it in the context of zos testing yet, but it works for truffle-contract based tests. Maybe have a look?
HI @Dennison, thanks. Actually I forgot that, so it could have been one problem. But now that I fixed, I have a Error: The contract code couldn't be stored, please check your gas limit., and I think I’ve found the reason.
Since it’s too hard to explain, I’ll try to create a quick repository with some example code (I can’t shared the original one), as I’ll be offline for the next five days.
Hello, I’ve found a few interesting things. The first one, might be a mistake of mine, but still, it was what make the above error to happen.
Basically, I have a contract tree like this Base > Governance > Final (not the real names) and then I have an interface IFinal, with wich I was doing contract Base is IFinal. I think I should be doing it in final, right? That was my falt.
The second thing, which gave me a new error was the use of require(_fee <= FixidityLib.fixed1(), "Above 1.");.
Well, FixidityLib (which was published btw), is a set of two libraries, and in this case I’m calling on of them. This line above gave this error TypeError: Cannot read property 'match' of undefined.
If fixidity is set up so that a library calls another, and both have public or external methods, then that could be the case. We have a pending issue to support transitive solidity libraries in zOS.