Adds `full_activation_list()` method and uses it in `getblockchaininfo` (#8699)
This commit is contained in:
parent
bbb710f24c
commit
6b9b9942bf
|
@ -270,3 +270,28 @@ fn check_network_name() {
|
|||
"network must be displayed as configured network name"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_full_activation_list() {
|
||||
let network = testnet::Parameters::build()
|
||||
.with_activation_heights(ConfiguredActivationHeights {
|
||||
nu5: Some(1),
|
||||
..Default::default()
|
||||
})
|
||||
.to_network();
|
||||
|
||||
// We expect the first 8 network upgrades to be included, up to NU5
|
||||
let expected_network_upgrades = &NETWORK_UPGRADES_IN_ORDER[..8];
|
||||
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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,6 +258,9 @@ impl Network {
|
|||
/// When the environment variable TEST_FAKE_ACTIVATION_HEIGHTS is set
|
||||
/// and it's a test build, this returns a list of fake activation heights
|
||||
/// used by some tests.
|
||||
///
|
||||
/// Note: This skips implicit network upgrade activations, use [`Network::full_activation_list`]
|
||||
/// to get an explicit list of all network upgrade activations.
|
||||
pub fn activation_list(&self) -> BTreeMap<block::Height, NetworkUpgrade> {
|
||||
match self {
|
||||
// To prevent accidentally setting this somehow, only check the env var
|
||||
|
@ -283,6 +286,15 @@ impl Network {
|
|||
Testnet(params) => params.activation_heights().clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a vector of all implicit and explicit network upgrades for `network`,
|
||||
/// in ascending height order.
|
||||
pub fn full_activation_list(&self) -> Vec<(block::Height, NetworkUpgrade)> {
|
||||
NETWORK_UPGRADES_IN_ORDER
|
||||
.into_iter()
|
||||
.map_while(|nu| Some((NetworkUpgrade::activation_height(&nu, self)?, nu)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkUpgrade {
|
||||
|
|
|
@ -541,7 +541,7 @@ where
|
|||
//
|
||||
// Get the network upgrades in height order, like `zcashd`.
|
||||
let mut upgrades = IndexMap::new();
|
||||
for (activation_height, network_upgrade) in network.activation_list() {
|
||||
for (activation_height, network_upgrade) in network.full_activation_list() {
|
||||
// Zebra defines network upgrades based on incompatible consensus rule changes,
|
||||
// but zcashd defines them based on ZIPs.
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue