Skip to content

Commit 0f956a5

Browse files
committed
json: add Unknown variant to SoftforkType
Fixes #267. Without this variant, this call likely fails on some versions of bitcoind where other types of softfork deployments were active.
1 parent fc3a12d commit 0f956a5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

json/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,8 @@ pub struct Bip9SoftforkInfo {
878878
pub enum SoftforkType {
879879
Buried,
880880
Bip9,
881+
#[serde(other)]
882+
Unknown,
881883
}
882884

883885
/// Status of a softfork
@@ -2078,3 +2080,18 @@ where
20782080
}
20792081
Ok(Some(res))
20802082
}
2083+
2084+
#[cfg(test)]
2085+
mod tests {
2086+
use super::*;
2087+
2088+
#[test]
2089+
fn test_softfork_type() {
2090+
let buried: SoftforkType = serde_json::from_str("\"buried\"").unwrap();
2091+
assert_eq!(buried, SoftforkType::Buried);
2092+
let bip9: SoftforkType = serde_json::from_str("\"bip9\"").unwrap();
2093+
assert_eq!(bip9, SoftforkType::Bip9);
2094+
let unknown: SoftforkType = serde_json::from_str("\"bip8\"").unwrap();
2095+
assert_eq!(unknown, SoftforkType::Unknown);
2096+
}
2097+
}

0 commit comments

Comments
 (0)