Skip to content

Commit

Permalink
add new YamlProperties type and test that installs app with roles_set…
Browse files Browse the repository at this point in the history
…tings set
  • Loading branch information
matthme committed Nov 26, 2024
1 parent 33ead65 commit 9539e9e
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ resolver = "2"
opt-level = "z"

[workspace.dependencies]
hdk = "0.5.0-dev.0"
hdk = "0.5.0-dev.6"
4 changes: 2 additions & 2 deletions docs/client.dnamodifiersopt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
```typescript
export type DnaModifiersOpt = {
network_seed?: NetworkSeed;
properties?: Uint8Array;
properties?: YamlProperties;
origin_time?: Timestamp;
quantum_time?: Duration;
};
```
**References:** [NetworkSeed](./client.networkseed.md)<!-- -->, [Timestamp](./client.timestamp.md)<!-- -->, [Duration](./client.duration.md)
**References:** [NetworkSeed](./client.networkseed.md)<!-- -->, [YamlProperties](./client.yamlproperties.md)<!-- -->, [Timestamp](./client.timestamp.md)<!-- -->, [Duration](./client.duration.md)

11 changes: 11 additions & 0 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,17 @@ If the key could not be deleted from all cells, the call [RevokeAgentKeyRequest]



</td></tr>
<tr><td>

[YamlProperties](./client.yamlproperties.md)


</td><td>

Any value that is serializable to a Yaml value


</td></tr>
<tr><td>

Expand Down
13 changes: 13 additions & 0 deletions docs/client.yamlproperties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [YamlProperties](./client.yamlproperties.md)

## YamlProperties type

Any value that is serializable to a Yaml value

**Signature:**

```typescript
export type YamlProperties = any;
```
8 changes: 7 additions & 1 deletion src/api/admin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,15 @@ export type RoleSettings =
modifiers?: DnaModifiersOpt;
};

