Skip to content

Commit 357d0d7

Browse files
committed
Validation changes to make explicit Fablo supports Fabric up to 3.0.0-beta
Signed-off-by: Jakub Dzikowski <[email protected]>
1 parent fce9648 commit 357d0d7

7 files changed

+78
-14
lines changed

e2e/__snapshots__/extendConfig.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9806,14 +9806,14 @@ exports[`extend config samples/fablo-config-hlf3-1orgs-1chaincode.json 1`] = `
98069806
"orderer": "V2_0",
98079807
},
98089808
"engine": "docker",
9809-
"fabricBaseosVersion": "3.0.0",
9809+
"fabricBaseosVersion": "3.0.0-beta",
98109810
"fabricCaVersion": "1.5.5",
9811-
"fabricCcenvVersion": "3.0.0",
9811+
"fabricCcenvVersion": "3.0.0-beta",
98129812
"fabricJavaenvVersion": "2.5",
98139813
"fabricNodeenvVersion": "2.5",
98149814
"fabricRecommendedNodeVersion": "16",
98159815
"fabricToolsVersion": "3.0.0-beta",
9816-
"fabricVersion": "3.0.0",
9816+
"fabricVersion": "3.0.0-beta",
98179817
"monitoring": {
98189818
"loglevel": "debug",
98199819
},
@@ -10764,14 +10764,14 @@ exports[`extend config samples/fablo-config-hlf3-bft-1orgs-1chaincode.json 1`] =
1076410764
"orderer": "V2_0",
1076510765
},
1076610766
"engine": "docker",
10767-
"fabricBaseosVersion": "3.0.0",
10767+
"fabricBaseosVersion": "3.0.0-beta",
1076810768
"fabricCaVersion": "1.5.5",
10769-
"fabricCcenvVersion": "3.0.0",
10769+
"fabricCcenvVersion": "3.0.0-beta",
1077010770
"fabricJavaenvVersion": "2.5",
1077110771
"fabricNodeenvVersion": "2.5",
1077210772
"fabricRecommendedNodeVersion": "16",
1077310773
"fabricToolsVersion": "3.0.0-beta",
10774-
"fabricVersion": "3.0.0",
10774+
"fabricVersion": "3.0.0-beta",
1077510775
"monitoring": {
1077610776
"loglevel": "debug",
1077710777
},

e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`samples/fablo-config-hlf3-1orgs-1chaincode.json should create proper e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/.npm/_logs/2024-12-07T09_57_41_821Z-debug-0.log from samples/fablo-config-hlf3-1orgs-1chaincode.json 1`] = `
4+
"0 verbose cli /usr/local/bin/node /usr/local/bin/npm
5+
1 info using [email protected]
6+
2 info using [email protected]
7+
3 timing npm:load:whichnode Completed in 6ms
8+
4 timing config:load:defaults Completed in 1ms
9+
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
10+
6 timing config:load:builtin Completed in 1ms
11+
7 timing config:load:cli Completed in 2ms
12+
8 timing config:load:env Completed in 0ms
13+
9 timing config:load:project Completed in 7ms
14+
10 timing config:load:file:/network/workspace/.npmrc Completed in 2ms
15+
11 timing config:load:user Completed in 2ms
16+
12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
17+
13 timing config:load:global Completed in 0ms
18+
14 timing config:load:setEnvs Completed in 0ms
19+
15 timing config:load Completed in 15ms
20+
16 timing npm:load:configload Completed in 15ms
21+
17 timing npm:load:mkdirpcache Completed in 8ms
22+
18 timing npm:load:mkdirplogs Completed in 12ms
23+
19 verbose title npm root
24+
20 verbose argv "root" "--global"
25+
21 timing npm:load:setTitle Completed in 2ms
26+
22 timing config:load:flatten Completed in 2ms
27+
23 timing npm:load:display Completed in 3ms
28+
24 verbose logfile logs-max:10 dir:/network/workspace/.npm/_logs/2024-12-07T09_57_41_821Z-
29+
25 verbose logfile /network/workspace/.npm/_logs/2024-12-07T09_57_41_821Z-debug-0.log
30+
26 timing npm:load:logFile Completed in 68ms
31+
27 timing npm:load:timers Completed in 0ms
32+
28 timing npm:load:configScope Completed in 0ms
33+
29 timing npm:load Completed in 118ms
34+
30 timing command:root Completed in 5ms
35+
31 verbose exit 0
36+
32 timing npm Completed in 140ms
37+
33 info ok
38+
"
39+
`;
40+
341
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`] = `
442
"/config
543
/crypto-config
@@ -1521,12 +1559,12 @@ CHAINCODES_BASE_DIR=<absolute path>
15211559
COMPOSE_PROJECT_NAME=<name with timestamp>
15221560
LOGGING_LEVEL=debug
15231561
1524-
FABRIC_VERSION=3.0.0
1562+
FABRIC_VERSION=3.0.0-beta
15251563
FABRIC_TOOLS_VERSION=3.0.0-beta
15261564
FABRIC_CA_VERSION=1.5.5
15271565
FABRIC_CA_POSTGRES_VERSION=14
1528-
FABRIC_CCENV_VERSION=3.0.0
1529-
FABRIC_BASEOS_VERSION=3.0.0
1566+
FABRIC_CCENV_VERSION=3.0.0-beta
1567+
FABRIC_BASEOS_VERSION=3.0.0-beta
15301568
FABRIC_JAVAENV_VERSION=2.5
15311569
FABRIC_NODEENV_VERSION=2.5
15321570
RECOMMENDED_NODE_VERSION=16
@@ -3406,6 +3444,7 @@ echo "Executing post-generate hook"
34063444
34073445
exports[`samples/fablo-config-hlf3-1orgs-1chaincode.json should create proper files from samples/fablo-config-hlf3-1orgs-1chaincode.json 1`] = `
34083446
[
3447+
"e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/.npm/_logs/2024-12-07T09_57_41_821Z-debug-0.log",
34093448
"e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/.gitignore",
34103449
"e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/configtx.yaml",
34113450
"e2e/__tmp__/samples/fablo-config-hlf3-1orgs-1chaincode.json.tmpdir/fablo-target/fabric-config/connection-profiles/connection-profile-orderer.json",

e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,12 +1547,12 @@ CHAINCODES_BASE_DIR=<absolute path>
15471547
COMPOSE_PROJECT_NAME=<name with timestamp>
15481548
LOGGING_LEVEL=debug
15491549
1550-
FABRIC_VERSION=3.0.0
1550+
FABRIC_VERSION=3.0.0-beta
15511551
FABRIC_TOOLS_VERSION=3.0.0-beta
15521552
FABRIC_CA_VERSION=1.5.5
15531553
FABRIC_CA_POSTGRES_VERSION=14
1554-
FABRIC_CCENV_VERSION=3.0.0
1555-
FABRIC_BASEOS_VERSION=3.0.0
1554+
FABRIC_CCENV_VERSION=3.0.0-beta
1555+
FABRIC_BASEOS_VERSION=3.0.0-beta
15561556
FABRIC_JAVAENV_VERSION=2.5
15571557
FABRIC_NODEENV_VERSION=2.5
15581558
RECOMMENDED_NODE_VERSION=16

samples/fablo-config-hlf3-1orgs-1chaincode.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.0.0/schema.json",
33
"global": {
4-
"fabricVersion": "3.0.0",
4+
"fabricVersion": "3.0.0-beta",
55
"tls": true,
66
"monitoring": {
77
"loglevel": "debug"

samples/fablo-config-hlf3-bft-1orgs-1chaincode.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.0.0/schema.json",
33
"global": {
4-
"fabricVersion": "3.0.0",
4+
"fabricVersion": "3.0.0-beta",
55
"tls": true,
66
"monitoring": {
77
"loglevel": "debug"

src/repositoryUtils.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ describe("repositoryUtils", () => {
1919
expect(version("1.4.0").isGreaterOrEqual("1.4.1")).toBe(false);
2020
expect(version("1.4.0").isGreaterOrEqual("1.3.0")).toBe(true);
2121
expect(version("1.4.0").isGreaterOrEqual("2.1.0")).toBe(false);
22+
expect(version("3.0.0").isGreaterOrEqual("3.0.0-beta")).toBe(true);
23+
expect(version("3.0.0-beta").isGreaterOrEqual("3.0.0")).toBe(true);
24+
expect(version("3.0.0").isGreaterOrEqual("3.0.0")).toBe(true);
25+
expect(version("3.0.0").isGreaterOrEqual("3.0.1")).toBe(false);
2226
});
2327
});

src/validate/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ValidateGenerator extends Generator {
9090
this._validateIfConfigFileExists(this.options.fabloConfig);
9191

9292
const networkConfig = parseFabloConfig(this.fs.read(this.options.fabloConfigPath));
93+
this._validateFabricVersion(networkConfig.global);
9394
this._validateJsonSchema(networkConfig);
9495
this._validateSupportedFabloVersion(networkConfig.$schema);
9596
this._validateOrgs(networkConfig.orgs);
@@ -122,6 +123,26 @@ class ValidateGenerator extends Generator {
122123
this._verifyFabricVersion(networkConfig.global);
123124
}
124125

126+
private _validateFabricVersion(global: GlobalJson) {
127+
// 1. we support fabric up to 3.0.0-beta
128+
if (version(global.fabricVersion).isGreaterOrEqual("3.0.0") && global.fabricVersion !== "3.0.0-beta") {
129+
const objectToEmit = {
130+
category: validationCategories.CRITICAL,
131+
message: `Fabric ${global.fabricVersion} is not supported. Fablo supports only Fabric up to 3.0.0-beta.`,
132+
};
133+
this.emit(validationErrorType.CRITICAL, objectToEmit);
134+
}
135+
136+
// 2. we support Fabric starting from 2.0.0
137+
if (!version(global.fabricVersion).isGreaterOrEqual("2.0.0")) {
138+
const objectToEmit = {
139+
category: validationCategories.CRITICAL,
140+
message: `Fabric ${global.fabricVersion} is not supported. Fablo supports only Fabric starting from 2.0.0.`,
141+
};
142+
this.emit(validationErrorType.CRITICAL, objectToEmit);
143+
}
144+
}
145+
125146
async shortSummary() {
126147
console.log(`Validation errors count: ${this.errors.count()}`);
127148
console.log(`Validation warnings count: ${this.warnings.count()}`);

0 commit comments

Comments
 (0)