Skip to content

Commit

Permalink
FABN-1386: TSLint and Docker image fixes
Browse files Browse the repository at this point in the history
- Gulp run of TSLint was not checking typed rules correctly.
- Fixed some promise handing errors now identified by TSLint.
- Docker images were being incorrectly tagged as '2.0.0-stable'
  rather than as '2.0.0'. This failed current chaincode container
  image builds.

Signed-off-by: Mark S. Lewis <[email protected]>
Change-Id: Ib7f2a6db30b178b115e9110a8c78cd391bf6ba7d
  • Loading branch information
bestbeforetoday committed Oct 30, 2019
1 parent 982cf3a commit 39b44e0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
11 changes: 7 additions & 4 deletions build/tasks/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
# SPDX-License-Identifier: Apache-2.0
*/
const gulp = require('gulp');
const tslint = require('gulp-tslint');
const gulpTslint = require('gulp-tslint');
const tslint = require('tslint');

gulp.task('tslint', () => {
const program = tslint.Linter.createProgram('tslint.json');
return gulp.src([
'fabric-client/**/*.ts',
'fabric-network/**/*.ts',
Expand All @@ -16,9 +18,10 @@ gulp.task('tslint', () => {
'!fabric-network/node_modules/**',
'!fabric-client/coverage/**',
'!fabric-client/node_modules/**',
]).pipe(tslint({
formatter: 'prose'
})).pipe(tslint.report({
]).pipe(gulpTslint({
formatter: 'prose',
program
})).pipe(gulpTslint.report({
summarizeFailureOutput: true
}));
});
2 changes: 1 addition & 1 deletion fabric-network/src/impl/wallet/hsmx509identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ export class HsmX509Provider implements IdentityProvider {
username: name,
};
const user: Client.User = await client.createUser(userData);
client.setUserContext(user, true);
await client.setUserContext(user, true);
}
}
2 changes: 1 addition & 1 deletion fabric-network/src/impl/wallet/x509identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ export class X509Provider implements IdentityProvider {
username: name,
};
const user: Client.User = await client.createUser(userData);
client.setUserContext(user, true);
await client.setUserContext(user, true);
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"test:network": "npm run compile-src && npm run coverage -- 'fabric-network/test/**/*.{js,ts}'",
"test:protos": "npm run coverage -- 'fabric-protos/test/**/*.{js,ts}",
"test:cucumber": "cucumber-js ./test/scenario/features/*.feature",
"test:ts-cucumber": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register",
"test:ts-cucumber-tagged": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register --tags @lifecycle",
"test:all": "nyc npm run unit-test:all",
"test:ts-cucumber": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register",
"test:ts-cucumber-tagged": "cucumber-js ./test/ts-scenario/features/*.feature --require './test/ts-scenario/steps/**/*.ts' --require './test/ts-scenario/support/**/*.ts' --require-module ts-node/register --tags @lifecycle",
"test:all": "nyc npm run unit-test:all",
"unit-test:all": "npm run unit-test -- 'fabric-common/test/**/*.{js,ts}' && npm run unit-test -- 'fabric-ca-client/test/**/*.{js,ts}' && npm run unit-test -- 'fabric-client/test/**/*.{js,ts}' && npm run unit-test -- 'fabric-network/test/**/*.{js,ts}'",
"unit-test": "mocha --require ts-node/register --exclude 'fabric-client/test/data/**'",
"compile": "npm run compile-src && npm run compile-test",
Expand Down
21 changes: 12 additions & 9 deletions scripts/utility/fabric_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@ NEXUS_URL=nexus3.hyperledger.org:10001
ORG_NAME="hyperledger/fabric"
ARCH=$1
: ${STABLE_VERSION:=$2}
STABLE_TAG=$ARCH-$STABLE_VERSION
echo "---------> STABLE_VERSION:" $STABLE_VERSION
STABLE_TAG="${ARCH}-${STABLE_VERSION}"
VERSION_TAG="${STABLE_VERSION%%-*}"
echo "---------> STABLE_VERSION: ${STABLE_VERSION}"

dockerTag() {
for IMAGES in ca peer orderer ccenv baseos nodeenv javaenv tools; do
echo "Images: $IMAGES"
echo "Images: ${IMAGES}"
echo
docker pull $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
NEXUS_IMAGE="${NEXUS_URL}/${ORG_NAME}-${IMAGES}:${STABLE_TAG}"
docker pull "${NEXUS_IMAGE}"
if [ $? != 0 ]; then
echo "FAILED: Docker Pull Failed on $IMAGES"
echo "FAILED: Docker Pull Failed on ${IMAGES}"
exit 1
fi
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES
docker tag $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG $ORG_NAME-$IMAGES:$STABLE_TAG
echo "$ORG_NAME-$IMAGES:$STABLE_TAG"
IMAGE_NAME="${ORG_NAME}-${IMAGES}"
docker tag "${NEXUS_IMAGE}" "${IMAGE_NAME}"
docker tag "${NEXUS_IMAGE}" "${IMAGE_NAME}:${VERSION_TAG}"
echo "${IMAGE_NAME}:${VERSION_TAG}"
echo "Deleting Nexus docker images: $IMAGES"
docker rmi -f $NEXUS_URL/$ORG_NAME-$IMAGES:$STABLE_TAG
docker rmi -f "${NEXUS_IMAGE}"
done
}

Expand Down
6 changes: 3 additions & 3 deletions test/ts-scenario/steps/lib/deprecatedSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const supportedLanguageTypes: string[] = ['node', 'golang'];
export async function sdk_chaincode_install_for_org(ccType: 'golang' | 'car' | 'java' | 'node', ccName: string, ccVersion: string, chaincodeId: string, tls: boolean, ccp: CommonConnectionProfileHelper, orgName: string, channelName: string): Promise<void> {

if (!supportedLanguageTypes.includes(ccType)) {
Promise.reject(`Unsupported test ccType ${ccType}`);
throw new Error(`Unsupported test ccType ${ccType}`);
}

Client.setConfigSetting('request-timeout', Constants.INSTALL_TIMEOUT);
Expand Down Expand Up @@ -134,7 +134,7 @@ export async function sdk_chaincode_install_for_org(ccType: 'golang' | 'car' | '
*/
export async function sdk_chaincode_instantiate(ccName: string, ccType: 'golang' | 'car' | 'java' | 'node', ccVersion: string, chaincodeId: string, args: string, upgrade: boolean, tls: boolean, ccp: CommonConnectionProfileHelper, orgName: string, channelName: string, policy: any): Promise<void> {
if (!supportedLanguageTypes.includes(ccType)) {
Promise.reject(`Unsupported test ccType: ${ccType}`);
throw new Error(`Unsupported test ccType: ${ccType}`);
}

Client.setConfigSetting('request-timeout', Constants.INSTANTIATE_TIMEOUT);
Expand Down Expand Up @@ -213,7 +213,7 @@ export async function sdk_chaincode_instantiate(ccName: string, ccType: 'golang'
const proposal: Client.Proposal = results[1];
for (const proposalResponse of proposalResponses) {
if (!((proposalResponse as Client.ProposalResponse).response && (proposalResponse as Client.ProposalResponse).response.status === 200)) {
Promise.reject(`The proposal of type ${type} was bad: ${JSON.stringify(proposalResponse)}`);
throw new Error(`The proposal of type ${type} was bad: ${JSON.stringify(proposalResponse)}`);
}
}

Expand Down
5 changes: 1 addition & 4 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"extends": [
"tslint:recommended"
],
"extends": "tslint:recommended",
"rules": {
"trailing-comma": [
false,
Expand All @@ -24,7 +22,6 @@
"forin": false,
"max-line-length": false,
"no-string-literal": false,
"no-use-before-declare": true,
"object-literal-sort-keys": false,
"object-literal-shorthand": false,
"ordered-imports": false,
Expand Down

0 comments on commit 39b44e0

Please sign in to comment.