diff --git a/crates/core/component/chain/src/component/view.rs b/crates/core/component/chain/src/component/view.rs index f6f867319a..12abc8ae5f 100644 --- a/crates/core/component/chain/src/component/view.rs +++ b/crates/core/component/chain/src/component/view.rs @@ -71,7 +71,8 @@ pub trait StateReadExt: StateRead { .await? .ok_or_else(|| anyhow!("Missing block_timestamp"))?; - Ok(Time::from_str(×tamp_string).unwrap()) + Ok(Time::from_str(×tamp_string) + .context("block_timestamp was an invalid RFC3339 time string")?) } /// Checks a provided chain_id against the chain state. diff --git a/crates/core/component/chain/src/genesis/app_state.rs b/crates/core/component/chain/src/genesis/app_state.rs index 07b67c1fe5..ee5221c345 100644 --- a/crates/core/component/chain/src/genesis/app_state.rs +++ b/crates/core/component/chain/src/genesis/app_state.rs @@ -1,3 +1,4 @@ +use anyhow::Context; use penumbra_proto::{ core::chain::v1alpha1 as pb, core::stake::v1alpha1 as pb_stake, DomainType, TypeUrl, }; @@ -27,23 +28,39 @@ impl Default for AppState { allocations: vec![ Allocation { amount: 1000u128.into(), - denom: "penumbra".parse().unwrap(), - address: crate::test_keys::ADDRESS_0_STR.parse().unwrap(), + denom: "penumbra" + .parse() + .expect("hardcoded \"penumbra\" denom should be parseable"), + address: crate::test_keys::ADDRESS_0_STR + .parse() + .expect("hardcoded test address should be valid"), }, Allocation { amount: 100u128.into(), - denom: "test_usd".parse().unwrap(), - address: crate::test_keys::ADDRESS_0_STR.parse().unwrap(), + denom: "test_usd" + .parse() + .expect("hardcoded \"test_usd\" denom should be parseable"), + address: crate::test_keys::ADDRESS_0_STR + .parse() + .expect("hardcoded test address should be valid"), }, Allocation { amount: 100u128.into(), - denom: "gm".parse().unwrap(), - address: crate::test_keys::ADDRESS_1_STR.parse().unwrap(), + denom: "gm" + .parse() + .expect("hardcoded \"gm\" denom should be parseable"), + address: crate::test_keys::ADDRESS_1_STR + .parse() + .expect("hardcoded test address should be valid"), }, Allocation { amount: 100u128.into(), - denom: "gn".parse().unwrap(), - address: crate::test_keys::ADDRESS_1_STR.parse().unwrap(), + denom: "gn" + .parse() + .expect("hardcoded \"gn\" denom should be parseable"), + address: crate::test_keys::ADDRESS_1_STR + .parse() + .expect("hardcoded test address should be valid"), }, ], } @@ -65,7 +82,10 @@ impl TryFrom for AppState { fn try_from(msg: pb::GenesisAppState) -> Result { Ok(AppState { - chain_params: msg.chain_params.unwrap().try_into()?, + chain_params: msg + .chain_params + .context("chain params not present in protobuf message")? + .try_into()?, validators: msg .validators .into_iter() diff --git a/crates/core/component/chain/src/lib.rs b/crates/core/component/chain/src/lib.rs index 12132b6ecc..faa4df4200 100644 --- a/crates/core/component/chain/src/lib.rs +++ b/crates/core/component/chain/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::unwrap_used)] #![cfg_attr(docsrs, feature(doc_cfg))] mod epoch; @@ -33,11 +34,25 @@ pub mod test_keys { /// These addresses both correspond to the test wallet above. pub const ADDRESS_1_STR: &str = "penumbrav2t1gl609fq6xzjcqn3hz3crysw2s0nkt330lyhaq403ztmrm3yygsgdklt9uxfs0gedwp6sypp5k5ln9t62lvs9t0a990q832wnxak8r939g5u6uz5aessd8saxvv7ewlz4hhqnws"; - pub static ADDRESS_0: Lazy
= Lazy::new(|| ADDRESS_0_STR.parse().unwrap()); - pub static ADDRESS_1: Lazy
= Lazy::new(|| ADDRESS_1_STR.parse().unwrap()); + pub static ADDRESS_0: Lazy
= Lazy::new(|| { + ADDRESS_0_STR + .parse() + .expect("hardcoded test addresses should be valid") + }); + pub static ADDRESS_1: Lazy
= Lazy::new(|| { + ADDRESS_1_STR + .parse() + .expect("hardcoded test addresses should be valid") + }); - pub static SPEND_KEY: Lazy = - Lazy::new(|| SpendKey::from_seed_phrase(SEED_PHRASE.parse().unwrap(), 0)); + pub static SPEND_KEY: Lazy = Lazy::new(|| { + SpendKey::from_seed_phrase( + SEED_PHRASE + .parse() + .expect("hardcoded test seed phrase should be valid"), + 0, + ) + }); pub static FULL_VIEWING_KEY: Lazy = Lazy::new(|| SPEND_KEY.full_viewing_key().clone());