Skip to content

Commit

Permalink
blockchain: remove unnecessary conversion to u128 [tiny change]
Browse files Browse the repository at this point in the history
Left over from previous commit. Conversion to u128 in the match
statement is unnecessary. Get rid of it and with that move the
conversion down to call to test_update.
  • Loading branch information
mina86 authored Oct 31, 2023
1 parent 3cf272c commit 4bc35a2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions common/blockchain/src/candidates/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,16 @@ impl TestCtx {
fn test(&mut self, pubkey: u8, stake: u8) {
let old_state = self.candidates.clone();
let pubkey = MockPubKey(u32::from(pubkey));
let stake = u128::from(stake);

let this = self as *mut TestCtx;
let res = std::panic::catch_unwind(|| {
// SAFETY: It’s test code. I don’t care. ;) It’s probably safe but
// self.candidates may be in inconsistent state. This is fine since
// we’re panicking anyway.
let this = unsafe { &mut *this };
match u128::from(stake) {
match stake {
0 => this.test_remove(pubkey),
_ => this.test_update(pubkey.clone(), stake),
_ => this.test_update(pubkey.clone(), u128::from(stake)),
}
});

Expand Down

0 comments on commit 4bc35a2

Please sign in to comment.