forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples/supply-chain): fix test infra - migrate to Fabric v2.5.6
The supply chain app's build and execution scripts should finally be working after this and also be much more stable than before due to the flakiness of the Fabric V1 test ledger not being an issue anymore. 1.The new contract is compiled with go v1.20 and therefore has to have the contract method names capitalized insted of camelCase, otherwise the methods are not possible to be exported and the contract deployment fails even if everything else is correct. 2. The supply chain app now uses the newest edition of the Fabric v2 AIO test ledger container image which uses Fabric v2.5.6 (current LTS at the time of this writing). 3. The shipment contract's source code has been migrated to Fabric v2 meaning that instead of a stub object we get a context object for each method's first parameter and then the stub can be acquired from that context object. 4. The method arguments no longer need to be passed around as an array of strings and instead the contract method's input arguments are first-class go method parameters. 5. Re-enabled a test case that was being skipped until now due to flakiness: ...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts` Depends on hyperledger-cacti#3058 Depends on hyperledger-cacti#3054 Fixes hyperledger-cacti#2945 Fixes hyperledger-cacti#2969 Fixes hyperledger-cacti#1899 Fixes hyperledger-cacti#1521 Fixes hyperledger-cacti#1518 Signed-off-by: Peter Somogyvari <[email protected]>
- Loading branch information
Showing
10 changed files
with
246 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ackend/src/main/typescript/infrastructure/shipment-golang-contract-pinned-dependencies.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* These are the pinned dependencies used to build the go source code that is | ||
* located in the file at: | ||
* examples/cactus-example-supply-chain-backend/src/main/go/shipment.ts | ||
*/ | ||
export const SHIPMENT_GOLANG_CONTRACT_PINNED_DEPENDENCIES = [ | ||
"github.com/hyperledger/[email protected]", | ||
"github.com/hyperledger/[email protected]", | ||
"github.com/hyperledger/[email protected]", | ||
"github.com/hyperledger/fabric-samples/asset-transfer-private-data/[email protected]", | ||
"github.com/stretchr/[email protected]", | ||
"google.golang.org/[email protected]", | ||
"github.com/davecgh/[email protected]", // indirect | ||
"github.com/go-openapi/[email protected]", // indirect | ||
"github.com/go-openapi/[email protected]", // indirect | ||
"github.com/go-openapi/[email protected]", // indirect | ||
"github.com/go-openapi/[email protected]", // indirect | ||
"github.com/gobuffalo/[email protected]", // indirect | ||
"github.com/gobuffalo/[email protected]", // indirect | ||
"github.com/gobuffalo/[email protected]", // indirect | ||
"github.com/golang/[email protected]", // indirect | ||
"github.com/joho/[email protected]", // indirect | ||
"github.com/josharian/[email protected]", // indirect | ||
"github.com/mailru/[email protected]", // indirect | ||
"github.com/pmezard/[email protected]", // indirect | ||
"github.com/rogpeppe/[email protected]", // indirect | ||
"github.com/xeipuuv/[email protected]", // indirect | ||
"github.com/xeipuuv/[email protected]", // indirect | ||
"github.com/xeipuuv/[email protected]", // indirect | ||
"golang.org/x/[email protected]", // indirect | ||
"golang.org/x/[email protected]", // indirect | ||
"golang.org/x/[email protected]", // indirect | ||
"golang.org/x/[email protected]", // indirect | ||
"google.golang.org/genproto/googleapis/[email protected]", // indirect | ||
"google.golang.org/[email protected]", // indirect | ||
"gopkg.in/[email protected]", // indirect | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { Account } from "web3-core"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
import { DiscoveryOptions } from "fabric-network"; | ||
import { | ||
Logger, | ||
Checks, | ||
|
@@ -13,38 +14,31 @@ import { | |
PluginLedgerConnectorQuorum, | ||
Web3SigningCredentialType, | ||
} from "@hyperledger/cactus-plugin-ledger-connector-quorum"; | ||
import { IPluginKeychain } from "@hyperledger/cactus-core-api"; | ||
import { FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1 } from "@hyperledger/cactus-test-tooling"; | ||
import { FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2 } from "@hyperledger/cactus-test-tooling"; | ||
import { | ||
BesuTestLedger, | ||
DEFAULT_FABRIC_2_AIO_IMAGE_NAME, | ||
FABRIC_25_LTS_AIO_FABRIC_VERSION, | ||
FABRIC_25_LTS_AIO_IMAGE_VERSION, | ||
FabricTestLedgerV1, | ||
QuorumTestLedger, | ||
} from "@hyperledger/cactus-test-tooling"; | ||
|
||
import BambooHarvestRepositoryJSON from "../../json/generated/BambooHarvestRepository.json"; | ||
import BookshelfRepositoryJSON from "../../json/generated/BookshelfRepository.json"; | ||
import { | ||
IEthContractDeployment, | ||
ISupplyChainContractDeploymentInfo, | ||
IFabricContractDeployment, | ||
// OrgEnv, | ||
} from "@hyperledger/cactus-example-supply-chain-business-logic-plugin"; | ||
import { | ||
PluginLedgerConnectorFabric, | ||
DefaultEventHandlerStrategy, | ||
} from "@hyperledger/cactus-plugin-ledger-connector-fabric"; | ||
import { DiscoveryOptions } from "fabric-network"; | ||
import { SHIPMENT_CONTRACT_GO_SOURCE } from "../../go/shipment"; | ||
import { IPluginKeychain } from "@hyperledger/cactus-core-api"; | ||
|
||
export const org1Env = { | ||
CORE_PEER_LOCALMSPID: "Org1MSP", | ||
CORE_PEER_ADDRESS: "peer0.org1.example.com:7051", | ||
CORE_PEER_MSPCONFIGPATH: | ||
"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp", | ||
CORE_PEER_TLS_ROOTCERT_FILE: | ||
"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt", | ||
ORDERER_TLS_ROOTCERT_FILE: | ||
"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem", | ||
}; | ||
import BambooHarvestRepositoryJSON from "../../json/generated/BambooHarvestRepository.json"; | ||
import BookshelfRepositoryJSON from "../../json/generated/BookshelfRepository.json"; | ||
import { SHIPMENT_CONTRACT_GO_SOURCE } from "../../go/shipment"; | ||
import { SHIPMENT_GOLANG_CONTRACT_PINNED_DEPENDENCIES } from "./shipment-golang-contract-pinned-dependencies"; | ||
|
||
export interface ISupplyChainAppDummyInfrastructureOptions { | ||
logLevel?: LogLevelDesc; | ||
|
@@ -113,8 +107,10 @@ export class SupplyChainAppDummyInfrastructure { | |
}); | ||
this.fabric = new FabricTestLedgerV1({ | ||
publishAllPorts: true, | ||
imageName: "ghcr.io/hyperledger/cactus-fabric-all-in-one", | ||
imageName: DEFAULT_FABRIC_2_AIO_IMAGE_NAME, | ||
imageVersion: FABRIC_25_LTS_AIO_IMAGE_VERSION, | ||
logLevel: level, | ||
envVars: new Map([["FABRIC_VERSION", FABRIC_25_LTS_AIO_FABRIC_VERSION]]), | ||
emitContainerLogs: true, | ||
}); | ||
|
||
|
@@ -292,16 +288,20 @@ export class SupplyChainAppDummyInfrastructure { | |
sshConfig: sshConfig, | ||
logLevel: this.options.logLevel || "INFO", | ||
connectionProfile: connectionProfile, | ||
cliContainerEnv: org1Env, | ||
cliContainerEnv: FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1, | ||
discoveryOptions: discoveryOptions, | ||
eventHandlerOptions: { | ||
strategy: DefaultEventHandlerStrategy.NetworkScopeAllfortx, | ||
}, | ||
}); | ||
|
||
const res = await connector.deployContractGoSourceV1({ | ||
tlsRootCertFiles: org1Env.CORE_PEER_TLS_ROOTCERT_FILE as string, | ||
targetPeerAddresses: [org1Env.CORE_PEER_ADDRESS as string], | ||
tlsRootCertFiles: | ||
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.CORE_PEER_TLS_ROOTCERT_FILE, | ||
targetPeerAddresses: [ | ||
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.CORE_PEER_ADDRESS, | ||
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2.CORE_PEER_ADDRESS, | ||
], | ||
policyDslSource: "OR('Org1MSP.member','Org2MSP.member')", | ||
channelId: "mychannel", | ||
chainCodeVersion: "1.0.0", | ||
|
@@ -311,29 +311,11 @@ export class SupplyChainAppDummyInfrastructure { | |
filename: "shipment.go", | ||
}, | ||
moduleName: "shipment", | ||
targetOrganizations: [org1Env], | ||
pinnedDeps: [ | ||
"github.com/Knetic/[email protected]+incompatible", | ||
"github.com/Shopify/[email protected]", | ||
"github.com/fsouza/[email protected]", | ||
"github.com/grpc-ecosystem/[email protected]", | ||
"github.com/hashicorp/[email protected]", | ||
"github.com/hyperledger/[email protected]", | ||
"github.com/hyperledger/[email protected]", | ||
"github.com/miekg/[email protected]", | ||
"github.com/mitchellh/[email protected]", | ||
"github.com/onsi/[email protected]", | ||
"github.com/onsi/[email protected]", | ||
"github.com/op/[email protected]", | ||
"github.com/pkg/[email protected]", | ||
"github.com/spf13/[email protected]", | ||
"github.com/stretchr/[email protected]", | ||
"github.com/sykesm/[email protected]", | ||
"go.uber.org/[email protected]", | ||
"golang.org/x/[email protected]", | ||
"golang.org/x/[email protected]", | ||
"google.golang.org/[email protected]", | ||
targetOrganizations: [ | ||
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1, | ||
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2, | ||
], | ||
pinnedDeps: SHIPMENT_GOLANG_CONTRACT_PINNED_DEPENDENCIES, | ||
}); | ||
this.log.debug("Supply chain app Fabric contract deployment result:", res); | ||
|
||
|
Oops, something went wrong.