Skip to content
Snippets Groups Projects
Commit f2561adb authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

fix clippy

parent 71a378f2
No related branches found
No related tags found
1 merge request!176gtest genesis parsing
Pipeline #33249 waiting for manual action
......@@ -176,7 +176,7 @@ pub fn build_genesis(
// IDENTITIES //
for (name, identity) in &genesis_data.identities {
// identity name
if !validate_idty_name(&name) {
if !validate_idty_name(name) {
return Err(format!("Identity name '{}' is invalid", &name));
}
......@@ -239,10 +239,8 @@ pub fn build_genesis(
value: common_runtime::IdtyValue {
data: IdtyData::new(),
next_creatable_identity_on: identity.next_cert_issuable_on,
old_owner_key: match identity.old_owner_key.clone() {
Some(address) => Some((address, 0)), // FIXME old owner key expiration
None => None,
},
// FIXME old owner key expiration
old_owner_key: identity.old_owner_key.clone().map(|address| (address, 0)),
// old_owner_key: None,
owner_key: identity.owner_key.clone(),
// TODO remove the removable_on field of identity
......@@ -279,11 +277,11 @@ pub fn build_genesis(
}
// CERTIFICATIONS //
for (_, identity) in &genesis_data.identities {
for identity in genesis_data.identities.values() {
let mut certs = BTreeMap::new();
for (issuer, expire_on) in &identity.certs_received {
if let Some(issuer) = &genesis_data.identities.get(issuer) {
certs.insert(issuer.index, Some(expire_on.clone()));
certs.insert(issuer.index, Some(*expire_on));
counter_cert += 1;
} else {
log::error!("Identity '{}' does not exist", issuer);
......@@ -355,7 +353,7 @@ pub fn build_genesis(
for (idty_index, receiver_certs) in &certs_by_receiver {
if receiver_certs.len() < MIN_CERT as usize {
let name = identity_index.get(idty_index).unwrap();
let identity = genesis_data.identities.get(name.clone()).unwrap();
let identity = genesis_data.identities.get(&(*name).clone()).unwrap();
if identity.membership_expire_on != 0 {
log::warn!(
"[{}] has received only {}/{} certifications",
......@@ -431,14 +429,14 @@ pub fn build_genesis(
);
assert_eq!(
accounts.len(),
identity_index.len() + &genesis_data.wallets.len()
identity_index.len() + genesis_data.wallets.len()
);
// no inactive tech comm
for tech_com_member in &genesis_data.technical_committee {
assert!(!inactive_identities.values().any(|&v| v == tech_com_member));
}
// no inactive smith
for (smith, _) in &genesis_data.smiths {
for smith in genesis_data.smiths.keys() {
assert!(!inactive_identities.values().any(|&v| v == smith));
}
......
......@@ -143,14 +143,15 @@ impl SubstrateCli for Cli {
let client_spec: gtest::ClientSpec = serde_json::from_slice(
&std::fs::read(
std::env::var("DUNITER_GTEST_CLIENT_SPEC")
.unwrap_or(JSON_CLIENT_SPEC.to_string()),
.unwrap_or_else(|_| JSON_CLIENT_SPEC.to_string()),
)
.map_err(|e| format!("failed to read {JSON_CLIENT_SPEC} {e}"))?[..],
)
.map_err(|e| format!("failed to parse {e}"))?;
let genesis_data: gtest_genesis::GenesisJson = serde_json::from_slice(
&std::fs::read(
std::env::var("DUNITER_GTEST_GENESIS").unwrap_or(JSON_GENESIS.to_string()),
std::env::var("DUNITER_GTEST_GENESIS")
.unwrap_or_else(|_| JSON_GENESIS.to_string()),
)
.map_err(|e| format!("failed to read {JSON_GENESIS} {e}"))?[..],
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment