I'm seeing some weird behavior when calling initialize
with manually constructed transaction data as shown here https://docs.zeppelinos.org/docs/advanced.html#calling-initialize-functions-manually-in-your-unit-tests
This will revert:
const initializeData = encodeCall("initialize", ['address', 'address'], [dataSource, oracleConsumer.address])
await oracle.sendTransaction({data: initializeData, from: accounts[0]})
However this works as intended:
const initializeData = encodeCall("initialize", ['address', 'address'], [dataSource, oracleConsumer.address])
await web3.eth.sendTransaction({data: initializeData, to: oracle.address, from: accounts[0], gasLimit: 500000})
Has anyone run into this before?
1 Like
Hey Chris! Thanks for posting here!
Have you tried sending the transaction through the contract object and setting the gas limit?
Yes, but it still reverted when the gasLimit was set. I can post a link to the full code in a bit.
Weird. I’ll tag @spalladino to see if he can help with this
chris.whinfrey:
This will revert:
const initializeData = encodeCall("initialize", ['address', 'address'], [dataSource, oracleConsumer.address])
await oracle.sendTransaction({data: initializeData, from: accounts[0]})
However this works as intended:
const initializeData = encodeCall("initialize", ['address', 'address'], [dataSource, oracleConsumer.address])
await web3.eth.sendTransaction({data: initializeData, to: oracle.address, from: accounts[0], gasLimit: 500000})
Congratulations, you've found one of truffle's undocumented changes
The issue is that truffle-contract's sendTransaction
now clears the data
field . From their docs, it does so because its it's intent is to call the fallback function (though it didn't use to enforce the tx having no data previous to truffle 5).
The good news is that you should be able to use the newly added methods
property to call any overloaded function (though I haven't personally tried it, let me know how that goes!).
5 Likes
Thanks a lot @nventuro ! I was not aware of that breaking change. I’ve filed an issue to fix this on the v2.2 docs.
1 Like