Merge rust-bitcoin/rust-bitcoin#1647: Fix absolute lock time examples and tests
c3cc9e52ab
Fix absolute lock time examples and tests (Tobin C. Harding) Pull request description: An absolute lock time of 100 is nonsensical because we are well past block 100. This value was used because it makes sense for _relative_ locktimes but for absolute lock times it makes the examples and tests slightly confusing. ACKs for top commit: apoelstra: ACKc3cc9e52ab
Kixunil: ACKc3cc9e52ab
Tree-SHA512: f490ef111bce0989c4ce8300c507c21b454448af4a91b9ef7a2fc05407411ca8721c9caa3dd1f0e8c0c133c4892c5c512f2d881af2cc67ae843d87eacae76ef1
This commit is contained in:
commit
e4e7449562
|
@ -62,8 +62,8 @@ pub const LOCK_TIME_THRESHOLD: u32 = 500_000_000;
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
||||||
/// # let n = LockTime::from_consensus(100); // n OP_CHECKLOCKTIMEVERIFY
|
/// # let n = LockTime::from_consensus(741521); // n OP_CHECKLOCKTIMEVERIFY
|
||||||
/// # let lock_time = LockTime::from_consensus(100); // nLockTime
|
/// # let lock_time = LockTime::from_consensus(741521); // nLockTime
|
||||||
/// // To compare absolute lock times there are various `is_satisfied_*` methods, you may also use:
|
/// // To compare absolute lock times there are various `is_satisfied_*` methods, you may also use:
|
||||||
/// let is_satisfied = match (n, lock_time) {
|
/// let is_satisfied = match (n, lock_time) {
|
||||||
/// (Blocks(n), Blocks(lock_time)) => n <= lock_time,
|
/// (Blocks(n), Blocks(lock_time)) => n <= lock_time,
|
||||||
|
@ -226,8 +226,8 @@ impl LockTime {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
||||||
/// let lock_time = LockTime::from_consensus(100);
|
/// let lock_time = LockTime::from_consensus(741521);
|
||||||
/// let check = LockTime::from_consensus(100 + 1);
|
/// let check = LockTime::from_consensus(741521 + 1);
|
||||||
/// assert!(lock_time.is_implied_by(check));
|
/// assert!(lock_time.is_implied_by(check));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -255,8 +255,8 @@ impl LockTime {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
/// # use bitcoin::absolute::{LockTime, LockTime::*};
|
||||||
/// # let n = LockTime::from_consensus(100); // n OP_CHECKLOCKTIMEVERIFY
|
/// # let n = LockTime::from_consensus(741521); // n OP_CHECKLOCKTIMEVERIFY
|
||||||
/// # let lock_time = LockTime::from_consensus(100 + 1); // nLockTime
|
/// # let lock_time = LockTime::from_consensus(741521 + 1); // nLockTime
|
||||||
///
|
///
|
||||||
/// let is_satisfied = match (n, lock_time) {
|
/// let is_satisfied = match (n, lock_time) {
|
||||||
/// (Blocks(n), Blocks(lock_time)) => n <= lock_time,
|
/// (Blocks(n), Blocks(lock_time)) => n <= lock_time,
|
||||||
|
@ -764,12 +764,12 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_and_alternate() {
|
fn display_and_alternate() {
|
||||||
let n = LockTime::from_consensus(100);
|
let n = LockTime::from_consensus(741521);
|
||||||
let s = format!("{}", n);
|
let s = format!("{}", n);
|
||||||
assert_eq!(&s, "100");
|
assert_eq!(&s, "741521");
|
||||||
|
|
||||||
let got = format!("{:#}", n);
|
let got = format!("{:#}", n);
|
||||||
assert_eq!(got, "block-height 100");
|
assert_eq!(got, "block-height 741521");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue