Simplifies the `ParametersBuilder::activation_heights()` method and removes an unnecessary test.
This commit is contained in:
parent
0abe87312b
commit
1dfad530b1
|
@ -60,7 +60,8 @@ impl ParametersBuilder {
|
|||
pub fn activation_heights(
|
||||
mut self,
|
||||
ConfiguredActivationHeights {
|
||||
before_overwinter,
|
||||
// TODO: Find out if `BeforeOverwinter` is required at Height(1), remove this filter if it's not required to be at Height(1)
|
||||
before_overwinter: _,
|
||||
overwinter,
|
||||
sapling,
|
||||
blossom,
|
||||
|
@ -75,15 +76,14 @@ impl ParametersBuilder {
|
|||
//
|
||||
// These must be in order so that later network upgrades overwrite prior ones
|
||||
// if multiple network upgrades are configured with the same activation height.
|
||||
let activation_heights: BTreeMap<_, _> = before_overwinter
|
||||
let activation_heights: BTreeMap<_, _> = overwinter
|
||||
.into_iter()
|
||||
.map(|h| (h, BeforeOverwinter))
|
||||
.chain(overwinter.into_iter().map(|h| (h, Overwinter)))
|
||||
.map(|h| (h, Overwinter))
|
||||
.chain(sapling.into_iter().map(|h| (h, Sapling)))
|
||||
.chain(blossom.into_iter().map(|h| (h, Blossom)))
|
||||
.chain(heartwood.into_iter().map(|h| (h, Heartwood)))
|
||||
.chain(canopy.into_iter().map(|h| (h, Canopy)))
|
||||
.chain(nu5.into_iter().map(|h| (h, Nu5))) // TODO: Find out if `BeforeOverwinter` is required at Height(1), remove this filter if it's not required to be at Height(1)
|
||||
.chain(nu5.into_iter().map(|h| (h, Nu5)))
|
||||
.filter(|&(_, nu)| nu != NetworkUpgrade::BeforeOverwinter)
|
||||
.map(|(h, nu)| (h.try_into().expect("activation height must be valid"), nu))
|
||||
.collect();
|
||||
|
|
|
@ -125,27 +125,3 @@ fn activates_network_upgrades_correctly() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks that there are no duplicate activation heights when using configured activation heights.
|
||||
// TODO: Convert this to a proptest.
|
||||
#[test]
|
||||
fn no_duplicate_activation_heights() {
|
||||
let network = testnet::Parameters::build()
|
||||
.activation_heights(ConfiguredActivationHeights {
|
||||
overwinter: Some(2),
|
||||
..Default::default()
|
||||
})
|
||||
.to_network();
|
||||
|
||||
for target_nu in NETWORK_UPGRADES_IN_ORDER.into_iter().skip(1) {
|
||||
assert!(
|
||||
network
|
||||
.activation_list()
|
||||
.into_iter()
|
||||
.filter(|&(_h, nu)| nu == target_nu)
|
||||
.count()
|
||||
<= 1,
|
||||
"there should be at most 1 activation height per possible network upgrade"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue