Skip to content
Snippets Groups Projects

Fix identities live tests

Merged Hugo Trentesaux requested to merge hugo-live-test into master
1 unresolved thread
Files
2
@@ -23,7 +23,7 @@ use sp_core::{blake2_128, ByteArray, H256};
@@ -23,7 +23,7 @@ use sp_core::{blake2_128, ByteArray, H256};
use std::collections::HashMap;
use std::collections::HashMap;
use subxt::config::SubstrateConfig as GdevConfig;
use subxt::config::SubstrateConfig as GdevConfig;
const DEFAULT_ENDPOINT: &str = "wss://gdev.librelois.fr:443/ws";
const DEFAULT_ENDPOINT: &str = "ws://localhost:9944";
const TREASURY_ACCOUNT_ID: [u8; 32] =
const TREASURY_ACCOUNT_ID: [u8; 32] =
hex!("6d6f646c70792f74727372790000000000000000000000000000000000000000");
hex!("6d6f646c70792f74727372790000000000000000000000000000000000000000");
@@ -90,7 +90,7 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
@@ -90,7 +90,7 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
account_id_bytes.copy_from_slice(&key.0[48..]);
account_id_bytes.copy_from_slice(&key.0[48..]);
accounts.insert(AccountId32::new(account_id_bytes), account_info);
accounts.insert(AccountId32::new(account_id_bytes), account_info);
}
}
println!("accounts: {}.", accounts.len());
println!("accounts.len(): {}.", accounts.len());
// Collect identities
// Collect identities
let mut identities = HashMap::new();
let mut identities = HashMap::new();
@@ -107,7 +107,7 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
@@ -107,7 +107,7 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
idty_index_bytes.copy_from_slice(&key.0[40..]);
idty_index_bytes.copy_from_slice(&key.0[40..]);
identities.insert(IdtyIndex::from_le_bytes(idty_index_bytes), idty_value);
identities.insert(IdtyIndex::from_le_bytes(idty_index_bytes), idty_value);
}
}
println!("identities: {}.", identities.len());
println!("identities.len(): {}.", identities.len());
// Collect identity_index_of
// Collect identity_index_of
let mut identity_index_of = HashMap::new();
let mut identity_index_of = HashMap::new();
@@ -124,7 +124,7 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
@@ -124,7 +124,7 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
blake2_128_bytes.copy_from_slice(&key.0[32..]);
blake2_128_bytes.copy_from_slice(&key.0[32..]);
identity_index_of.insert(blake2_128_bytes, idty_index);
identity_index_of.insert(blake2_128_bytes, idty_index);
}
}
println!("identity_index_of: {}.", identities.len());
println!("identity_index_of.len(): {}.", identity_index_of.len());
let storage = Storage {
let storage = Storage {
accounts,
accounts,
@@ -193,9 +193,9 @@ mod verifier {
@@ -193,9 +193,9 @@ mod verifier {
);
);
}
}
// Rule 3: If the account have consumers, it shoul have at least one provider
// Rule 3: If the account have consumers, it should have at least one provider
if account_info.consumers > 0 {
if account_info.consumers > 0 {
// Rule 1: If the account is not s
// Rule 1: If the account is not sufficient [...]
self.assert(
self.assert(
account_info.providers > 0,
account_info.providers > 0,
format!("Account {} has no providers nor sufficients.", account_id),
format!("Account {} has no providers nor sufficients.", account_id),
@@ -239,7 +239,7 @@ mod verifier {
@@ -239,7 +239,7 @@ mod verifier {
match idty_value.status {
match idty_value.status {
IdtyStatus::Validated => {
IdtyStatus::Validated => {
// Rule 3: If the identity is validated, removable_on shoud be zero
// Rule 3: If the identity is validated, removable_on should be zero
self.assert(
self.assert(
idty_value.removable_on == 0,
idty_value.removable_on == 0,
format!(
format!(
@@ -249,7 +249,7 @@ mod verifier {
@@ -249,7 +249,7 @@ mod verifier {
);
);
}
}
_ => {
_ => {
// Rule 4: If the identity is not validated, next_creatable_identity_on shoud be zero
// Rule 4: If the identity is not validated, next_creatable_identity_on should 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",
@@ -268,7 +268,11 @@ mod verifier {
@@ -268,7 +268,11 @@ mod verifier {
// Rule1: identity_index_of should have the same lenght as identities
// Rule1: identity_index_of should have the same lenght as identities
self.assert(
self.assert(
identities.len() == identity_index_of.len(),
identities.len() == identity_index_of.len(),
"identities.len() != identity_index_of.len().".to_owned(),
format!(
 
"identities.len({}) != identity_index_of.len({}).",
 
identities.len(),
 
identity_index_of.len()
 
),
);
);
for (blake2_128_owner_key, idty_index) in identity_index_of {
for (blake2_128_owner_key, idty_index) in identity_index_of {
Loading