From 4d1542b89cd03f3395ec6a95b54e989a75a55e9a Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Wed, 27 Mar 2024 00:24:35 +0000 Subject: [PATCH] Lint + format --- dnas/checked/zomes/integrity/fetch/src/lib.rs | 2 +- .../zomes/integrity/signing_keys/src/lib.rs | 2 +- tests/src/checked/signing_keys/common.ts | 94 +++++++++++-------- .../signing_keys/key-collection.test.ts | 33 +++++-- .../signing_keys/reference-count.test.ts | 25 ++++- .../signing_keys/validation-key-dist.test.ts | 23 ++++- 6 files changed, 122 insertions(+), 57 deletions(-) diff --git a/dnas/checked/zomes/integrity/fetch/src/lib.rs b/dnas/checked/zomes/integrity/fetch/src/lib.rs index 9914eb2..ea3180c 100644 --- a/dnas/checked/zomes/integrity/fetch/src/lib.rs +++ b/dnas/checked/zomes/integrity/fetch/src/lib.rs @@ -1,9 +1,9 @@ use hdi::prelude::*; pub mod prelude { - pub use fetch_types::*; pub use crate::LinkTypes; pub use crate::{EntryTypes, UnitEntryTypes}; + pub use fetch_types::*; } #[derive(Serialize, Deserialize)] diff --git a/dnas/checked/zomes/integrity/signing_keys/src/lib.rs b/dnas/checked/zomes/integrity/signing_keys/src/lib.rs index 120877a..c7d9319 100644 --- a/dnas/checked/zomes/integrity/signing_keys/src/lib.rs +++ b/dnas/checked/zomes/integrity/signing_keys/src/lib.rs @@ -9,12 +9,12 @@ use hdi::prelude::*; use signing_keys_types::*; pub mod prelude { - pub use signing_keys_types::*; pub use crate::key_collection::*; pub use crate::key_util::*; pub use crate::verification_key_dist::*; pub use crate::LinkTypes; pub use crate::{EntryTypes, UnitEntryTypes}; + pub use signing_keys_types::*; } #[derive(Serialize, Deserialize)] diff --git a/tests/src/checked/signing_keys/common.ts b/tests/src/checked/signing_keys/common.ts index 520e4d7..06f7a7f 100644 --- a/tests/src/checked/signing_keys/common.ts +++ b/tests/src/checked/signing_keys/common.ts @@ -1,5 +1,5 @@ import { CallableCell } from "@holochain/tryorama"; -import {ActionHash, AgentPubKey, Record} from "@holochain/client"; +import { ActionHash, AgentPubKey, Record } from "@holochain/client"; import { decode } from "@msgpack/msgpack"; const utf8Encode = new TextEncoder(); @@ -16,8 +16,8 @@ export interface VerificationKeyDistMarkCompromised { } export type VfKeyDistMark = - | { Rotated: VerificationKeyDistMarkRotated } - | { Compromised: VerificationKeyDistMarkCompromised }; + | { Rotated: VerificationKeyDistMarkRotated } + | { Compromised: VerificationKeyDistMarkCompromised }; export interface VerificationKeyDist { verification_key: string; @@ -121,16 +121,20 @@ export async function createKeyCollection( } export const getMyKeyCollections = async ( - cell: CallableCell, + cell: CallableCell, ): Promise => { return cell.callZome({ zome_name: "signing_keys", fn_name: "get_my_key_collections", payload: null, }); -} +}; -export const linkVerificationKeyToKeyCollection = async (cell: CallableCell, verification_key_dist_address: ActionHash, key_collection_name: string): Promise => { +export const linkVerificationKeyToKeyCollection = async ( + cell: CallableCell, + verification_key_dist_address: ActionHash, + key_collection_name: string, +): Promise => { return cell.callZome({ zome_name: "signing_keys", fn_name: "link_verification_key_to_key_collection", @@ -138,10 +142,14 @@ export const linkVerificationKeyToKeyCollection = async (cell: CallableCell, ver verification_key_dist_address, key_collection_name, }, - }) -} + }); +}; -export const unlinkVerificationKeyToKeyCollection = async (cell: CallableCell, verification_key_dist_address: ActionHash, key_collection_name: string): Promise => { +export const unlinkVerificationKeyToKeyCollection = async ( + cell: CallableCell, + verification_key_dist_address: ActionHash, + key_collection_name: string, +): Promise => { return cell.callZome({ zome_name: "signing_keys", fn_name: "unlink_verification_key_from_key_collection", @@ -149,28 +157,36 @@ export const unlinkVerificationKeyToKeyCollection = async (cell: CallableCell, v verification_key_dist_address, key_collection_name, }, - }) -} + }); +}; -export const getMyVerificationKeyDistributions = async (cell: CallableCell): Promise => { +export const getMyVerificationKeyDistributions = async ( + cell: CallableCell, +): Promise => { return cell.callZome({ - zome_name: "signing_keys", - fn_name: "get_my_verification_key_distributions", - payload: null, - }); -} + zome_name: "signing_keys", + fn_name: "get_my_verification_key_distributions", + payload: null, + }); +}; -export const searchKeys = async (cell: CallableCell, agent_pub_key: AgentPubKey): Promise => { +export const searchKeys = async ( + cell: CallableCell, + agent_pub_key: AgentPubKey, +): Promise => { return cell.callZome({ - zome_name: "signing_keys", - fn_name: "search_keys", - payload: { - agent_pub_key, - }, - }); -} + zome_name: "signing_keys", + fn_name: "search_keys", + payload: { + agent_pub_key, + }, + }); +}; -export const searchKeysLocal = async (cell: CallableCell, agent_pub_key: AgentPubKey): Promise => { +export const searchKeysLocal = async ( + cell: CallableCell, + agent_pub_key: AgentPubKey, +): Promise => { return cell.callZome({ zome_name: "signing_keys", fn_name: "search_keys_local", @@ -178,17 +194,19 @@ export const searchKeysLocal = async (cell: CallableCell, agent_pub_key: AgentPu agent_pub_key, }, }); -} +}; -export const markVerificationKeyRotated = async (cell: CallableCell, verification_key_dist_address: ActionHash, mark: VfKeyDistMark): Promise => { +export const markVerificationKeyRotated = async ( + cell: CallableCell, + verification_key_dist_address: ActionHash, + mark: VfKeyDistMark, +): Promise => { return cell.callZome({ - zome_name: "signing_keys", - fn_name: "mark_verification_key_dist", - payload: { - verification_key_dist_address, - mark, - }, - }) -} - - + zome_name: "signing_keys", + fn_name: "mark_verification_key_dist", + payload: { + verification_key_dist_address, + mark, + }, + }); +}; diff --git a/tests/src/checked/signing_keys/key-collection.test.ts b/tests/src/checked/signing_keys/key-collection.test.ts index c91ed57..6087308 100644 --- a/tests/src/checked/signing_keys/key-collection.test.ts +++ b/tests/src/checked/signing_keys/key-collection.test.ts @@ -4,7 +4,6 @@ import { runScenario, dhtSync } from "@holochain/tryorama"; import { Record } from "@holochain/client"; import { - KeyCollectionWithKeys, createKeyCollection, distributeVerificationKey, sampleMiniSignKey, @@ -103,9 +102,13 @@ test("Link verification key distribution to collection", async () => { assert.ok(key_collection_record); // Bob links Alice's verification key to the key collection - await linkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test"); + await linkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test", + ); - const key_collections= await getMyKeyCollections(bob.cells[0]); + const key_collections = await getMyKeyCollections(bob.cells[0]); assert.equal(key_collections.length, 1); assert.equal(key_collections[0].verification_keys.length, 1); @@ -141,10 +144,18 @@ test("Unlink verification key from collection", async () => { assert.ok(key_collection_record); // Bob links Alice's verification key to the key collection - await linkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test"); + await linkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test", + ); // Bob unlinks Alice's verification key from the key collection - await unlinkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test"); + await unlinkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test", + ); // Now getting key collections should return a single, empty key collection const key_collections = await getMyKeyCollections(bob.cells[0]); @@ -190,13 +201,21 @@ test("Remote validation", async () => { verification_key_record.signed_action.hashed.hash; // Bob links Alice's verification key to the key collection - await linkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test 1"); + await linkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test 1", + ); // The DHT shouldn't sync if the remote validation fails await dhtSync([alice, bob], alice.cells[0].cell_id[0]); // Bob unlinks Alice's verification key from the key collection - await unlinkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test 1"); + await unlinkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test 1", + ); // The DHT shouldn't sync if the remote validation fails await dhtSync([alice, bob], alice.cells[0].cell_id[0]); diff --git a/tests/src/checked/signing_keys/reference-count.test.ts b/tests/src/checked/signing_keys/reference-count.test.ts index a44c336..4e26727 100644 --- a/tests/src/checked/signing_keys/reference-count.test.ts +++ b/tests/src/checked/signing_keys/reference-count.test.ts @@ -4,7 +4,6 @@ import { runScenario, dhtSync } from "@holochain/tryorama"; import { Record } from "@holochain/client"; import { - KeyCollectionWithKeys, createKeyCollection, distributeVerificationKey, sampleMiniSignKey, @@ -45,7 +44,11 @@ test("Get my keys for a key which is in another agent's collection", async () => await createKeyCollection(bob.cells[0], "a test"); // Bob links Alice's verification key to their key collection - await linkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test"); + await linkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test", + ); await dhtSync([alice, bob], alice.cells[0].cell_id[0]); @@ -84,7 +87,11 @@ test("Search for a key which is in another agent's collection", async () => { await createKeyCollection(bob.cells[0], "a test"); // Bob links Alice's verification key to their key collection - await linkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "a test"); + await linkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "a test", + ); await dhtSync([alice, bob], alice.cells[0].cell_id[0]); @@ -126,13 +133,21 @@ test("Get my key collections for a key which is in another agent's collection", await createKeyCollection(bob.cells[0], "bob test"); // Bob links Alice's verification key to their key collection - await linkVerificationKeyToKeyCollection(bob.cells[0], vf_key_dist_address, "bob test"); + await linkVerificationKeyToKeyCollection( + bob.cells[0], + vf_key_dist_address, + "bob test", + ); // Carol creates a collection await createKeyCollection(carol.cells[0], "carol test"); // Carol links Alice's verification key to their key collection - await linkVerificationKeyToKeyCollection(carol.cells[0], vf_key_dist_address, "carol test"); + await linkVerificationKeyToKeyCollection( + carol.cells[0], + vf_key_dist_address, + "carol test", + ); await dhtSync([alice, bob, carol], alice.cells[0].cell_id[0]); diff --git a/tests/src/checked/signing_keys/validation-key-dist.test.ts b/tests/src/checked/signing_keys/validation-key-dist.test.ts index b7d5610..deb8ab8 100644 --- a/tests/src/checked/signing_keys/validation-key-dist.test.ts +++ b/tests/src/checked/signing_keys/validation-key-dist.test.ts @@ -4,7 +4,6 @@ import { runScenario, dhtSync } from "@holochain/tryorama"; import { Record } from "@holochain/client"; import { - VerificationKeyResponse, distributeVerificationKey, sampleMiniSignKey, testAppPath, @@ -12,7 +11,11 @@ import { sampleMiniSignProofSignature, sampleMiniSignProofSignature2, sampleMiniSignProof2, - sampleMiniSignKey2, getMyVerificationKeyDistributions, searchKeys, searchKeysLocal, markVerificationKeyRotated, + sampleMiniSignKey2, + getMyVerificationKeyDistributions, + searchKeys, + searchKeysLocal, + markVerificationKeyRotated, } from "./common.js"; test("Distribute a key", async () => { @@ -116,7 +119,10 @@ test("Search for a key", async () => { // Note: This is more of a PoC than anything at this point, but it's a start // Bob searches for Alice's key while offline - const offline_responses = await searchKeysLocal(bob.cells[0], alice.agentPubKey); + const offline_responses = await searchKeysLocal( + bob.cells[0], + alice.agentPubKey, + ); assert.equal(offline_responses.length, 1); assert.equal(offline_responses[0].verification_key_dist.name, "test"); @@ -157,7 +163,12 @@ test("Mark a key as compromised", async () => { // Alice marks her own key as compromised const compromisedSince = new Date().getUTCMilliseconds() * 1000; - await markVerificationKeyRotated(alice.cells[0], vf_key_dist_address, { Compromised: { note: "I think someone is using my private key!", since: compromisedSince } }) + await markVerificationKeyRotated(alice.cells[0], vf_key_dist_address, { + Compromised: { + note: "I think someone is using my private key!", + since: compromisedSince, + }, + }); // TODO should not need to DHT sync here. What I actually want is an 'Alice synced' to be serving up the links // that Bob will need in the next step. For now, the test is flaky without this sync... @@ -219,7 +230,9 @@ test("Mark a key as rotated", async () => { const new_vf_key_dist_address = new_record.signed_action.hashed.hash; // Alice marks her own key as compromised - await markVerificationKeyRotated(alice.cells[0], vf_key_dist_address, { Rotated: { new_verification_key_dist_address: new_vf_key_dist_address } }) + await markVerificationKeyRotated(alice.cells[0], vf_key_dist_address, { + Rotated: { new_verification_key_dist_address: new_vf_key_dist_address }, + }); // TODO should not need to DHT sync here. What I actually want is an 'Alice synced' to be serving up the links // that Bob will need in the next step. For now, the test is flaky without this sync...