Skip to content

Commit 2bb341b

Browse files
committed
Add test for BTC/kb conversion
Add a test to check that we can convert 0.000001 BTC/kB to sats i.e., 100 sats per kB (note naive div / 1000 truncates to zero).
1 parent eea11c3 commit 2bb341b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

types/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,16 @@ impl ScriptSig {
288288
ScriptBuf::from_hex(&self.hex)
289289
}
290290
}
291+
292+
#[cfg(test)]
293+
mod tests {
294+
use super::*;
295+
296+
#[test]
297+
fn convert_btc_per_kb() {
298+
// per kB = per kvB because this is a conversion of legacy transaction weights.
299+
let f: f64 = 0.000001;
300+
let got = btc_per_kb(f).unwrap();
301+
assert_eq!(got, Some(FeeRate::from_sat_per_kwu(25)))
302+
}
303+
}

0 commit comments

Comments
 (0)