-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d1542b
commit ffd7d6d
Showing
8 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export const testAppPath = process.cwd() + "/../workdir/checked.happ"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {CallableCell} from "@holochain/tryorama"; | ||
import {AgentPubKey, Record} from "@holochain/client"; | ||
|
||
export interface PrepareFetchRequest { | ||
fetch_url: string; | ||
} | ||
|
||
// #[derive(Serialize, Deserialize, Debug)] | ||
// pub struct FetchCheckSignaturePinned { | ||
// pub author: AgentPubKey, | ||
// pub key_collection: String, | ||
// pub key_name: String, | ||
// } | ||
// | ||
// #[derive(Serialize, Deserialize, Debug)] | ||
// pub enum FetchCheckSignatureReason { | ||
// RandomRecent, | ||
// RandomHistorical, | ||
// Pinned(FetchCheckSignaturePinned), | ||
// } | ||
// | ||
// #[derive(Serialize, Deserialize, Debug)] | ||
// pub struct FetchCheckSignature { | ||
// signature: Vec<u8>, | ||
// reason: FetchCheckSignatureReason, | ||
// } | ||
|
||
export interface FetchCheckSignaturePinned { | ||
author: AgentPubKey; | ||
key_collection: string; | ||
key_name: string; | ||
} | ||
|
||
export type FetchCheckSignatureReason = | ||
| { RandomRecent: null } | ||
| { RandomHistorical: null } | ||
| { Pinned: FetchCheckSignaturePinned }; | ||
|
||
export interface FetchCheckSignature { | ||
signature: Uint8Array; | ||
reason: FetchCheckSignatureReason; | ||
} | ||
|
||
export const prepareFetch = async ( | ||
cell: CallableCell, | ||
request: PrepareFetchRequest, | ||
): Promise<FetchCheckSignature[]> => { | ||
return cell.callZome({ | ||
zome_name: "fetch", | ||
fn_name: "prepare_fetch", | ||
payload: request, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { assert, test } from "vitest"; | ||
|
||
import { runScenario } from "@holochain/tryorama"; | ||
|
||
import {testAppPath} from "../common"; | ||
import {prepareFetch} from "./common"; | ||
|
||
test("Fetch with no existing signatures", async () => { | ||
await runScenario(async (scenario) => { | ||
const appSource = { appBundleSource: { path: testAppPath } }; | ||
|
||
const [alice] = await scenario.addPlayersWithApps([appSource]); | ||
|
||
const check_signatures = await prepareFetch(alice.cells[0], { fetch_url: "https://example.com/sample.csv" }); | ||
|
||
assert.equal(check_signatures.length, 0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters