Skip to content

Commit

Permalink
test(trustchain): many getOrCreateTrustchain with different creds fai…
Browse files Browse the repository at this point in the history
…ls (#7282)
  • Loading branch information
gre committed Jul 9, 2024
1 parent 1fc8d79 commit 0e09748
Show file tree
Hide file tree
Showing 5 changed files with 1,402 additions and 0 deletions.
Binary file modified libs/trustchain/scripts/app.elf
Binary file not shown.
1,375 changes: 1,375 additions & 0 deletions libs/trustchain/src/__tests__/sdk/membersManySelfAdd.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions libs/trustchain/src/__tests__/sdk/membersManySelfAdd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import json from "./membersManySelfAdd.json";
import { replayTrustchainSdkTests } from "../../test-helpers/replayTrustchainSdkTests";
import { scenario } from "../../test-scenarios/membersManySelfAdd";
replayTrustchainSdkTests(json, scenario);
1 change: 1 addition & 0 deletions libs/trustchain/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class SDK implements TrustchainSDK {
}

invariant(trustchainRootId, "trustchainRootId should be defined");
log("trustchain", "getOrCreateTrustchain rootId=" + trustchainRootId);

// make a stream tree from all the trustchains associated to this root id
let { streamTree } = await withJwt(jwt => fetchTrustchain(jwt, trustchainRootId));
Expand Down
22 changes: 22 additions & 0 deletions libs/trustchain/src/test-scenarios/membersManySelfAdd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getEnv } from "@ledgerhq/live-env";
import Transport from "@ledgerhq/hw-transport";
import { getSdk } from "..";

export async function scenario(transport: Transport) {
const applicationId = 16;

let trustchainId;
const n = 10;
for (let i = 1; i < n; i++) {
const name = "Member " + i;
const sdk = getSdk(!!getEnv("MOCK"), { applicationId, name });
const creds = await sdk.initMemberCredentials();
const { trustchain } = await sdk.getOrCreateTrustchain(transport, creds);
if (!trustchainId) trustchainId = trustchain.rootId;
expect(trustchain.rootId).toBe(trustchainId);
if (i === n - 1) {
// cleanup
await sdk.destroyTrustchain(trustchain, creds);
}
}
}

0 comments on commit 0e09748

Please sign in to comment.