Skip to content

Commit

Permalink
use js-yaml in test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Nov 26, 2024
1 parent 9539e9e commit f4e52c7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/client.dnamodifiersopt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## DnaModifiersOpt type


**Signature:**

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,7 @@ This type is meant to be opaque
</td><td>



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

Expand Down Expand Up @@ -2736,6 +2737,7 @@ If the key could not be deleted from all cells, the call [RevokeAgentKeyRequest]
</td><td>



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

Expand Down
1 change: 1 addition & 0 deletions docs/client.rolesettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## RoleSettings type


**Signature:**

```typescript
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@
"isomorphic-ws": "^5.0.0",
"js-base64": "^3.7.5",
"js-sha512": "^0.9.0",
"js-yaml": "4.1.0",
"libsodium-wrappers": "^0.7.13",
"lodash-es": "^4.17.21",
"ws": "^8.14.2"
},
"devDependencies": {
"@microsoft/api-documenter": "^7.21.7",
"@microsoft/api-extractor": "^7.34.4",
"@types/js-yaml": "4.0.9",
"@types/libsodium-wrappers": "^0.7.11",
"@types/lodash-es": "^4.17.6",
"@types/tape": "^4.13.2",
Expand Down
7 changes: 7 additions & 0 deletions src/api/admin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export type MemproofMap = { [key: RoleName]: MembraneProof };
*/
export type RoleSettingsMap = { [key: RoleName]: RoleSettings };

/**
* @public
*/
export type RoleSettings =
| {
type: "UseExisting";
Expand All @@ -175,11 +178,15 @@ export type RoleSettings =
};

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

/**
* @public
*/
export type DnaModifiersOpt = {
network_seed?: NetworkSeed;
properties?: YamlProperties;
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const installAppAndDna = async (
installed_app_id,
agent_key: agent,
path,
membrane_proofs: {},
roles_settings: {},
});
assert(CellType.Provisioned in app.cell_info[role_name][0]);
const cell_id = app.cell_info[role_name][0][CellType.Provisioned].cell_id;
Expand Down Expand Up @@ -159,7 +159,7 @@ export const createAppWsAndInstallApp = async (
installed_app_id,
agent_key: agent,
path,
membrane_proofs: {},
roles_settings: {},
});
assert(CellType.Provisioned in app.cell_info[role_name][0]);
const cell_id = app.cell_info[role_name][0][CellType.Provisioned].cell_id;
Expand Down
14 changes: 9 additions & 5 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { decode, encode } from "@msgpack/msgpack";
import { decode } from "@msgpack/msgpack";
import assert from "node:assert/strict";
import fs from "node:fs";
import test from "tape";
import yaml from "js-yaml";
import zlib from "zlib";
import {
ActionHash,
Expand Down Expand Up @@ -580,6 +581,8 @@ test(
nanos: 0,
};

const progenitorKey = fakeAgentPubKey();

await admin.installApp({
installed_app_id,
agent_key: agent,
Expand Down Expand Up @@ -610,7 +613,7 @@ test(
membrane_proof: new Uint8Array(6),
modifiers: {
network_seed: "hello",
properties: { specialProp: "prop" },
properties: yaml.dump({ progenitor: progenitorKey }),
origin_time: originTime,
quantum_time: quantumTime,
},
Expand All @@ -623,9 +626,10 @@ test(
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.deepEqual(
yaml.load(decode(provisionedCell.dna_modifiers.properties) as string),
{ progenitor: progenitorKey }
);
t.equal(provisionedCell.dna_modifiers.origin_time, originTime);
t.deepEqual(provisionedCell.dna_modifiers.quantum_time, quantumTime);
})
Expand Down

0 comments on commit f4e52c7

Please sign in to comment.