github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/docs/source/dev-setup/build.rst (about)

     1  Building Hyperledger Fabric
     2  ---------------------------
     3  
     4  The following instructions assume that you have already set up your
     5  :doc:`development environment <devenv>`.
     6  
     7  To build Hyperledger Fabric:
     8  
     9  ::
    10  
    11      cd $GOPATH/src/github.com/hyperledger/fabric
    12      make dist-clean all
    13  
    14  Running the unit tests
    15  ~~~~~~~~~~~~~~~~~~~~~~
    16  
    17  Before running the unit tests, a PKCS #11 cryptographic token implementation
    18  must be installed and configured. The PKCS #11 API is used by the bccsp
    19  component of Fabric to interact with devices, such as hardware security modules
    20  (HSMs), that store cryptographic information and perform cryptographic
    21  computations. For test environments, SoftHSM can be used to satisfy this
    22  requirement.
    23  
    24  SoftHSM can be installed with the following commands:
    25  
    26  ::
    27  
    28      sudo apt install libsofthsm2 # Ubuntu
    29      sudo yum install softhsm     # CentOS
    30      brew install softhsm         # macOS
    31  
    32  Once SoftHSM is installed, additional configuration may be required. For
    33  example, the default configuration file stores token data in a system directory
    34  that unprivileged users are unable to write to.
    35  
    36  Configuration typically involves copying ``/etc/softhsm2.conf`` to
    37  ``$HOME/.config/softhsm2/softhsm2.conf`` and changing ``directories.tokendir``
    38  to an appropriate location. Please see the man page for ``softhsm2.conf`` for
    39  details.
    40  
    41  After SoftHSM has been configured, the following command can be used to
    42  initialize the required token:
    43  
    44  ::
    45  
    46      softhsm2-util --init-token --slot 0 --label "ForFabric" --so-pin 1234 --pin 98765432
    47  
    48  If the test cannot find libsofthsm2.so in your environment, specify its path,
    49  the PIN and the label of the token through environment variables. For example,
    50  on macOS:
    51  
    52  ::
    53  
    54      export PKCS11_LIB="/usr/local/Cellar/softhsm/2.5.0/lib/softhsm/libsofthsm2.so"
    55      export PKCS11_PIN=98765432
    56      export PKCS11_LABEL="ForFabric"
    57  
    58  Use the following sequence to run all unit tests:
    59  
    60  ::
    61  
    62      cd $GOPATH/src/github.com/hyperledger/fabric
    63      make unit-test
    64  
    65  To run a subset of tests, set the TEST_PKGS environment variable.
    66  Specify a list of packages (separated by space), for example:
    67  
    68  ::
    69  
    70      export TEST_PKGS="github.com/hyperledger/fabric/core/ledger/..."
    71      make unit-test
    72  
    73  To run a specific test use the ``-run RE`` flag where RE is a regular
    74  expression that matches the test case name. To run tests with verbose
    75  output use the ``-v`` flag. For example, to run the ``TestGetFoo`` test
    76  case, change to the directory containing the ``foo_test.go`` and
    77  call/execute
    78  
    79  ::
    80  
    81      go test -v -run=TestGetFoo
    82  
    83  
    84  Running Node.js Client SDK Unit Tests
    85  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    86  
    87  You must also run the Node.js unit tests to ensure that the Node.js
    88  client SDK is not broken by your changes. To run the Node.js unit tests,
    89  follow the instructions
    90  `here <https://github.com/hyperledger/fabric-sdk-node/blob/master/README.md>`__.
    91  
    92  Configuration
    93  -------------
    94  
    95  Configuration utilizes the `viper <https://github.com/spf13/viper>`__
    96  and `cobra <https://github.com/spf13/cobra>`__ libraries.
    97  
    98  There is a **core.yaml** file that contains the configuration for the
    99  peer process. Many of the configuration settings can be overridden on
   100  the command line by setting ENV variables that match the configuration
   101  setting, but by prefixing with *'CORE\_'*. For example, setting
   102  `peer.networkId` can be accomplished with:
   103  
   104  ::
   105  
   106      CORE_PEER_NETWORKID=custom-network-id peer
   107  
   108  .. Licensed under Creative Commons Attribution 4.0 International License
   109     https://creativecommons.org/licenses/by/4.0/