Skip to content

Commit

Permalink
Improve variants for parsing network (#184)
Browse files Browse the repository at this point in the history
* Improve variants for parsing network

* Update changelog

* Pin lightning_encoding to not bump MSRV
  • Loading branch information
h4sh3d authored Nov 30, 2021
1 parent 9d0c91d commit 5bbae9a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Improve variants for `FromStr` network parsing ([#184](https://github.com/farcaster-project/farcaster-core/pull/184))

## [0.4.0] - 2021-11-17

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bitvec = { version = "0.22.3" }
fixed-hash = { version = "0.7.0", default-features = false }
hex = "0.4.3"
inet2_addr = { version = "0.5.0", default-features = false, features = ["tor", "strict_encoding"] }
lightning_encoding = "0.5.0-beta.3"
lightning_encoding = "=0.5.0-beta.3"
serde_crate = { package = "serde", version = "1", features = ["derive"], optional = true }
strict_encoding = "1.7.4"
strict_encoding_derive = "1.7.4"
Expand Down
14 changes: 11 additions & 3 deletions src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ impl FromStr for Network {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"Mainnet" => Ok(Network::Mainnet),
"Testnet" => Ok(Network::Testnet),
"Local" => Ok(Network::Local),
"Mainnet" | "mainnet" => Ok(Network::Mainnet),
"Testnet" | "testnet" => Ok(Network::Testnet),
"Local" | "local" => Ok(Network::Local),
_ => Err(consensus::Error::UnknownType),
}
}
Expand Down Expand Up @@ -354,6 +354,14 @@ mod tests {
}
}

#[test]
fn parse_network() {
for s in ["Mainnet", "mainnet", "Testnet", "testnet", "Local", "local"].iter() {
let parse = Network::from_str(s);
assert!(parse.is_ok());
}
}

#[test]
fn display_fee_strategy() {
let strategy = FeeStrategy::Fixed(SatPerVByte::from_sat(100));
Expand Down

0 comments on commit 5bbae9a

Please sign in to comment.