Welcome to the Fabric-SDK-Node test readme.
There are three types of testing that are used to support Fabric-SDK-Node:
- Unit
- Functional
- Scenario
Unit tests are located in a package/test
directory that mirrors the package/lib
directory and are Mocha based.
The functional tests are currently written in Tape, with the intention of testing the Fabric-SDK-Node package capabilities from a user perspective against a live Hyperledger Fabric Network.
The scenario tests are written in typescript and use Cucumber, with the intention of providing high level test coverage from a scenario perspective. For more information, please refer to the README within the scenario directory.
Test certificates are set to expire a year after generation. Due to this the test suite generates new certificates as part of the build process, and is a manual requirement prior to running the tests locally. This process is orchestrated using test scripts that:
- Download, install and export the path to the 1.4 Hyperledger Fabric binaries used for generating crypto material
- Generate the crypto-material, matching channel blocks and fabric-ca certificates required by the docker-compose files and test suites
Use the npm task npm run installAndGenerateCerts
to perform the above on a linux x64 machine, or npm run installAndGenerateCertsMac
for a mac. This is only required to be performed upon initial project clone, and then yearly afterwards.
The folder structure is the following:
test
│ README.md
│
└───fixtures
└───integration
└───ts-scenario
fixtures
holds all the configuration files used by the integration and scenario testsintegration
contains the integration test suitets-scenario
contains the typescripts scenario test suite
Below are the steps required to run Hardware Security Module (HSM) tests locally.
In order to run the tests in the absence of a real HSM, a software emulator of the PKCS#11 interface is required. For more information please refer to SoftHSM.
SoftHSM can either be installed using the package manager for your host system:
- Ubuntu:
apt-get install softhsm2
- macOS:
brew install softhsm
- Windows: unsupported
Or compiled and installed from source:
- install openssl 1.0.0+ or botan 1.10.0+
- download the source code from https://dist.opendnssec.org/source/softhsm-2.2.0.tar.gz
tar -xvf softhsm-2.2.0.tar.gz
cd softhsm-2.2.0
./configure --disable-gost
(would require additional libraries, turn it off unless you need gost algorithm support for the Russian market)make
sudo make install
export SOFTHSM2_CONF="./test/fixtures/hsm/softhsm2.conf"
softhsm2-util --init-token --slot 0 --label "My token 1"
Then you will be prompted two PINs: SO (Security Officer) PIN that can be used to re-initialize the token, and user PIN (see below) to be used by applications to access the token for generating and retrieving keys.
By default the tests run with SoftHSM using slot 0
and user PIN 98765432
. If your configuration is different, use
these environment variables to pass in the values:
- PKCS11_LIB - path to the SoftHSM2 library; if not specified, the tests search a list of common install locations
- PKCS11_PIN
- PKCS11_SLOT
To turn these tests off, the npm script tapeIntegrationNoHSM
should be specified.