Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fabric-test-ledger): add support to enrolling users in different Orgs #2249

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import test, { Test } from "tape-promise/tape";

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

test.skip("BEFORE " + testCase, async (t: Test) => {
t.skip();
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning did not throw OK");
t.end();
Expand All @@ -38,9 +40,10 @@ test.skip(testCase, async (t: Test) => {
const ledger = new FabricTestLedgerV1({
emitContainerLogs: true,
publishAllPorts: true,
logLevel: "debug",
imageName: "ghcr.io/hyperledger/cactus-fabric2-all-in-one",
envVars: new Map([["FABRIC_VERSION", "2.2.0"]]),
logLevel,
imageName: DEFAULT_FABRIC_2_AIO_IMAGE_NAME,
imageVersion: DEFAULT_FABRIC_2_AIO_IMAGE_VERSION,
envVars: new Map([["FABRIC_VERSION", DEFAULT_FABRIC_2_AIO_FABRIC_VERSION]]),
extraOrgs: [extraOrg],
});

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

//Should return error, as there is no org101 in the default deployment of Fabric AIO image nor it was added
const error = "/Error.*/";

const error = "/no such container - Could not find the file.*/";
await t.rejects(ledger.getConnectionProfileOrgX("org101"), error);

//Let us add org 3 and retrieve the connection profile

t.end();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const ledgerChannelName = "mychannel";
const ledgerContractName = "basic";

// Log settings
const testLogLevel: LogLevelDesc = "info"; // default: info
const sutLogLevel: LogLevelDesc = "info"; // default: info
const testLogLevel: LogLevelDesc = "TRACE"; // default: info
const sutLogLevel: LogLevelDesc = "TRACE"; // default: info

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

// Enroll admin and user
const enrollAdminOut = await ledger.enrollAdmin();
log.debug("Enrolled admin OK.");
const adminWallet = enrollAdminOut[1];
const [userIdentity] = await ledger.enrollUser(adminWallet);
log.debug("Enrolled user OK.");

// Create Keychain Plugin
const keychainId = uuidv4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { LogLevelDesc } from "@hyperledger/cactus-common";
const testCase = "obtains configuration profiles from Fabric 2.x ledger";
const logLevel: LogLevelDesc = "TRACE";

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

test.skip(testCase, async (t: Test) => {
test(testCase, async (t: Test) => {
const ledger = new FabricTestLedgerV1({
emitContainerLogs: true,
publishAllPorts: true,
Expand All @@ -42,10 +42,10 @@ test.skip(testCase, async (t: Test) => {

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

const connectionProfileOrg1 = await ledger.getConnectionProfileOrgX("1");
const connectionProfileOrg1 = await ledger.getConnectionProfileOrgX("org1");
t.isEquivalent(connectionProfile, connectionProfileOrg1);

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

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

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

t.end();
});

test.skip("AFTER " + testCase, async (t: Test) => {
test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning did not throw OK");
t.end();
Expand Down
Loading
Loading