Skip to content
Snippets Groups Projects
Commit d52003ad authored by Éloïs's avatar Éloïs
Browse files

tests(sanity):rule "If idty have old_owner_key, old account should…

"If idty have old_owner_key, old account should exist and be sufficient"
parent 5ad8b375
No related branches found
No related tags found
No related merge requests found
Pipeline #17786 failed
...@@ -221,7 +221,7 @@ mod verifier { ...@@ -221,7 +221,7 @@ mod verifier {
identities: &HashMap<IdtyIndex, IdtyValue>, identities: &HashMap<IdtyIndex, IdtyValue>,
) { ) {
for (idty_index, idty_value) in identities { for (idty_index, idty_value) in identities {
// Rule 1: each identity should have an account // Eeach identity should have an account
let maybe_account = accounts.get(&idty_value.owner_key); let maybe_account = accounts.get(&idty_value.owner_key);
self.assert( self.assert(
maybe_account.is_some(), maybe_account.is_some(),
...@@ -229,7 +229,7 @@ mod verifier { ...@@ -229,7 +229,7 @@ mod verifier {
); );
if let Some(account) = maybe_account { if let Some(account) = maybe_account {
// Rule 2: each identity account should be sufficient // Each identity account should be sufficient
self.assert( self.assert(
account.sufficients > 0, account.sufficients > 0,
format!( format!(
...@@ -239,9 +239,26 @@ mod verifier { ...@@ -239,9 +239,26 @@ mod verifier {
); );
} }
if let Some((ref old_owner_key, _last_change)) = idty_value.old_owner_key {
// If the identity have an old_owner_key, the old account should still exist
let old_account = accounts.get(old_owner_key);
self.assert(
old_account.is_some(),
format!("Identity {} old account not exist anymore.", idty_index),
);
if let Some(account) = old_account {
// If the identity have an old_owner_key, the old account should still
// sufficients
self.assert(
account.sufficients > 0,
format!("Identity {} old account not sufficient", idty_index),
);
}
}
match idty_value.status { match idty_value.status {
IdtyStatus::Validated => { IdtyStatus::Validated => {
// Rule 3: If the identity is validated, removable_on shoud be zero // If the identity is validated, removable_on shoud be zero
self.assert( self.assert(
idty_value.removable_on == 0, idty_value.removable_on == 0,
format!( format!(
...@@ -260,7 +277,7 @@ mod verifier { ...@@ -260,7 +277,7 @@ mod verifier {
); );
} }
_ => { _ => {
// Rule 4: If the identity is not validated, next_creatable_identity_on shoud be zero // If the identity is not validated, next_creatable_identity_on shoud be zero
self.assert( self.assert(
idty_value.next_creatable_identity_on == 0, idty_value.next_creatable_identity_on == 0,
format!("Identity {} is corrupted: next_creatable_identity_on > 0 on non-validated idty", format!("Identity {} is corrupted: next_creatable_identity_on > 0 on non-validated idty",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment