Skip to content

Commit

Permalink
build(deps): remove ipfs from odap tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
  • Loading branch information
outSH committed Oct 25, 2023
1 parent bcad3be commit 70cd17a
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 981 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import http, { Server } from "http";
import { Server as SocketIoServer } from "socket.io";
import { AddressInfo } from "net";
import { v4 as uuidv4 } from "uuid";
import { PluginObjectStoreIpfs } from "@hyperledger/cactus-plugin-object-store-ipfs";
import bodyParser from "body-parser";
import express from "express";
import { DefaultApi as ObjectStoreIpfsApi } from "@hyperledger/cactus-plugin-object-store-ipfs";
import { AssetProfile } from "../../../main/typescript/generated/openapi/typescript-axios";
import {
IListenOptions,
Expand Down Expand Up @@ -52,7 +50,6 @@ import {
ReceiptType,
Web3SigningCredential,
} from "@hyperledger/cactus-plugin-ledger-connector-besu";
import { dynamicImportKuboRpcClientESMWorkaround } from "@hyperledger/cacti-esm-compat-hacks";
import Web3 from "web3";

import { makeSessionDataChecks } from "../make-checks";
Expand Down Expand Up @@ -133,51 +130,6 @@ beforeAll(async () => {
fail("Pruning didn't throw OK");
});

{
// IPFS configuration
ipfsContainer = new GoIpfsTestContainer({ logLevel });
expect(ipfsContainer).not.toBeUndefined();

const container = await ipfsContainer.start();
expect(container).not.toBeUndefined();

const expressApp = express();
expressApp.use(bodyParser.json({ limit: "250mb" }));
ipfsServer = http.createServer(expressApp);
const listenOptions: IListenOptions = {
hostname: "localhost",
port: 0,
server: ipfsServer,
};

const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo;
const { address, port } = addressInfo;
ipfsApiHost = `http://${address}:${port}`;

const config = new Configuration({ basePath: ipfsApiHost });
const apiClient = new ObjectStoreIpfsApi(config);

expect(apiClient).not.toBeUndefined();

const ipfsApiUrl = await ipfsContainer.getApiUrl();

const kuboRpcModule = await dynamicImportKuboRpcClientESMWorkaround();
const ipfsClientOrOptions = kuboRpcModule.create({
url: ipfsApiUrl,
});

const instanceId = uuidv4();
const pluginIpfs = new PluginObjectStoreIpfs({
parentDir: `/${uuidv4()}/${uuidv4()}/`,
logLevel,
instanceId,
ipfsClientOrOptions,
});

await pluginIpfs.getOrCreateWebServices();
await pluginIpfs.registerWebServices(expressApp);
}

{
// Fabric ledger connection
const channelId = "mychannel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import http, { Server } from "http";
import { Server as SocketIoServer } from "socket.io";
import { AddressInfo } from "net";
import { v4 as uuidv4 } from "uuid";
import { PluginObjectStoreIpfs } from "@hyperledger/cactus-plugin-object-store-ipfs";
import bodyParser from "body-parser";
import express from "express";
import { DefaultApi as ObjectStoreIpfsApi } from "@hyperledger/cactus-plugin-object-store-ipfs";
import { AssetProfile } from "../../../main/typescript/generated/openapi/typescript-axios";
import {
IListenOptions,
Expand Down Expand Up @@ -51,7 +49,6 @@ import {
ReceiptType,
Web3SigningCredential,
} from "@hyperledger/cactus-plugin-ledger-connector-besu";
import { dynamicImportKuboRpcClientESMWorkaround } from "@hyperledger/cacti-esm-compat-hacks";
import Web3 from "web3";

import { makeSessionDataChecks } from "../make-checks";
Expand Down Expand Up @@ -130,51 +127,6 @@ beforeAll(async () => {
fail("Pruning didn't throw OK");
});

{
// IPFS configuration
ipfsContainer = new GoIpfsTestContainer({ logLevel });
expect(ipfsContainer).not.toBeUndefined();

const container = await ipfsContainer.start();
expect(container).not.toBeUndefined();

const expressApp = express();
expressApp.use(bodyParser.json({ limit: "250mb" }));
ipfsServer = http.createServer(expressApp);
const listenOptions: IListenOptions = {
hostname: "localhost",
port: 0,
server: ipfsServer,
};

const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo;
const { address, port } = addressInfo;
ipfsApiHost = `http://${address}:${port}`;

const config = new Configuration({ basePath: ipfsApiHost });
const apiClient = new ObjectStoreIpfsApi(config);

expect(apiClient).not.toBeUndefined();

const ipfsApiUrl = await ipfsContainer.getApiUrl();

const kuboRpcModule = await dynamicImportKuboRpcClientESMWorkaround();
const ipfsClientOrOptions = kuboRpcModule.create({
url: ipfsApiUrl,
});

const instanceId = uuidv4();
const pluginIpfs = new PluginObjectStoreIpfs({
parentDir: `/${uuidv4()}/${uuidv4()}/`,
logLevel,
instanceId,
ipfsClientOrOptions,
});

await pluginIpfs.getOrCreateWebServices();
await pluginIpfs.registerWebServices(expressApp);
}

{
// Fabric ledger connection
const channelId = "mychannel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import http, { Server } from "http";
import { Server as SocketIoServer } from "socket.io";
import { AddressInfo } from "net";
import { v4 as uuidv4 } from "uuid";
import { PluginObjectStoreIpfs } from "@hyperledger/cactus-plugin-object-store-ipfs";
import bodyParser from "body-parser";
import express from "express";
import { DefaultApi as ObjectStoreIpfsApi } from "@hyperledger/cactus-plugin-object-store-ipfs";
import { AssetProfile } from "../../../main/typescript/generated/openapi/typescript-axios";
import {
IListenOptions,
Expand Down Expand Up @@ -51,7 +49,6 @@ import {
ReceiptType,
Web3SigningCredential,
} from "@hyperledger/cactus-plugin-ledger-connector-besu";
import { dynamicImportKuboRpcClientESMWorkaround } from "@hyperledger/cacti-esm-compat-hacks";
import Web3 from "web3";

import { makeSessionDataChecks } from "../make-checks";
Expand Down Expand Up @@ -130,51 +127,6 @@ beforeAll(async () => {
fail("Pruning didn't throw OK");
});

{
// IPFS configuration
ipfsContainer = new GoIpfsTestContainer({ logLevel });
expect(ipfsContainer).not.toBeUndefined();

const container = await ipfsContainer.start();
expect(container).not.toBeUndefined();

const expressApp = express();
expressApp.use(bodyParser.json({ limit: "250mb" }));
ipfsServer = http.createServer(expressApp);
const listenOptions: IListenOptions = {
hostname: "localhost",
port: 0,
server: ipfsServer,
};

const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo;
const { address, port } = addressInfo;
ipfsApiHost = `http://${address}:${port}`;

const config = new Configuration({ basePath: ipfsApiHost });
const apiClient = new ObjectStoreIpfsApi(config);

expect(apiClient).not.toBeUndefined();

const ipfsApiUrl = await ipfsContainer.getApiUrl();

const kuboRpcModule = await dynamicImportKuboRpcClientESMWorkaround();
const ipfsClientOrOptions = kuboRpcModule.create({
url: ipfsApiUrl,
});

const instanceId = uuidv4();
const pluginIpfs = new PluginObjectStoreIpfs({
parentDir: `/${uuidv4()}/${uuidv4()}/`,
logLevel,
instanceId,
ipfsClientOrOptions,
});

await pluginIpfs.getOrCreateWebServices();
await pluginIpfs.registerWebServices(expressApp);
}

{
// Fabric ledger connection
const channelId = "mychannel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@ import http, { Server } from "http";
import type { AddressInfo } from "net";
import { v4 as uuidv4 } from "uuid";
import "jest-extended";
import { PluginObjectStoreIpfs } from "@hyperledger/cactus-plugin-object-store-ipfs";
import bodyParser from "body-parser";
import express, { Express } from "express";
import { DefaultApi as ObjectStoreIpfsApi } from "@hyperledger/cactus-plugin-object-store-ipfs";
import {
IListenOptions,
LogLevelDesc,
Secp256k1Keys,
Servers,
} from "@hyperledger/cactus-common";
import { Configuration } from "@hyperledger/cactus-core-api";
import {
IPluginOdapGatewayConstructorOptions,
PluginOdapGateway,
} from "../../../main/typescript/gateway/plugin-odap-gateway";
import { GoIpfsTestContainer } from "@hyperledger/cactus-test-tooling";
import { dynamicImportKuboRpcClientESMWorkaround } from "@hyperledger/cacti-esm-compat-hacks";
import {
AssetProfile,
ClientV1Request,
Expand All @@ -38,8 +33,6 @@ const MAX_TIMEOUT = 5000;
const FABRIC_ASSET_ID = uuidv4();
const BESU_ASSET_ID = uuidv4();

const logLevel: LogLevelDesc = "INFO";

let odapServerGatewayPluginOptions: IPluginOdapGatewayConstructorOptions;
let odapClientGatewayPluginOptions: IPluginOdapGatewayConstructorOptions;

Expand All @@ -65,50 +58,6 @@ let clientExpressApp: Express;
let clientListenOptions: IListenOptions;

beforeAll(async () => {
{
// Define IPFS connection
ipfsContainer = new GoIpfsTestContainer({ logLevel });
expect(ipfsContainer).not.toBeUndefined();

const container = await ipfsContainer.start();
expect(container).not.toBeUndefined();

const expressApp = express();
expressApp.use(bodyParser.json({ limit: "250mb" }));
ipfsServer = http.createServer(expressApp);
const listenOptions: IListenOptions = {
hostname: "localhost",
port: 0,
server: ipfsServer,
};

const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo;
const { address, port } = addressInfo;
ipfsApiHost = `http://${address}:${port}`;

const config = new Configuration({ basePath: ipfsApiHost });
const ipfsApi = new ObjectStoreIpfsApi(config);

expect(ipfsApi).not.toBeUndefined();

const ipfsApiUrl = await ipfsContainer.getApiUrl();

const kuboRpcModule = await dynamicImportKuboRpcClientESMWorkaround();
const ipfsClientOrOptions = kuboRpcModule.create({
url: ipfsApiUrl,
});

const instanceId = uuidv4();
const pluginIpfs = new PluginObjectStoreIpfs({
parentDir: `/${uuidv4()}/${uuidv4()}/`,
logLevel,
instanceId,
ipfsClientOrOptions,
});

await pluginIpfs.getOrCreateWebServices();
await pluginIpfs.registerWebServices(expressApp);
}
{
// Server Gateway configuration
odapServerGatewayPluginOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import http, { Server } from "http";
import { Server as SocketIoServer } from "socket.io";
import { AddressInfo } from "net";
import { v4 as uuidv4 } from "uuid";
import { PluginObjectStoreIpfs } from "@hyperledger/cactus-plugin-object-store-ipfs";
import bodyParser from "body-parser";
import express from "express";
import { DefaultApi as ObjectStoreIpfsApi } from "@hyperledger/cactus-plugin-object-store-ipfs";
import { AssetProfile } from "../../../main/typescript/generated/openapi/typescript-axios";
import {
IListenOptions,
Expand Down Expand Up @@ -52,7 +50,6 @@ import {
PluginFactoryLedgerConnector,
Web3SigningCredential,
} from "@hyperledger/cactus-plugin-ledger-connector-besu";
import { dynamicImportKuboRpcClientESMWorkaround } from "@hyperledger/cacti-esm-compat-hacks";

import { makeSessionDataChecks } from "../make-checks";
import {
Expand Down Expand Up @@ -125,51 +122,6 @@ beforeAll(async () => {
fail("Pruning didn't throw OK");
});

{
// IPFS configuration
ipfsContainer = new GoIpfsTestContainer({ logLevel });
expect(ipfsContainer).not.toBeUndefined();

const container = await ipfsContainer.start();
expect(container).not.toBeUndefined();

const expressApp = express();
expressApp.use(bodyParser.json({ limit: "250mb" }));
ipfsServer = http.createServer(expressApp);
const listenOptions: IListenOptions = {
hostname: "localhost",
port: 0,
server: ipfsServer,
};

const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo;
const { address, port } = addressInfo;
ipfsApiHost = `http://${address}:${port}`;

const config = new Configuration({ basePath: ipfsApiHost });
const apiClient = new ObjectStoreIpfsApi(config);

expect(apiClient).not.toBeUndefined();

const ipfsApiUrl = await ipfsContainer.getApiUrl();

const kuboRpcModule = await dynamicImportKuboRpcClientESMWorkaround();
const ipfsClientOrOptions = kuboRpcModule.create({
url: ipfsApiUrl,
});

const instanceId = uuidv4();
const pluginIpfs = new PluginObjectStoreIpfs({
parentDir: `/${uuidv4()}/${uuidv4()}/`,
logLevel,
instanceId,
ipfsClientOrOptions,
});

await pluginIpfs.getOrCreateWebServices();
await pluginIpfs.registerWebServices(expressApp);
}

{
// Fabric ledger connection
const channelId = "mychannel";
Expand Down
Loading

0 comments on commit 70cd17a

Please sign in to comment.