zebra-chain 6.0.2

Core Zcash data structures
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//! Fixed test vectors for the network consensus parameters.

use zcash_protocol::consensus::{self as zp_consensus, NetworkConstants as _, Parameters};

use crate::{
    amount::{Amount, NonNegative},
    block::Height,
    parameters::{
        network::error::ParametersBuilderError,
        subsidy::{self, block_subsidy, funding_stream_values, FundingStreamReceiver},
        testnet::{
            self, ConfiguredActivationHeights, ConfiguredFundingStreamRecipient,
            ConfiguredFundingStreams, ConfiguredLockboxDisbursement, RegtestParameters,
            MAX_NETWORK_NAME_LENGTH, RESERVED_NETWORK_NAMES,
        },
        Network, NetworkUpgrade, MAINNET_ACTIVATION_HEIGHTS, TESTNET_ACTIVATION_HEIGHTS,
    },
};

/// Checks that every method in the `Parameters` impl for `zebra_chain::Network` has the same output
/// as the Parameters impl for `zcash_protocol::consensus::NetworkType` on Mainnet and the default Testnet.
#[test]
fn check_parameters_impl() {
    let zp_network_upgrades = [
        zp_consensus::NetworkUpgrade::Overwinter,
        zp_consensus::NetworkUpgrade::Sapling,
        zp_consensus::NetworkUpgrade::Blossom,
        zp_consensus::NetworkUpgrade::Heartwood,
        zp_consensus::NetworkUpgrade::Canopy,
        zp_consensus::NetworkUpgrade::Nu5,
    ];

    for (network, zp_network) in [
        (Network::Mainnet, zp_consensus::Network::MainNetwork),
        (
            Network::new_default_testnet(),
            zp_consensus::Network::TestNetwork,
        ),
    ] {
        for nu in zp_network_upgrades {
            let activation_height = network
                .activation_height(nu)
                .expect("must have activation height for past network upgrades");

            assert_eq!(
                activation_height,
                zp_network
                    .activation_height(nu)
                    .expect("must have activation height for past network upgrades"),
                "Parameters::activation_heights() outputs must match"
            );

            let activation_height: u32 = activation_height.into();

            for height in (activation_height - 1)..=(activation_height + 1) {
                for nu in zp_network_upgrades {
                    let height = zp_consensus::BlockHeight::from_u32(height);
                    assert_eq!(
                        network.is_nu_active(nu, height),
                        zp_network.is_nu_active(nu, height),
                        "Parameters::is_nu_active() outputs must match",
                    );
                }
            }
        }

        assert_eq!(
            network.coin_type(),
            zp_network.coin_type(),
            "Parameters::coin_type() outputs must match"
        );
        assert_eq!(
            network.hrp_sapling_extended_spending_key(),
            zp_network.hrp_sapling_extended_spending_key(),
            "Parameters::hrp_sapling_extended_spending_key() outputs must match"
        );
        assert_eq!(
            network.hrp_sapling_extended_full_viewing_key(),
            zp_network.hrp_sapling_extended_full_viewing_key(),
            "Parameters::hrp_sapling_extended_full_viewing_key() outputs must match"
        );
        assert_eq!(
            network.hrp_sapling_payment_address(),
            zp_network.hrp_sapling_payment_address(),
            "Parameters::hrp_sapling_payment_address() outputs must match"
        );
        assert_eq!(
            network.b58_pubkey_address_prefix(),
            zp_network.b58_pubkey_address_prefix(),
            "Parameters::b58_pubkey_address_prefix() outputs must match"
        );
        assert_eq!(
            network.b58_script_address_prefix(),
            zp_network.b58_script_address_prefix(),
            "Parameters::b58_script_address_prefix() outputs must match"
        );
    }
}

/// Checks that `NetworkUpgrade::activation_height()` returns the activation height of the next
/// network upgrade if it doesn't find an activation height for a prior network upgrade, that the
/// `Genesis` upgrade is always at `Height(0)`, and that the default Mainnet/Testnet/Regtest activation
/// heights are what's expected.
#[test]
fn activates_network_upgrades_correctly() {
    let expected_activation_height = 1;
    let network = testnet::Parameters::build()
        .with_activation_heights(ConfiguredActivationHeights {
            nu7: Some(expected_activation_height),
            ..Default::default()
        })
        .expect("failed to set activation heights")
        .clear_funding_streams()
        .to_network()
        .expect("failed to build configured network");

    let genesis_activation_height = NetworkUpgrade::Genesis
        .activation_height(&network)
        .expect("must return an activation height");

    assert_eq!(
        genesis_activation_height,
        Height(0),
        "activation height for all networks after Genesis and BeforeOverwinter should match NU5 activation height"
    );

    for nu in NetworkUpgrade::iter().skip(1) {
        let activation_height = nu
            .activation_height(&network)
            .expect("must return an activation height");

        assert_eq!(
            activation_height, Height(expected_activation_height),
            "activation height for all networks after Genesis and BeforeOverwinter \
            should match NU5 activation height, network_upgrade: {nu}, activation_height: {activation_height:?}"
        );
    }

    let expected_default_regtest_activation_heights = &[
        (Height(0), NetworkUpgrade::Genesis),
        (Height(1), NetworkUpgrade::Canopy),
        (Height(1), NetworkUpgrade::Nu7),
    ];

    for (network, expected_activation_heights) in [
        (Network::Mainnet, MAINNET_ACTIVATION_HEIGHTS),
        (Network::new_default_testnet(), TESTNET_ACTIVATION_HEIGHTS),
        (
            Network::new_regtest(
                ConfiguredActivationHeights {
                    nu7: Some(1),
                    ..Default::default()
                }
                .into(),
            ),
            expected_default_regtest_activation_heights,
        ),
    ] {
        assert_eq!(
            network.activation_list(),
            expected_activation_heights.iter().cloned().collect(),
            "network activation list should match expected activation heights"
        );
    }
}

/// Checks that configured testnet names are validated and used correctly.
#[test]
fn check_configured_network_name() {
    // Checks that reserved network names cannot be used for configured testnets.
    for reserved_network_name in RESERVED_NETWORK_NAMES {
        let err = testnet::Parameters::build()
            .with_network_name(reserved_network_name.to_string())
            .expect_err("should fail when using reserved network name");

        assert!(
            matches!(err, ParametersBuilderError::ReservedNetworkName { .. }),
            "unexpected error: {err:?}"
        )
    }

    // Check that max length is enforced
    let err = testnet::Parameters::build()
        .with_network_name("a".repeat(MAX_NETWORK_NAME_LENGTH + 1))
        .expect_err("should fail for invalid name");

    assert!(
        matches!(err, ParametersBuilderError::NetworkNameTooLong { .. }),
        "unexpected error: {err:?}"
    );

    // Check that network names may only contain alphanumeric characters and '_'.
    let err = testnet::Parameters::build()
        .with_network_name("!!!!non-alphanumeric-name".to_string())
        .expect_err("should fail for invalid name");

    assert!(
        matches!(err, ParametersBuilderError::InvalidCharacter),
        "unexpected error: {err:?}"
    );

    // Checks that network names are displayed correctly
    assert_eq!(
        Network::new_default_testnet().to_string(),
        "Testnet",
        "default testnet should be displayed as 'Testnet'"
    );
    assert_eq!(
        Network::Mainnet.to_string(),
        "Mainnet",
        "Mainnet should be displayed as 'Mainnet'"
    );
    assert_eq!(
        Network::new_regtest(Default::default()).to_string(),
        "Regtest",
        "Regtest should be displayed as 'Regtest'"
    );

    // Check that network name can contain alphanumeric characters and '_'.
    let expected_name = "ConfiguredTestnet_1";
    let network = testnet::Parameters::build()
        // Check that network name can contain `MAX_NETWORK_NAME_LENGTH` characters
        .with_network_name("a".repeat(MAX_NETWORK_NAME_LENGTH))
        .expect("failed to set first network name")
        .with_network_name(expected_name)
        .expect("failed to set expected network name")
        .to_network()
        .expect("failed to build configured network");

    // Check that configured network name is displayed
    assert_eq!(
        network.to_string(),
        expected_name,
        "network must be displayed as configured network name"
    );
}

/// Checks that configured testnet names are validated and used correctly.
#[test]
fn check_network_name() {
    // Checks that reserved network names cannot be used for configured testnets.
    for reserved_network_name in RESERVED_NETWORK_NAMES {
        let err = testnet::Parameters::build()
            .with_network_name(reserved_network_name.to_string())
            .expect_err("should fail when using reserved network name");

        assert!(
            matches!(err, ParametersBuilderError::ReservedNetworkName { .. }),
            "unexpected error: {err:?}"
        )
    }

    // Check that max length is enforced
    let err = testnet::Parameters::build()
        .with_network_name("a".repeat(MAX_NETWORK_NAME_LENGTH + 1))
        .expect_err("should fail for invalid name");

    assert!(
        matches!(err, ParametersBuilderError::NetworkNameTooLong { .. }),
        "unexpected error: {err:?}"
    );

    // Check that network names may only contain alphanumeric characters and '_'.
    let err = testnet::Parameters::build()
        .with_network_name("!!!!non-alphanumeric-name".to_string())
        .expect_err("should fail for invalid name");

    assert!(
        matches!(err, ParametersBuilderError::InvalidCharacter),
        "unexpected error: {err:?}"
    );

    // Checks that network names are displayed correctly
    assert_eq!(
        Network::new_default_testnet().to_string(),
        "Testnet",
        "default testnet should be displayed as 'Testnet'"
    );
    assert_eq!(
        Network::Mainnet.to_string(),
        "Mainnet",
        "Mainnet should be displayed as 'Mainnet'"
    );

    // TODO: Check Regtest

    // Check that network name can contain alphanumeric characters and '_'.
    let expected_name = "ConfiguredTestnet_1";
    let network = testnet::Parameters::build()
        // Check that network name can contain `MAX_NETWORK_NAME_LENGTH` characters
        .with_network_name("a".repeat(MAX_NETWORK_NAME_LENGTH))
        .expect("failed to set first network name")
        .with_network_name(expected_name)
        .expect("failed to set expected network name")
        .to_network()
        .expect("failed to build configured network");

    // Check that configured network name is displayed
    assert_eq!(
        network.to_string(),
        expected_name,
        "network must be displayed as configured network name"
    );
}

#[test]
fn check_full_activation_list() {
    let network = testnet::Parameters::build()
        .with_activation_heights(ConfiguredActivationHeights {
            // Update this to be the latest network upgrade in Zebra, and update
            // the code below to expect the latest number of network upgrades.
            nu7: Some(1),
            ..Default::default()
        })
        .expect("failed to set activation heights")
        .clear_funding_streams()
        .to_network()
        .expect("failed to build configured network");

    // We expect the first 11 network upgrades to be included, up to and including NU7
    let expected_network_upgrades = NetworkUpgrade::iter().take(11);
    let full_activation_list_network_upgrades: Vec<_> = network
        .full_activation_list()
        .into_iter()
        .map(|(_, nu)| nu)
        .collect();

    for expected_network_upgrade in expected_network_upgrades {
        assert!(
            full_activation_list_network_upgrades.contains(&expected_network_upgrade),
            "full activation list should contain expected network upgrade"
        );
    }
}

/// Tests that a set of constraints are enforced when building Testnet parameters,
/// and that funding stream configurations that should be valid can be built.
#[test]
fn check_configured_funding_stream_constraints() {
    let configured_funding_streams = [
        Default::default(),
        ConfiguredFundingStreams {
            height_range: Some(Height(2_000_000)..Height(2_200_000)),
            ..Default::default()
        },
        ConfiguredFundingStreams {
            height_range: Some(Height(20)..Height(30)),
            recipients: None,
        },
        ConfiguredFundingStreams {
            recipients: Some(vec![ConfiguredFundingStreamRecipient {
                receiver: FundingStreamReceiver::Ecc,
                numerator: 20,
                addresses: Some(
                    subsidy::constants::testnet::FUNDING_STREAM_ECC_ADDRESSES
                        .map(Into::into)
                        .to_vec(),
                ),
            }]),
            ..Default::default()
        },
        ConfiguredFundingStreams {
            recipients: Some(vec![ConfiguredFundingStreamRecipient {
                receiver: FundingStreamReceiver::Ecc,
                numerator: 100,
                addresses: Some(
                    subsidy::constants::testnet::FUNDING_STREAM_ECC_ADDRESSES
                        .map(Into::into)
                        .to_vec(),
                ),
            }]),
            ..Default::default()
        },
    ];

    for configured_funding_streams in configured_funding_streams {
        for is_pre_nu6 in [false, true] {
            let (network_funding_streams, default_funding_streams) = if is_pre_nu6 {
                (
                    testnet::Parameters::build()
                        .with_funding_streams(vec![configured_funding_streams.clone()])
                        .to_network()
                        .expect("failed to build configured network")
                        .all_funding_streams()[0]
                        .clone(),
                    subsidy::constants::testnet::FUNDING_STREAMS[0].clone(),
                )
            } else {
                (
                    testnet::Parameters::build()
                        .with_funding_streams(vec![
                            Default::default(),
                            configured_funding_streams.clone(),
                        ])
                        .to_network()
                        .expect("failed to build configured network")
                        .all_funding_streams()[1]
                        .clone(),
                    subsidy::constants::testnet::FUNDING_STREAMS[1].clone(),
                )
            };

            let expected_height_range = configured_funding_streams
                .height_range
                .clone()
                .unwrap_or(default_funding_streams.height_range().clone());

            assert_eq!(
                network_funding_streams.height_range().clone(),
                expected_height_range,
                "should use default start height when unconfigured"
            );

            let expected_recipients = configured_funding_streams
                .recipients
                .clone()
                .map(|recipients| {
                    recipients
                        .into_iter()
                        .map(ConfiguredFundingStreamRecipient::into_recipient)
                        .collect()
                })
                .unwrap_or(default_funding_streams.recipients().clone());

            assert_eq!(
                network_funding_streams.recipients().clone(),
                expected_recipients,
                "should use default recipients when unconfigured"
            );
        }
    }

    std::panic::set_hook(Box::new(|_| {}));

    // should panic when there are fewer addresses than the max funding stream address index.
    let expected_panic_num_addresses = std::panic::catch_unwind(|| {
        testnet::Parameters::build()
            .with_funding_streams(vec![ConfiguredFundingStreams {
                recipients: Some(vec![ConfiguredFundingStreamRecipient {
                    receiver: FundingStreamReceiver::Ecc,
                    numerator: 10,
                    addresses: Some(vec![]),
                }]),
                ..Default::default()
            }])
            .to_network()
    });

    // should panic when sum of numerators is greater than funding stream denominator.
    let expected_panic_numerator = std::panic::catch_unwind(|| {
        testnet::Parameters::build()
            .with_funding_streams(vec![ConfiguredFundingStreams {
                recipients: Some(vec![ConfiguredFundingStreamRecipient {
                    receiver: FundingStreamReceiver::Ecc,
                    numerator: 101,
                    addresses: Some(
                        subsidy::constants::testnet::FUNDING_STREAM_ECC_ADDRESSES
                            .map(Into::into)
                            .to_vec(),
                    ),
                }]),
                ..Default::default()
            }])
            .to_network()
    });

    // should panic when recipient addresses are for Mainnet.
    let expected_panic_wrong_addr_network = std::panic::catch_unwind(|| {
        testnet::Parameters::build()
            .with_funding_streams(vec![ConfiguredFundingStreams {
                recipients: Some(vec![ConfiguredFundingStreamRecipient {
                    receiver: FundingStreamReceiver::Ecc,
                    numerator: 10,
                    addresses: Some(
                        subsidy::constants::mainnet::FUNDING_STREAM_ECC_ADDRESSES
                            .map(Into::into)
                            .to_vec(),
                    ),
                }]),
                ..Default::default()
            }])
            .to_network()
    });

    // drop panic hook before expecting errors.
    let _ = std::panic::take_hook();

    expected_panic_num_addresses.expect_err("should panic when there are too few addresses");
    expected_panic_numerator.expect_err(
        "should panic when sum of numerators is greater than funding stream denominator",
    );
    expected_panic_wrong_addr_network
        .expect_err("should panic when recipient addresses are for Mainnet");
}

