Skip to content

Commit 594ab37

Browse files
AndreAugusto11sandeepnRES
authored andcommitted
feat(fabric-test-ledger): add support to enrolling users in different Orgs
Created new methods to avoid breaking changes in the API exported New methods created: * getConnectionProfileOrgX * enrollAdminV2 * enrollUserV2 * createCaClientV2 closes hyperledger-cacti#2248 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: André Augusto <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
1 parent fb64660 commit 594ab37

File tree

4 files changed

+135
-57
lines changed

4 files changed

+135
-57
lines changed

packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/add-orgs.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import test, { Test } from "tape-promise/tape";
44

55
import {
6+
DEFAULT_FABRIC_2_AIO_FABRIC_VERSION,
7+
DEFAULT_FABRIC_2_AIO_IMAGE_NAME,
8+
DEFAULT_FABRIC_2_AIO_IMAGE_VERSION,
69
FabricTestLedgerV1,
710
pruneDockerAllIfGithubAction,
811
} from "@hyperledger/cactus-test-tooling";
@@ -18,7 +21,6 @@ const testCase = "adds org4 to the network";
1821
const logLevel: LogLevelDesc = "TRACE";
1922

2023
test.skip("BEFORE " + testCase, async (t: Test) => {
21-
t.skip();
2224
const pruning = pruneDockerAllIfGithubAction({ logLevel });
2325
await t.doesNotReject(pruning, "Pruning did not throw OK");
2426
t.end();
@@ -38,9 +40,10 @@ test.skip(testCase, async (t: Test) => {
3840
const ledger = new FabricTestLedgerV1({
3941
emitContainerLogs: true,
4042
publishAllPorts: true,
41-
logLevel: "debug",
42-
imageName: "ghcr.io/hyperledger/cactus-fabric2-all-in-one",
43-
envVars: new Map([["FABRIC_VERSION", "2.2.0"]]),
43+
logLevel,
44+
imageName: DEFAULT_FABRIC_2_AIO_IMAGE_NAME,
45+
imageVersion: DEFAULT_FABRIC_2_AIO_IMAGE_VERSION,
46+
envVars: new Map([["FABRIC_VERSION", DEFAULT_FABRIC_2_AIO_FABRIC_VERSION]]),
4447
extraOrgs: [extraOrg],
4548
});
4649

@@ -88,12 +91,9 @@ test.skip(testCase, async (t: Test) => {
8891
);
8992

9093
//Should return error, as there is no org101 in the default deployment of Fabric AIO image nor it was added
91-
const error = "/Error.*/";
92-
94+
const error = "/no such container - Could not find the file.*/";
9395
await t.rejects(ledger.getConnectionProfileOrgX("org101"), error);
9496

95-
//Let us add org 3 and retrieve the connection profile
96-
9797
t.end();
9898
});
9999

packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/fabric-watch-blocks-v1-endpoint.test.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ const ledgerChannelName = "mychannel";
6060
const ledgerContractName = "basic";
6161

6262
// Log settings
63-
const testLogLevel: LogLevelDesc = "info"; // default: info
64-
const sutLogLevel: LogLevelDesc = "info"; // default: info
63+
const testLogLevel: LogLevelDesc = "TRACE"; // default: info
64+
const sutLogLevel: LogLevelDesc = "TRACE"; // default: info
6565

6666
// Logger setup
6767
const log: Logger = LoggerProvider.getOrCreate({
@@ -108,12 +108,15 @@ describe("watchBlocksV1 of fabric connector tests", () => {
108108
// Get connection profile
109109
log.info("Get fabric connection profile for Org1...");
110110
const connectionProfile = await ledger.getConnectionProfileOrg1();
111+
log.debug("Fabric connection profile for Org1 OK: %o", connectionProfile);
111112
expect(connectionProfile).toBeTruthy();
112113

113114
// Enroll admin and user
114115
const enrollAdminOut = await ledger.enrollAdmin();
116+
log.debug("Enrolled admin OK.");
115117
const adminWallet = enrollAdminOut[1];
116118
const [userIdentity] = await ledger.enrollUser(adminWallet);
119+
log.debug("Enrolled user OK.");
117120

118121
// Create Keychain Plugin
119122
const keychainId = uuidv4();

packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/obtain-profiles.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import { LogLevelDesc } from "@hyperledger/cactus-common";
1515
const testCase = "obtains configuration profiles from Fabric 2.x ledger";
1616
const logLevel: LogLevelDesc = "TRACE";
1717

18-
test.skip("BEFORE " + testCase, async (t: Test) => {
18+
test("BEFORE " + testCase, async (t: Test) => {
1919
const pruning = pruneDockerAllIfGithubAction({ logLevel });
2020
await t.doesNotReject(pruning, "Pruning did not throw OK");
2121
t.end();
2222
});
2323

24-
test.skip(testCase, async (t: Test) => {
24+
test(testCase, async (t: Test) => {
2525
const ledger = new FabricTestLedgerV1({
2626
emitContainerLogs: true,
2727
publishAllPorts: true,
@@ -42,10 +42,10 @@ test.skip(testCase, async (t: Test) => {
4242

4343
t.ok(connectionProfile, "getConnectionProfileOrg1() out truthy OK");
4444

45-
const connectionProfileOrg1 = await ledger.getConnectionProfileOrgX("1");
45+
const connectionProfileOrg1 = await ledger.getConnectionProfileOrgX("org1");
4646
t.isEquivalent(connectionProfile, connectionProfileOrg1);
4747

48-
const connectionProfileOrg2 = await ledger.getConnectionProfileOrgX("2");
48+
const connectionProfileOrg2 = await ledger.getConnectionProfileOrgX("org2");
4949
t.ok(connectionProfileOrg2, "getConnectionProfileOrg2() out truthy OK");
5050

5151
t.notDeepEqual(
@@ -55,13 +55,13 @@ test.skip(testCase, async (t: Test) => {
5555
);
5656

5757
//Should return error, as there is no Org3 in the default deployment of Fabric AIO image
58-
const error = "/Error.*/";
59-
await t.rejects(ledger.getConnectionProfileOrgX("3"), error);
58+
const error = "/no such container - Could not find the file.*/";
59+
await t.rejects(ledger.getConnectionProfileOrgX("org3"), error);
6060

6161
t.end();
6262
});
6363

64-
test.skip("AFTER " + testCase, async (t: Test) => {
64+
test("AFTER " + testCase, async (t: Test) => {
6565
const pruning = pruneDockerAllIfGithubAction({ logLevel });
6666
await t.doesNotReject(pruning, "Pruning did not throw OK");
6767
t.end();

0 commit comments

Comments
 (0)