This document provides guidelines and steps for setting up your local development environment for the Fabric Smart Client (FSC).
For general development best practices, see the following guidelines:
Before you begin, ensure you have the following installed:
- Go — Install Go (see the required version in
go.mod) - Docker — Install Docker Engine (or a compatible container manager)
Clone the FSC repository to your local workspace.
Throughout this document, $FSC_PATH refers to the local path of your cloned repository.
export FSC_PATH=$HOME/myprojects/fabric-smart-client
git clone https://github.com/hyperledger-labs/fabric-smart-client.git $FSC_PATH
cd $FSC_PATHFSC provides several helper tools for building, testing, and monitoring. Install them using:
make install-tools install-linter-tool monitoring-docker-images testing-docker-imagesPlatform-specific tools are also required for Fabric and Fabric-x.
Install the Fabric binaries and Docker images:
make install-fabric-bins fabric-docker-images To install a specific Fabric version, set the FABRIC_VERSION variable:
FABRIC_VERSION=3.1.0 make install-fabric-binsThe default FABRIC_VERSION is defined in the project Makefile.
Install Fabric-x configuration tools and Docker images:
make install-fxconfig install-configtxgen fabricx-docker-images Most integration tests require Fabric(x) binaries to launch a local test network.
Set the FAB_BINS environment variable to point to the directory containing these binaries:
export FAB_BINS=/home/yourusername/fabric/binNOTE: Do not store the Fabric binaries inside your fabric-smart-client repository. Doing so may cause integration tests to fail when installing chaincode.
FSC includes both unit tests and integration tests. Integration tests are powered by the NWO (Network Orchestrator), which programmatically creates DLT networks and FSC application nodes.
Run static analysis and linting:
make checks
make lintRun all unit tests:
make unit-tests
make unit-tests-postgres
make unit-tests-sdkFor coverage analysis:
GO_TEST_PARAMS="-coverprofile=cov.out" make unit-tests
go tool cover -func=cov.out
go tool cover -html=cov.outList all available integration tests:
make list-integration-testsRun all integration tests:
make integration-testsRun a specific integration tests (e.g., Fabric IOU test):
make integration-tests-fabric-iouEnable profiling for deeper analysis:
export FSCNODE_PROFILER=true
make integration-tests-fabric-iouEnable coverage profiling:
mkdir -p covdata
GOCOVERDIR=covdata make integration-tests
go tool covdata textfmt -i=covdata -o profile.txtCreating a new integration test is straightforward. Each test includes a test harness and a network topology file.
Example:
mkdir integration/fabricx/helloworld
touch integration/fabricx/helloworld/topology.go
touch integration/fabricx/helloworld/helloworld_test.gotopology.go— defines the network topology (organizations, peers, orderers, etc.)helloworld_test.go— defines the test harness and scenarios
For reference, review existing tests in the integration/ directory.
Run your new integration test:
make integration-tests-fabricx-helloworld