Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 83 characters in body
Source Link
Bruno
  • 8.5k
  • 1
  • 13
  • 37

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 -- --nocapture.:

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:

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 -- --nocapture.

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

This is in specific to the tests found here:

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:

added 25 characters in body
Source Link
Bruno
  • 8.5k
  • 1
  • 13
  • 37

WhenI 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 -- --nocapture.

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

This is in specific to the tests found here:

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 -- --nocapture.

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

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 -- --nocapture.

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

This is in specific to the tests found here:

Source Link
Bruno
  • 8.5k
  • 1
  • 13
  • 37

How to print / output from within async tokio test

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 -- --nocapture.

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