diff --git a/packages/cactus-plugin-ledger-connector-corda/README.md b/packages/cactus-plugin-ledger-connector-corda/README.md index 3d0113e700..480b720aa9 100644 --- a/packages/cactus-plugin-ledger-connector-corda/README.md +++ b/packages/cactus-plugin-ledger-connector-corda/README.md @@ -570,7 +570,11 @@ full name of the container image otherwise referred to as `cactus-corda-connecto From the project root: ```sh -DOCKER_BUILDKIT=1 docker build ./packages/cactus-plugin-ledger-connector-corda/src/main-server/ -t cccs +DOCKER_BUILDKIT=1 docker build \ + ./packages/cactus-plugin-ledger-connector-corda/src/main-server/ \ + --progress=plain \ + --tag cccs \ + --tag "ghcr.io/hyperledger/cactus-connector-corda-server:$(date +%F)-$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)-$(git rev-parse --short HEAD)" ``` ## Scan The Locally Built Container Image for Vulnerabilities with Trivy diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/jvm/serde/factory/create-jvm-int.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/jvm/serde/factory/create-jvm-int.ts new file mode 100644 index 0000000000..ea799644e7 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/jvm/serde/factory/create-jvm-int.ts @@ -0,0 +1,12 @@ +import { JvmObject } from "../../../generated/openapi/typescript-axios/api"; +import { JvmTypeKind } from "../../../generated/openapi/typescript-axios/api"; + +export function createJvmInt(data: number): JvmObject { + return { + jvmTypeKind: JvmTypeKind.Primitive, + jvmType: { + fqClassName: "java.lang.Integer", + }, + primitiveValue: data, + }; +} diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/public-api.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/public-api.ts index 96b4e6e71f..7bc9ecc5cf 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/public-api.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/public-api.ts @@ -44,6 +44,7 @@ export { createJvmCordaX500Name, } from "./jvm/serde/factory/create-jvm-corda-x500-name"; +export { createJvmInt } from "./jvm/serde/factory/create-jvm-int"; export { createJvmLong } from "./jvm/serde/factory/create-jvm-long"; export { createJvmCurrency } from "./jvm/serde/factory/create-jvm-currency"; diff --git a/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/flow-database-access-v4.8.test.ts b/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/flow-database-access-v4.8.test.ts index 9703ccf8fd..3c9bfb0267 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/flow-database-access-v4.8.test.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/flow-database-access-v4.8.test.ts @@ -5,12 +5,9 @@ import { Containers, CordaTestLedger, pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { LogLevelDesc } from "@hyperledger/cactus-common"; -import { - SampleCordappEnum, CordaConnectorContainer, } from "@hyperledger/cactus-test-tooling"; +import { LogLevelDesc } from "@hyperledger/cactus-common"; import { CordappDeploymentConfig, @@ -18,9 +15,10 @@ import { DeployContractJarsV1Request, FlowInvocationType, InvokeContractV1Request, - JvmTypeKind, } from "../../../main/typescript/generated/openapi/typescript-axios/index"; import { Configuration } from "@hyperledger/cactus-core-api"; +import { createJvmString } from "../../../main/typescript/jvm/serde/factory/create-jvm-string"; +import { createJvmInt } from "../../../main/typescript"; const testCase = "Tests are passing on the JVM side"; const logLevel: LogLevelDesc = "TRACE"; @@ -38,8 +36,9 @@ test("BEFORE " + testCase, async (t: Test) => { test(testCase, async (t: Test) => { const ledger = new CordaTestLedger({ imageName: "ghcr.io/hyperledger/cactus-corda-4-8-all-in-one-flowdb", - imageVersion: "2021-11-23--feat-1493", + imageVersion: "2024-07-08-hotfix-1", logLevel, + rpcPortA: 10006, // @see: ./tools/docker/corda-all-in-one/corda-v4_8-flowdb/build.gradle }); t.ok(ledger, "CordaTestLedger v4.8 instantaited OK"); @@ -48,7 +47,7 @@ test(testCase, async (t: Test) => { await ledger.destroy(); await pruneDockerAllIfGithubAction({ logLevel }); }); - const ledgerContainer = await ledger.start(); + const ledgerContainer = await ledger.start(false); t.ok( ledgerContainer, "CordaTestLedger v4.8 container truthy post-start() OK", @@ -57,7 +56,13 @@ test(testCase, async (t: Test) => { await ledger.logDebugPorts(); const partyARpcPort = await ledger.getRpcAPublicPort(); - const jarFiles = await ledger.pullCordappJars(SampleCordappEnum.BASIC_FLOW); + // We cannot import SampleCordappEnum here because it causes a circular + // import cycle which means that the import statement does compile but will + // yield undefinedat runtime and the test will crash on this line. + // So, instead of importing the enum, we just hardcode a magic string which is + // the exact opposite of what we should be doing but until we figure out the + // circular imports problem it's an acceptable workaround. + const jarFiles = await ledger.pullCordappJars("BASIC_FLOW" as never); t.comment(`Fetched ${jarFiles.length} cordapp jars OK`); const internalIpOrUndefined = await internalIpV4(); @@ -66,13 +71,14 @@ test(testCase, async (t: Test) => { t.comment(`Internal IP (based on default gateway): ${internalIp}`); const partyARpcUsername = "user1"; - const partyARpcPassword = "password"; + const partyARpcPassword = "test"; const springAppConfig = { logging: { level: { root: "INFO", "net.corda": "INFO", "org.hyperledger.cactus": "DEBUG", + "org.hyperledger.cacti": "DEBUG", }, }, cactus: { @@ -92,8 +98,6 @@ test(testCase, async (t: Test) => { const connector = new CordaConnectorContainer({ logLevel, - imageName: "ghcr.io/hyperledger/cactus-connector-corda-server", - imageVersion: "2021-11-23--feat-1493", envVars: [envVarSpringAppJson], }); t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK"); @@ -106,7 +110,7 @@ test(testCase, async (t: Test) => { } }); - const connectorContainer = await connector.start(); + const connectorContainer = await connector.start(false); t.ok(connectorContainer, "CordaConnectorContainer started OK"); await connector.logDebugPorts(); @@ -146,22 +150,12 @@ test(testCase, async (t: Test) => { flowFullClassName: "net.corda.samples.flowdb.AddTokenValueFlow", flowInvocationType: FlowInvocationType.FlowDynamic, params: [ - { - jvmTypeKind: JvmTypeKind.Primitive, - jvmType: { - fqClassName: "java.lang.String", - }, - primitiveValue: myToken, - }, - { - jvmTypeKind: JvmTypeKind.Primitive, - jvmType: { - fqClassName: "java.lang.Integer", - }, - primitiveValue: initialValue, - }, + createJvmString({ + data: myToken, + }), + createJvmInt(initialValue), ], - } as unknown as InvokeContractV1Request; + }; const resAdd = await apiClient.invokeContractV1(reqAdd); t.ok(resAdd, "InvokeContractV1Request truthy OK"); @@ -173,15 +167,11 @@ test(testCase, async (t: Test) => { flowFullClassName: "net.corda.samples.flowdb.QueryTokenValueFlow", flowInvocationType: FlowInvocationType.FlowDynamic, params: [ - { - jvmTypeKind: JvmTypeKind.Primitive, - jvmType: { - fqClassName: "java.lang.String", - }, - primitiveValue: myToken, - }, + createJvmString({ + data: myToken, + }), ], - } as unknown as InvokeContractV1Request; + }; const resQuery = await apiClient.invokeContractV1(reqQuery); t.ok(resQuery, "InvokeContractV1Request truthy OK"); @@ -202,22 +192,12 @@ test(testCase, async (t: Test) => { flowFullClassName: "net.corda.samples.flowdb.UpdateTokenValueFlow", flowInvocationType: FlowInvocationType.FlowDynamic, params: [ - { - jvmTypeKind: JvmTypeKind.Primitive, - jvmType: { - fqClassName: "java.lang.String", - }, - primitiveValue: myToken, - }, - { - jvmTypeKind: JvmTypeKind.Primitive, - jvmType: { - fqClassName: "java.lang.Integer", - }, - primitiveValue: finalValue, - }, + createJvmString({ + data: myToken, + }), + createJvmInt(finalValue), ], - } as unknown as InvokeContractV1Request; + }; const resUpd = await apiClient.invokeContractV1(reqUpd); t.ok(resUpd, "InvokeContractV1Request truthy OK"); diff --git a/packages/cactus-test-tooling/src/main/typescript/corda-connector/corda-connector-container.ts b/packages/cactus-test-tooling/src/main/typescript/corda-connector/corda-connector-container.ts index 642217a096..06633ba926 100644 --- a/packages/cactus-test-tooling/src/main/typescript/corda-connector/corda-connector-container.ts +++ b/packages/cactus-test-tooling/src/main/typescript/corda-connector/corda-connector-container.ts @@ -17,8 +17,9 @@ import { Containers } from "../common/containers"; * Provides default options for Corda connector server */ const DEFAULTS = Object.freeze({ - imageVersion: "2021-03-01-7e07b5b", - imageName: "petermetz/cactus-connector-corda-server", + imageVersion: + "2024-07-09-test-connector-corda-fix-flow-database-access-v4-8-37919dc84", + imageName: "ghcr.io/hyperledger/cactus-connector-corda-server", apiPort: 8080, envVars: [], }); @@ -120,7 +121,9 @@ export class CordaConnectorContainer { [`${this.apiPort}/tcp`]: {}, // REST API HTTP port [`9001/tcp`]: {}, // SupervisorD Web UI }, - PublishAllPorts: true, + HostConfig: { + PublishAllPorts: true, + }, Env: this.envVars, }, {}, diff --git a/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts index d633ccada9..d453dfc1db 100644 --- a/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts +++ b/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts @@ -145,7 +145,9 @@ export class CordaTestLedger implements ITestLedger { [`${this.rpcPortC}/tcp`]: {}, // corda PartyC RPC "22/tcp": {}, // ssh server }, - PublishAllPorts: true, + HostConfig: { + PublishAllPorts: true, + }, // TODO: this can be removed once the new docker image is published and // specified as the default one to be used by the tests. // Healthcheck: {