mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 17:11:05 +00:00
FRAME: Fix the Referenda confirming alarm (#13704)
* Fix the Referenda confirming alarm
* Add minimal regression test
This fails on 40e1704e1c since the
downwards rounding voids the curve delay.
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
---------
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -1206,7 +1206,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
|||||||
let until_approval = track.min_approval.delay(approval);
|
let until_approval = track.min_approval.delay(approval);
|
||||||
let until_support = track.min_support.delay(support);
|
let until_support = track.min_support.delay(support);
|
||||||
let offset = until_support.max(until_approval);
|
let offset = until_support.max(until_approval);
|
||||||
deciding.since.saturating_add(offset * track.decision_period)
|
deciding.since.saturating_add(offset.mul_ceil(track.decision_period))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,24 @@ fn alarm_interval_works() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn decision_time_is_correct() {
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
let decision_time = |since: u64| {
|
||||||
|
Pallet::<Test>::decision_time(
|
||||||
|
&DecidingStatus { since: since.into(), confirming: None },
|
||||||
|
&Tally { ayes: 100, nays: 5 },
|
||||||
|
TestTracksInfo::tracks()[0].0,
|
||||||
|
&TestTracksInfo::tracks()[0].1,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
for i in 0u64..=100 {
|
||||||
|
assert!(decision_time(i) > i, "The decision time should be delayed by the curve");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn auto_timeout_should_happen_with_nothing_but_submit() {
|
fn auto_timeout_should_happen_with_nothing_but_submit() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
|
|||||||
Reference in New Issue
Block a user