From 33d4ea82c3883e73bbb08150304d29319f72da39 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 23 Jan 2020 11:18:49 +0000 Subject: [PATCH 1/9] [FABCN-377] Prepare for v2.1 unstable builds (WIP) Signed-off-by: James Taylor --- apis/fabric-contract-api/package.json | 6 +++--- apis/fabric-shim-api/package.json | 4 ++-- ci/azure-pipelines.yml | 10 +++++----- docs/_jsdoc/tutorials/using-chaincodeinterface.md | 4 ++-- libraries/fabric-shim-crypto/package.json | 4 ++-- libraries/fabric-shim/package.json | 8 ++++---- package.json | 4 ++-- test/chaincodes/annotations/package.json | 4 ++-- test/chaincodes/clientidentity/package.json | 4 ++-- test/chaincodes/crosschaincode/package.json | 4 ++-- test/chaincodes/crosschaincode2/package.json | 4 ++-- test/chaincodes/crud/package.json | 4 ++-- test/chaincodes/encryption/package.json | 6 +++--- test/chaincodes/events/package.json | 4 ++-- test/chaincodes/query/package.json | 4 ++-- test/chaincodes/scenario/package.json | 4 ++-- test/fv/package.json | 10 +++++----- .../network/docker-compose/docker-compose-base.yaml | 2 +- 18 files changed, 45 insertions(+), 45 deletions(-) diff --git a/apis/fabric-contract-api/package.json b/apis/fabric-contract-api/package.json index 22ce1d86..a551ef88 100644 --- a/apis/fabric-contract-api/package.json +++ b/apis/fabric-contract-api/package.json @@ -1,7 +1,7 @@ { "name": "fabric-contract-api", - "version": "2.0.1", - "tag": "latest", + "version": "2.1.0-unstable", + "tag": "unstable", "description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other", "main": "index.js", "repository": { @@ -46,7 +46,7 @@ "lines": 100 }, "dependencies": { - "fabric-shim-api": "2.0.1", + "fabric-shim-api": "2.1.0-unstable", "class-transformer": "^0.2.2", "fast-safe-stringify": "~2.0.7", "get-params": "^0.1.2", diff --git a/apis/fabric-shim-api/package.json b/apis/fabric-shim-api/package.json index 7093bfc3..cb143063 100644 --- a/apis/fabric-shim-api/package.json +++ b/apis/fabric-shim-api/package.json @@ -1,7 +1,7 @@ { "name": "fabric-shim-api", - "version": "2.0.1", - "tag": "latest", + "version": "2.1.0-unstable", + "tag": "unstable", "description": "A node.js API of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other", "main": "index.js", "repository": { diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index d09b74b7..193e22b6 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -278,7 +278,7 @@ stages: workingFile: '$(Agent.TempDirectory)/.npmrc' customEndpoint: 'fabric-chainode-node-npm' - script: | - find $(Pipeline.Workspace)/node-tgz/ -maxdepth 1 -type f -name 'fabric-*.tgz' -exec npm publish {} --tag latest \; + find $(Pipeline.Workspace)/node-tgz/ -maxdepth 1 -type f -name 'fabric-*.tgz' -exec npm publish {} --tag unstable \; displayName: 'npm publish' - job: jsdoc_publish steps: @@ -303,11 +303,11 @@ stages: docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD} echo "Logged in to docker registry" # tag nodeenv image to PACKAGE_VERSION - docker tag hyperledger/fabric-nodeenv hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION) + docker tag hyperledger/fabric-nodeenv fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable # push nodeenv to repository - docker push hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION) - ./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)" --target "hyperledger/fabric-nodeenv:$(BuildData.PACKAGE_VERSION)" - ./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)" --target "hyperledger/fabric-nodeenv:2.0" + docker push hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable + ./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable" --target "hyperledger/fabric-nodeenv:$(BuildData.PACKAGE_VERSION)-unstable" + ./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable" --target "hyperledger/fabric-nodeenv:2.0-unstable" env: DOCKER_REGISTRY_USERNAME: $(DockerHub-Username) DOCKER_REGISTRY_PASSWORD: $(DockerHub-Password) diff --git a/docs/_jsdoc/tutorials/using-chaincodeinterface.md b/docs/_jsdoc/tutorials/using-chaincodeinterface.md index b9d2854e..fd718e69 100644 --- a/docs/_jsdoc/tutorials/using-chaincodeinterface.md +++ b/docs/_jsdoc/tutorials/using-chaincodeinterface.md @@ -8,7 +8,7 @@ cd mycc // create a new node project npm init // install fabric-shim at master branch -npm install 2.0.1 +npm install 2.1.0-unstable // or using the released version npm install fabric-shim touch mychaincode.js @@ -68,7 +68,7 @@ Finally, update the "start" script in package.json to "node mychaincode.js": "engineStrict": true, "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1" + "fabric-shim": "2.1.0-unstable" } } ``` diff --git a/libraries/fabric-shim-crypto/package.json b/libraries/fabric-shim-crypto/package.json index 1b9878c2..df212c6b 100644 --- a/libraries/fabric-shim-crypto/package.json +++ b/libraries/fabric-shim-crypto/package.json @@ -1,7 +1,7 @@ { "name": "fabric-shim-crypto", - "version": "2.0.1", - "tag": "latest", + "version": "2.1.0-unstable", + "tag": "unstable", "description": "A node.js implementation of encryption library for Hyperledger Fabric chaincode shim", "main": "index.js", "repository": { diff --git a/libraries/fabric-shim/package.json b/libraries/fabric-shim/package.json index 4bef192c..8a646631 100644 --- a/libraries/fabric-shim/package.json +++ b/libraries/fabric-shim/package.json @@ -1,7 +1,7 @@ { "name": "fabric-shim", - "version": "2.0.1", - "tag": "latest", + "version": "2.1.0-unstable", + "tag": "unstable", "description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other", "main": "index.js", "bin": { @@ -61,8 +61,8 @@ "@grpc/proto-loader": "^0.5.1", "@types/node": "^8.9.4", "ajv": "^6.5.5", - "fabric-contract-api": "2.0.1", - "fabric-shim-api": "2.0.1", + "fabric-contract-api": "2.1.0-unstable", + "fabric-shim-api": "2.1.0-unstable", "fs-extra": "8.1.0", "grpc": "^1.23.3", "reflect-metadata": "^0.1.12", diff --git a/package.json b/package.json index 68069d1e..4bcb2a27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fabric-shim-test", - "version": "2.0.1", - "tag": "latest", + "version": "2.1.0-unstable", + "tag": "unstable", "description": "fabric-shim, fabric-shim-crypto", "testFabricVersion": "master", "testFabricCAVersion": "1.4.4", diff --git a/test/chaincodes/annotations/package.json b/test/chaincodes/annotations/package.json index 824e64f3..a1569758 100644 --- a/test/chaincodes/annotations/package.json +++ b/test/chaincodes/annotations/package.json @@ -18,8 +18,8 @@ "author": "", "license": "APACHE-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1", + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable", "@types/node": "^10.3.6", "ts-node": "^3.3.0", "tslint": "^5.6.0", diff --git a/test/chaincodes/clientidentity/package.json b/test/chaincodes/clientidentity/package.json index 4746af5e..8b37df2f 100644 --- a/test/chaincodes/clientidentity/package.json +++ b/test/chaincodes/clientidentity/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/chaincodes/crosschaincode/package.json b/test/chaincodes/crosschaincode/package.json index 1475de2e..6a5f10b3 100644 --- a/test/chaincodes/crosschaincode/package.json +++ b/test/chaincodes/crosschaincode/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/chaincodes/crosschaincode2/package.json b/test/chaincodes/crosschaincode2/package.json index bd4c43bf..edccc4aa 100644 --- a/test/chaincodes/crosschaincode2/package.json +++ b/test/chaincodes/crosschaincode2/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/chaincodes/crud/package.json b/test/chaincodes/crud/package.json index 7a7bf972..10026753 100644 --- a/test/chaincodes/crud/package.json +++ b/test/chaincodes/crud/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/chaincodes/encryption/package.json b/test/chaincodes/encryption/package.json index bc4d5948..11e619f1 100644 --- a/test/chaincodes/encryption/package.json +++ b/test/chaincodes/encryption/package.json @@ -15,8 +15,8 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1", - "fabric-shim-crypto": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable", + "fabric-shim-crypto": "2.1.0-unstable" } } diff --git a/test/chaincodes/events/package.json b/test/chaincodes/events/package.json index d3d3903c..5eab7a36 100644 --- a/test/chaincodes/events/package.json +++ b/test/chaincodes/events/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/chaincodes/query/package.json b/test/chaincodes/query/package.json index 38c5b25f..8d9db575 100644 --- a/test/chaincodes/query/package.json +++ b/test/chaincodes/query/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/chaincodes/scenario/package.json b/test/chaincodes/scenario/package.json index 46e4d316..479ba50e 100644 --- a/test/chaincodes/scenario/package.json +++ b/test/chaincodes/scenario/package.json @@ -15,7 +15,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "fabric-shim": "2.0.1", - "fabric-contract-api": "2.0.1" + "fabric-shim": "2.1.0-unstable", + "fabric-contract-api": "2.1.0-unstable" } } diff --git a/test/fv/package.json b/test/fv/package.json index 7d7b8fed..206aca7d 100644 --- a/test/fv/package.json +++ b/test/fv/package.json @@ -1,6 +1,6 @@ { "name": "fvtests", - "version": "2.0.1", + "version": "2.1.0-unstable", "description": "fv tests", "testFabricVersion": "master", "testFabricThirdParty": "0.4.15", @@ -26,10 +26,10 @@ "del": "^3.0.0", "delay": "4.3.0", "eslint": "6.6.0", - "fabric-contract-api": "2.0.1", - "fabric-shim": "2.0.1", - "fabric-shim-api": "2.0.1", - "fabric-shim-crypto": "2.0.1", + "fabric-contract-api": "2.1.0-unstable", + "fabric-shim": "2.1.0-unstable", + "fabric-shim-api": "2.1.0-unstable", + "fabric-shim-crypto": "2.1.0-unstable", "fs-extra": "8.1.0", "git-rev-sync": "1.12.0", "gulp": "^4.0.0", diff --git a/tools/toolchain/network/docker-compose/docker-compose-base.yaml b/tools/toolchain/network/docker-compose/docker-compose-base.yaml index 6bb4bb8b..4d680787 100644 --- a/tools/toolchain/network/docker-compose/docker-compose-base.yaml +++ b/tools/toolchain/network/docker-compose/docker-compose-base.yaml @@ -92,7 +92,7 @@ services: # # bridge network as the peers # # https://docs.docker.com/compose/networking/ - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=node_default - - CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.0.1 + - CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.1.0-unstable # Allow more time for chaincode container to build on install. - CORE_CHAINCODE_EXECUTETIMEOUT=300s working_dir: /opt/gopath/src/github.com/hyperledger/fabric From d62ecae42268e0ce65bc743527a693b62ec8f1bd Mon Sep 17 00:00:00 2001 From: Matthew B White Date: Fri, 17 Jan 2020 14:15:31 +0000 Subject: [PATCH 2/9] [FABCN-373] Compatibility Matrix Ammended all the node-engines in package.json to match that in the docker image Signed-off-by: Matthew B White Change-Id: Ia536ed66daf857679adf9f858b35d206a4f1007f --- COMPATIBILITY.md | 51 ++++++++++++++++++++ README.md | 4 ++ libraries/fabric-shim/test/unit/chaincode.js | 2 +- package.json | 18 ++----- 4 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 COMPATIBILITY.md diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md new file mode 100644 index 00000000..04aae776 --- /dev/null +++ b/COMPATIBILITY.md @@ -0,0 +1,51 @@ +# Support and Compatibility for fabric-chaincode-java + +Github is used for code base management, issues should reported in the [FABCN](https://jira.hyperledger.org/projects/FABCN/issues/) component in JIRA. + + +## Summary of Compatibility + +This table shows the summary of the compatibility of the Node modules at versions 1.4 and 2.0, together with the Nodejs runtime they require and the Fabric Peer versions they can communicate with. + +| | Peer Connectivity v1.4 | NodeJS | Peer Connectivity v2.0 | +| --------------------- | ---------------------- | ------ | ---------------------- | +| Node modules **v1.4** | Yes | 8 | Yes | +| Node modules **v2.0** | Yes | 10 | Yes | + +By default a Fabric Peer v1.4 will create a Nodejs v8 , and a Fabric Peer v2.0 will create a Nodejs v12 runtime. Whilst is the default, the docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_NODE_RUNTIME` on the peer to the name of the docker image. For example `CORE_CHAINCODE_NODE_RUNTIME=example/customNodeRuntime:latest` + +The Node modules will connect to the peer whilst running; this is referred to as 'Fabric Peer Connectivity' in the table. For example, whilst the Fabric Peer v1.4 will create a Nodejs 8 runtime, if a Nodejs 12 runtime was configured, the Node modules at v2.0.0 still function when connecting to the Fabric Peer v1.4. + +## Compatibility + +The key elements are :  + +- the version of the Fabric Contract Node modules used +- the version of the Nodejs runtime used to run the code +- When starting a chaincode container to run a Smart Contract the version of the runtime that is used is determined by these factors: + +Fabric v1.4.2, and Fabric v2.0.0 will, by default, start up docker image to host the chaincode and contracts. The version of the docker image used is defined by the version of Fabric in use. + +With Fabric v2.0.0, the chaincode container can be configured to be started by other means, and not the Peer. In this case, the environment used is not in the control of Fabric. + +Node modules that are produced are `fabric-contract-api`, `fabric-shim`, `fabric-shim-crypto` & `fabric-shim-api` + +### Supported Runtimes + +v1.4.x and v2.0.0 Node modules are supported running in Nodejs 12.13 with the x86_64 architecture. Later Nodejs 12 versions are supported but are not tested. + +v1.4.x Node modules are supported running Nodejs 8.16.1 with the  x86_64 architecture. Later Nodejs 8 versions are supported but are not tested. + +Architecture Support: all docker images, runtimes, tools are tested under x86_64 ONLY + +### Default Peer Runtime selection + +When using Fabric 2.0.0, the default docker image that is used to run the Node chaincode is node:12.13.0-alpine  + +*Note:* With the default docker image used by Fabric 2.0.0 the packaged code will be installed with npm. If a `package-lock.json` or a `npm-shrinkwrap.json` file is present, `npm ci --only=production` will be used. Otherwise `npm install --production` will be used.  + +When using Fabric 1.4.4, the docker image that is used to run the Node chaincode is node v8.16.1. It is installed with npm install --production + +### Supported Runtime communication with the Peer +  +Subject to a suitable runtime environment, the 1.4.4 Node modules and 2.0.0 Node modules can used to communicate with a Fabric 2.0.0 or 1.4.4 Peer - with the level of functionality that is implied by the Fabric version in use.  \ No newline at end of file diff --git a/README.md b/README.md index 58b82e94..e09e1345 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ As an application developer, to learn about how to implement **"Smart Contracts" - docker images - [fabric-nodeenv](https://hub.docker.com/r/hyperledger/fabric-nodeenv) +## Compatibility + +For details on what Nodejs runtime and versions of Hyperledger Fabric can be used please see the [compatibility document](COMPATIBILITY.md). + --- ## License diff --git a/libraries/fabric-shim/test/unit/chaincode.js b/libraries/fabric-shim/test/unit/chaincode.js index c1842dc0..9fcdcc05 100644 --- a/libraries/fabric-shim/test/unit/chaincode.js +++ b/libraries/fabric-shim/test/unit/chaincode.js @@ -257,7 +257,7 @@ describe('Chaincode', () => { expect(typeof testOpts[attr]).to.deep.equal('string'); const json = JSON.parse(testOpts[attr]); - expect(json.name).to.deep.equal('fabric-shim-test'); + expect(json.name).to.deep.equal('fabric-chaincode-node'); }); Chaincode.__set__('Handler', handlerClass); diff --git a/package.json b/package.json index 4bcb2a27..844df0be 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,11 @@ { - "name": "fabric-shim-test", + "name": "fabric-chaincode-node", "version": "2.1.0-unstable", "tag": "unstable", - "description": "fabric-shim, fabric-shim-crypto", + "description": "fabric-chaincode-node monorepo, built with rush", "testFabricVersion": "master", "testFabricCAVersion": "1.4.4", "testFabricThirdParty": "0.4.15", "docsLatestVersion": "release-1.4", - "engines": { - "node": "^10.15.2", - "npm": "^6.4.1" - }, - "engineStrict": true, - "license": "Apache-2.0", - "scripts": { - }, - "dependencies": { - }, - "devDependencies": { - - } + "license": "Apache-2.0" } From 0e7a80e1863539b757471b6cd28a8689e61a9813 Mon Sep 17 00:00:00 2001 From: Andrew Hurt Date: Thu, 30 Jan 2020 10:58:40 +0000 Subject: [PATCH 3/9] [FABCN-382] fix compatibility.md title Signed-off-by: Andrew Hurt --- COMPATIBILITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 04aae776..8ee91582 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -1,4 +1,4 @@ -# Support and Compatibility for fabric-chaincode-java +# Support and Compatibility for fabric-chaincode-node Github is used for code base management, issues should reported in the [FABCN](https://jira.hyperledger.org/projects/FABCN/issues/) component in JIRA. @@ -47,5 +47,5 @@ When using Fabric 2.0.0, the default docker image that is used to run the Node c When using Fabric 1.4.4, the docker image that is used to run the Node chaincode is node v8.16.1. It is installed with npm install --production ### Supported Runtime communication with the Peer -  + Subject to a suitable runtime environment, the 1.4.4 Node modules and 2.0.0 Node modules can used to communicate with a Fabric 2.0.0 or 1.4.4 Peer - with the level of functionality that is implied by the Fabric version in use.  \ No newline at end of file From 659d36d38bdef0e324f0edd531d6af9f830fa6d4 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 31 Jan 2020 11:24:52 +0000 Subject: [PATCH 4/9] Improve build reliability It looks like rushjs symlinking can cause issues with the CopyFiles task. Use a script instead as suggested in microsoft/azure-pipelines-tasks#9046 Signed-off-by: James Taylor --- ci/azure-pipelines.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 193e22b6..b29eb69f 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -86,19 +86,16 @@ stages: codeCoverageTool: 'cobertura' summaryFileLocation: '**/cobertura-coverage.xml' artifactName: 'Unit Test Coverage' - # CopyFiles can follow symlinks hence be careful with node_modules - - task: CopyFiles@2 - condition: or(succeeded(), failed()) # publish either way - inputs: - contents: | - **/*.build*.log - !**/node_modules/** - targetFolder: $(Build.ArtifactStagingDirectory)/logs + - script: | + mkdir -p $(Build.ArtifactStagingDirectory)/logs + find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} $(Build.ArtifactStagingDirectory)/logs \; + displayName: 'Copy build logs' - task: PublishBuildArtifacts@1 condition: or(succeeded(), failed()) # publish either way inputs: pathToPublish: $(Build.ArtifactStagingDirectory)/logs artifactName: 'Build logs' + displayName: 'Publish build logs' # Copy the built artifacts to the staging directory, tgz, and the docker image - script: | @@ -161,11 +158,16 @@ stages: **/*.build*.log !**/node_modules/** targetFolder: $(Build.ArtifactStagingDirectory)/testlogs + - script: | + mkdir -p $(Build.ArtifactStagingDirectory)/testlogs + find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} $(Build.ArtifactStagingDirectory)/testlogs \; + displayName: 'Copy test logs' - task: PublishBuildArtifacts@1 condition: or(succeeded(), failed()) # publish either way inputs: pathToPublish: $(Build.ArtifactStagingDirectory)/testlogs artifactName: 'Test logs' + displayName: 'Publish test logs' - task: PublishBuildArtifacts@1 condition: or(succeeded(), failed()) # publish either way inputs: From a3ff93c7cb38024d25191a7f4b52958970b43c52 Mon Sep 17 00:00:00 2001 From: Ry Jones Date: Mon, 3 Feb 2020 12:39:09 -0800 Subject: [PATCH 5/9] Add readme to redirect to site Signed-off-by: Ry Jones --- docs/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..3a804c13 --- /dev/null +++ b/docs/README.md @@ -0,0 +1 @@ +[You probably want to look here](https://hyperledger.github.io/fabric-chaincode-node/) From dd8799e9dd7091e00ecd9196a16165d6bf4793bd Mon Sep 17 00:00:00 2001 From: lesleyannj Date: Sun, 5 Jan 2020 19:33:22 +0000 Subject: [PATCH 6/9] FABCN-241 Remove to.be.ok Signed-off-by: lesleyannj --- libraries/fabric-shim/test/unit/stub.js | 78 ++++++++++++------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/libraries/fabric-shim/test/unit/stub.js b/libraries/fabric-shim/test/unit/stub.js index dc837344..ccba16ed 100644 --- a/libraries/fabric-shim/test/unit/stub.js +++ b/libraries/fabric-shim/test/unit/stub.js @@ -414,17 +414,17 @@ describe('Stub', () => { }); expect(stub.binding).to.deep.equal('some proposal binding'); - expect(_proposalProtoProposalDecodeStub.calledOnce).to.be.ok; + expect(_proposalProtoProposalDecodeStub.calledOnce).to.be.true; expect(_proposalProtoProposalDecodeStub.firstCall.args).to.deep.equal(['some bytes']); - expect(_commonProtoHeaderDecodeStub.calledOnce).to.be.ok; + expect(_commonProtoHeaderDecodeStub.calledOnce).to.be.true; expect(_commonProtoHeaderDecodeStub.firstCall.args).to.deep.equal([decodedProposal.header]); - expect(_commonProtoSignatureHeaderDecodeStub.calledOnce).to.be.ok; + expect(_commonProtoSignatureHeaderDecodeStub.calledOnce).to.be.true; expect(_commonProtoSignatureHeaderDecodeStub.firstCall.args).to.deep.equal([decodedHeader.signatureHeader]); - expect(_idProtoSerializedIdentityDecodeStub.calledOnce).to.be.ok; + expect(_idProtoSerializedIdentityDecodeStub.calledOnce).to.be.true; expect(_idProtoSerializedIdentityDecodeStub.firstCall.args).to.deep.equal([decodedSigHeader.creator]); - expect(_commonProtoChannelHeaderDecodeStub.calledOnce).to.be.ok; + expect(_commonProtoChannelHeaderDecodeStub.calledOnce).to.be.true; expect(_commonProtoChannelHeaderDecodeStub.firstCall.args).to.deep.equal([decodedHeader.channelHeader]); - expect(_proposalProtoChaincodeProposalPayloadDecodeStub.calledOnce).to.be.ok; + expect(_proposalProtoChaincodeProposalPayloadDecodeStub.calledOnce).to.be.true; expect(_proposalProtoChaincodeProposalPayloadDecodeStub.firstCall.args).to.deep.equal([decodedProposal.payload]); Stub.__set__('computeProposalBinding', saveComputeProposalBinding); @@ -625,7 +625,7 @@ describe('Stub', () => { const result = await stub.getState('a key'); expect(result).to.deep.equal('some state'); - expect(handleGetStateStub.calledOnce).to.be.ok; + expect(handleGetStateStub.calledOnce).to.be.true; expect(handleGetStateStub.firstCall.args).to.deep.equal(['', 'a key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -643,7 +643,7 @@ describe('Stub', () => { const result = await stub.putState('a key', 'a value'); expect(result).to.deep.equal('some state'); - expect(handlePutStateStub.calledOnce).to.be.ok; + expect(handlePutStateStub.calledOnce).to.be.true; expect(handlePutStateStub.firstCall.args).to.deep.equal(['', 'a key', Buffer.from('a value'), 'dummyChannelId', 'dummyTxid']); }); it ('should return handler.handlePutState', async () => { @@ -658,7 +658,7 @@ describe('Stub', () => { const result = await stub.putState('a key', {a:'value'}); expect(result).to.deep.equal('some state'); - expect(handlePutStateStub.calledOnce).to.be.ok; + expect(handlePutStateStub.calledOnce).to.be.true; expect(handlePutStateStub.firstCall.args).to.deep.equal(['', 'a key', {a:'value'}, 'dummyChannelId', 'dummyTxid']); }); }); @@ -676,7 +676,7 @@ describe('Stub', () => { const result = await stub.deleteState('a key'); expect(result).to.deep.equal('some state'); - expect(handleDeleteStateStub.calledOnce).to.be.ok; + expect(handleDeleteStateStub.calledOnce).to.be.true; expect(handleDeleteStateStub.firstCall.args).to.deep.equal(['', 'a key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -726,7 +726,7 @@ describe('Stub', () => { const result = await stub.getStateByRange('start key', 'end key'); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; expect(handleGetStateByRangeStub.firstCall.args).to.deep.equal(['', 'start key', 'end key', 'dummyChannelId', 'dummyTxid']); }); @@ -744,7 +744,7 @@ describe('Stub', () => { const result = await stub.getStateByRange(null, 'end key'); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; expect(handleGetStateByRangeStub.firstCall.args).to.deep.equal(['', EMPTY_KEY_SUBSTITUTE, 'end key', 'dummyChannelId', 'dummyTxid']); }); @@ -797,7 +797,7 @@ describe('Stub', () => { const result = await stub.getStateByRangeWithPagination(null, 'end key', 3); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; const metadataBuffer = fabprotos.protos.QueryResponseMetadata.encode({ bookmark: '', fetchedRecordsCount: 3 @@ -817,7 +817,7 @@ describe('Stub', () => { const result = await stub.getStateByRangeWithPagination('start key', 'end key', 3); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; const metadataBuffer = fabprotos.protos.QueryResponseMetadata.encode({ bookmark: '', fetchedRecordsCount: 3 @@ -837,7 +837,7 @@ describe('Stub', () => { const result = await stub.getStateByRangeWithPagination('start key', 'end key', 3, 'a bookmark'); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; const metadataBuffer = fabprotos.protos.QueryResponseMetadata.encode({ bookmark: 'a bookmark', fetchedRecordsCount: 3 @@ -859,7 +859,7 @@ describe('Stub', () => { const result = await stub.getQueryResult('a query'); expect(result).to.deep.equal('some query result'); - expect(handleGetQueryResultStub.calledOnce).to.be.ok; + expect(handleGetQueryResultStub.calledOnce).to.be.true; expect(handleGetQueryResultStub.firstCall.args).to.deep.equal(['', 'a query', null, 'dummyChannelId', 'dummyTxid']); }); }); @@ -877,7 +877,7 @@ describe('Stub', () => { const result = await stub.getQueryResultWithPagination('a query', 3); expect(result).to.deep.equal('some query result'); - expect(handleGetQueryResultStub.calledOnce).to.be.ok; + expect(handleGetQueryResultStub.calledOnce).to.be.true; const metadata = handleGetQueryResultStub.firstCall.args[2]; const decoded = fabprotos.protos.QueryMetadata.decode(metadata); expect(decoded.pageSize).to.equal(3); @@ -896,7 +896,7 @@ describe('Stub', () => { const result = await stub.getQueryResultWithPagination('a query', 3, 'a bookmark'); expect(result).to.deep.equal('some query result'); - expect(handleGetQueryResultStub.calledOnce).to.be.ok; + expect(handleGetQueryResultStub.calledOnce).to.be.true; const metadata = handleGetQueryResultStub.firstCall.args[2]; const decoded = fabprotos.protos.QueryMetadata.decode(metadata); expect(decoded.pageSize).to.equal(3); @@ -917,7 +917,7 @@ describe('Stub', () => { const result = await stub.getHistoryForKey('a key'); expect(result).to.deep.equal('some history'); - expect(handleGetHistoryForKeyStub.calledOnce).to.be.ok; + expect(handleGetHistoryForKeyStub.calledOnce).to.be.true; expect(handleGetHistoryForKeyStub.firstCall.args).to.deep.equal(['a key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -940,7 +940,7 @@ describe('Stub', () => { const result = await stub.invokeChaincode('chaincodeName', ['some', 'args'], 'someChannel'); expect(result).to.deep.equal('invoked'); - expect(handleInvokeChaincodeStub.calledOnce).to.be.ok; + expect(handleInvokeChaincodeStub.calledOnce).to.be.true; expect(handleInvokeChaincodeStub.firstCall.args).to.deep.equal(['chaincodeName/someChannel', ['some', 'args'], 'dummyChannelId', 'dummyTxid']); }); @@ -948,7 +948,7 @@ describe('Stub', () => { const result = await stub.invokeChaincode('chaincodeName', ['some', 'args']); expect(result).to.deep.equal('invoked'); - expect(handleInvokeChaincodeStub.calledOnce).to.be.ok; + expect(handleInvokeChaincodeStub.calledOnce).to.be.true; expect(handleInvokeChaincodeStub.firstCall.args).to.deep.equal(['chaincodeName', ['some', 'args'], 'dummyChannelId', 'dummyTxid']); }); }); @@ -1003,7 +1003,7 @@ describe('Stub', () => { expect(() => { stub.createCompositeKey('some type', 'some attributes'); }).to.throw(/attributes must be an array/); - expect(mockValidate.calledOnce).to.be.ok; + expect(mockValidate.calledOnce).to.be.true; expect(mockValidate.firstCall.args).to.deep.equal(['some type']); }); @@ -1014,7 +1014,7 @@ describe('Stub', () => { const result = stub.createCompositeKey('some type', ['attr1', 'attr2']); expect(result).to.deep.equal(`${COMPOSITEKEY_NS}some type${MIN_UNICODE_RUNE_VALUE}attr1${MIN_UNICODE_RUNE_VALUE}attr2${MIN_UNICODE_RUNE_VALUE}`); - expect(mockValidate.calledThrice).to.be.ok; + expect(mockValidate.calledThrice).to.be.true; expect(mockValidate.firstCall.args).to.deep.equal(['some type']); expect(mockValidate.secondCall.args).to.deep.equal(['attr1']); expect(mockValidate.thirdCall.args).to.deep.equal(['attr2']); @@ -1070,9 +1070,9 @@ describe('Stub', () => { const result = await stub.getStateByPartialCompositeKey('some type', ['attr1', 'attr2']); expect(result).to.deep.equal('some state'); - expect(createCompositeKeyStub.calledOnce).to.be.ok; + expect(createCompositeKeyStub.calledOnce).to.be.true; expect(createCompositeKeyStub.firstCall.args).to.deep.equal(['some type', ['attr1', 'attr2']]); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; expect(handleGetStateByRangeStub.firstCall.args).to.deep.equal(['', 'some composite key', `some composite key${MAX_UNICODE_RUNE_VALUE}`, 'dummyChannelId', 'dummyTxid']); }); }); @@ -1097,9 +1097,9 @@ describe('Stub', () => { const result = await stub.getStateByPartialCompositeKeyWithPagination('some type', ['attr1', 'attr2'], 3); expect(result).to.deep.equal(response); - expect(createCompositeKeyStub.calledOnce).to.be.ok; + expect(createCompositeKeyStub.calledOnce).to.be.true; expect(createCompositeKeyStub.firstCall.args).to.deep.equal(['some type', ['attr1', 'attr2']]); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; const metadata = handleGetStateByRangeStub.firstCall.args[5]; const decoded = fabprotos.protos.QueryMetadata.decode(metadata); expect(decoded.pageSize).to.equal(3); @@ -1116,9 +1116,9 @@ describe('Stub', () => { const createCompositeKeyStub = sinon.stub(stub, 'createCompositeKey').returns('some composite key'); const result = await stub.getStateByPartialCompositeKeyWithPagination('some type', ['attr1', 'attr2'], 23, 'a bookmark'); expect(result).to.deep.equal(response); - expect(createCompositeKeyStub.calledOnce).to.be.ok; + expect(createCompositeKeyStub.calledOnce).to.be.true; expect(createCompositeKeyStub.firstCall.args).to.deep.equal(['some type', ['attr1', 'attr2']]); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; const metadata = handleGetStateByRangeStub.firstCall.args[5]; const decoded = fabprotos.protos.QueryMetadata.decode(metadata); expect(decoded.pageSize).to.equal(23); @@ -1158,7 +1158,7 @@ describe('Stub', () => { const result = await stub.getPrivateData('some collection', 'some key'); expect(result).to.deep.equal('some state'); - expect(handleGetStateStub.calledOnce).to.be.ok; + expect(handleGetStateStub.calledOnce).to.be.true; expect(handleGetStateStub.firstCall.args).to.deep.equal(['some collection', 'some key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -1195,7 +1195,7 @@ describe('Stub', () => { const result = await stub.getPrivateDataHash('some collection', 'some key'); expect(result).to.deep.equal('some state'); - expect(handleGetPrivateDataHashStub.calledOnce).to.be.ok; + expect(handleGetPrivateDataHashStub.calledOnce).to.be.true; expect(handleGetPrivateDataHashStub.firstCall.args).to.deep.equal(['some collection', 'some key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -1241,7 +1241,7 @@ describe('Stub', () => { it ('should return handler.handlePutState with string', async () => { const result = await stub.putPrivateData('some collection', 'some key', 'some value'); expect(result).to.deep.equal('some state'); - expect(handlePutStateStub.calledOnce).to.be.ok; + expect(handlePutStateStub.calledOnce).to.be.true; expect(handlePutStateStub.firstCall.args).to.deep.equal(['some collection', 'some key', Buffer.from('some value'), 'dummyChannelId', 'dummyTxid']); }); @@ -1249,7 +1249,7 @@ describe('Stub', () => { const result = await stub.putPrivateData('some collection', 'some key', {some :'value'}); expect(result).to.deep.equal('some state'); - expect(handlePutStateStub.calledOnce).to.be.ok; + expect(handlePutStateStub.calledOnce).to.be.true; expect(handlePutStateStub.firstCall.args).to.deep.equal(['some collection', 'some key', {some :'value'}, 'dummyChannelId', 'dummyTxid']); }); }); @@ -1286,7 +1286,7 @@ describe('Stub', () => { const result = await stub.deletePrivateData('some collection', 'some key'); expect(result).to.deep.equal('some state'); - expect(handleDeleteStateStub.calledOnce).to.be.ok; + expect(handleDeleteStateStub.calledOnce).to.be.true; expect(handleDeleteStateStub.firstCall.args).to.deep.equal(['some collection', 'some key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -1362,7 +1362,7 @@ describe('Stub', () => { const result = await stub.getPrivateDataByRange('some collection', null, 'some end key'); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; expect(handleGetStateByRangeStub.firstCall.args).to.deep.equal(['some collection', EMPTY_KEY_SUBSTITUTE, 'some end key', 'dummyChannelId', 'dummyTxid']); }); @@ -1370,7 +1370,7 @@ describe('Stub', () => { const result = await stub.getPrivateDataByRange('some collection', 'some start key', 'some end key'); expect(result).to.deep.equal('some state'); - expect(handleGetStateByRangeStub.calledOnce).to.be.ok; + expect(handleGetStateByRangeStub.calledOnce).to.be.true; expect(handleGetStateByRangeStub.firstCall.args).to.deep.equal(['some collection', 'some start key', 'some end key', 'dummyChannelId', 'dummyTxid']); }); }); @@ -1413,9 +1413,9 @@ describe('Stub', () => { const result = await stub.getPrivateDataByPartialCompositeKey('some collection', 'some type', ['arg1', 'arg2']); expect(result).to.deep.equal('some data by range'); - expect(createCompositeKeyStub.calledOnce).to.be.ok; + expect(createCompositeKeyStub.calledOnce).to.be.true; expect(createCompositeKeyStub.firstCall.args).to.deep.equal(['some type', ['arg1', 'arg2']]); - expect(getPrivateDataByRangeStub.calledOnce).to.be.ok; + expect(getPrivateDataByRangeStub.calledOnce).to.be.true; expect(getPrivateDataByRangeStub.firstCall.args).to.deep.equal(['some collection', 'some composite key', `some composite key${MAX_UNICODE_RUNE_VALUE}`]); }); }); @@ -1452,7 +1452,7 @@ describe('Stub', () => { const result = await stub.getPrivateDataQueryResult('some collection', 'some query'); expect(result).to.deep.equal('some query result'); - expect(handleGetQueryResultStub.calledOnce).to.be.ok; + expect(handleGetQueryResultStub.calledOnce).to.be.true; expect(handleGetQueryResultStub.firstCall.args).to.deep.equal(['some collection', 'some query', null, 'dummyChannelId', 'dummyTxid']); }); }); From de8c29cf8ed99a0ad6c3f81a599132bb07c5af5d Mon Sep 17 00:00:00 2001 From: lesleyannj Date: Mon, 6 Jan 2020 02:32:17 +0000 Subject: [PATCH 7/9] FABCN-241 Change to.be.ok Signed-off-by: lesleyannj --- .../fabric-shim-crypto/test/shim-crypto.js | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/libraries/fabric-shim-crypto/test/shim-crypto.js b/libraries/fabric-shim-crypto/test/shim-crypto.js index fa91ad31..3e711b23 100644 --- a/libraries/fabric-shim-crypto/test/shim-crypto.js +++ b/libraries/fabric-shim-crypto/test/shim-crypto.js @@ -71,9 +71,9 @@ describe('enc-sign', () => { expect(sc.signKey).to.be.undefined; expect(sc._ecdsa).to.be.undefined; - expect(mockCreateCipher.calledOnce).to.be.ok; + expect(mockCreateCipher.calledOnce).to.be.true; expect(mockCreateCipher.firstCall.args).to.deep.equal([ALGORITHM, mapItems.encryptKey.value, mapItems.iv.value]); - expect(mockCreateDecipher.calledOnce).to.be.ok; + expect(mockCreateDecipher.calledOnce).to.be.true; expect(mockCreateDecipher.firstCall.args).to.deep.equal([ALGORITHM, mapItems.encryptKey.value, mapItems.iv.value]); }); @@ -90,11 +90,11 @@ describe('enc-sign', () => { expect(sc.signKey).to.be.undefined; expect(sc._ecdsa).to.be.undefined; - expect(mockRandomBytes.calledOnce).to.be.ok; + expect(mockRandomBytes.calledOnce).to.be.true; expect(mockRandomBytes.firstCall.args).to.deep.equal([16]); - expect(mockCreateCipher.calledOnce).to.be.ok; + expect(mockCreateCipher.calledOnce).to.be.true; expect(mockCreateCipher.firstCall.args).to.deep.equal([ALGORITHM, mapItems.encryptKey.value, 'some random bytes']); - expect(mockCreateDecipher.calledOnce).to.be.ok; + expect(mockCreateDecipher.calledOnce).to.be.true; expect(mockCreateDecipher.firstCall.args).to.deep.equal([ALGORITHM, mapItems.encryptKey.value, 'some random bytes']); }); @@ -108,9 +108,9 @@ describe('enc-sign', () => { expect(sc.signKey).to.deep.equal('some imported signKey'); expect(sc._ecdsa).to.deep.equal(ecStubInstance); - expect(mockImportKey.calledOnce).to.be.ok; + expect(mockImportKey.calledOnce).to.be.true; expect(mockImportKey.firstCall.args).to.deep.equal([mapItems.signKey.value]); - expect(mockEC.calledOnce).to.be.ok; + expect(mockEC.calledOnce).to.be.true; expect(mockEC.firstCall.args).to.deep.equal([elliptic.curves.p256]); clearSignKeyMocks(); @@ -136,9 +136,9 @@ describe('enc-sign', () => { const sc = newShimCrypto(['encryptKey']); expect(sc.encrypt('some message').toString('hex')).to.deep.equal('00000000001111111111'); - expect(updateStub.calledOnce).to.be.ok; + expect(updateStub.calledOnce).to.be.true; expect(updateStub.firstCall.args).to.deep.equal(['some message', null, 'hex']); - expect(finalStub.calledOnce).to.be.ok; + expect(finalStub.calledOnce).to.be.true; expect(finalStub.firstCall.args).to.deep.equal(['hex']); }); }); @@ -164,9 +164,9 @@ describe('enc-sign', () => { const sc = newShimCrypto(['encryptKey']); expect(sc.decrypt('00000000001111111111').toString('utf8')).to.deep.equal('some message'); - expect(updateStub.calledOnce).to.be.ok; + expect(updateStub.calledOnce).to.be.true; expect(updateStub.firstCall.args).to.deep.equal(['00000000001111111111', null, 'utf8']); - expect(finalStub.calledOnce).to.be.ok; + expect(finalStub.calledOnce).to.be.true; expect(finalStub.firstCall.args).to.deep.equal(['utf8']); }); @@ -242,13 +242,13 @@ describe('enc-sign', () => { const sc = newShimCrypto(['signKey']); expect(sc.sign('some message')).to.deep.equal('some DER'); - expect(ecStubInstance.keyFromPrivate.calledOnce).to.be.ok; + expect(ecStubInstance.keyFromPrivate.calledOnce).to.be.true; expect(ecStubInstance.keyFromPrivate.firstCall.args).to.deep.equal(['some prvKeyHex', 'hex']); - expect(hashStub.calledOnce).to.be.ok; + expect(hashStub.calledOnce).to.be.true; expect(hashStub.firstCall.args).to.deep.equal(['some message']); - expect(ecStubInstance.sign.calledOnce).to.be.ok; + expect(ecStubInstance.sign.calledOnce).to.be.true; expect(ecStubInstance.sign.firstCall.args).to.deep.equal(['some hash', 'some key from private']); - expect(_preventMalleabilityStub.calledOnce).to.be.ok; + expect(_preventMalleabilityStub.calledOnce).to.be.true; expect(_preventMalleabilityStub.firstCall.args).to.deep.equal(['some signed message', 'some params']); ShimCrypto.__set__('_preventMalleability', savePreventMalleability); @@ -340,9 +340,9 @@ describe('enc-sign', () => { const result = sc.verify('some sig', 'some message'); expect(result.ok).to.deep.equal(false); - expect(result.error instanceof Error).to.be.ok; + expect(result.error instanceof Error).to.be.true; expect(result.error.message).to.deep.equal('Invalid S value in signature. Must be smaller than half of the order.'); - expect(_checkMalleabilityStub.calledOnce).to.be.ok; + expect(_checkMalleabilityStub.calledOnce).to.be.true; expect(_checkMalleabilityStub.firstCall.args).to.deep.equal(['some sig', 'some params']); ShimCrypto.__set__('_checkMalleability', saveCheckMalleability); @@ -366,11 +366,11 @@ describe('enc-sign', () => { expect(result.ok).to.deep.equal(true); expect(result.error).to.deep.equal(null); - expect(_checkMalleabilityStub.calledOnce).to.be.ok; + expect(_checkMalleabilityStub.calledOnce).to.be.true; expect(_checkMalleabilityStub.firstCall.args).to.deep.equal(['some sig', 'some params']); - expect(ecStubInstance.keyFromPublic.calledOnce).to.be.ok; + expect(ecStubInstance.keyFromPublic.calledOnce).to.be.true; expect(ecStubInstance.keyFromPublic.firstCall.args).to.deep.equal(['some pubKeyHex', 'hex']); - expect(mockVerifyStub.calledOnce).to.be.ok; + expect(mockVerifyStub.calledOnce).to.be.true; expect(mockVerifyStub.firstCall.args).to.deep.equal(['some hash', 'some sig']); ShimCrypto.__set__('_checkMalleability', saveCheckMalleability); @@ -403,13 +403,13 @@ describe('enc-sign', () => { const result = sc.verify('some sig', 'some message'); expect(result.ok).to.deep.equal(false); - expect(result.error instanceof Error).to.be.ok; + expect(result.error instanceof Error).to.be.true; expect(result.error.message).to.deep.equal('Signature failed to verify'); - expect(_checkMalleabilityStub.calledOnce).to.be.ok; + expect(_checkMalleabilityStub.calledOnce).to.be.true; expect(_checkMalleabilityStub.firstCall.args).to.deep.equal(['some sig', 'some params']); - expect(ecStubInstance.keyFromPublic.calledOnce).to.be.ok; + expect(ecStubInstance.keyFromPublic.calledOnce).to.be.true; expect(ecStubInstance.keyFromPublic.firstCall.args).to.deep.equal(['some pubKeyHex', 'hex']); - expect(mockVerifyStub.calledOnce).to.be.ok; + expect(mockVerifyStub.calledOnce).to.be.true; expect(mockVerifyStub.firstCall.args).to.deep.equal(['some hash', 'some sig']); ShimCrypto.__set__('_checkMalleability', saveCheckMalleability); @@ -431,11 +431,11 @@ describe('enc-sign', () => { const result = ShimCrypto.__get__('hash')('some message'); expect(result).to.deep.equal('some digest'); - expect(createHashStub.calledOnce).to.be.ok; + expect(createHashStub.calledOnce).to.be.true; expect(createHashStub.firstCall.args).to.deep.equal(['sha256']); - expect(updateStub.calledOnce).to.be.ok; + expect(updateStub.calledOnce).to.be.true; expect(updateStub.firstCall.args).to.deep.equal(['some message']); - expect(digestStub.calledOnce).to.be.ok; + expect(digestStub.calledOnce).to.be.true; expect(digestStub.firstCall.args).to.deep.equal(['hex']); createHashStub.restore(); @@ -503,8 +503,9 @@ describe('enc-sign', () => { sinon.stub(KEYUTIL, 'getKey').returns(mockKey); - expect(importKey('some raw content') instanceof ECDSAKey).to.be.ok; - expect(mockECDSAKey.calledWithNew).to.be.ok; + expect(importKey('some raw content') instanceof ECDSAKey).to.be.true; + expect(mockECDSAKey.calledWithNew).to.be.ok; // Believe wrong + expect(mockECDSAKey.calledWithNew()).to.be.false; expect(mockECDSAKey.firstCall.args).to.deep.equal([mockKey]); ShimCrypto.__set__('ECDSAKey', ECDSAKey); @@ -580,7 +581,7 @@ i6dOfok= }); expect(result).to.deep.equal(sig); - expect(sig.s.cmp.calledOnce).to.be.ok; + expect(sig.s.cmp.calledOnce).to.be.true; expect(sig.s.cmp.firstCall.args).to.deep.equal([halfOrdersForCurve.secp256r1]); }); @@ -612,9 +613,10 @@ i6dOfok= const result = _preventMalleability(sig, curveParams); expect(result.s).to.deep.equal('some sub'); - expect(mockBN.calledWithNew).to.be.ok; + expect(mockBN.calledWithNew).to.be.ok; // Believe wrong + expect(mockBN.calledWithNew()).to.be.false; expect(mockBN.firstCall.args).to.deep.equal(['some string', 16]); - expect(curveParams.n.toString.calledOnce).to.be.ok; + expect(curveParams.n.toString.calledOnce).to.be.true; expect(curveParams.n.toString.firstCall.args).to.deep.equal([16]); ShimCrypto.__set__('BN', saveBN); @@ -690,7 +692,7 @@ i6dOfok= expect(_checkMalleability('some sig', { name: 'secp256r1' })).to.deep.equal(false); - expect(cmpStub.calledOnce).to.be.ok; + expect(cmpStub.calledOnce).to.be.true; expect(cmpStub.firstCall.args).to.deep.equal([halfOrdersForCurve.secp256r1]); ShimCrypto.__set__('Signature', saveSig); @@ -716,7 +718,7 @@ i6dOfok= expect(_checkMalleability('some sig', { name: 'secp256r1' })).to.deep.equal(true); - expect(cmpStub.calledOnce).to.be.ok; + expect(cmpStub.calledOnce).to.be.true; expect(cmpStub.firstCall.args).to.deep.equal([halfOrdersForCurve.secp256r1]); ShimCrypto.__set__('Signature', saveSig); From 4df348a6f9c4df607ea000a6f246900f635e3d2c Mon Sep 17 00:00:00 2001 From: lesleyannj Date: Mon, 6 Jan 2020 03:12:14 +0000 Subject: [PATCH 8/9] FABCN-241 Remove to.be.ok Signed-off-by: lesleyannj --- libraries/fabric-shim/test/unit/handler.js | 232 +++++++++++---------- 1 file changed, 119 insertions(+), 113 deletions(-) diff --git a/libraries/fabric-shim/test/unit/handler.js b/libraries/fabric-shim/test/unit/handler.js index 09bf0530..c952f4dd 100644 --- a/libraries/fabric-shim/test/unit/handler.js +++ b/libraries/fabric-shim/test/unit/handler.js @@ -90,7 +90,7 @@ describe('Handler', () => { it ('should call the resolve function', () => { qMsg.success('response'); - expect(resolve.calledOnce).to.be.ok; + expect(resolve.calledOnce).to.be.true; expect(resolve.firstCall.args).to.deep.equal(['response']); }); }); @@ -99,7 +99,7 @@ describe('Handler', () => { it ('should call the reject function', () => { qMsg.fail('err'); - expect(reject.calledOnce).to.be.ok; + expect(reject.calledOnce).to.be.true; expect(reject.firstCall.args).to.deep.equal(['err']); }); }); @@ -138,7 +138,7 @@ describe('Handler', () => { it ('should add message to the queue and call sendMsg and handle when txContentId not in txQueues', () => { qHandler.queueMsg(qMsg); - expect(mockSendMsg.calledOnce).to.be.ok; + expect(mockSendMsg.calledOnce).to.be.true; expect(mockSendMsg.firstCall.args).to.deep.equal([txContextId]); expect(qHandler.txQueues[txContextId]).to.deep.equal([qMsg]); }); @@ -148,7 +148,7 @@ describe('Handler', () => { qHandler.queueMsg(qMsg); - expect(mockSendMsg.calledOnce).to.be.ok; + expect(mockSendMsg.calledOnce).to.be.true; expect(mockSendMsg.firstCall.args).to.deep.equal([txContextId]); expect(qHandler.txQueues[txContextId]).to.deep.equal([qMsg]); }); @@ -158,7 +158,7 @@ describe('Handler', () => { qHandler.queueMsg(qMsg); - expect(mockSendMsg.notCalled).to.be.ok; + expect(mockSendMsg.notCalled).to.be.true; expect(qHandler.txQueues[txContextId]).to.deep.equal(['some qMsg', qMsg]); }); }); @@ -204,12 +204,12 @@ describe('Handler', () => { qHandler.handleMsgResponse(response); - expect(mockGetCurrMsg.calledOnce).to.be.ok; + expect(mockGetCurrMsg.calledOnce).to.be.true; expect(mockGetCurrMsg.firstCall.args).to.deep.equal([response.channel_id + response.txid]); - expect(mockParseResponse.notCalled).to.be.ok; - expect(qMsg.success.notCalled).to.be.ok; - expect(qMsg.fail.notCalled).to.be.ok; - expect(mockRemoveCurrentAndSendNextMsg.notCalled).to.be.ok; + expect(mockParseResponse.notCalled).to.be.true; + expect(qMsg.success.notCalled).to.be.true; + expect(qMsg.fail.notCalled).to.be.true; + expect(mockRemoveCurrentAndSendNextMsg.notCalled).to.be.true; }); it ('should call qMsg success when parseResponse does not throw an error _removeCurrentAndSendNextMsg', () => { @@ -218,14 +218,14 @@ describe('Handler', () => { qHandler.handleMsgResponse(response); - expect(mockGetCurrMsg.calledOnce).to.be.ok; + expect(mockGetCurrMsg.calledOnce).to.be.true; expect(mockGetCurrMsg.firstCall.args).to.deep.equal([response.channel_id + response.txid]); - expect(mockParseResponse.calledOnce).to.be.ok; + expect(mockParseResponse.calledOnce).to.be.true; expect(mockParseResponse.firstCall.args).to.deep.equal([mockHandler, response, 'some method']); - expect(qMsg.success.calledOnce).to.be.ok; + expect(qMsg.success.calledOnce).to.be.true; expect(qMsg.success.firstCall.args).to.deep.equal(['parsed response']); - expect(qMsg.fail.notCalled).to.be.ok; - expect(mockRemoveCurrentAndSendNextMsg.calledOnce).to.be.ok; + expect(qMsg.fail.notCalled).to.be.true; + expect(mockRemoveCurrentAndSendNextMsg.calledOnce).to.be.true; expect(mockRemoveCurrentAndSendNextMsg.firstCall.args).to.deep.equal([response.channel_id + response.txid]); }); @@ -236,14 +236,14 @@ describe('Handler', () => { qHandler.handleMsgResponse(response); - expect(mockGetCurrMsg.calledOnce).to.be.ok; + expect(mockGetCurrMsg.calledOnce).to.be.true; expect(mockGetCurrMsg.firstCall.args).to.deep.equal([response.channel_id + response.txid]); - expect(mockParseResponse.calledOnce).to.be.ok; + expect(mockParseResponse.calledOnce).to.be.true; expect(mockParseResponse.firstCall.args).to.deep.equal([mockHandler, response, 'some method']); - expect(qMsg.success.notCalled).to.be.ok; - expect(qMsg.fail.calledOnce).to.be.ok; + expect(qMsg.success.notCalled).to.be.true; + expect(qMsg.fail.calledOnce).to.be.true; expect(qMsg.fail.firstCall.args).to.deep.equal([err]); - expect(mockRemoveCurrentAndSendNextMsg.calledOnce).to.be.ok; + expect(mockRemoveCurrentAndSendNextMsg.calledOnce).to.be.true; expect(mockRemoveCurrentAndSendNextMsg.firstCall.args).to.deep.equal([response.channel_id + response.txid]); }); }); @@ -287,7 +287,7 @@ describe('Handler', () => { qHandler._removeCurrentAndSendNextMsg(txContextId); - expect(sendMsg.calledOnce).to.be.ok; + expect(sendMsg.calledOnce).to.be.true; expect(qHandler.txQueues[txContextId]).to.deep.equal(['message2']); expect(qHandler.txQueues[alternateTxContextId]).to.deep.equal(['message3', 'message4']); }); @@ -297,7 +297,7 @@ describe('Handler', () => { qHandler._removeCurrentAndSendNextMsg(txContextId); - expect(sendMsg.notCalled).to.be.ok; + expect(sendMsg.notCalled).to.be.true; expect(qHandler.txQueues[txContextId]).to.be.undefined; expect(qHandler.txQueues[alternateTxContextId]).to.deep.equal(['message3', 'message4']); }); @@ -307,7 +307,7 @@ describe('Handler', () => { qHandler._removeCurrentAndSendNextMsg(txContextId); - expect(sendMsg.notCalled).to.be.ok; + expect(sendMsg.notCalled).to.be.true; expect(qHandler.txQueues[txContextId]).to.be.null; expect(qHandler.txQueues[alternateTxContextId]).to.deep.equal(['message3', 'message4']); }); @@ -326,10 +326,10 @@ describe('Handler', () => { qHandler._sendMsg(txContextId); - expect(getCurrStub.calledOnce).to.be.ok; + expect(getCurrStub.calledOnce).to.be.true; expect(getCurrStub.firstCall.args).to.deep.equal([txContextId]); - expect(qHandler.stream.write.notCalled).to.be.ok; - expect(mockQMsg.fail.notCalled).to.be.ok; + expect(qHandler.stream.write.notCalled).to.be.true; + expect(mockQMsg.fail.notCalled).to.be.true; }); it ('should write to the stream the current message', () => { @@ -337,11 +337,11 @@ describe('Handler', () => { qHandler._sendMsg(txContextId); - expect(getCurrStub.calledOnce).to.be.ok; + expect(getCurrStub.calledOnce).to.be.true; expect(getCurrStub.firstCall.args).to.deep.equal([txContextId]); - expect(qHandler.stream.write.calledOnce).to.be.ok; + expect(qHandler.stream.write.calledOnce).to.be.true; expect(qHandler.stream.write.firstCall.args).to.deep.equal(['some message']); - expect(mockQMsg.fail.notCalled).to.be.ok; + expect(mockQMsg.fail.notCalled).to.be.true; }); it ('should call fail on the QMsg if stream write errors', () => { @@ -352,9 +352,9 @@ describe('Handler', () => { qHandler._sendMsg(txContextId); - expect(getCurrStub.calledOnce).to.be.ok; + expect(getCurrStub.calledOnce).to.be.true; expect(getCurrStub.firstCall.args).to.deep.equal([txContextId]); - expect(mockQMsg.fail.calledOnce).to.be.ok; + expect(mockQMsg.fail.calledOnce).to.be.true; expect(mockQMsg.fail.firstCall.args).to.deep.equal([err]); }); }); @@ -400,7 +400,7 @@ describe('Handler', () => { expect(handler._request_timeout).to.deep.equal(30000); expect(handler._endpoint.addr).to.deep.equal(mockPeerAddress.base); - expect(credsSpy.calledOnce).to.be.ok; + expect(credsSpy.calledOnce).to.be.true; expect(handler._endpoint.creds.constructor.name).to.deep.equal('ChannelCredentials'); expect(handler._client.constructor.name).to.deep.equal('ServiceClient'); @@ -472,8 +472,8 @@ describe('Handler', () => { expect(handler._options.cert).to.deep.equal(mockOpts.cert); expect(handler._request_timeout).to.deep.equal(30000); expect(handler._endpoint.addr).to.deep.equal(mockPeerAddress.base); - expect(credsSpy.calledOnce).to.be.ok; - expect(credsSpy.calledWith(Buffer.from(mockOpts.pem), Buffer.from(mockOpts.key, 'base64'), Buffer.from(mockOpts.cert, 'base64'))).to.be.ok; + expect(credsSpy.calledOnce).to.be.true; + expect(credsSpy.calledWith(Buffer.from(mockOpts.pem), Buffer.from(mockOpts.key, 'base64'), Buffer.from(mockOpts.cert, 'base64'))).to.be.true; expect(handler._endpoint.creds.constructor.name).to.deep.equal('ChannelCredentials'); expect(handler._client.constructor.name).to.deep.equal('ServiceClient'); }); @@ -495,7 +495,7 @@ describe('Handler', () => { handler.close(); - expect(handler._stream.end.calledOnce).to.be.ok; + expect(handler._stream.end.calledOnce).to.be.true; }); }); @@ -518,12 +518,13 @@ describe('Handler', () => { handler.chat('some starter message'); - expect(handler._client.register.calledOnce).to.be.ok; - expect(mockMsgQueueHandler.calledWithNew).to.been.ok; + expect(handler._client.register.calledOnce).to.be.true; + expect(mockMsgQueueHandler.calledWithNew).to.be.ok; // believe wrong + expect(mockMsgQueueHandler.calledWithNew()).to.be.false; expect(handler._stream).to.deep.equal(mockStream); expect(handler.msgQueueHandler).to.deep.equal(new mockMsgQueueHandler(handler)); - expect(mockStream.write.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; expect(mockStream.write.firstCall.args).to.deep.equal(['some starter message']); expect(mockStream.on.callCount).to.deep.equal(3); expect(mockStream.on.firstCall.args[0]).to.deep.equal('data'); @@ -595,8 +596,8 @@ describe('Handler', () => { eventReg.data(badRegisteredMsg); - expect(mockStream.write.calledTwice).to.be.ok; - expect(mockNewErrorMsg.calledOnce).to.be.ok; + expect(mockStream.write.calledTwice).to.be.true; + expect(mockNewErrorMsg.calledOnce).to.be.true; expect(mockStream.write.secondCall.args).to.deep.equal(['some error']); expect(mockNewErrorMsg.firstCall.args).to.deep.equal([badRegisteredMsg, 'created']); }); @@ -609,8 +610,8 @@ describe('Handler', () => { eventReg.data(registeredMsg); eventReg.data(badEstablishedMsg); - expect(mockStream.write.calledTwice).to.be.ok; - expect(mockNewErrorMsg.calledOnce).to.be.ok; + expect(mockStream.write.calledTwice).to.be.true; + expect(mockNewErrorMsg.calledOnce).to.be.true; expect(mockStream.write.secondCall.args).to.deep.equal(['some error']); expect(mockNewErrorMsg.firstCall.args).to.deep.equal([badEstablishedMsg, 'established']); }); @@ -620,11 +621,11 @@ describe('Handler', () => { eventReg.data(establishedMsg); eventReg.data(registeredMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.notCalled).to.be.ok; - expect(handleInitSpy.notCalled).to.be.ok; - expect(handleTransactionSpy.notCalled).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.notCalled).to.be.true; + expect(handleInitSpy.notCalled).to.be.true; + expect(handleTransactionSpy.notCalled).to.be.true; }); it ('should do nothing when in state ready and MSG_TYPE equals READY', () => { @@ -632,11 +633,11 @@ describe('Handler', () => { eventReg.data(establishedMsg); eventReg.data(establishedMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.notCalled).to.be.ok; - expect(handleInitSpy.notCalled).to.be.ok; - expect(handleTransactionSpy.notCalled).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.notCalled).to.be.true; + expect(handleInitSpy.notCalled).to.be.true; + expect(handleTransactionSpy.notCalled).to.be.true; }); it ('should call handleMsgResponse when in state ready and MSG_TYPE equals RESPONSE', () => { @@ -651,12 +652,12 @@ describe('Handler', () => { eventReg.data(readyMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.calledOnce).to.be.true; expect(handleMsgResponseSpy.firstCall.args).to.deep.equal([readyMsg]); - expect(handleInitSpy.notCalled).to.be.ok; - expect(handleTransactionSpy.notCalled).to.be.ok; + expect(handleInitSpy.notCalled).to.be.true; + expect(handleTransactionSpy.notCalled).to.be.true; }); it ('should call handleMsgResponse when in state ready and MSG_TYPE equals ERROR', () => { @@ -671,12 +672,12 @@ describe('Handler', () => { eventReg.data(readyMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.calledOnce).to.be.true; expect(handleMsgResponseSpy.firstCall.args).to.deep.equal([readyMsg]); - expect(handleInitSpy.notCalled).to.be.ok; - expect(handleTransactionSpy.notCalled).to.be.ok; + expect(handleInitSpy.notCalled).to.be.true; + expect(handleTransactionSpy.notCalled).to.be.true; }); it ('should call handleInit when in state ready and MSG_TYPE equals INIT', () => { @@ -690,12 +691,12 @@ describe('Handler', () => { }; eventReg.data(readyMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.notCalled).to.be.ok; - expect(handleInitSpy.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.notCalled).to.be.true; + expect(handleInitSpy.calledOnce).to.be.true; expect(handleInitSpy.firstCall.args).to.deep.equal([readyMsg]); - expect(handleTransactionSpy.notCalled).to.be.ok; + expect(handleTransactionSpy.notCalled).to.be.true; }); it ('should call handleTransaction when in state ready and MSG_TYPE equals TRANSACTION', () => { @@ -709,11 +710,11 @@ describe('Handler', () => { }; eventReg.data(readyMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.notCalled).to.be.ok; - expect(handleInitSpy.notCalled).to.be.ok; - expect(handleTransactionSpy.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.notCalled).to.be.true; + expect(handleInitSpy.notCalled).to.be.true; + expect(handleTransactionSpy.calledOnce).to.be.true; expect(handleTransactionSpy.firstCall.args).to.deep.equal([readyMsg]); }); @@ -730,12 +731,12 @@ describe('Handler', () => { }; eventReg.data(readyMsg); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockNewErrorMsg.notCalled).to.be.ok; - expect(handleMsgResponseSpy.notCalled).to.be.ok; - expect(handleInitSpy.notCalled).to.be.ok; - expect(handleTransactionSpy.notCalled).to.be.ok; - expect(processStub.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockNewErrorMsg.notCalled).to.be.true; + expect(handleMsgResponseSpy.notCalled).to.be.true; + expect(handleInitSpy.notCalled).to.be.true; + expect(handleTransactionSpy.notCalled).to.be.true; + expect(processStub.calledOnce).to.be.true; expect(processStub.firstCall.args).to.deep.equal([1]); processStub.restore(); @@ -757,8 +758,8 @@ describe('Handler', () => { eventReg.end(); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockStream.cancel.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockStream.cancel.calledOnce).to.be.true; }); }); @@ -777,8 +778,8 @@ describe('Handler', () => { eventReg.error({}); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockStream.end.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockStream.end.calledOnce).to.be.true; }); it ('should end the with error', () => { const eventReg = {}; @@ -794,8 +795,8 @@ describe('Handler', () => { const error = new Error(); eventReg.error(error); - expect(mockStream.write.calledOnce).to.be.ok; - expect(mockStream.end.calledOnce).to.be.ok; + expect(mockStream.write.calledOnce).to.be.true; + expect(mockStream.end.calledOnce).to.be.true; }); }); }); @@ -810,7 +811,7 @@ describe('Handler', () => { const handler = new Handler(mockChaincodeImpl, mockPeerAddress.unsecure); handler.handleInit('some message'); - expect(handleMessage.calledOnce).to.be.ok; + expect(handleMessage.calledOnce).to.be.true; expect(handleMessage.firstCall.args).to.deep.equal(['some message', handler, 'init']); Handler.__set__('handleMessage', savedHandleMessage); @@ -827,7 +828,7 @@ describe('Handler', () => { const handler = new Handler(mockChaincodeImpl, mockPeerAddress.unsecure); handler.handleTransaction('some message'); - expect(handleMessage.calledOnce).to.be.ok; + expect(handleMessage.calledOnce).to.be.true; expect(handleMessage.firstCall.args).to.deep.equal(['some message', handler, 'invoke']); Handler.__set__('handleMessage', savedHandleMessage); @@ -1545,8 +1546,8 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'init'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); }); @@ -1558,8 +1559,8 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'init'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); }); @@ -1568,13 +1569,13 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'init'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler.chaincode.Init.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler.chaincode.Init.calledOnce).to.be.true; expect(mockHandler.chaincode.Init.firstCall.args[0]).to.deep.equal(mockStub); const text = '[theChannelID-aTX] Calling chaincode Init() has not called success or error.'; expectedResponse.payload = Buffer.from(text); - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0].payload.toString()).to.equal(text); expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); }); @@ -1584,12 +1585,12 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'invoke'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler.chaincode.Invoke.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler.chaincode.Invoke.calledOnce).to.be.true; expect(mockHandler.chaincode.Invoke.firstCall.args[0]).to.deep.equal(mockStub); const text = '[theChannelID-aTX] Calling chaincode Invoke() has not called success or error.'; expectedResponse.payload = Buffer.from(text); - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0].payload.toString()).to.equal(text); expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); @@ -1600,13 +1601,13 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'init'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler.chaincode.Init.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler.chaincode.Init.calledOnce).to.be.true; expect(mockHandler.chaincode.Init.firstCall.args[0]).to.deep.equal(mockStub); const text = '[theChannelID-aTX] Calling chaincode Init() has not called success or error.'; expectedResponse.payload = Buffer.from(text); - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0].payload.toString()).to.equal(text); expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); @@ -1617,13 +1618,13 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'invoke'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler.chaincode.Invoke.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler.chaincode.Invoke.calledOnce).to.be.true; expect(mockHandler.chaincode.Invoke.firstCall.args[0]).to.deep.equal(mockStub); const text = '[theChannelID-aTX] Calling chaincode Invoke() has not called success or error.'; expectedResponse.payload = Buffer.from(text); - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); expect(mockHandler._stream.write.firstCall.args[0].payload.toString()).to.equal(text); }); @@ -1647,10 +1648,10 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'init'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler.chaincode.Init.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler.chaincode.Init.calledOnce).to.be.true; expect(mockHandler.chaincode.Init.firstCall.args[0]).to.deep.equal(mockStub); - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); }); @@ -1659,10 +1660,10 @@ describe('Handler', () => { await handleMessage(msg, mockHandler, 'invoke'); - expect(decodeStub.calledOnce).to.be.ok; - expect(mockHandler.chaincode.Invoke.calledOnce).to.be.ok; + expect(decodeStub.calledOnce).to.be.true; + expect(mockHandler.chaincode.Invoke.calledOnce).to.be.true; expect(mockHandler.chaincode.Invoke.firstCall.args[0]).to.deep.equal(mockStub); - expect(mockHandler._stream.write.calledOnce).to.be.ok; + expect(mockHandler._stream.write.calledOnce).to.be.true; expect(mockHandler._stream.write.firstCall.args[0]).to.deep.equal(expectedResponse); }); }); @@ -1680,7 +1681,8 @@ describe('Handler', () => { const createStub = Handler.__get__('createStub'); createStub({}, 'channelID', 'txID', 'some input', 'some proposal'); - expect(mockStub.calledWithNew).to.be.ok; + expect(mockStub.calledWithNew).to.be.ok; //believe wrong + expect(mockStub.calledWithNew()).to.be.false; expect(mockStub.firstCall.args[0]).to.deep.equal({}); expect(mockStub.firstCall.args[1]).to.deep.equal('channelID'); expect(mockStub.firstCall.args[2]).to.deep.equal('txID'); @@ -1851,7 +1853,8 @@ describe('Handler', () => { parseResponse(handler, res, 'GetStateByRange'); - expect(mockStateQueryIterator.calledWithNew).to.be.ok; + expect(mockStateQueryIterator.calledWithNew).to.be.ok; // believe wrong + expect(mockStateQueryIterator.calledWithNew()).to.be.false; expect(mockStateQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, qrDecodedPayload]); }); @@ -1869,7 +1872,8 @@ describe('Handler', () => { const result = parseResponse(handler, res, 'GetStateByRange'); - expect(mockStateQueryIterator.calledWithNew).to.be.ok; + expect(mockStateQueryIterator.calledWithNew).to.be.ok; // believe wrong + expect(mockStateQueryIterator.calledWithNew()).to.be.false; expect(mockStateQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, pagedQrPayload]); expect(result.metadata).to.eql(mdDecodedPayload); @@ -1884,7 +1888,8 @@ describe('Handler', () => { parseResponse(handler, res, 'GetQueryResult'); - expect(mockStateQueryIterator.calledWithNew).to.be.ok; + expect(mockStateQueryIterator.calledWithNew).to.be.ok; // believe wrong + expect(mockStateQueryIterator.calledWithNew()).to.be.false; expect(mockStateQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, qrDecodedPayload]); }); @@ -1896,7 +1901,8 @@ describe('Handler', () => { parseResponse(handler, res, 'GetHistoryForKey'); - expect(mockHistoryQueryIterator.calledWithNew).to.be.ok; + expect(mockHistoryQueryIterator.calledWithNew).to.be.ok; // believe wrong + expect(mockHistoryQueryIterator.calledWithNew()).to.be.false; expect(mockHistoryQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, qrDecodedPayload]); }); From 0014244b0869c2109af0abd1e23c77894edc4de3 Mon Sep 17 00:00:00 2001 From: Johnny Da Costa Date: Mon, 17 Feb 2020 16:18:57 +0100 Subject: [PATCH 9/9] fix: remove semicolon Signed-off-by: Johnny Da Costa --- docs/_jsdoc/tutorials/using-iterators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_jsdoc/tutorials/using-iterators.md b/docs/_jsdoc/tutorials/using-iterators.md index c50e05fe..e9c498c2 100644 --- a/docs/_jsdoc/tutorials/using-iterators.md +++ b/docs/_jsdoc/tutorials/using-iterators.md @@ -39,7 +39,7 @@ async function getAllResults(iterator) { const res = await iterator.next(); if (res.value) { // if not a getHistoryForKey iterator then key is contained in res.value.key - allResults.push(res.value.value.toString('utf8');); + allResults.push(res.value.value.toString('utf8')); } // check to see if we have reached then end