Add TestEnv::setup_with_config - #42
Conversation
7d3798a to
7b26c34
Compare
tvpeter
left a comment
There was a problem hiding this comment.
Hi @luisschwab, I left a few comments.
7b26c34 to
b4536a9
Compare
|
Can you share the error? CI and local testing is passing for me. |
|
This looks like a race condition happening on your local |
|
Try adding a timeout after the #[test]
fn test_get_prune_height() {
// Spawn an unpruned node.
let env_unpruned = TestEnv::new();
// Assert that `getblockchaininfo.pruned` is `None`.
let unpruned_res = env_unpruned.client.get_prune_height().unwrap();
assert_eq!(unpruned_res, None);
// Spawn a node with manual pruning enabled.
let mut node_config = Conf::default();
node_config.args.push("-prune=1");
node_config.args.push("-fastprune");
let env_pruned = TestEnv::new_with_config(&node_config);
// Mine 1000 blocks.
let block_count = 1000;
let _hashes = env_pruned.mine_blocks(block_count as usize, None);
// Assert that `getblockchaininfo.pruned` is `Some(0)`.
let pruned_res = env_pruned.client.get_prune_height().unwrap();
assert_eq!(pruned_res, Some(0));
// Prune the last 2 blocks.
let _ = env_pruned.corepc_client.prune_blockchain(block_count - 2);
+ std::thread::sleep(std::time::Duration::from_secs(2));
// Assert that `getblockchaininfo.prunedheight` is > 0.
// Note: it's not possible to assert on a specific block height since Bitcoin Core
// prunes at the block file level (`blkXXXX.dat`), and not at block height level.
let pruned_res = env_pruned.client.get_prune_height().unwrap();
assert!(pruned_res > Some(0));
} |
|
|
Did you set |
I have set it to point to my |
|
Try unsetting |
I have done that, and it's still the same output. This is clogging this PR conversation, so let's wait for others to confirm, then I will revert to check the reason it's failing on my end. Thank you. |
ValuedMammal
left a comment
There was a problem hiding this comment.
TestEnv::new_with_config would be a nice addition. I would prefer we keep the error handling using anyhow instead of unwraping everywhere. TestEnv already exposes the corepc_node::Client as env.bitcoind.client (it says so right in the docs), so no need to initialize a new client AFAICT. I'm not sure what may have been the cause of @tvpeter's slow test.
Now that we have GetBlockchainInfo, "get prune height" is just client.get_blockchain_info()?.prune_height
|
@luisschwab, can you please rebase and resolve conflicts? I would like to retest once that is done. |
Allows the caller to setup a `TestEnv` using a custom `BitcoinD` configuration.
b4536a9 to
d0c249f
Compare
TestEnv and Implement Client::get_prune_heightTestEnv::setup_with_config
|
@tvpeter @ValuedMammal rebased, sorry for the delay |
|
tACK d0c249f |

Changelog