Skip to content

Commit

Permalink
fix: add tls option for iroha
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxu12 committed Aug 20, 2021
1 parent d596734 commit 90729be
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@
"timeoutLimit": {
"type": "number",
"nullable": false
},
"tls": {
"type": "boolean",
"nullable": false,
"description": "Can only be set to false for an insecure grpc connection."
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ export interface IrohaBaseConfig {
* @memberof IrohaBaseConfig
*/
timeoutLimit?: number;
/**
* Can only be set to false for an insecure grpc connection.
* @type {boolean}
* @memberof IrohaBaseConfig
*/
tls?: boolean;
}
/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,18 @@ export class PluginLedgerConnectorIroha
}
const irohaHostPort = `${baseConfig.irohaHost}:${baseConfig.irohaPort}`;

let grpcCredentials;
if (baseConfig.tls) {
throw new RuntimeError("TLS option is not supported");
} else {
grpcCredentials = grpc.credentials.createInsecure();
}
const commandService = new CommandService(
irohaHostPort,
//TODO:do something in the production environment
grpc.credentials.createInsecure(),
);
const queryService = new QueryService(
irohaHostPort,
grpc.credentials.createInsecure(),
grpcCredentials,
);
const queryService = new QueryService(irohaHostPort, grpcCredentials);
const commandOptions = {
privateKeys: baseConfig.privKey, //need an array of keys for command
creatorAccountId: baseConfig.creatorAccountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv1],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [asset, domain1, 3],
};
Expand Down Expand Up @@ -212,6 +213,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv2],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [asset, domain2, 3],
};
Expand All @@ -232,6 +234,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv1],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [assetID1, "100.000"],
};
Expand All @@ -254,6 +257,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv1],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [assetID1, "30.000"],
};
Expand All @@ -274,6 +278,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv2],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [assetID2, "30.000"],
};
Expand All @@ -294,6 +299,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv1],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [adminID1, 10, assetID1],
};
Expand All @@ -320,6 +326,7 @@ test(testCase, async (t: Test) => {
privKey: [adminPriv2],
quorum: 1,
timeoutLimit: 5000,
tls: false,
},
params: [adminID2, 10, assetID2],
};
Expand Down
Loading

0 comments on commit 90729be

Please sign in to comment.