Updates tests
This commit is contained in:
parent
4b86bd6952
commit
7533e2fbc0
|
@ -202,7 +202,7 @@ fn block_test_vectors_height_mainnet() {
|
|||
fn block_test_vectors_height_testnet() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
block_test_vectors_height(Testnet);
|
||||
block_test_vectors_height(Network::new_default_testnet());
|
||||
}
|
||||
|
||||
/// Test that the block test vector indexes match the heights in the block data,
|
||||
|
@ -245,7 +245,7 @@ fn block_commitment_mainnet() {
|
|||
fn block_commitment_testnet() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
block_commitment(Testnet);
|
||||
block_commitment(Network::new_default_testnet());
|
||||
}
|
||||
|
||||
/// Check that the block commitment field parses without errors.
|
||||
|
|
|
@ -22,10 +22,10 @@ use eyre::Result;
|
|||
/// higher level API.
|
||||
#[test]
|
||||
fn push_and_prune() -> Result<()> {
|
||||
push_and_prune_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Heartwood)?;
|
||||
push_and_prune_for_network_upgrade(Network::Testnet, NetworkUpgrade::Heartwood)?;
|
||||
push_and_prune_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Canopy)?;
|
||||
push_and_prune_for_network_upgrade(Network::Testnet, NetworkUpgrade::Canopy)?;
|
||||
for network in Network::iter() {
|
||||
push_and_prune_for_network_upgrade(network.clone(), NetworkUpgrade::Heartwood)?;
|
||||
push_and_prune_for_network_upgrade(network, NetworkUpgrade::Canopy)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,9 @@ fn push_and_prune_for_network_upgrade(
|
|||
fn upgrade() -> Result<()> {
|
||||
// The history tree only exists Hearwood-onward, and the only upgrade for which
|
||||
// we have vectors since then is Canopy. Therefore, only test the Heartwood->Canopy upgrade.
|
||||
upgrade_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Canopy)?;
|
||||
upgrade_for_network_upgrade(Network::Testnet, NetworkUpgrade::Canopy)?;
|
||||
for network in Network::iter() {
|
||||
upgrade_for_network_upgrade(network, NetworkUpgrade::Canopy)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ proptest! {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
assert!(Network::Mainnet.is_max_block_time_enforced(height));
|
||||
assert_eq!(Network::Testnet.is_max_block_time_enforced(height), TESTNET_MAX_TIME_START_HEIGHT <= height);
|
||||
assert_eq!(Network::new_default_testnet().is_max_block_time_enforced(height), TESTNET_MAX_TIME_START_HEIGHT <= height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ fn activation_bijective() {
|
|||
let mainnet_nus: HashSet<&NetworkUpgrade> = mainnet_activations.values().collect();
|
||||
assert_eq!(MAINNET_ACTIVATION_HEIGHTS.len(), mainnet_nus.len());
|
||||
|
||||
let testnet_activations = Testnet.activation_list();
|
||||
let testnet_activations = Network::new_default_testnet().activation_list();
|
||||
let testnet_heights: HashSet<&block::Height> = testnet_activations.keys().collect();
|
||||
assert_eq!(TESTNET_ACTIVATION_HEIGHTS.len(), testnet_heights.len());
|
||||
|
||||
|
@ -38,7 +38,7 @@ fn activation_extremes_mainnet() {
|
|||
#[test]
|
||||
fn activation_extremes_testnet() {
|
||||
let _init_guard = zebra_test::init();
|
||||
activation_extremes(Testnet)
|
||||
activation_extremes(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Test the activation_list, activation_height, current, and next functions
|
||||
|
@ -115,7 +115,7 @@ fn activation_consistent_mainnet() {
|
|||
#[test]
|
||||
fn activation_consistent_testnet() {
|
||||
let _init_guard = zebra_test::init();
|
||||
activation_consistent(Testnet)
|
||||
activation_consistent(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Check that the `activation_height`, `is_activation_height`,
|
||||
|
@ -178,7 +178,7 @@ fn branch_id_extremes_mainnet() {
|
|||
#[test]
|
||||
fn branch_id_extremes_testnet() {
|
||||
let _init_guard = zebra_test::init();
|
||||
branch_id_extremes(Testnet)
|
||||
branch_id_extremes(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Test the branch_id_list, branch_id, and current functions for `network` with
|
||||
|
@ -217,7 +217,7 @@ fn branch_id_consistent_mainnet() {
|
|||
#[test]
|
||||
fn branch_id_consistent_testnet() {
|
||||
let _init_guard = zebra_test::init();
|
||||
branch_id_consistent(Testnet)
|
||||
branch_id_consistent(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Check that the branch_id and current functions are consistent for `network`.
|
||||
|
|
|
@ -11,10 +11,10 @@ use eyre::Result;
|
|||
/// and its next block.
|
||||
#[test]
|
||||
fn tree() -> Result<()> {
|
||||
tree_for_network_upgrade(&Network::Mainnet, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(&Network::Testnet, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(&Network::Mainnet, NetworkUpgrade::Canopy)?;
|
||||
tree_for_network_upgrade(&Network::Testnet, NetworkUpgrade::Canopy)?;
|
||||
for network in Network::iter() {
|
||||
tree_for_network_upgrade(&network, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(&network, NetworkUpgrade::Canopy)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,9 @@ fn incremental_roots() {
|
|||
|
||||
#[test]
|
||||
fn incremental_roots_with_blocks() -> Result<()> {
|
||||
incremental_roots_with_blocks_for_network(Network::Mainnet)?;
|
||||
incremental_roots_with_blocks_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
incremental_roots_with_blocks_for_network(network)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ fn incremental_roots() {
|
|||
|
||||
#[test]
|
||||
fn incremental_roots_with_blocks() -> Result<()> {
|
||||
incremental_roots_with_blocks_for_network(Network::Mainnet)?;
|
||||
incremental_roots_with_blocks_for_network(Network::Testnet)?;
|
||||
|
||||
for network in Network::iter() {
|
||||
incremental_roots_with_blocks_for_network(network)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -343,9 +343,9 @@ fn empty_v5_librustzcash_round_trip() {
|
|||
#[test]
|
||||
fn fake_v5_round_trip() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
fake_v5_round_trip_for_network(Network::Mainnet);
|
||||
fake_v5_round_trip_for_network(Network::Testnet);
|
||||
for network in Network::iter() {
|
||||
fake_v5_round_trip_for_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
fn fake_v5_round_trip_for_network(network: Network) {
|
||||
|
@ -491,9 +491,9 @@ fn invalid_orchard_nullifier() {
|
|||
#[test]
|
||||
fn fake_v5_librustzcash_round_trip() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
fake_v5_librustzcash_round_trip_for_network(Network::Mainnet);
|
||||
fake_v5_librustzcash_round_trip_for_network(Network::Testnet);
|
||||
for network in Network::iter() {
|
||||
fake_v5_librustzcash_round_trip_for_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
fn fake_v5_librustzcash_round_trip_for_network(network: Network) {
|
||||
|
@ -931,9 +931,9 @@ fn zip244_sighash() -> Result<()> {
|
|||
#[test]
|
||||
fn binding_signatures() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
binding_signatures_for_network(Network::Mainnet);
|
||||
binding_signatures_for_network(Network::Testnet);
|
||||
for network in Network::iter() {
|
||||
binding_signatures_for_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
fn binding_signatures_for_network(network: Network) {
|
||||
|
|
|
@ -300,7 +300,7 @@ mod tests {
|
|||
])
|
||||
.expect("A PublicKey from slice");
|
||||
|
||||
let t_addr = pub_key.to_address(Network::Testnet);
|
||||
let t_addr = pub_key.to_address(Network::new_default_testnet());
|
||||
|
||||
assert_eq!(format!("{t_addr}"), "tmTc6trRhbv96kGfA99i7vrFwb5p7BVFwc3");
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ mod tests {
|
|||
|
||||
let script = Script::new(&[0; 20]);
|
||||
|
||||
let t_addr = script.to_address(Network::Testnet);
|
||||
let t_addr = script.to_address(Network::new_default_testnet());
|
||||
|
||||
assert_eq!(format!("{t_addr}"), "t2L51LcmpA43UMvKTw2Lwtt9LMjwyqU2V1P");
|
||||
}
|
||||
|
|
|
@ -67,15 +67,17 @@ fn get_transparent_output_address() -> Result<()> {
|
|||
let addr = transparent_output_address(&transaction.outputs()[0], &Network::Mainnet)
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "t3M5FDmPfWNRG3HRLddbicsuSCvKuk9hxzZ");
|
||||
let addr = transparent_output_address(&transaction.outputs()[0], &Network::Testnet)
|
||||
.expect("should return address");
|
||||
let addr =
|
||||
transparent_output_address(&transaction.outputs()[0], &Network::new_default_testnet())
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "t294SGSVoNq2daz15ZNbmAW65KQZ5e3nN5G");
|
||||
// Public key hash e4ff5512ffafe9287992a1cd177ca6e408e03003
|
||||
let addr = transparent_output_address(&transaction.outputs()[1], &Network::Mainnet)
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "t1ekRwsd4LaSsd6NXgsx66q2HxQWTLCF44y");
|
||||
let addr = transparent_output_address(&transaction.outputs()[1], &Network::Testnet)
|
||||
.expect("should return address");
|
||||
let addr =
|
||||
transparent_output_address(&transaction.outputs()[1], &Network::new_default_testnet())
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "tmWbBGi7TjExNmLZyMcFpxVh3ZPbGrpbX3H");
|
||||
|
||||
Ok(())
|
||||
|
@ -84,9 +86,9 @@ fn get_transparent_output_address() -> Result<()> {
|
|||
#[test]
|
||||
fn get_transparent_output_address_with_blocks() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
get_transparent_output_address_with_blocks_for_network(Network::Mainnet);
|
||||
get_transparent_output_address_with_blocks_for_network(Network::Testnet);
|
||||
for network in Network::iter() {
|
||||
get_transparent_output_address_with_blocks_for_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that the block test vector indexes match the heights in the block data,
|
||||
|
|
|
@ -263,8 +263,9 @@ fn compact_bitcoin_test_vectors() {
|
|||
/// Test blocks using CompactDifficulty.
|
||||
#[test]
|
||||
fn block_difficulty() -> Result<(), Report> {
|
||||
block_difficulty_for_network(Network::Mainnet)?;
|
||||
block_difficulty_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
block_difficulty_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -349,8 +350,9 @@ fn block_difficulty_for_network(network: Network) -> Result<(), Report> {
|
|||
/// Test that the genesis block threshold is PowLimit
|
||||
#[test]
|
||||
fn genesis_block_difficulty() -> Result<(), Report> {
|
||||
genesis_block_difficulty_for_network(Network::Mainnet)?;
|
||||
genesis_block_difficulty_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
genesis_block_difficulty_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -454,7 +456,10 @@ fn check_testnet_minimum_difficulty_block(height: block::Height) -> Result<(), R
|
|||
// threshold, as documented in ZIP-205 and ZIP-208:
|
||||
// https://zips.z.cash/zip-0205#change-to-difficulty-adjustment-on-testnet
|
||||
// https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-testnet
|
||||
match NetworkUpgrade::minimum_difficulty_spacing_for_height(&Network::Testnet, height) {
|
||||
match NetworkUpgrade::minimum_difficulty_spacing_for_height(
|
||||
&Network::new_default_testnet(),
|
||||
height,
|
||||
) {
|
||||
None => Err(eyre!("the minimum difficulty rule is not active"))?,
|
||||
Some(spacing) if (time_gap <= spacing) => Err(eyre!(
|
||||
"minimum difficulty block times must be more than 6 target spacing intervals apart"
|
||||
|
@ -477,12 +482,12 @@ fn check_testnet_minimum_difficulty_block(height: block::Height) -> Result<(), R
|
|||
|
||||
/// SPANDOC: Check that the testnet minimum difficulty is the PoWLimit {?height, ?threshold, ?hash}
|
||||
{
|
||||
assert_eq!(threshold, Network::Testnet.target_difficulty_limit(),
|
||||
assert_eq!(threshold, Network::new_default_testnet().target_difficulty_limit(),
|
||||
"testnet minimum difficulty thresholds should be equal to the PoWLimit. Hint: Blocks with large gaps are allowed to have the minimum difficulty, but it's not required.");
|
||||
// all blocks pass the minimum difficulty threshold, even if they aren't minimum
|
||||
// difficulty blocks, because it's the lowest permitted difficulty
|
||||
assert!(
|
||||
hash <= Network::Testnet.target_difficulty_limit(),
|
||||
hash <= Network::new_default_testnet().target_difficulty_limit(),
|
||||
"testnet minimum difficulty hashes must be less than the PoWLimit"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ fn test_funding_stream_addresses() -> Result<(), Report> {
|
|||
let address =
|
||||
transparent::Address::from_str(address).expect("address should deserialize");
|
||||
assert_eq!(
|
||||
&address.network(),
|
||||
&address.network().bip70_network_name(),
|
||||
network,
|
||||
"incorrect network for {receiver:?} funding stream address constant: {address}",
|
||||
);
|
||||
|
|
|
@ -122,9 +122,9 @@ mod test {
|
|||
#[test]
|
||||
fn halving_test() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
halving_for_network(&Network::Mainnet)?;
|
||||
halving_for_network(&Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
halving_for_network(&network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -249,8 +249,9 @@ mod test {
|
|||
fn block_subsidy_test() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
block_subsidy_for_network(&Network::Mainnet)?;
|
||||
block_subsidy_for_network(&Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
block_subsidy_for_network(&network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -181,9 +181,9 @@ fn coinbase_is_first_for_historical_blocks() -> Result<(), Report> {
|
|||
#[test]
|
||||
fn difficulty_is_valid_for_historical_blocks() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
difficulty_is_valid_for_network(Network::Mainnet)?;
|
||||
difficulty_is_valid_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
difficulty_is_valid_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -285,9 +285,9 @@ fn equihash_is_valid_for_historical_blocks() -> Result<(), Report> {
|
|||
#[test]
|
||||
fn subsidy_is_valid_for_historical_blocks() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
subsidy_is_valid_for_network(Network::Mainnet)?;
|
||||
subsidy_is_valid_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
subsidy_is_valid_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -388,9 +388,9 @@ fn coinbase_validation_failure() -> Result<(), Report> {
|
|||
#[test]
|
||||
fn funding_stream_validation() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
funding_stream_validation_for_network(Network::Mainnet)?;
|
||||
funding_stream_validation_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
funding_stream_validation_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -463,9 +463,9 @@ fn funding_stream_validation_failure() -> Result<(), Report> {
|
|||
#[test]
|
||||
fn miner_fees_validation_success() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
miner_fees_validation_for_network(Network::Mainnet)?;
|
||||
miner_fees_validation_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
miner_fees_validation_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -546,12 +546,14 @@ fn merkle_root_is_valid() -> Result<(), Report> {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
// test all original blocks available, all blocks validate
|
||||
merkle_root_is_valid_for_network(Network::Mainnet)?;
|
||||
merkle_root_is_valid_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
merkle_root_is_valid_for_network(network)?;
|
||||
}
|
||||
|
||||
// create and test fake blocks with v5 transactions, all blocks fail validation
|
||||
merkle_root_fake_v5_for_network(Network::Mainnet)?;
|
||||
merkle_root_fake_v5_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
merkle_root_fake_v5_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -683,8 +685,9 @@ fn legacy_sigops_count_for_historic_blocks() {
|
|||
fn transaction_expiration_height_validation() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
transaction_expiration_height_for_network(&Network::Mainnet)?;
|
||||
transaction_expiration_height_for_network(&Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
transaction_expiration_height_for_network(&network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ fn checkpoint_list_load_hard_coded() -> Result<(), BoxError> {
|
|||
.expect("hard-coded Testnet checkpoint list should parse");
|
||||
|
||||
let _ = Mainnet.checkpoint_list();
|
||||
let _ = Testnet.checkpoint_list();
|
||||
let _ = Network::new_default_testnet().checkpoint_list();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ fn checkpoint_list_hard_coded_mandatory_mainnet() -> Result<(), BoxError> {
|
|||
|
||||
#[test]
|
||||
fn checkpoint_list_hard_coded_mandatory_testnet() -> Result<(), BoxError> {
|
||||
checkpoint_list_hard_coded_mandatory(Testnet)
|
||||
checkpoint_list_hard_coded_mandatory(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Check that the hard-coded lists cover the mandatory checkpoint
|
||||
|
@ -274,7 +274,7 @@ fn checkpoint_list_hard_coded_max_gap_mainnet() -> Result<(), BoxError> {
|
|||
|
||||
#[test]
|
||||
fn checkpoint_list_hard_coded_max_gap_testnet() -> Result<(), BoxError> {
|
||||
checkpoint_list_hard_coded_max_gap(Testnet)
|
||||
checkpoint_list_hard_coded_max_gap(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Check that the hard-coded checkpoints are within [`MAX_CHECKPOINT_HEIGHT_GAP`],
|
||||
|
|
|
@ -205,18 +205,30 @@ async fn multi_item_checkpoint_list() -> Result<(), Report> {
|
|||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn continuous_blockchain_no_restart() -> Result<(), Report> {
|
||||
continuous_blockchain(None, Mainnet).await?;
|
||||
continuous_blockchain(None, Testnet).await?;
|
||||
for network in Network::iter() {
|
||||
continuous_blockchain(None, network).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn continuous_blockchain_restart() -> Result<(), Report> {
|
||||
for height in 0..zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS.len() {
|
||||
continuous_blockchain(Some(block::Height(height.try_into().unwrap())), Mainnet).await?;
|
||||
}
|
||||
for height in 0..zebra_test::vectors::CONTINUOUS_TESTNET_BLOCKS.len() {
|
||||
continuous_blockchain(Some(block::Height(height.try_into().unwrap())), Testnet).await?;
|
||||
for network in Network::iter() {
|
||||
for height in 0..zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS.len() {
|
||||
continuous_blockchain(
|
||||
Some(block::Height(height.try_into().unwrap())),
|
||||
network.clone(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
for height in 0..zebra_test::vectors::CONTINUOUS_TESTNET_BLOCKS.len() {
|
||||
continuous_blockchain(
|
||||
Some(block::Height(height.try_into().unwrap())),
|
||||
network.clone(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -42,13 +42,8 @@ mod prop;
|
|||
fn v5_fake_transactions() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let networks = vec![
|
||||
(Network::Mainnet, zebra_test::vectors::MAINNET_BLOCKS.iter()),
|
||||
(Network::Testnet, zebra_test::vectors::TESTNET_BLOCKS.iter()),
|
||||
];
|
||||
|
||||
for (network, blocks) in networks {
|
||||
for transaction in fake_v5_transactions_for_network(&network, blocks) {
|
||||
for network in Network::iter() {
|
||||
for transaction in fake_v5_transactions_for_network(&network, network.block_iter()) {
|
||||
match check::has_inputs_and_outputs(&transaction) {
|
||||
Ok(()) => (),
|
||||
Err(TransactionError::NoInputs) | Err(TransactionError::NoOutputs) => (),
|
||||
|
@ -858,16 +853,12 @@ async fn v5_transaction_is_rejected_before_nu5_activation() {
|
|||
const V5_TRANSACTION_VERSION: u32 = 5;
|
||||
|
||||
let canopy = NetworkUpgrade::Canopy;
|
||||
let networks = vec![
|
||||
(Network::Mainnet, zebra_test::vectors::MAINNET_BLOCKS.iter()),
|
||||
(Network::Testnet, zebra_test::vectors::TESTNET_BLOCKS.iter()),
|
||||
];
|
||||
|
||||
for (network, blocks) in networks {
|
||||
for network in Network::iter() {
|
||||
let state_service = service_fn(|_| async { unreachable!("Service should not be called") });
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let transaction = fake_v5_transactions_for_network(&network, blocks)
|
||||
let transaction = fake_v5_transactions_for_network(&network, network.block_iter())
|
||||
.next_back()
|
||||
.expect("At least one fake V5 transaction in the test vectors");
|
||||
|
||||
|
@ -899,7 +890,7 @@ fn v5_transaction_is_accepted_after_nu5_activation_mainnet() {
|
|||
|
||||
#[test]
|
||||
fn v5_transaction_is_accepted_after_nu5_activation_testnet() {
|
||||
v5_transaction_is_accepted_after_nu5_activation_for_network(Network::Testnet)
|
||||
v5_transaction_is_accepted_after_nu5_activation_for_network(Network::new_default_testnet())
|
||||
}
|
||||
|
||||
fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network) {
|
||||
|
@ -1544,7 +1535,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejecte
|
|||
/// Test if V5 transaction with transparent funds is accepted.
|
||||
#[tokio::test]
|
||||
async fn v5_transaction_with_transparent_transfer_is_accepted() {
|
||||
let network = Network::Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let nu5_activation_height = network_upgrade
|
||||
|
@ -1601,12 +1592,13 @@ async fn v5_transaction_with_transparent_transfer_is_accepted() {
|
|||
/// accepted.
|
||||
#[tokio::test]
|
||||
async fn v5_transaction_with_last_valid_expiry_height() {
|
||||
let network = Network::new_default_testnet();
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(&Network::Testnet, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Nu5
|
||||
.activation_height(&Network::Testnet)
|
||||
.activation_height(&network)
|
||||
.expect("Nu5 activation height for testnet is specified");
|
||||
let fund_height = (block_height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -1646,12 +1638,13 @@ async fn v5_transaction_with_last_valid_expiry_height() {
|
|||
/// is equal to the height of the block the transaction belongs to.
|
||||
#[tokio::test]
|
||||
async fn v5_coinbase_transaction_expiry_height() {
|
||||
let network = Network::new_default_testnet();
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(&Network::Testnet, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Nu5
|
||||
.activation_height(&Network::Testnet)
|
||||
.activation_height(&network)
|
||||
.expect("Nu5 activation height for testnet is specified");
|
||||
|
||||
let (input, output) = mock_coinbase_transparent_output(block_height);
|
||||
|
@ -1761,12 +1754,14 @@ async fn v5_coinbase_transaction_expiry_height() {
|
|||
/// Tests if an expired non-coinbase V5 transaction is rejected.
|
||||
#[tokio::test]
|
||||
async fn v5_transaction_with_too_low_expiry_height() {
|
||||
let network = Network::new_default_testnet();
|
||||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(&Network::Testnet, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Nu5
|
||||
.activation_height(&Network::Testnet)
|
||||
.activation_height(&network)
|
||||
.expect("Nu5 activation height for testnet is specified");
|
||||
let fund_height = (block_height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -1864,7 +1859,7 @@ async fn v5_transaction_with_exceeding_expiry_height() {
|
|||
/// Test if V5 coinbase transaction is accepted.
|
||||
#[tokio::test]
|
||||
async fn v5_coinbase_transaction_is_accepted() {
|
||||
let network = Network::Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let nu5_activation_height = network_upgrade
|
||||
|
@ -1916,7 +1911,7 @@ async fn v5_coinbase_transaction_is_accepted() {
|
|||
/// script prevents spending the source UTXO.
|
||||
#[tokio::test]
|
||||
async fn v5_transaction_with_transparent_transfer_is_rejected_by_the_script() {
|
||||
let network = Network::Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let nu5_activation_height = network_upgrade
|
||||
|
@ -2759,8 +2754,9 @@ fn add_to_sprout_pool_after_nu() {
|
|||
fn coinbase_outputs_are_decryptable_for_historical_blocks() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
coinbase_outputs_are_decryptable_for_historical_blocks_for_network(Network::Mainnet)?;
|
||||
coinbase_outputs_are_decryptable_for_historical_blocks_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
coinbase_outputs_are_decryptable_for_historical_blocks_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -2844,7 +2840,7 @@ fn fill_action_with_note_encryption_test_vector(
|
|||
/// viewing key.
|
||||
#[test]
|
||||
fn coinbase_outputs_are_decryptable_for_fake_v5_blocks() {
|
||||
let network = Network::Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
|
||||
for v in zebra_test::vectors::ORCHARD_NOTE_ENCRYPTION_ZERO_VECTOR.iter() {
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
|
@ -2886,7 +2882,7 @@ fn coinbase_outputs_are_decryptable_for_fake_v5_blocks() {
|
|||
/// viewing key.
|
||||
#[test]
|
||||
fn shielded_outputs_are_not_decryptable_for_fake_v5_blocks() {
|
||||
let network = Network::Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
|
||||
for v in zebra_test::vectors::ORCHARD_NOTE_ENCRYPTION_VECTOR.iter() {
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
|
|
|
@ -38,7 +38,7 @@ async fn test_grpc_response_data() {
|
|||
zebra_test::net::random_known_port()
|
||||
),
|
||||
test_mocked_rpc_response_data_for_network(
|
||||
Network::Testnet,
|
||||
Network::new_default_testnet(),
|
||||
zebra_test::net::random_known_port()
|
||||
),
|
||||
);
|
||||
|
|
|
@ -14,8 +14,6 @@ use crate::{
|
|||
|
||||
use super::super::*;
|
||||
|
||||
use Network::*;
|
||||
|
||||
/// Test that `connect_isolated` sends a version message with minimal distinguishing features,
|
||||
/// when sent over TCP.
|
||||
#[tokio::test]
|
||||
|
@ -26,8 +24,9 @@ async fn connect_isolated_sends_anonymised_version_message_tcp() {
|
|||
return;
|
||||
}
|
||||
|
||||
connect_isolated_sends_anonymised_version_message_tcp_net(Mainnet).await;
|
||||
connect_isolated_sends_anonymised_version_message_tcp_net(Testnet).await;
|
||||
for network in Network::iter() {
|
||||
connect_isolated_sends_anonymised_version_message_tcp_net(network).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn connect_isolated_sends_anonymised_version_message_tcp_net(network: Network) {
|
||||
|
@ -82,9 +81,9 @@ async fn connect_isolated_sends_anonymised_version_message_tcp_net(network: Netw
|
|||
#[tokio::test]
|
||||
async fn connect_isolated_sends_anonymised_version_message_mem() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
connect_isolated_sends_anonymised_version_message_mem_net(Mainnet).await;
|
||||
connect_isolated_sends_anonymised_version_message_mem_net(Testnet).await;
|
||||
for network in Network::iter() {
|
||||
connect_isolated_sends_anonymised_version_message_mem_net(network).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn connect_isolated_sends_anonymised_version_message_mem_net(network: Network) {
|
||||
|
|
|
@ -80,8 +80,9 @@ async fn local_listener_unspecified_port_unspecified_addr_v4() {
|
|||
|
||||
// these tests might fail on machines with no configured IPv4 addresses
|
||||
// (localhost should be enough)
|
||||
local_listener_port_with("0.0.0.0:0".parse().unwrap(), Mainnet).await;
|
||||
local_listener_port_with("0.0.0.0:0".parse().unwrap(), Testnet).await;
|
||||
for network in Network::iter() {
|
||||
local_listener_port_with("0.0.0.0:0".parse().unwrap(), network).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that zebra-network discovers dynamic bind-to-all-interfaces listener ports,
|
||||
|
@ -101,8 +102,9 @@ async fn local_listener_unspecified_port_unspecified_addr_v6() {
|
|||
}
|
||||
|
||||
// these tests might fail on machines with no configured IPv6 addresses
|
||||
local_listener_port_with("[::]:0".parse().unwrap(), Mainnet).await;
|
||||
local_listener_port_with("[::]:0".parse().unwrap(), Testnet).await;
|
||||
for network in Network::iter() {
|
||||
local_listener_port_with("[::]:0".parse().unwrap(), network).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that zebra-network discovers dynamic localhost listener ports,
|
||||
|
@ -116,8 +118,9 @@ async fn local_listener_unspecified_port_localhost_addr_v4() {
|
|||
}
|
||||
|
||||
// these tests might fail on machines with unusual IPv4 localhost configs
|
||||
local_listener_port_with("127.0.0.1:0".parse().unwrap(), Mainnet).await;
|
||||
local_listener_port_with("127.0.0.1:0".parse().unwrap(), Testnet).await;
|
||||
for network in Network::iter() {
|
||||
local_listener_port_with("127.0.0.1:0".parse().unwrap(), network).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that zebra-network discovers dynamic localhost listener ports,
|
||||
|
@ -135,8 +138,9 @@ async fn local_listener_unspecified_port_localhost_addr_v6() {
|
|||
}
|
||||
|
||||
// these tests might fail on machines with no configured IPv6 addresses
|
||||
local_listener_port_with("[::1]:0".parse().unwrap(), Mainnet).await;
|
||||
local_listener_port_with("[::1]:0".parse().unwrap(), Testnet).await;
|
||||
for network in Network::iter() {
|
||||
local_listener_port_with("[::1]:0".parse().unwrap(), network).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that zebra-network propagates fixed localhost listener ports to the `AddressBook`.
|
||||
|
@ -150,8 +154,9 @@ async fn local_listener_fixed_port_localhost_addr_v4() {
|
|||
return;
|
||||
}
|
||||
|
||||
local_listener_port_with(SocketAddr::new(localhost_v4, random_known_port()), Mainnet).await;
|
||||
local_listener_port_with(SocketAddr::new(localhost_v4, random_known_port()), Testnet).await;
|
||||
for network in Network::iter() {
|
||||
local_listener_port_with(SocketAddr::new(localhost_v4, random_known_port()), network).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that zebra-network propagates fixed localhost listener ports to the `AddressBook`.
|
||||
|
@ -169,8 +174,9 @@ async fn local_listener_fixed_port_localhost_addr_v6() {
|
|||
return;
|
||||
}
|
||||
|
||||
local_listener_port_with(SocketAddr::new(localhost_v6, random_known_port()), Mainnet).await;
|
||||
local_listener_port_with(SocketAddr::new(localhost_v6, random_known_port()), Testnet).await;
|
||||
for network in Network::iter() {
|
||||
local_listener_port_with(SocketAddr::new(localhost_v6, random_known_port()), network).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test zebra-network with a peer limit of zero peers on mainnet.
|
||||
|
@ -207,8 +213,15 @@ async fn peer_limit_zero_testnet() {
|
|||
let unreachable_inbound_service =
|
||||
service_fn(|_| async { unreachable!("inbound service should never be called") });
|
||||
|
||||
let address_book =
|
||||
init_with_peer_limit(0, unreachable_inbound_service, Testnet, None, None).await;
|
||||
let address_book = init_with_peer_limit(
|
||||
0,
|
||||
unreachable_inbound_service,
|
||||
Network::new_default_testnet(),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
address_book.lock().unwrap().peers().count(),
|
||||
0,
|
||||
|
@ -247,7 +260,14 @@ async fn peer_limit_one_testnet() {
|
|||
|
||||
let nil_inbound_service = service_fn(|_| async { Ok(Response::Nil) });
|
||||
|
||||
let _ = init_with_peer_limit(1, nil_inbound_service, Testnet, None, None).await;
|
||||
let _ = init_with_peer_limit(
|
||||
1,
|
||||
nil_inbound_service,
|
||||
Network::new_default_testnet(),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Let the crawler run for a while.
|
||||
tokio::time::sleep(CRAWLER_TEST_DURATION).await;
|
||||
|
@ -285,7 +305,14 @@ async fn peer_limit_two_testnet() {
|
|||
|
||||
let nil_inbound_service = service_fn(|_| async { Ok(Response::Nil) });
|
||||
|
||||
let _ = init_with_peer_limit(2, nil_inbound_service, Testnet, None, None).await;
|
||||
let _ = init_with_peer_limit(
|
||||
2,
|
||||
nil_inbound_service,
|
||||
Network::new_default_testnet(),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Let the crawler run for a while.
|
||||
tokio::time::sleep(CRAWLER_TEST_DURATION).await;
|
||||
|
|
|
@ -207,7 +207,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn version_extremes_testnet() {
|
||||
version_extremes(&Testnet)
|
||||
version_extremes(&Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Test the min_specified_for_upgrade and min_specified_for_height functions for `network` with
|
||||
|
@ -235,7 +235,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn version_consistent_testnet() {
|
||||
version_consistent(&Testnet)
|
||||
version_consistent(&Network::new_default_testnet())
|
||||
}
|
||||
|
||||
/// Check that the min_specified_for_upgrade and min_specified_for_height functions
|
||||
|
|
|
@ -11,11 +11,8 @@ use insta::dynamic_redaction;
|
|||
use tower::buffer::Buffer;
|
||||
|
||||
use zebra_chain::{
|
||||
block::Block,
|
||||
chain_tip::mock::MockChainTip,
|
||||
parameters::Network::{Mainnet, Testnet},
|
||||
serialization::ZcashDeserializeInto,
|
||||
subtree::NoteCommitmentSubtreeData,
|
||||
block::Block, chain_tip::mock::MockChainTip, parameters::Network::Mainnet,
|
||||
serialization::ZcashDeserializeInto, subtree::NoteCommitmentSubtreeData,
|
||||
};
|
||||
use zebra_state::{ReadRequest, ReadResponse, MAX_ON_DISK_HEIGHT};
|
||||
use zebra_test::mock_service::MockService;
|
||||
|
@ -33,12 +30,13 @@ pub const EXCESSIVE_BLOCK_HEIGHT: u32 = MAX_ON_DISK_HEIGHT.0 + 1;
|
|||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_rpc_response_data() {
|
||||
let _init_guard = zebra_test::init();
|
||||
let default_testnet = Network::new_default_testnet();
|
||||
|
||||
tokio::join!(
|
||||
test_rpc_response_data_for_network(&Mainnet),
|
||||
test_rpc_response_data_for_network(&Testnet),
|
||||
test_rpc_response_data_for_network(&default_testnet),
|
||||
test_mocked_rpc_response_data_for_network(&Mainnet),
|
||||
test_mocked_rpc_response_data_for_network(&Testnet),
|
||||
test_mocked_rpc_response_data_for_network(&default_testnet),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ async fn rpc_getaddresstxids_invalid_arguments() {
|
|||
async fn rpc_getaddresstxids_response() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
for network in [Mainnet, Testnet] {
|
||||
for network in Network::iter() {
|
||||
let blocks: Vec<Arc<Block>> = network
|
||||
.blockchain_map()
|
||||
.iter()
|
||||
|
|
|
@ -28,10 +28,7 @@ use std::collections::BTreeMap;
|
|||
|
||||
use itertools::Itertools;
|
||||
|
||||
use zebra_chain::{
|
||||
block::Height,
|
||||
parameters::Network::{self, *},
|
||||
};
|
||||
use zebra_chain::{block::Height, parameters::Network};
|
||||
use zebra_state::{RawBytes, ReadDisk, SaplingScannedDatabaseIndex, TransactionLocation, KV};
|
||||
|
||||
use crate::storage::{db::ScannerDb, Storage};
|
||||
|
@ -45,8 +42,9 @@ use crate::storage::{db::ScannerDb, Storage};
|
|||
fn test_database_format() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
test_database_format_with_network(Mainnet);
|
||||
test_database_format_with_network(Testnet);
|
||||
for network in Network::iter() {
|
||||
test_database_format_with_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshot raw and typed database formats for `network`.
|
||||
|
|
|
@ -89,13 +89,14 @@ impl PreparedChain {
|
|||
// The history tree only works with Heartwood onward.
|
||||
// Since the network will be chosen later, we pick the larger
|
||||
// between the mainnet and testnet Heartwood activation heights.
|
||||
let main_height = NetworkUpgrade::Heartwood
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("must have height");
|
||||
let test_height = NetworkUpgrade::Heartwood
|
||||
.activation_height(&Network::Testnet)
|
||||
.expect("must have height");
|
||||
let height = std::cmp::max(main_height, test_height);
|
||||
let height = Network::iter()
|
||||
.map(|network| {
|
||||
NetworkUpgrade::Heartwood
|
||||
.activation_height(&network)
|
||||
.expect("must have height")
|
||||
})
|
||||
.max()
|
||||
.expect("Network::iter() must return non-empty iterator");
|
||||
|
||||
PreparedChain {
|
||||
ledger_strategy: Some(LedgerState::height_strategy(
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use zebra_chain::{
|
||||
block::Block,
|
||||
parameters::Network::{self, *},
|
||||
serialization::ZcashDeserializeInto,
|
||||
};
|
||||
use zebra_chain::{block::Block, parameters::Network, serialization::ZcashDeserializeInto};
|
||||
|
||||
use crate::{
|
||||
service::finalized_state::{
|
||||
|
@ -50,9 +46,9 @@ use crate::{
|
|||
#[test]
|
||||
fn test_raw_rocksdb_column_families() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
test_raw_rocksdb_column_families_with_network(Mainnet);
|
||||
test_raw_rocksdb_column_families_with_network(Testnet);
|
||||
for network in Network::iter() {
|
||||
test_raw_rocksdb_column_families_with_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshot raw column families for `network`.
|
||||
|
|
|
@ -37,7 +37,7 @@ use serde::Serialize;
|
|||
use zebra_chain::{
|
||||
block::{self, Block, Height, SerializedBlock},
|
||||
orchard,
|
||||
parameters::Network::{self, *},
|
||||
parameters::Network,
|
||||
sapling,
|
||||
serialization::{ZcashDeserializeInto, ZcashSerialize},
|
||||
transaction::{self, Transaction},
|
||||
|
@ -153,9 +153,9 @@ impl TransactionData {
|
|||
#[test]
|
||||
fn test_block_and_transaction_data() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
test_block_and_transaction_data_with_network(Mainnet);
|
||||
test_block_and_transaction_data_with_network(Testnet);
|
||||
for network in Network::iter() {
|
||||
test_block_and_transaction_data_with_network(network);
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshot finalized block and transaction data for `network`.
|
||||
|
|
|
@ -43,7 +43,7 @@ fn test_block_db_round_trip() {
|
|||
.map(|(_height, block)| block.zcash_deserialize_into().unwrap());
|
||||
|
||||
test_block_db_round_trip_with(&Mainnet, mainnet_test_cases);
|
||||
test_block_db_round_trip_with(&Testnet, testnet_test_cases);
|
||||
test_block_db_round_trip_with(&Network::new_default_testnet(), testnet_test_cases);
|
||||
|
||||
// It doesn't matter if these blocks are mainnet or testnet,
|
||||
// because there is no validation at this level of the database.
|
||||
|
|
|
@ -134,8 +134,9 @@ fn ord_matches_work() -> Result<()> {
|
|||
fn best_chain_wins() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
best_chain_wins_for_network(Network::Mainnet)?;
|
||||
best_chain_wins_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
best_chain_wins_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -172,8 +173,9 @@ fn best_chain_wins_for_network(network: Network) -> Result<()> {
|
|||
fn finalize_pops_from_best_chain() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
finalize_pops_from_best_chain_for_network(Network::Mainnet)?;
|
||||
finalize_pops_from_best_chain_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
finalize_pops_from_best_chain_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -219,8 +221,9 @@ fn finalize_pops_from_best_chain_for_network(network: Network) -> Result<()> {
|
|||
fn commit_block_extending_best_chain_doesnt_drop_worst_chains() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(Network::Mainnet)?;
|
||||
commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -264,10 +267,9 @@ fn commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(
|
|||
#[test]
|
||||
fn shorter_chain_can_be_best_chain() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
shorter_chain_can_be_best_chain_for_network(Network::Mainnet)?;
|
||||
shorter_chain_can_be_best_chain_for_network(Network::Testnet)?;
|
||||
|
||||
for network in Network::iter() {
|
||||
shorter_chain_can_be_best_chain_for_network(network)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -307,9 +309,9 @@ fn shorter_chain_can_be_best_chain_for_network(network: Network) -> Result<()> {
|
|||
#[test]
|
||||
fn longer_chain_with_more_work_wins() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
longer_chain_with_more_work_wins_for_network(Network::Mainnet)?;
|
||||
longer_chain_with_more_work_wins_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
longer_chain_with_more_work_wins_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -355,8 +357,9 @@ fn longer_chain_with_more_work_wins_for_network(network: Network) -> Result<()>
|
|||
fn equal_length_goes_to_more_work() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
equal_length_goes_to_more_work_for_network(Network::Mainnet)?;
|
||||
equal_length_goes_to_more_work_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
equal_length_goes_to_more_work_for_network(network)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -394,8 +397,9 @@ fn equal_length_goes_to_more_work_for_network(network: Network) -> Result<()> {
|
|||
|
||||
#[test]
|
||||
fn history_tree_is_updated() -> Result<()> {
|
||||
history_tree_is_updated_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Heartwood)?;
|
||||
history_tree_is_updated_for_network_upgrade(Network::Testnet, NetworkUpgrade::Heartwood)?;
|
||||
for network in Network::iter() {
|
||||
history_tree_is_updated_for_network_upgrade(network, NetworkUpgrade::Heartwood)?;
|
||||
}
|
||||
// TODO: we can't test other upgrades until we have a method for creating a FinalizedState
|
||||
// with a HistoryTree.
|
||||
Ok(())
|
||||
|
@ -497,8 +501,9 @@ fn history_tree_is_updated_for_network_upgrade(
|
|||
|
||||
#[test]
|
||||
fn commitment_is_validated() {
|
||||
commitment_is_validated_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Heartwood);
|
||||
commitment_is_validated_for_network_upgrade(Network::Testnet, NetworkUpgrade::Heartwood);
|
||||
for network in Network::iter() {
|
||||
commitment_is_validated_for_network_upgrade(network, NetworkUpgrade::Heartwood);
|
||||
}
|
||||
// TODO: we can't test other upgrades until we have a method for creating a FinalizedState
|
||||
// with a HistoryTree.
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ async fn check_transcripts_mainnet() -> Result<(), Report> {
|
|||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn check_transcripts_testnet() -> Result<(), Report> {
|
||||
check_transcripts(Network::Testnet).await
|
||||
check_transcripts(Network::new_default_testnet()).await
|
||||
}
|
||||
|
||||
#[spandoc::spandoc]
|
||||
|
|
|
@ -60,8 +60,9 @@ fn mempool_storage_basic() -> Result<()> {
|
|||
|
||||
// Test multiple times to catch intermittent bugs since eviction is randomized
|
||||
for _ in 0..10 {
|
||||
mempool_storage_basic_for_network(Network::Mainnet)?;
|
||||
mempool_storage_basic_for_network(Network::Testnet)?;
|
||||
for network in Network::iter() {
|
||||
mempool_storage_basic_for_network(network)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -236,10 +237,9 @@ fn mempool_storage_crud_same_effects_mainnet() {
|
|||
#[test]
|
||||
fn mempool_expired_basic() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
mempool_expired_basic_for_network(Network::Mainnet)?;
|
||||
mempool_expired_basic_for_network(Network::Testnet)?;
|
||||
|
||||
for network in Network::iter() {
|
||||
mempool_expired_basic_for_network(network)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -1051,7 +1051,7 @@ fn sync_one_checkpoint_mainnet() -> Result<()> {
|
|||
fn sync_one_checkpoint_testnet() -> Result<()> {
|
||||
sync_until(
|
||||
TINY_CHECKPOINT_TEST_HEIGHT,
|
||||
&Testnet,
|
||||
&Network::new_default_testnet(),
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
TINY_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1271,7 +1271,7 @@ fn sync_to_mandatory_checkpoint_mainnet() -> Result<()> {
|
|||
#[cfg_attr(feature = "test_sync_to_mandatory_checkpoint_testnet", test)]
|
||||
fn sync_to_mandatory_checkpoint_testnet() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
let network = Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
create_cached_database(network)
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ fn sync_past_mandatory_checkpoint_mainnet() -> Result<()> {
|
|||
#[cfg_attr(feature = "test_sync_past_mandatory_checkpoint_testnet", test)]
|
||||
fn sync_past_mandatory_checkpoint_testnet() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
let network = Testnet;
|
||||
let network = Network::new_default_testnet();
|
||||
sync_past_mandatory_checkpoint(network)
|
||||
}
|
||||
|
||||
|
@ -1322,7 +1322,10 @@ fn full_sync_mainnet() -> Result<()> {
|
|||
#[ignore]
|
||||
fn full_sync_testnet() -> Result<()> {
|
||||
// TODO: add "ZEBRA" at the start of this env var, to avoid clashes
|
||||
full_sync_test(Testnet, "FULL_SYNC_TESTNET_TIMEOUT_MINUTES")
|
||||
full_sync_test(
|
||||
Network::new_default_testnet(),
|
||||
"FULL_SYNC_TESTNET_TIMEOUT_MINUTES",
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "prometheus")]
|
||||
|
@ -2529,14 +2532,14 @@ async fn generate_checkpoints_mainnet() -> Result<()> {
|
|||
#[ignore]
|
||||
#[cfg(feature = "zebra-checkpoints")]
|
||||
async fn generate_checkpoints_testnet() -> Result<()> {
|
||||
common::checkpoints::run(Testnet).await
|
||||
common::checkpoints::run(Network::new_default_testnet()).await
|
||||
}
|
||||
|
||||
/// Check that new states are created with the current state format version,
|
||||
/// and that restarting `zebrad` doesn't change the format version.
|
||||
#[tokio::test]
|
||||
async fn new_state_format() -> Result<()> {
|
||||
for network in [Mainnet, Testnet] {
|
||||
for network in Network::iter() {
|
||||
state_format_test("new_state_format_test", &network, 2, None).await?;
|
||||
}
|
||||
|
||||
|
@ -2554,7 +2557,7 @@ async fn update_state_format() -> Result<()> {
|
|||
fake_version.minor = 0;
|
||||
fake_version.patch = 0;
|
||||
|
||||
for network in [Mainnet, Testnet] {
|
||||
for network in Network::iter() {
|
||||
state_format_test("update_state_format_test", &network, 3, Some(&fake_version)).await?;
|
||||
}
|
||||
|
||||
|
@ -2571,7 +2574,7 @@ async fn downgrade_state_format() -> Result<()> {
|
|||
fake_version.minor = u16::MAX.into();
|
||||
fake_version.patch = 0;
|
||||
|
||||
for network in [Mainnet, Testnet] {
|
||||
for network in Network::iter() {
|
||||
state_format_test(
|
||||
"downgrade_state_format_test",
|
||||
&network,
|
||||
|
|
|
@ -15,7 +15,7 @@ use tempfile::TempDir;
|
|||
|
||||
use zebra_chain::{
|
||||
block::{Height, HeightDiff, TryIntoHeight},
|
||||
parameters::Network::{self, *},
|
||||
parameters::Network,
|
||||
transparent::MIN_TRANSPARENT_COINBASE_MATURITY,
|
||||
};
|
||||
use zebra_consensus::MAX_CHECKPOINT_HEIGHT_GAP;
|
||||
|
@ -82,7 +82,7 @@ pub async fn run(network: Network) -> Result<()> {
|
|||
// Wait for the upgrade if needed.
|
||||
// Currently we only write an image for testnet, which is quick.
|
||||
// (Mainnet would need to wait at the end of this function, if the upgrade is long.)
|
||||
if network == Testnet {
|
||||
if network.is_a_test_network() {
|
||||
let state_version_message = wait_for_state_version_message(&mut zebrad)?;
|
||||
|
||||
// Before we write a cached state image, wait for a database upgrade.
|
||||
|
|
Loading…
Reference in New Issue