Fix last tests broken by secondary PoW factor adjustment

This commit is contained in:
Ignotus Peverell 2018-10-15 22:53:28 +00:00
parent 3c6b5a0a9c
commit a41022f1e3
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
2 changed files with 5 additions and 4 deletions
core/tests
wallet/tests/common

View file

@ -408,17 +408,17 @@ fn next_target_adjustment() {
let diff_one = Difficulty::one();
assert_eq!(
next_difficulty(1, vec![HeaderInfo::from_ts_diff(cur_time, diff_one)]),
HeaderInfo::from_diff_scaling(Difficulty::one(), 1),
HeaderInfo::from_diff_scaling(Difficulty::one(), 4),
);
assert_eq!(
next_difficulty(1, vec![HeaderInfo::new(cur_time, diff_one, 10, true)]),
HeaderInfo::from_diff_scaling(Difficulty::one(), 1),
HeaderInfo::from_diff_scaling(Difficulty::one(), 4),
);
let mut hi = HeaderInfo::from_diff_scaling(diff_one, 1);
assert_eq!(
next_difficulty(1, repeat(60, hi.clone(), DIFFICULTY_ADJUST_WINDOW, None)),
HeaderInfo::from_diff_scaling(Difficulty::one(), 1),
HeaderInfo::from_diff_scaling(Difficulty::one(), 4),
);
hi.is_secondary = true;
assert_eq!(
@ -428,7 +428,7 @@ fn next_target_adjustment() {
hi.secondary_scaling = 100;
assert_eq!(
next_difficulty(1, repeat(60, hi.clone(), DIFFICULTY_ADJUST_WINDOW, None)),
HeaderInfo::from_diff_scaling(Difficulty::one(), 93),
HeaderInfo::from_diff_scaling(Difficulty::one(), 106),
);
// Check we don't get stuck on difficulty 1

View file

@ -97,6 +97,7 @@ pub fn add_block_with_reward(chain: &Chain, txs: Vec<&Transaction>, reward: CbDa
(output, kernel),
).unwrap();
b.header.timestamp = prev.timestamp + Duration::seconds(60);
b.header.pow.scaling_difficulty = next_header_info.secondary_scaling;
chain.set_txhashset_roots(&mut b, false).unwrap();
pow::pow_size(
&mut b.header,