/// Check that `new_regtest()` constructs a network with the provided funding streams.
#[test]
fn check_configured_funding_stream_regtest() {
    let default_testnet = Network::new_default_testnet();

    let default_pre_nu6_funding_streams = &default_testnet.all_funding_streams()[0];
    let mut configured_pre_nu6_funding_streams =
        ConfiguredFundingStreams::from(default_pre_nu6_funding_streams);
    configured_pre_nu6_funding_streams.height_range = Some(
        default_pre_nu6_funding_streams.height_range().start
            ..(default_pre_nu6_funding_streams.height_range().start + 20).unwrap(),
    );

    let default_post_nu6_funding_streams = &default_testnet.all_funding_streams()[1];
    let mut configured_post_nu6_funding_streams =
        ConfiguredFundingStreams::from(default_post_nu6_funding_streams);
    configured_post_nu6_funding_streams.height_range = Some(
        default_post_nu6_funding_streams.height_range().start
            ..(default_post_nu6_funding_streams.height_range().start + 20).unwrap(),
    );

    let regtest = Network::new_regtest(RegtestParameters {
        activation_heights: (&default_testnet.activation_list()).into(),
        funding_streams: Some(vec![
            configured_pre_nu6_funding_streams.clone(),
            configured_post_nu6_funding_streams.clone(),
        ]),
        ..Default::default()
    });

    let expected_pre_nu6_funding_streams =
        configured_pre_nu6_funding_streams.into_funding_streams_unchecked();
    let expected_post_nu6_funding_streams =
        configured_post_nu6_funding_streams.into_funding_streams_unchecked();

    assert_eq!(
        &expected_pre_nu6_funding_streams,
        &regtest.all_funding_streams()[0]
    );
    assert_eq!(
        &expected_post_nu6_funding_streams,
        &regtest.all_funding_streams()[1]
    );
}

#[test]
fn sum_of_one_time_lockbox_disbursements_is_correct() {
    let mut configured_activation_heights: ConfiguredActivationHeights =
        Network::new_default_testnet().activation_list().into();
    configured_activation_heights.nu6_1 = Some(2_976_000 + 420_000);

    let custom_testnet = testnet::Parameters::build()
        .with_activation_heights(configured_activation_heights)
        .expect("failed to set activation heights")
        .with_lockbox_disbursements(vec![ConfiguredLockboxDisbursement {
            address: "t26ovBdKAJLtrvBsE2QGF4nqBkEuptuPFZz".to_string(),
            amount: Amount::new_from_zec(78_750),
        }])
        .to_network()
        .expect("failed to build configured network");

    for network in Network::iter().chain(std::iter::once(custom_testnet)) {
        let Some(nu6_1_activation_height) = NetworkUpgrade::Nu6_1.activation_height(&network)
        else {
            tracing::warn!(
                ?network,
                "skipping check as there's no NU6.1 activation height for this network"
            );
            continue;
        };

        let total_disbursement_output_value = network
            .lockbox_disbursements(nu6_1_activation_height)
            .into_iter()
            .map(|(_addr, expected_amount)| expected_amount)
            .try_fold(crate::amount::Amount::zero(), |a, b| a + b)
            .expect("sum of output values should be valid Amount");

        assert_eq!(
            total_disbursement_output_value,
            network.lockbox_disbursement_total_amount(nu6_1_activation_height),
            "sum of lockbox disbursement output values should match expected total"
        );

        let last_nu6_height = nu6_1_activation_height.previous().unwrap();
        let expected_total_lockbox_disbursement_value =
            lockbox_input_value(&network, last_nu6_height);

        assert_eq!(
            expected_total_lockbox_disbursement_value,
            network.lockbox_disbursement_total_amount(nu6_1_activation_height),
            "total lockbox disbursement value should match expected total"
        );
    }
}

/// Lockbox funding stream total input value for a block height.
///
/// Assumes a constant funding stream amount per block.
fn lockbox_input_value(network: &Network, height: Height) -> Amount<NonNegative> {
    let Some(nu6_activation_height) = NetworkUpgrade::Nu6.activation_height(network) else {
        return Amount::zero();
    };

    let total_block_subsidy = block_subsidy(height, network).unwrap();
    let &deferred_amount_per_block =
        funding_stream_values(nu6_activation_height, network, total_block_subsidy)
            .expect("we always expect a funding stream hashmap response even if empty")
            .get(&FundingStreamReceiver::Deferred)
            .expect("we expect a lockbox funding stream after NU5");

    let post_nu6_funding_stream_height_range = network.all_funding_streams()[1].height_range();

    // `min(height, last_height_with_deferred_pool_contribution) - (nu6_activation_height - 1)`,
    // We decrement NU6 activation height since it's an inclusive lower bound.
    // Funding stream height range end bound is not incremented since it's an exclusive end bound
    let num_blocks_with_lockbox_output = (height.0 + 1)
        .min(post_nu6_funding_stream_height_range.end.0)
        .saturating_sub(post_nu6_funding_stream_height_range.start.0);

    (deferred_amount_per_block * num_blocks_with_lockbox_output.into())
        .expect("lockbox input value should fit in Amount")
}

#[test]
fn funding_streams_default_values() {
    let _init_guard = zebra_test::init();

    let fs = vec![
        ConfiguredFundingStreams {
            height_range: Some(Height(1_028_500 - 1)..Height(2_796_000 - 1)),
            // Will read from existing values
            recipients: None,
        },
        ConfiguredFundingStreams {
            // Will read from existing values
            height_range: None,
            recipients: Some(vec![
                ConfiguredFundingStreamRecipient {
                    receiver: FundingStreamReceiver::Deferred,
                    numerator: 1,
                    addresses: None,
                },
                ConfiguredFundingStreamRecipient {
                    receiver: FundingStreamReceiver::MajorGrants,
                    numerator: 2,
                    addresses: Some(
                        subsidy::constants::testnet::POST_NU6_FUNDING_STREAM_FPF_ADDRESSES
                            .iter()
                            .map(|s| s.to_string())
                            .collect(),
                    ),
                },
            ]),
        },
    ];

    let network = testnet::Parameters::build()
        .with_funding_streams(fs)
        .to_network()
        .expect("failed to build configured network");

    // Check if value hasn't changed
    assert_eq!(
        network.all_funding_streams()[0].height_range().clone(),
        Height(1_028_500 - 1)..Height(2_796_000 - 1)
    );
    // Check if value was copied from default
    assert_eq!(
        network.all_funding_streams()[0]
            .recipients()
            .get(&FundingStreamReceiver::ZcashFoundation)
            .unwrap()
            .addresses(),
        subsidy::constants::testnet::FUNDING_STREAMS[0]
            .recipients()
            .get(&FundingStreamReceiver::ZcashFoundation)
            .unwrap()
            .addresses()
    );
    // Check if value was copied from default
    assert_eq!(
        network.all_funding_streams()[1].height_range(),
        subsidy::constants::testnet::FUNDING_STREAMS[1].height_range()
    );
    // Check if value hasn't changed
    assert_eq!(
        network.all_funding_streams()[1]
            .recipients()
            .get(&FundingStreamReceiver::Deferred)
            .unwrap()
            .numerator(),
        1
    );
}