forked from tempoxyz/tempo-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (59 loc) · 2.17 KB
/
Makefile
File metadata and controls
71 lines (59 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.PHONY: build_examples clean test check fix help integration docs fuzz fuzz-all
# Default target
all: check
# Builds all examples
build_examples:
cd examples/feepayer && go build -o ../../bin/feepayer ./cmd
go build -o bin/simple-send ./examples/simple-send
# Cleans all targets
clean:
go clean
rm -rf bin/
rm -f cover.out cover.html coverage.out
# Run unit tests only (excludes integration tests)
test:
go test -race ./pkg/transaction ./pkg/signer ./pkg/client
# Run unit tests with coverage
test-coverage:
go test -race -coverprofile=coverage.out ./pkg/transaction ./pkg/signer ./pkg/client
go tool cover -html=coverage.out -o cover.html
# Run checks as well as unit tests
check:
test -z "$$(gofmt -l .)" || (echo "Code needs formatting. Run 'make fix'" && gofmt -l . && exit 1)
go vet ./...
go test -race ./pkg/transaction ./pkg/signer ./pkg/client
# Formats code and tidies dependencies
fix:
gofmt -s -w .
go mod tidy
cd examples/feepayer && go mod tidy
# Run integration tests only (uses docker-compose tempo node by default)
integration:
@TEMPO_RPC_URL=$${TEMPO_RPC_URL:-http://localhost:8545} go test -run TestIntegration -timeout=5m ./tests
# Start godoc server for viewing documentation
docs:
which godoc > /dev/null || (echo "Installing godoc..." && go install golang.org/x/tools/cmd/godoc@latest)
echo "Documentation available at http://localhost:6060/pkg/github.com/tempoxyz/tempo-go/"
echo "Press Ctrl+C to stop the server"
@godoc -http=:6060
# Fuzz test duration (default 10s, override with FUZZTIME=1m)
FUZZTIME ?= 10s
# Run a single fuzz test: make fuzz FUZZ=FuzzTestName PKG=./pkg/transaction/
fuzz:
ifndef FUZZ
$(error Usage: make fuzz FUZZ=FuzzTestName PKG=./pkg/package/)
endif
ifndef PKG
$(error Usage: make fuzz FUZZ=FuzzTestName PKG=./pkg/package/)
endif
go test -fuzz=$(FUZZ) -fuzztime=$(FUZZTIME) $(PKG)
# Run all fuzz tests sequentially
fuzz-all:
@for pkg in ./pkg/transaction ./pkg/signer; do \
echo "=== Fuzzing $$pkg ==="; \
for test in $$(go test -list 'Fuzz.*' $$pkg 2>/dev/null | grep '^Fuzz'); do \
echo "Running $$test..."; \
go test -fuzz=$$test -fuzztime=$(FUZZTIME) $$pkg || exit 1; \
done; \
done
@echo "=== All fuzz tests complete ==="