diff --git a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-k8s.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-k8s.json.test.ts.snap index bb08cf08..40a039f8 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-k8s.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-k8s.json.test.ts.snap @@ -1,5 +1,65 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf2-1org-1chaincode-k8s.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-k8s.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf2-1org-1chaincode-k8s.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "2.4.7", + "tls": false, + "engine": "kubernetes" + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com" + }, + "orderers": [ + { + "groupName": "group1", + "type": "solo", + "instances": 1 + } + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + } + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0", + "peer1" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "node", + "channel": "my-channel1", + "directory": "./chaincodes/chaincode-kv-node" + } + ] +} +" +`; + exports[`samples/fablo-config-hlf2-1org-1chaincode-k8s.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-k8s.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf2-1org-1chaincode-k8s.json 1`] = ` "/config /crypto-config @@ -514,6 +574,7 @@ exports[`samples/fablo-config-hlf2-1org-1chaincode-k8s.json should create proper exports[`samples/fablo-config-hlf2-1org-1chaincode-k8s.json should create proper files from samples/fablo-config-hlf2-1org-1chaincode-k8s.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-k8s.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-k8s.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-k8s.json.tmpdir/fablo-target/fabric-k8s.sh", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-k8s.json.tmpdir/fablo-target/fabric-k8s/.env", diff --git a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.test.ts.snap index 549ebe20..7cfa707c 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.test.ts.snap @@ -1,5 +1,74 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "2.5.12", + "tls": false, + "peerDevMode": true, + "engine": "docker" + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com", + "mspName": "OrdererMSP" + }, + "orderers": [ + { + "groupName": "group1", + "type": "solo", + "instances": 1 + } + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com", + "mspName": "Org1MSP" + }, + "ca": { + "db": "postgres" + }, + "peer": { + "instances": 1, + "db": "CouchDb" + }, + "tools": { + "fabloRest": true + } + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "node", + "channel": "my-channel1", + "directory": "./chaincodes/chaincode-kv-node", + "privateData": [] + } + ], + "hooks": {} +}" +`; + exports[`samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json 1`] = ` "/config /crypto-config @@ -3466,6 +3535,7 @@ exports[`samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json should cre exports[`samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json should create proper files from samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json", diff --git a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap index d4a29726..6869515b 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap @@ -1,5 +1,64 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf2-1org-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf2-1org-1chaincode.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "2.5.9", + "tls": false + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com" + }, + "orderers": [ + { + "groupName": "group1", + "type": "solo", + "instances": 1 + } + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + } + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0", + "peer1" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "node", + "channel": "my-channel1", + "directory": "./chaincodes/chaincode-kv-node" + } + ] +} +" +`; + exports[`samples/fablo-config-hlf2-1org-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf2-1org-1chaincode.json 1`] = ` "/config /crypto-config @@ -3539,6 +3598,7 @@ exports[`samples/fablo-config-hlf2-1org-1chaincode.json should create proper e2e exports[`samples/fablo-config-hlf2-1org-1chaincode.json should create proper files from samples/fablo-config-hlf2-1org-1chaincode.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode.json.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf2-1org-1chaincode.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json", diff --git a/e2e/__snapshots__/fablo-config-hlf2-1org-2chaincode-raft-ccaas.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-1org-2chaincode-raft-ccaas.json.test.ts.snap index 25dc83f2..2db0156a 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-1org-2chaincode-raft-ccaas.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-1org-2chaincode-raft-ccaas.json.test.ts.snap @@ -1,5 +1,90 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "3.0.0", + "tls": true + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com" + }, + "orderers": [ + { + "groupName": "group1", + "type": "raft", + "instances": 1 + } + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com" + }, + "ca": { + "db": "postgres" + }, + "peer": { + "instances": 1, + "db": "CouchDb" + }, + "tools": { + "fabloRest": true + } + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0" + ] + } + ] + }, + { + "name": "my-channel2", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "ccaas", + "channel": "my-channel1", + "image": "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" + }, + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "ccaas", + "channel": "my-channel2", + "image": "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" + } + ], + "hooks": { + "postGenerate": "perl -i -pe 's/MaxMessageCount: 10/MaxMessageCount: 1/g' \\"./fablo-target/fabric-config/configtx.yaml\\"" + } +} +" +`; + exports[`samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json 1`] = ` "/config /crypto-config @@ -3688,6 +3773,7 @@ exports[`samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json should create exports[`samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json should create proper files from samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json", diff --git a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap index 947bd00e..1d5b1674 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.test.ts.snap @@ -1,5 +1,67 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml should create proper e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.tmpdir/fablo-target/fablo-config.yaml from samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml 1`] = ` +"--- +"$schema": https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json +global: + fabricVersion: 2.5.12 + tls: false + +orgs: + - organization: + name: Orderer + domain: orderer.example.com + orderers: + - groupName: group1 + prefix: orderer + type: solo + instances: 1 + - organization: + name: Org1 + domain: org1.example.com + peer: + instances: 2 + - organization: + name: Org2 + domain: org2.example.com + peer: + instances: 1 +channels: + - name: my-channel1 + orgs: + - name: Org1 + peers: + - peer0 + - peer1 + - name: Org2 + peers: + - peer0 +chaincodes: + - name: or-policy-chaincode + version: 0.0.1 + lang: node + channel: my-channel1 + init: '{"Args":[]}' + endorsement: OR('Org1MSP.member', 'Org2MSP.member') + directory: "./chaincodes/chaincode-kv-node" + privateData: + - name: org1-collection + orgNames: + - Org1 + - name: and-policy-chaincode + version: 0.0.1 + lang: golang + channel: my-channel1 + endorsement: AND('Org1MSP.member', 'Org2MSP.member') + directory: "./chaincodes/chaincode-kv-go" + privateData: + - name: both-orgs-collection + orgNames: + - Org1 + - Org2 +" +`; + exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml should create proper e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml 1`] = ` "/config /crypto-config @@ -4501,6 +4563,7 @@ exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml should cr exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml should create proper files from samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.tmpdir/fablo-target/fablo-config.yaml", "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.tmpdir/fablo-target/fabric-config/collections/my-channel1-and-policy-chaincode.json", "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml.tmpdir/fablo-target/fabric-config/collections/my-channel1-or-policy-chaincode.json", diff --git a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap index fcf6576e..730e7261 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.test.ts.snap @@ -1,5 +1,90 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml should create proper e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.tmpdir/fablo-target/fablo-config.yaml from samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml 1`] = ` +"--- +"$schema": https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json +global: + fabricVersion: 2.5.12 + tls: true + tools: + explorer: true + monitoring: + loglevel: debug +orgs: + - organization: + name: Orderer1 + domain: orderer1.com + orderers: + - groupName: group1 + type: raft + instances: 3 + - organization: + name: Orderer2 + domain: orderer2.com + orderers: + - groupName: group2 + type: solo + instances: 1 + - organization: + name: Org1 + domain: org1.example.com + # this is the default configuration for peers that may be used in other orgs + peer: &defaultPeerConfig + prefix: peer + instances: 2 + anchorPeerInstances: 2 + db: LevelDb + tools: + fabloRest: true + - organization: + name: Org2 + domain: org2.example.com + peer: *defaultPeerConfig +channels: + - name: my-channel1 + orgs: + - name: Org1 + peers: + - peer0 + - name: Org2 + peers: + - peer0 + - name: my-channel2 + orgs: + - name: Org1 + peers: + - peer1 + - name: Org2 + peers: + - peer1 + - name: my-channel3 + ordererGroup: group2 + orgs: + - name: Org1 + peers: + - peer0 + - name: Org2 + peers: + - peer1 +chaincodes: + - name: chaincode1 + version: 0.0.1 + lang: node + channel: my-channel1 + endorsement: OR ('Org1MSP.member', 'Org2MSP.member') + directory: "./chaincodes/chaincode-kv-node" + - name: chaincode2 + version: 0.0.1 + lang: java + channel: my-channel2 + endorsement: OR ('Org1MSP.member', 'Org2MSP.member') + directory: "./chaincodes/chaincode-java-simple" +hooks: + # changes MaxMessageCount to 1 + postGenerate: "perl -i -pe 's/MaxMessageCount: 10/MaxMessageCount: 1/g' \\"./fablo-target/fabric-config/configtx.yaml\\"" +" +`; + exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml should create proper e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml 1`] = ` "/config /crypto-config @@ -6434,6 +6519,7 @@ exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml should create pro exports[`samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml should create proper files from samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.tmpdir/fablo-target/fablo-config.yaml", "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer1.json", diff --git a/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap index 323f64b5..d5ba1ab9 100644 --- a/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.test.ts.snap @@ -1,5 +1,139 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "2.3.2", + "tls": true, + "tools": { + "explorer": true + } + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com" + }, + "orderers": [ + { + "groupName": "group1", + "type": "raft", + "instances": 2 + } + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + }, + "orderers": [ + { + "groupName": "group1", + "type": "raft", + "instances": 2 + } + ] + }, + { + "organization": { + "name": "Org2", + "domain": "org2.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + }, + "orderers": [ + { + "groupName": "group1", + "type": "raft", + "instances": 2 + } + ] + }, + { + "organization": { + "name": "Org3", + "domain": "org3.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + }, + "orderers": [ + { + "groupName": "group1", + "type": "raft", + "instances": 2 + } + ] + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0", + "peer1" + ] + } + ] + }, + { + "name": "my-channel2", + "orgs": [ + { + "name": "Org2", + "peers": [ + "peer0", + "peer1" + ] + } + ] + }, + { + "name": "my-channel3", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0", + "peer1" + ] + }, + { + "name": "Org2", + "peers": [ + "peer0", + "peer1" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "node", + "channel": "my-channel1", + "directory": "./chaincodes/chaincode-kv-node" + } + ] +} +" +`; + exports[`samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json should create proper e2e/__tmp__/samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json 1`] = ` "/config /crypto-config @@ -6998,6 +7132,7 @@ exports[`samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json should cr exports[`samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json should create proper files from samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json", diff --git a/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap index 9d6ea331..9ae42ddb 100644 --- a/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap @@ -1,5 +1,67 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf3-1orgs-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf3-1orgs-1chaincode.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "3.0.0", + "tls": true, + "monitoring": { + "loglevel": "debug" + } + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com" + }, + "orderers": [ + { + "groupName": "group1", + "type": "raft", + "instances": 4 + } + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + } + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0", + "peer1" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "node", + "channel": "my-channel1", + "directory": "./chaincodes/chaincode-kv-node" + } + ] + } + " +`; + exports[`samples/fablo-config-hlf3-1orgs-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf3-1orgs-1chaincode.json 1`] = ` "/config /crypto-config @@ -3917,6 +3979,7 @@ exports[`samples/fablo-config-hlf3-1orgs-1chaincode.json should create proper e2 exports[`samples/fablo-config-hlf3-1orgs-1chaincode.json should create proper files from samples/fablo-config-hlf3-1orgs-1chaincode.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json", diff --git a/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap index 53ce0a80..81ae9a00 100644 --- a/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap @@ -1,5 +1,68 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`samples/fablo-config-hlf3-bft-1orgs-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-bft-1orgs-1chaincode.json.tmpdir/fablo-target/fablo-config.json from samples/fablo-config-hlf3-bft-1orgs-1chaincode.json 1`] = ` +"{ + "$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.3.0/schema.json", + "global": { + "fabricVersion": "3.0.0", + "tls": true, + "monitoring": { + "loglevel": "debug" + } + }, + "orgs": [ + { + "organization": { + "name": "Orderer", + "domain": "orderer.example.com" + }, + "orderers": [ + { + "groupName": "group1", + "type": "BFT", + "instances": 4 + } + + ] + }, + { + "organization": { + "name": "Org1", + "domain": "org1.example.com" + }, + "peer": { + "instances": 2, + "db": "LevelDb" + } + } + ], + "channels": [ + { + "name": "my-channel1", + "orgs": [ + { + "name": "Org1", + "peers": [ + "peer0", + "peer1" + ] + } + ] + } + ], + "chaincodes": [ + { + "name": "chaincode1", + "version": "0.0.1", + "lang": "node", + "channel": "my-channel1", + "directory": "./chaincodes/chaincode-kv-node" + } + ] + } + " +`; + exports[`samples/fablo-config-hlf3-bft-1orgs-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-bft-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore from samples/fablo-config-hlf3-bft-1orgs-1chaincode.json 1`] = ` "/config /crypto-config @@ -3941,6 +4004,7 @@ exports[`samples/fablo-config-hlf3-bft-1orgs-1chaincode.json should create prope exports[`samples/fablo-config-hlf3-bft-1orgs-1chaincode.json should create proper files from samples/fablo-config-hlf3-bft-1orgs-1chaincode.json 1`] = ` [ + "e2e/__tmp__/samples/fablo-config-hlf3-bft-1orgs-1chaincode.json.tmpdir/fablo-target/fablo-config.json", "e2e/__tmp__/samples/fablo-config-hlf3-bft-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore", "e2e/__tmp__/samples/fablo-config-hlf3-bft-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/configtx.yaml", "e2e/__tmp__/samples/fablo-config-hlf3-bft-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json", diff --git a/fablo.sh b/fablo.sh index e815e6b6..3ebed6b3 100755 --- a/fablo.sh +++ b/fablo.sh @@ -28,6 +28,75 @@ getDefaultFabloConfig() { fi } +snapshotFabloConfigToTarget() { + local fablo_config="$1" + local fablo_target="$2" + + if [ -z "$fablo_config" ] || [ ! -f "$fablo_config" ]; then + return + fi + + mkdir -p "$fablo_target" + + local ext="${fablo_config##*.}" + local preserved_name="fablo-config.$ext" + cp -f "$fablo_config" "$fablo_target/$preserved_name" + +} + +getStoredConfigSnapshotPath() { + if [ -f "$FABLO_TARGET/fablo-config.json" ]; then + echo "$FABLO_TARGET/fablo-config.json" + elif [ -f "$FABLO_TARGET/fablo-config.yaml" ]; then + echo "$FABLO_TARGET/fablo-config.yaml" + elif [ -f "$FABLO_TARGET/fablo-config.yml" ]; then + echo "$FABLO_TARGET/fablo-config.yml" + else + echo "" + fi +} + +verifyConfigMatchesOrFail() { + local current_config=${1:-$(getDefaultFabloConfig)} + + if [ -z "$current_config" ] || [ ! -f "$current_config" ]; then + return + fi + + local stored_config + stored_config="$(getStoredConfigSnapshotPath)" + + if [ -z "$stored_config" ]; then + echo "No stored config snapshot found in '$FABLO_TARGET'. Storing current config snapshot for future comparisons." + + local ext="${current_config##*.}" + if [ "$ext" = "json" ] || [ "$ext" = "yaml" ] || [ "$ext" = "yml" ] ; then + snapshotFabloConfigToTarget "$current_config" "$FABLO_TARGET" + else + echo "Error: Unsupported config file extension '.$ext'. Supported extensions are: .json, .yaml" + exit 1 + fi + return + fi + + if cmp -s "$stored_config" "$current_config"; then + return + fi + + echo "Error: Fablo configuration has changed since the network at '$FABLO_TARGET' was generated." + echo "Stored config: $stored_config" + echo "Current config: $current_config" + echo "" + echo "--- Diff (stored vs current) ---" + # Show unified diff + diff -u "$stored_config" "$current_config" || true + echo "--------------------------------" + echo "" + echo "Please run 'fablo prune' to remove the existing network before applying configuration changes," + echo "or run 'fablo recreate [path/to/fablo-config]' to prune and start with the new configuration." + exit 1 +} + getSnapshotPath() { path="${1:-'snapshot'}" if echo "$path" | grep -q "tar.gz$"; then @@ -204,6 +273,7 @@ generateNetworkConfig() { if [ -f "$fablo_target/hooks/post-generate.sh" ]; then ("$fablo_target/hooks/post-generate.sh") fi + snapshotFabloConfigToTarget "$fablo_config" "$fablo_target" } networkPrune() { @@ -220,9 +290,12 @@ networkPrune() { } networkUp() { + local fablo_config=${1:-$(getDefaultFabloConfig)} if [ ! -d "$FABLO_TARGET" ] || [ -z "$(ls -A "$FABLO_TARGET")" ]; then echo "Network target directory is empty" - generateNetworkConfig "$1" + generateNetworkConfig "$fablo_config" + else + verifyConfigMatchesOrFail "$fablo_config" fi executeFabloCommand up } diff --git a/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml b/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml index 5b9f8d3f..f3efcffb 100644 --- a/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml +++ b/samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.yaml @@ -55,4 +55,4 @@ chaincodes: - name: both-orgs-collection orgNames: - Org1 - - Org2 \ No newline at end of file + - Org2