-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: all publishers links; convert to Uint8Arrays in coordinator results; more concise link validation * chore: add publisher listing to example
- Loading branch information
Showing
16 changed files
with
438 additions
and
508 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
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,35 @@ | ||
use core::str; | ||
|
||
use hdi::prelude::*; | ||
|
||
pub fn validate_create_link_publisher( | ||
action: CreateLink, | ||
_base_address: AnyLinkableHash, | ||
target_address: AnyLinkableHash, | ||
tag: LinkTag, | ||
) -> ExternResult<ValidateCallbackResult> { | ||
if AnyLinkableHash::from(action.author) != target_address { | ||
return Ok(ValidateCallbackResult::Invalid( | ||
"Target of publisher link must author".to_string(), | ||
)); | ||
} | ||
|
||
if str::from_utf8(&tag.into_inner()).is_err() { | ||
return Ok(ValidateCallbackResult::Invalid( | ||
"Tag must be a valid utf-8 string".to_string(), | ||
)); | ||
} | ||
|
||
Ok(ValidateCallbackResult::Valid) | ||
} | ||
pub fn validate_delete_link_publisher( | ||
_action: DeleteLink, | ||
_original_action: CreateLink, | ||
_base: AnyLinkableHash, | ||
_target: AnyLinkableHash, | ||
_tag: LinkTag, | ||
) -> ExternResult<ValidateCallbackResult> { | ||
Ok(ValidateCallbackResult::Invalid(String::from( | ||
"Publisher links cannot be deleted", | ||
))) | ||
} |
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
24 changes: 24 additions & 0 deletions
24
packages/tryorama/src/oracle/agents_can_list_as_publishers.test.ts
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,24 @@ | ||
import { expect, test } from "vitest"; | ||
import { dhtSync, runScenario } from "@holochain/tryorama"; | ||
|
||
import { setupPlayer } from "../utils/setup-happ.js"; | ||
|
||
test("Agents can list as publishers", async () => { | ||
await runScenario(async (scenario) => { | ||
const [alice, aliceCoordinators] = await setupPlayer(scenario); | ||
const [bob, bobCoordinators] = await setupPlayer(scenario); | ||
await scenario.shareAllAgents(); | ||
|
||
// Authority creates a external_id Attestation | ||
await expect( | ||
aliceCoordinators.usernameRegistry.registerAsPublisher("some-topic") | ||
).resolves.not.toThrow(); | ||
|
||
await dhtSync([alice, bob], alice.cells[0].cell_id[0]); | ||
|
||
// Authority gets the external_id Attestation | ||
await expect( | ||
bobCoordinators.usernameRegistry.getAllPublishers() | ||
).resolves.toEqual([[alice.agentPubKey, "some-topic"]]); | ||
}); | ||
}); |
Oops, something went wrong.