I'm getting the following error while running a test in truffle:

Error: Returned error: VM Exception while processing transaction: revert

Now, the code is simply to big and complicated to run through Stackoverflow. So my question instead is,

-How can I debug this? (more specifically: how can I get the VM logs and see exactly what is ducking up the test)

After a lot of trial and error I know exactly what function is misbehaving, I just don't know exactly what's misbehaving about it: here is the code in case it provides any clarity:

function onOCTReceived
 address operator, 
 address from, 
 uint256 amount, 
 bytes calldata data
    return (0x0);

important to note bobAndAlice(data) is working like a charm independently of the onOCTReceived() function so doubt the error is there, plus deleting it doesn't offer any more clarity on whats going on.

Edit: Additional testing shows that onOCTReceived() works perfectly fine in remix too.

Any pointers or help is very much appreciated.

  • It's likely that bobAndAlice() reverts in this context. The raw data facilitates limitless possibilities. The function may have require() conditions that aren't met in this context. Consider posting that code so someone might pinpoint the issue. – Rob Hitchens Feb 7 at 15:27
  • When I run bobAndAlice as a stand alone function with the same data input, it works as expected. The same error is returned when I delete bobAndAlice the exact same issue is returned, I suspect the error might be on the return, but might be completely misguided here. :shrug: – Lucas Rodriguez Benitez Feb 7 at 15:28
  • "bobAndAlice(data) is working like a charm" with what data??? – goodvibration Feb 7 at 15:52
  • I don't think the data itself is relevant, the relevant part is that the data input is the same when executing as stand alone and when executing it within the function stated above, one works the other doesn't – Lucas Rodriguez Benitez Feb 7 at 16:05
  • Please check the edit and let me know how to debug the VM in truffle please, since I now think that the truffle VM is the actual issue:) – Lucas Rodriguez Benitez Feb 7 at 16:07

When you call function bobAndAlice from the off-chain, the msg.sender that this function executes with is the address of the account which you have used for calling it.

When you call function bobAndAlice from the on-chain, the msg.sender that this function executes with is the address of the contract which you have used for calling it.

From your description, it sounds like this function performs some operation on msg.sender, which completes successfully when your account is used, but reverts when the contract is used.

It could be something as simple as require(someCondition(msg.sender)).

It could be something more complicated, for example, function bobAndAlice tries to send funds back to the caller (via msg.sender.transfer), but in the case of your contract, there is no fallback function to receive it, i.e., no implementation for function() external payable.

Without seeing the code of function bobAndAlice, it is rather impossible to tell...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.