Skip to content

Commit

Permalink
Fix issue with chains which don't have 'expedited_voting_period'
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 committed Nov 10, 2023
1 parent 1e63ae9 commit fb84da0
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tools/test-framework/src/chain/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,23 @@ pub fn set_voting_period(genesis: &mut serde_json::Value, period: u64) -> Result
)
.ok_or_else(|| eyre!("failed to update voting_period in genesis file"))?;

let expedited_voting_period = genesis
let maybe_expedited_voting_period = genesis
.get_mut("app_state")
.and_then(|app_state| app_state.get_mut("gov"))
.and_then(|gov| get_mut_with_fallback(gov, "params", "expedited_voting_period"))
.and_then(|voting_params| voting_params.as_object_mut())
.ok_or_else(|| eyre!("failed to get voting_params in genesis file"))?;

expedited_voting_period
.insert(
"expedited_voting_period".to_owned(),
serde_json::Value::String(expedited_period),
)
.ok_or_else(|| eyre!("failed to update expedited_voting_period in genesis file"))?;
.and_then(|gov| get_mut_with_fallback(gov, "params", "expedited_voting_period"));

if let Some(expedited_voting_period) = maybe_expedited_voting_period {
let expedited_voting_period = expedited_voting_period
.as_object_mut()
.ok_or_else(|| eyre!("failed to get voting_params in genesis file"))?;

expedited_voting_period
.insert(
"expedited_voting_period".to_owned(),
serde_json::Value::String(expedited_period),
)
.ok_or_else(|| eyre!("failed to update expedited_voting_period in genesis file"))?;
}

Ok(())
}
Expand Down

0 comments on commit fb84da0

Please sign in to comment.