Performance Tip: Use
Ctrl+Fto jump to sections using anchor links (e.g.,#building-and-running)
make unit-tests- Run unit testsmake unit-tests-race- Unit tests with race detectormake integration-tests-fabtoken-fabric-t1- Fabtoken integration testsmake integration-tests-dlog-fabric-t1 TEST_FILTER="T1"- ZK integration tests with T1 filter
make fmt- Format code using gofmtmake lint- Check code stylemake lint-auto-fix- Auto-fix linting issues (recommended pre-commit)make install-tools- Install development dependenciesmake checks- Run all pre-CI checks (license, fmt, vet, etc.)make download-fabric- Download Fabric binariesmake docker-images- Prepare Docker imagesmake testing-docker-images- Prepare test Docker images
make clean- Remove build artifactsmake clean-all-containers- Remove Docker containersmake tidy- Synchronize Go dependenciesgo generate ./...- Generate mocks
token/
├── core/ # Driver implementations (fabtoken, zkatdlog)
├── driver/ # Interface definitions (ports)
├── services/ # High-level services (identity, network, ttx, storage)
└── sdk/ # Public API entry points
integration/
├── nwo/ # Network Orchestrator for test networks
└── token/ # Actual test suites (fungible, nft, dvp, etc.)
make install-tools
make download-fabric
export FAB_BINS=$PWD/../fabric/bin
make docker-images
make testing-docker-images# Code quality
make lint-auto-fix
make checks
# Testing
make unit-tests # Standard
make unit-tests-race # With race detection
make integration-tests-fabtoken-fabric-t1 # Integration tests# Performance profiling
go test -cpuprofile=cpu.out ./...
go test -memprofile=mem.out ./...
# Focused testing
make integration-tests-dlog-fabric TEST_FILTER="T1"- Chaincode packaging failed: Verify
FAB_BINSis set correctly and points to valid Fabric binaries - Docker errors: Run
make testing-docker-images - Linting errors on commit: Run
make lint-auto-fix - Test timeouts: Increase Docker resource allocation
- Permission denied:
chmod +xon Fabric binaries in$FAB_BINS - Container conflicts:
make clean-all-containers - Go module issues:
make tidy - Mock generation failures:
make install-tools(ensures counterfeiter is installed)
To ensure your commits pass CI automatically, understand what runs:
All PRs and pushes to main trigger these workflows:
-
Checks Job (Prerequisite):
- License verification
- Code formatting (
gofmt,goimports) - Static analysis (
govet,staticcheck,ineffassign,misspell) - Run locally with:
make checks
-
Unit Testing:
- Race detector enabled tests
- Regression tests
- Coverage reporting to Coveralls
-
Integration Testing (Extensive Matrix):
- Fabtoken (cleartext tokens): t1-t5
- ZKATDLog (privacy tokens): t1-t13
- Fabric-X, Interop, NFT, DVP, Update tests
- Stress tests
- All with coverage reporting
-
Separate Workflows:
- golangci-lint: Comprehensive linting (30 min timeout)
- Markdown links: Validates all doc links
- CodeQL: Security analysis (weekly + on push/PR)
- Always run
make checksandmake lint-auto-fixbefore committing - Verify
FAB_BINSis set for integration test compatibility - Address all linting and static check warnings promptly
- Keep dependencies updated with
make tidy
- Driver Pattern: Swappable token technologies via interfaces in
token/driver - Service Pattern: Encapsulated high-level logic in
token/services - TTX Service: Orchestrates token transaction lifecycle (Request → Assemble → Sign → Commit)
- Go 1.24+
- Hyperledger Fabric
- Fabric Smart Client (FSC)
- Idemix/zkatdlog (privacy)
- Mathlib
- Ginkgo (testing framework)
- Cobra (CLI framework)
- Located alongside implementation code (
*_test.go) - Use testify for assertions (
assertfor values,requirefor error handling) - Prefer table-driven tests for service logic
- Use context struct pattern to minimize mock boilerplate
- Located in
integration/directory - Utilize Network Orchestrator (NWO) for ephemeral Fabric networks
- Use
TEST_FILTERenvironment variable with Ginkgo labels for focused testing - Example:
TEST_FILTER="T1"runs only tests with T1 label
- Generate mocks with
counterfeiter(go generate ./...) - Use
disabled.Providerfor metrics to avoid nil panics - Use
noop.NewTracerProvider()for tracing - Employ Context Struct + Setup Helper pattern (see
token/services/ttxfor example)
- Error Handling: Handle errors explicitly; avoid blank identifier for errors
- Interfaces: Define small, focused interfaces on consumer side; favor composition
- Concurrency: Use goroutines and channels; avoid shared state; validate with race detector
- Globals: Avoid global variables for testability
- Documentation: All exported functions MUST have Godoc comments
- DCO Sign-off: All commits MUST be signed off (
git commit -s) - Linear History: Use rebase workflow; avoid merge commits
- License: Apache License, Version 2.0
Before implementing any task:
- Create
plan.mdin project root with:- Clear goal description
- Numbered implementation steps
- "Implementation Progress" section with
[ ] Pendingcheckboxes
- Update immediately when completing steps:
[x] Done+ brief change notes - Log blockers/decisions under
## Notes & Decisions - Mark plan as
✅ COMPLETEwhen finished
- Integration Tests: System temp directory (
/tmp/fsc-integration-<random>/...) - Containers:
docker logs <container_name> - Persisted Logs: Temporarily modify test to use
NewLocalTestSuite(outputs to./testdata)
- Manual Inspection: Use
time.Sleep()or pause loops in tests to inspect Docker state - Network Preservation: Check for
no-cleanupoption or manually comment test suite cleanup - Focused Tests: Modify
It(...)toFIt(...)to focus, orXIt(...)to skip (never commit these changes)
Makefile: Central control hub - read to discover targetsgo.mod: Project dependenciestools/tools.go: Tool dependencies source of truth (install withmake install-tools)token/: Core SDK logicintegration/: Integration tests and Network Orchestrator
To ensure your commits pass CI automatically, understand what runs:
All PRs and pushes to main trigger these workflows:
-
Checks Job (Prerequisite):
- License verification
- Code formatting (
gofmt,goimports) - Static analysis (
govet,staticcheck,ineffassign,misspell) - Run locally with:
make checks
-
Unit Testing:
- Race detector enabled tests
- Regression tests
- Coverage reporting to Coveralls
-
Integration Testing (Extensive Matrix):
- Fabtoken (cleartext tokens): t1-t5
- ZKATDLog (privacy tokens): t1-t13
- Fabric-X, Interop, NFT, DVP, Update tests
- Stress tests
- All with coverage reporting
-
Separate Workflows:
- golangci-lint: Comprehensive linting (30 min timeout)
- Markdown links: Validates all doc links
- CodeQL: Security analysis (weekly + on push/PR)
- Always run
make checksandmake lint-auto-fixbefore committing - Verify
FAB_BINSis set for integration test compatibility - Address all linting and static check warnings promptly
- Keep dependencies updated with
make tidy