1

I am writing a new test and when I run this code, the println's do not output in the terminal.

#[tokio::test]
async fn can_fetch_child_keys() {
    if std::option_env!("TEST_WS").is_none() {
        return
    }
    init_logger();
    let child_keys = Builder::<Block>::new()
        .mode(Mode::Online(OnlineConfig {
            transport: std::option_env!("TEST_WS").unwrap().to_owned().into(),
            pallets: vec!["Contracts".to_owned()],
            child_trie: true,
            ..Default::default()
        }))
        .build()
        .await
        .unwrap()
        .execute_with(|| {
            let child_keys = sp_io::storage::next_key(&[]).expect("some key must exist in the snapshot");
            assert!(sp_io::storage::get(&child_keys).is_some());
            child_keys
        });
    assert!(child_keys.len() > 0);
    
    println!("child_keys: {:?}", child_keys);
    println!("👩‍👦 child_keys.len(): {:?}", child_keys.len());
}

I have tried using:

RUST_LOG=debug cargo test --features=remote-test -p frame-remote-externalities can_fetch_child_keys -- --nocapture

Any suggestions on how to output in the terminal for debugging purposes?

This is in specific to the tests found here:

2 Answers 2

0

That test requires #[cfg(all(test, feature = "remote-test"))].

Try: cargo test --features remote-test -- --nocapture

0
0

Make sure you have TEST_WS environment variable defined:

RUST_LOG=debug TEST_WS=ws://127.0.0.1:9944 cargo test --features=remote-test -p frame-remote-externalities -- --nocapture

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.