Skip to content
Snippets Groups Projects
Unverified Commit 586b23ea authored by bgallois's avatar bgallois
Browse files

fix live-tests

parent 5922742f
No related branches found
No related tags found
No related merge requests found
Pipeline #32308 failed
......@@ -1962,6 +1962,7 @@ dependencies = [
"portpicker",
"serde_json",
"sp-keyring",
"sp-runtime",
"subxt",
"tokio",
]
......@@ -1971,9 +1972,10 @@ name = "duniter-live-tests"
version = "3.0.0"
dependencies = [
"anyhow",
"hex-literal 0.3.4",
"hex-literal",
"parity-scale-codec",
"sp-core",
"sp-runtime",
"subxt",
"tokio",
]
......@@ -2913,7 +2915,7 @@ dependencies = [
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal 0.4.1",
"hex-literal",
"log",
"pallet-atomic-swap",
"pallet-authority-discovery",
......@@ -2980,7 +2982,7 @@ dependencies = [
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal 0.4.1",
"hex-literal",
"log",
"pallet-atomic-swap",
"pallet-authority-discovery",
......@@ -3281,7 +3283,7 @@ dependencies = [
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal 0.4.1",
"hex-literal",
"log",
"pallet-atomic-swap",
"pallet-authority-discovery",
......@@ -3448,12 +3450,6 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hex-literal"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
[[package]]
name = "hex-literal"
version = "0.4.1"
......@@ -9917,6 +9913,7 @@ dependencies = [
"getrandom 0.2.10",
"hex",
"impl-serde",
"jsonrpsee",
"parity-scale-codec",
"parking_lot 0.12.1",
"primitive-types",
......
......@@ -10,8 +10,9 @@ version = '3.0.0'
[dev-dependencies]
anyhow = "1.0"
hex-literal = "0.3"
parity-scale-codec = "3.1.5"
hex-literal = "0.4"
parity-scale-codec = "3.4.0"
sp-core = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', default-features = false }
subxt = { git = 'https://github.com/duniter/subxt', branch = 'duniter-substrate-v0.9.42', default-features = false }
tokio = { version = "1.24.2", features = ["macros"], default-features = false }
subxt = { git = 'https://github.com/duniter/subxt', branch = 'duniter-substrate-v0.9.42', default-features = false, features = ["jsonrpsee-ws"] }
tokio = { version = "1.28", features = ["macros", "time", "rt-multi-thread"], default-features = false }
sp-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', default-features = false , features = ["std"] } # https://github.com/paritytech/subxt/issues/437
\ No newline at end of file
......@@ -72,18 +72,17 @@ async fn main() -> anyhow::Result<()> {
sanity_tests_at(client, maybe_block_hash).await
}
async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyhow::Result<()> {
async fn sanity_tests_at(client: Client, _maybe_block_hash: Option<H256>) -> anyhow::Result<()> {
// ===== Collect storage ===== //
// Collect accounts
let mut accounts = HashMap::new();
let mut accounts: HashMap<AccountId32, AccountInfo> = HashMap::new();
let mut account_iter = client
.storage()
.iter(
gdev::storage().system().account_root(),
100,
maybe_block_hash,
)
.at_latest()
.await
.unwrap()
.iter(gdev::storage().system().account_root(), 100)
.await?;
while let Some((key, account_info)) = account_iter.next().await? {
let mut account_id_bytes = [0u8; 32];
......@@ -93,31 +92,37 @@ async fn sanity_tests_at(client: Client, maybe_block_hash: Option<H256>) -> anyh
println!("accounts: {}.", accounts.len());
// Collect identities
let mut identities = HashMap::new();
let mut identities: HashMap<IdtyIndex, IdtyValue> = HashMap::new();
let mut idty_iter = client
.storage()
.iter(
gdev::storage().identity().identities_root(),
100,
maybe_block_hash,
)
.at_latest()
.await
.unwrap()
.iter(gdev::storage().identity().identities_root(), 100)
.await?;
while let Some((key, idty_value)) = idty_iter.next().await? {
let mut idty_index_bytes = [0u8; 4];
idty_index_bytes.copy_from_slice(&key.0[40..]);
identities.insert(IdtyIndex::from_le_bytes(idty_index_bytes), idty_value);
let idty_val = IdtyValue {
data: idty_value.data,
next_creatable_identity_on: idty_value.next_creatable_identity_on,
old_owner_key: None, // Not used in the live test, skip the conversion
owner_key: AccountId32::from(idty_value.owner_key.0),
removable_on: idty_value.removable_on,
status: idty_value.status,
};
identities.insert(IdtyIndex::from_le_bytes(idty_index_bytes), idty_val);
}
println!("identities: {}.", identities.len());
// Collect identity_index_of
let mut identity_index_of = HashMap::new();
let mut identity_index_of: HashMap<[u8; 16], IdtyIndex> = HashMap::new();
let mut idty_index_of_iter = client
.storage()
.iter(
gdev::storage().identity().identity_index_of_root(),
100,
maybe_block_hash,
)
.at_latest()
.await
.unwrap()
.iter(gdev::storage().identity().identity_index_of_root(), 100)
.await?;
while let Some((key, idty_index)) = idty_index_of_iter.next().await? {
let mut blake2_128_bytes = [0u8; 16];
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment