MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
6.07k stars 11.15k forks source link

How to debug a simtest sample? #19608

Closed oday0311 closed 5 days ago

oday0311 commented 2 weeks ago

there are many test function in sui with simtest init, how can we debug the test functions to know more about the process?

[sim_test]

async fn sim_execute_transaction_transfer()

stefan-mysten commented 2 weeks ago

@oday0311 Please do not install anything from random strangers on the internet.

stefan-mysten commented 2 weeks ago

Can you please clarify your question, what process are you referring to and what kind of debugging do you have in mind?

oday0311 commented 2 weeks ago

thanks for your remind, I check last person 's account , did not install his shit.

well, I just have some work with detail process of some simtest cases, I am using goland Ide with rust support, it is normal to debug with cargo normal test cases, but as for simtest test cases, I can not use the ide or any other way to set a break point to check the local vari or values.

so I normal using info!() logs to debug simtest cases. but it cost a lot of time to repeat,

is there any way , we can debug like normal case for simtest. set a breakpoint and check some of the values.

thanks again.

stefan-mysten commented 2 weeks ago

Got it. Honestly, I haven't used simtests. So for running simtests, you'd need to install https://github.com/MystenLabs/sui/blob/main/scripts/simtest/install.sh this script, and then I think you can do cargo simtest.

Debugging with breakpoints I do not know. I will relay this question internally!

oday0311 commented 2 weeks ago

thanks for your help. for running simtest, there are enough hint for the project to install simtest , but sometimes we need to debug simtest, please refer..

stefan-mysten commented 1 week ago

One option could be to switch to a [tokio::test] for that particular test, and debug it like this.

mwtian commented 1 week ago

Or you can add logs to relevant code paths and use RUST_LOG environment variable to adjust the log level.