pokt-network / pocket

Official implementation of the Pocket Network Protocol v1
https://pokt.network
MIT License
61 stars 33 forks source link

[Development] Documentation for local debugging using dlv #183

Open Olshansk opened 1 year ago

Olshansk commented 1 year ago

Objective

Document how to use the dlv debugger in LocalNet.

Origin Document

The LocalNet CLI and logging are useful, but we need to be able to step through the code in unit tests and in a dev environment

Goals

Deliverables

Non-goals / Non-deliverables

General issue deliverables

[Optional] Testing Methodology


Creator: @Olshansk Co-Owners: @andrewnguyen22

Olshansk commented 1 year ago

Copy pasting an idea from @bryanchriswhite to be documented in the docs in the future.

Screenshot 2023-03-06 at 3 25 42 PM
If anyone else finds themselves debugging a  flickering / flaky test, may I recommend this guide which blew my mind: 🤯 http://choly.ca/post/debugging-go-with-rr/

TLDR; `go test -c ... + rr + dlv`:
1. go test -c ... builds a test binary which can be run by another program or script
2. rr runs in a loop (with the test) until produces a failure once. 
3. The captured execution trace can then be replayed deterministically and debugged with dlv. 🤙 
Olshansk commented 1 year ago

@red-0ne Are you down to take on this ticket given the other work you've been doing?

red-0ne commented 1 year ago

Yes, dlv in unit tests are already working and helpful, would love to document it and take a look at the LocalNet scenario :+1: