From cf854675b52c00ae96c7602298b0b5dcd2c2edd2 Mon Sep 17 00:00:00 2001 From: Ryan Quinn Ford Date: Sat, 21 Sep 2024 19:40:42 +0200 Subject: [PATCH] deadlock? uwu --- crates/common/src/hashchain.rs | 2 +- crates/common/src/tree.rs | 6 ++++++ crates/prism/src/node_types/sequencer.rs | 6 ++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/common/src/hashchain.rs b/crates/common/src/hashchain.rs index 8375324..f736618 100644 --- a/crates/common/src/hashchain.rs +++ b/crates/common/src/hashchain.rs @@ -108,7 +108,7 @@ impl Hashchain { .find_map(|entry| match entry.operation.clone() { Operation::RevokeKey(args) if args.value == key => Some(true), Operation::AddKey(args) if args.value == key => Some(false), - Operation::CreateAccount(args) if args.value == key => Some(true), + Operation::CreateAccount(args) if args.value == key => Some(false), _ => None, }) .unwrap_or(false) diff --git a/crates/common/src/tree.rs b/crates/common/src/tree.rs index 9a123f7..ddc91b5 100644 --- a/crates/common/src/tree.rs +++ b/crates/common/src/tree.rs @@ -475,8 +475,11 @@ mod tests { let mut account = tree_state.create_account("key_1".to_string()); tree_state.insert_account(account.clone()).unwrap(); + + // Add a new key tree_state.add_key_to_account(&mut account).unwrap(); + // Update the account using the correct key index let update_proof = tree_state.update_account(account.clone()).unwrap(); assert!(update_proof.verify().is_ok()); @@ -519,6 +522,7 @@ mod tests { tree_state.add_key_to_account(&mut account1).unwrap(); tree_state.add_key_to_account(&mut account2).unwrap(); + // Update accounts using the correct key indices tree_state.update_account(account1.clone()).unwrap(); tree_state.update_account(account2.clone()).unwrap(); @@ -539,12 +543,14 @@ mod tests { test_tree.insert_account(account_1.clone()).unwrap(); test_tree.add_key_to_account(&mut account_1).unwrap(); + // Update account_1 using the correct key index test_tree.update_account(account_1.clone()).unwrap(); test_tree.insert_account(account_2.clone()).unwrap(); test_tree.add_key_to_account(&mut account_2).unwrap(); + // Update account_2 using the correct key index let last_proof = test_tree.update_account(account_2.clone()).unwrap(); assert_eq!( diff --git a/crates/prism/src/node_types/sequencer.rs b/crates/prism/src/node_types/sequencer.rs index f878cdc..91d4439 100644 --- a/crates/prism/src/node_types/sequencer.rs +++ b/crates/prism/src/node_types/sequencer.rs @@ -445,13 +445,11 @@ mod tests { Operation::AddKey(KeyOperationArgs { id: id.to_string(), - value: dbg!(new_key), + value: new_key, signature: SignatureBundle { key_idx, signature: signing_key - .sign(&dbg!( - bincode::serialize(&operation_without_signature).unwrap() - )) + .sign(&bincode::serialize(&operation_without_signature).unwrap()) .to_vec(), }, })