Safe_network testnet command

Note: I suggest this as a topic for all Q&A related to the testnet command.

I’m running local test networks using the testnet command and having trouble getting the logs to contain anything other than INFO or WARN messages. I tried the following which made no difference.
RUST_LOG=safe_network=trace testnet
RUST_LOG=sn_node=trace testnet

Using RUST_LOG=trace testnet causes a panic which reports that sn_node was passed -vv which is equivalent to info!

Is there a way to get TRACE output in the logs when using testnet?

The following does in fact work (as @joshuef says it should).

RUST_LOG=sn_node=trace testnet

Though in full I was doing this for each run:

pkill sn_node;rm -rf ~/.safe/node/local-test-network/;RUST_LOG=safe_network=trace target/debug/testnet

My problem appears to have been my system caching the files for a terminal window, possibly because I had removed the current directory for that terminal. The directory listing was still showing the files from yesterday until I changed directory and I guess commands in that window were seeing cached files rather than the new directories and their contents.


Yep. What you have there should work. That’s what we use on CI eg. :thinking:

I just checked locally (im on mac) and after a build w/ cargo --release --bin testnet:

RUST_LOG=safe_network=trace ./target/release/testnet i get trace logs.

Just as a (perhaps related?) aside, here is the full command I’m favouring at the moment, which I run from root of the safe_network repo:

killall sn_node ||true && rm -rf ~/.safe/node/local-test-network || true && RUST_LOG=safe_network=trace cargo run --release --bin testnet

The above ensures any existing nodes are killed, and data relted to that is cleaned up too.


Thanks @joshuef, I’m running a very similar combo command so odd that I’m not getting the same result. Will try again later. Just to confirm, the text ‘TRACE’ should appear in the logs?



 TRACE 2022-01-26T10:43:05.303016Z [sn/src/prefix_map/]:
	 ➤ Attempting to update prefixmap for Prefix()


Cool, I wasn’t aware of this command…

Perhaps someone could explain a little more about the command and its background? Is it much different from make run-local-baby-fleming or using sn_launch_tool?


The proliferation of options here may potentially be more confusing. I personally don’t think there’s really a need for both sn_launch_tool and the CLI mechanism for launching a local network, and possibly not testnet either.

I wanted to do some work in making things a bit more uniform. Should hopefully be able to soon.


as things stand, testnet uses sn_launch_tool, as does run_local_baby... .

Testnet I think is currently a bit more flexible of the two, you can eg add more nodes on to an existing network using that.

testnet is what’s used (at least by me), routinely in core testing (has no dep on cli eg).

as @chriso sez though, this could be smoothed out a fair chunk, so looking forward to that :+1:


I can feel the maidsafe’s fire!!


Problem solved, as noted in the OP here.