Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(strategy-tests): document delete transitions were selecting identity in complicated way #2006

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions packages/strategy-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,19 +891,14 @@ impl Strategy {
//todo: fix this into a search key request for the following
//let search_key_request = BTreeMap::from([(Purpose::AUTHENTICATION as u8, BTreeMap::from([(SecurityLevel::HIGH as u8, AllKeysOfKindRequest)]))]);

let request = IdentityKeysRequest {
identity_id: document.owner_id().to_buffer(),
request_type: KeyRequestType::SpecificKeys(vec![1]),
limit: Some(1),
offset: None,
};
let identity =
identity_fetch_callback(request.identity_id.into(), Some(request));
let identity_id = document.owner_id();
let identity = current_identities
.iter()
.find(|&identity| identity.id() == identity_id)
.expect("Expected to find the identity in current_identities");
let identity_contract_nonce = contract_nonce_counter
.get_mut(&(identity.id, contract.id()))
.expect(
"the identity should already have a nonce for that contract",
);
.entry((identity.id(), contract.id()))
.or_default();
*identity_contract_nonce += 1;

let document_delete_transition: DocumentDeleteTransition =
Expand All @@ -920,7 +915,7 @@ impl Strategy {

let document_batch_transition: DocumentsBatchTransition =
DocumentsBatchTransitionV0 {
owner_id: identity.id,
owner_id: identity.id(),
transitions: vec![document_delete_transition.into()],
user_fee_increase: 0,
signature_public_key_id: 1,
Expand All @@ -932,10 +927,12 @@ impl Strategy {
document_batch_transition.into();

let identity_public_key = identity
.loaded_public_keys
.values()
.next()
.expect("expected a key");
.get_first_public_key_matching(
Purpose::AUTHENTICATION,
HashSet::from([SecurityLevel::CRITICAL]),
HashSet::from([KeyType::ECDSA_SECP256K1, KeyType::BLS12_381]),
)
.expect("expected to get a signing key");

document_batch_transition
.sign_external(
Expand Down
Loading