I am debugging a bug happened on my truffle solidity test. I can narrow down the problem to an exception happened in the payable modifier.
my contract code:
import "zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol";
contract MyToken is ERC721Token {
function MyToken() ERC721Token(NAME, SYMB) public payable {
}
function purchase(uint256 _tokenId) public payable {
// all the code in this function is commented out when I do the test
}
}
my test code:
MyToken myToken = MyToken(contractAddress);
myToken.purchase.value(1000000000000000000).gas(1000000000000000000)(0);
exception:
Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:114:19)
contractAddress
and the ABI ofMyContract
correctly describes it?require(msg.value == 0)
and having payable is equibalent to removing that require.uint public initialBalance = 1 ether;
in your testing contract. truffleframework.com/docs/getting_started/…