Closed novusnota closed 3 months ago
What needs to be done here to make it "ready for review"?
@anton-trunov those sub-headings & their inner content:
I'll be finishing those today, shortly after I finish with Sublime updates. Hopefully, you'll have a bunch of stuff to review tomorrow morning :)
UPD: Made a lot for Sublime today, don't know if I'll finish this PR today too. I'll try, though.
In the testing/debugging page we should also cover how to test if a contract's receiver throws an exception. Here is a recent user request:
Here is a link of my smart contract: https://github.com/kaseen/LuckySixTON/blob/master/contracts/lucky_six.tact
Inside of receive function, i check if input is valid. If it is not valid i throw error with nativeThrow(12345);.
My question is, how can i catch this error when i'm writing unit tests the behavior of function to expect that it should revert.
For example, in hardhat framework for developing smart contracts in Solidity, there is a function expect(transaction).to.be.revertedWith(errorCode)
My question is, how can i catch this error when i'm writing unit tests the behavior of function to expect that it should revert.
Sandbox/Blueprint analogue would be to write something like this in tests:
expect(res.transactions).toHaveTransaction({
success: false,
exitCode: 5 // or whatever exit code is desired / undesired :)
});
Where res
is the result of sending a message to a certain receiver we're testing. I'll add that and more to the debugging page by the end of Tuesday, such that the end page will be comprehensive in many regards.
And one more popular request regarding testing: how to simulated time passing
And one more popular request regarding testing: how to simulate time passing
Hmm, I suppose simple "sleep/wait" will do. And, maybe, adding a separate test group, which won't overwrite the state of the blockchain between the individual tests in that group. On it!
Wait, no I meant blockchain.now
:
... setting up things
blockchain = await Blockchain.create();
... more setting up things
blockchain.now = STARTING_TIME;
... more tests
blockchain.now = SOME_LATER_TIME;
... more tests
Oh, I see. Sure!
Added a usage example to "Common debugging functions", right before the "Enabling debug mode ..."
Let's publish!
Closes #4
WIP, but almost there.
Preview: