Spotting the error

To debug the previous error, copy the transaction ID from ganache-cli:

Then feed it as an argument to the truffle debug <tx id> --network my_ganache debug command.

In this case, we run:

truffle debug 0x90e02cc211733cade22bd5ff3b1ea1600781b48a1c792d867cda83190f773319 --network my_ganache

Once executed, you’ll enter Truffle's debugging mode, as shown the following screenshot:

Keep pressing the Enter button to step through the code and trace the execution steps. Finally, the debugger will stop with an error message:

As a result, Truffle's debugger indicates that the exception (error) is raised due to a failed require() statement, as the evaluated expression (!Tplayer.exist(msg.sender)) will definitively always be false. This is because, if you remember, in the join() test we added the player first, therefore the exist() function will be always true, and hence our faulty require() will fail. The important point is that Truffle indicates to us where the code fails with an interesting message, instead of the previous error message generated by the VM.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset