mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Use sensible maths for from_rational (#13660)
* Use sensible maths for from_rational * Fixes * Fixes * More fixes * Remove debugging * Add fuzzer tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Prevent panics Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clean up old code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test all rounding modes of from_rational Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clean up code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Prevent panics" This reverts commit 7e88ac76138a1b590e68b68318505b69efe1e1f6. * fix imports Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * cleanup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fuzz test multiply_rational Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix import Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Return None in multiply_rational on zero div 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:
@@ -5461,7 +5461,7 @@ fn proportional_ledger_slash_works() {
|
||||
ledger.active = unit;
|
||||
ledger.total = unit * 4 + value;
|
||||
// When
|
||||
assert_eq!(ledger.slash(slash, 0, 0), slash - 5);
|
||||
assert_eq!(ledger.slash(slash, 0, 0), slash);
|
||||
// Then
|
||||
// The amount slashed out of `unit`
|
||||
let affected_balance = value + unit * 4;
|
||||
@@ -5477,12 +5477,12 @@ fn proportional_ledger_slash_works() {
|
||||
value - value_slash
|
||||
};
|
||||
assert_eq!(ledger.active, unit_slashed);
|
||||
assert_eq!(ledger.unlocking, vec![c(5, value_slashed)]);
|
||||
assert_eq!(ledger.total, value_slashed);
|
||||
assert_eq!(ledger.unlocking, vec![c(5, value_slashed), c(7, 32)]);
|
||||
assert_eq!(ledger.total, value_slashed + 32);
|
||||
assert_eq!(LedgerSlashPerEra::get().0, 0);
|
||||
assert_eq!(
|
||||
LedgerSlashPerEra::get().1,
|
||||
BTreeMap::from([(4, 0), (5, value_slashed), (6, 0), (7, 0)])
|
||||
BTreeMap::from([(4, 0), (5, value_slashed), (6, 0), (7, 32)])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user