/**
* Any value that is serializable to a Yaml value
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type YamlProperties = any;

export type DnaModifiersOpt = {
network_seed?: NetworkSeed;
properties?: Uint8Array;
properties?: YamlProperties;
origin_time?: Timestamp;
quantum_time?: Duration;
};
Expand Down
101 changes: 85 additions & 16 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decode } from "@msgpack/msgpack";
import { decode, encode } from "@msgpack/msgpack";
import assert from "node:assert/strict";
import fs from "node:fs";
import test from "tape";
Expand Down Expand Up @@ -29,10 +29,11 @@ import {
SignalType,
Signal,
isSameCell,
CallZomeRequestAllParams,
getSigningCredentials,
randomNonce,
getNonceExpiration,
ProvisionedCell,
Duration,
} from "../../src";
import {
FIXTURE_PATH,
Expand Down Expand Up @@ -85,7 +86,7 @@ test(
installed_app_id,
agent_key,
path: `${FIXTURE_PATH}/test.happ`,
membrane_proofs: {},
roles_settings: {},
});
const status: InstalledAppInfoStatus = installedApp.status;
t.deepEqual(
Expand Down Expand Up @@ -218,7 +219,7 @@ test(
path,
agent_key,
installed_app_id,
membrane_proofs: {},
roles_settings: {},
});
t.ok(installedApp);
t.deepEqual(installedApp.status, {
Expand Down Expand Up @@ -296,7 +297,7 @@ test(
installed_app_id,
agent_key,
path: `${FIXTURE_PATH}/test.happ`,
membrane_proofs: {},
roles_settings: {},
});

const dnaDefinition = await admin.getDnaDefinition(hash);
Expand Down Expand Up @@ -425,7 +426,7 @@ test(
const cap_secret = getSigningCredentials(cell_id)?.capSecret;
assert(cap_secret);

const zomeCallPayload: CallZomeRequestAllParams = {
const zomeCallPayload: CallZomeRequest = {
cell_id,
zome_name: TEST_ZOME_NAME,
fn_name: "foo",
Expand Down Expand Up @@ -562,6 +563,74 @@ test(
})
);

test(
"can install app with roles_settings",
withConductor(ADMIN_PORT, async (t) => {
const role_name = "foo";
const installed_app_id = "app";
const admin = await AdminWebsocket.connect({
url: ADMIN_WS_URL,
wsClientOptions: { origin: "client-test-admin" },
});
const agent = await admin.generateAgentPubKey();

const originTime = Date.now();
const quantumTime: Duration = {
secs: originTime,
nanos: 0,
};

await admin.installApp({
installed_app_id,
agent_key: agent,
bundle: {
manifest: {
manifest_version: "1",
name: "app",
roles: [
{
name: role_name,
provisioning: {
strategy: CellProvisioningStrategy.Create,
deferred: false,
},
dna: {
path: fs.realpathSync("test/e2e/fixture/test.dna"),
modifiers: { network_seed: "some_seed" },
},
},
],
membrane_proofs_deferred: true,
},
resources: {},
},
roles_settings: {
foo: {
type: "Provisioned",
membrane_proof: new Uint8Array(6),
modifiers: {
network_seed: "hello",
properties: { specialProp: "prop" },
origin_time: originTime,
quantum_time: quantumTime,
},
},
},
});

const apps = await admin.listApps({});
const appInfo = apps[0];
const provisionedCell: ProvisionedCell =
appInfo.cell_info["foo"][0][CellType.Provisioned];
t.equal(provisionedCell.dna_modifiers.network_seed, "hello");
t.deepEqual(decode(provisionedCell.dna_modifiers.properties), {
specialProp: "prop",
});
t.equal(provisionedCell.dna_modifiers.origin_time, originTime);
t.deepEqual(provisionedCell.dna_modifiers.quantum_time, quantumTime);
})
);

test(
"memproofs can be provided after app installation",
withConductor(ADMIN_PORT, async (t) => {
Expand Down Expand Up @@ -597,7 +666,7 @@ test(
},
resources: {},
},
membrane_proofs: {},
roles_settings: {},
});

const { port: appPort } = await admin.attachAppInterface({
Expand Down Expand Up @@ -697,7 +766,7 @@ test(
},
resources: {},
},
membrane_proofs: {},
roles_settings: {},
});
await admin.enableApp({ installed_app_id });
const { port: appPort } = await admin.attachAppInterface({
Expand Down Expand Up @@ -769,7 +838,7 @@ test(
dna_1: zippedDnaBundle,
},
},
membrane_proofs: {},
roles_settings: {},
});
await admin.enableApp({ installed_app_id });
const { port: appPort } = await admin.attachAppInterface({
Expand Down Expand Up @@ -963,7 +1032,7 @@ test("can inject agents", async (t) => {
let result = await admin1.installApp({
installed_app_id,
agent_key: agent_key_1,
membrane_proofs: {},
roles_settings: {},
path: `${FIXTURE_PATH}/test.happ`,
});
t.ok(result);
Expand Down Expand Up @@ -1001,7 +1070,7 @@ test("can inject agents", async (t) => {
result = await admin2.installApp({
installed_app_id,
agent_key: agent_key_2,
membrane_proofs: {},
roles_settings: {},
path: `${FIXTURE_PATH}/test.happ`,
});
t.ok(result);
Expand Down Expand Up @@ -1046,7 +1115,7 @@ test(

const tag = "test_tag";
const link: Link = await client.callZome({
cap_secret: null,
cap_secret: undefined,
cell_id,
provenance: cell_id[1],
zome_name: TEST_ZOME_NAME,
Expand Down Expand Up @@ -1074,15 +1143,15 @@ test(
await admin.authorizeSigningCredentials(cell_id);

const linkHash: ActionHash = await client.callZome({
cap_secret: null,
cap_secret: undefined,
cell_id,
provenance: cell_id[1],
zome_name: TEST_ZOME_NAME,
fn_name: "create_and_delete_link",
payload: null,
});
const activity: RegisterAgentActivity[] = await client.callZome({
cap_secret: null,
cap_secret: undefined,
cell_id,
provenance: cell_id[1],
zome_name: TEST_ZOME_NAME,
Expand Down Expand Up @@ -1180,14 +1249,14 @@ test(
const installedApp1 = await admin.installApp({
agent_key,
installed_app_id: "test-app1",
membrane_proofs: {},
roles_settings: {},
path: `${FIXTURE_PATH}/test.happ`,
network_seed: "1",
});
const installedApp2 = await admin.installApp({
agent_key,
installed_app_id: "test-app2",
membrane_proofs: {},
roles_settings: {},
path: `${FIXTURE_PATH}/test.happ`,
network_seed: "2",
});
Expand Down

0 comments on commit 9539e9e

Please sign in to comment.