2019-04-15 06:00:28 -07:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
2018-07-25 13:47:00 -07:00
|
|
|
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
|
|
|
|
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
|
2019-01-29 21:00:06 -08:00
|
|
|
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
|
2019-01-22 12:16:29 -08:00
|
|
|
COMMIT := $(shell git log -1 --format='%H')
|
2018-07-13 19:17:53 -07:00
|
|
|
LEDGER_ENABLED ?= true
|
2019-05-13 15:33:34 -07:00
|
|
|
BINDIR ?= $(GOPATH)/bin
|
2019-07-25 11:21:42 -07:00
|
|
|
SIMAPP = ./simapp
|
2019-06-19 05:24:11 -07:00
|
|
|
MOCKS_DIR = $(CURDIR)/tests/mocks
|
2019-03-18 05:45:25 -07:00
|
|
|
|
|
|
|
export GO111MODULE = on
|
2019-01-24 02:18:45 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
all: tools build lint test
|
2019-03-04 12:31:55 -08:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
# The below include contains the tools and runsim targets.
|
2019-04-09 02:41:00 -07:00
|
|
|
include contrib/devtools/Makefile
|
2019-03-04 12:31:55 -08:00
|
|
|
|
|
|
|
########################################
|
2019-05-18 01:42:24 -07:00
|
|
|
### Build
|
2019-03-04 12:31:55 -08:00
|
|
|
|
2019-03-18 05:45:25 -07:00
|
|
|
build: go.sum
|
2019-05-18 01:42:24 -07:00
|
|
|
@go build -mod=readonly ./...
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: build
|
|
|
|
|
|
|
|
update-swagger-docs: statik
|
|
|
|
$(BINDIR)/statik -src=client/lcd/swagger-ui -dest=client/lcd -f -m
|
2019-08-02 08:52:55 -07:00
|
|
|
@if [ -n "$(git status --porcelain)" ]; then \
|
|
|
|
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
|
2019-07-25 11:21:42 -07:00
|
|
|
exit 1;\
|
|
|
|
else \
|
2019-08-02 08:52:55 -07:00
|
|
|
echo "\033[92mSwagger docs are in sync\033[0m";\
|
2019-07-25 11:21:42 -07:00
|
|
|
fi
|
|
|
|
.PHONY: update-swagger-docs
|
2017-01-28 09:29:32 -08:00
|
|
|
|
2019-06-19 05:24:11 -07:00
|
|
|
mocks: $(MOCKS_DIR)
|
|
|
|
mockgen -source=x/auth/types/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: mocks
|
2019-06-19 05:24:11 -07:00
|
|
|
|
|
|
|
$(MOCKS_DIR):
|
|
|
|
mkdir -p $(MOCKS_DIR)
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Tools & dependencies
|
2017-08-30 11:42:24 -07:00
|
|
|
|
2019-03-18 05:45:25 -07:00
|
|
|
go-mod-cache: go.sum
|
|
|
|
@echo "--> Download go modules to local cache"
|
|
|
|
@go mod download
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: go-mod-cache
|
2018-08-28 09:53:56 -07:00
|
|
|
|
2019-05-02 09:30:29 -07:00
|
|
|
go.sum: go.mod
|
2019-03-19 09:52:43 -07:00
|
|
|
@echo "--> Ensure dependencies have not been modified"
|
2019-03-18 05:45:25 -07:00
|
|
|
@go mod verify
|
2019-07-04 07:54:06 -07:00
|
|
|
@go mod tidy
|
2018-01-16 11:23:32 -08:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
distclean:
|
2019-05-13 15:33:34 -07:00
|
|
|
rm -rf \
|
|
|
|
gitian-build-darwin/ \
|
|
|
|
gitian-build-linux/ \
|
|
|
|
gitian-build-windows/ \
|
|
|
|
.gitian-builder-cache/
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: distclean
|
2019-01-29 14:25:43 -08:00
|
|
|
|
2018-01-20 15:03:35 -08:00
|
|
|
########################################
|
|
|
|
### Documentation
|
|
|
|
|
|
|
|
godocs:
|
|
|
|
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types"
|
|
|
|
godoc -http=:6060
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Testing
|
|
|
|
|
2018-05-07 15:44:03 -07:00
|
|
|
test: test_unit
|
2017-06-15 08:16:00 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_ledger_mock:
|
2019-07-25 11:21:42 -07:00
|
|
|
@go test -mod=readonly `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger test_ledger_mock'
|
2018-02-20 13:13:27 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_ledger: test_ledger_mock
|
2019-03-19 09:52:43 -07:00
|
|
|
@go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger'
|
2019-02-05 10:21:04 -08:00
|
|
|
|
2017-06-15 12:11:47 -07:00
|
|
|
test_unit:
|
2019-03-19 09:52:43 -07:00
|
|
|
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock'
|
2017-01-11 21:07:56 -08:00
|
|
|
|
2018-06-11 18:12:37 -07:00
|
|
|
test_race:
|
2019-03-19 09:52:43 -07:00
|
|
|
@VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION)
|
2018-06-11 18:12:37 -07:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_nondeterminism:
|
2018-08-17 07:19:33 -07:00
|
|
|
@echo "Running nondeterminism test..."
|
2019-07-19 09:59:04 -07:00
|
|
|
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true -v -timeout 10m
|
2018-08-17 07:19:33 -07:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_custom_genesis_fast:
|
2019-01-29 14:53:42 -08:00
|
|
|
@echo "Running custom genesis simulation..."
|
|
|
|
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
|
2019-07-19 09:59:04 -07:00
|
|
|
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.gaiad/config/genesis.json \
|
|
|
|
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h
|
2019-01-29 14:53:42 -08:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_import_export: runsim
|
2019-05-18 01:42:24 -07:00
|
|
|
@echo "Running application import/export simulation. This may take several minutes..."
|
2019-07-25 11:21:42 -07:00
|
|
|
$(BINDIR)/runsim -j 4 $(SIMAPP) 50 5 TestAppImportExport
|
2018-11-08 16:28:28 -08:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_after_import: runsim
|
2019-05-18 01:42:24 -07:00
|
|
|
@echo "Running application simulation-after-import. This may take several minutes..."
|
2019-07-25 11:21:42 -07:00
|
|
|
$(BINDIR)/runsim -j 4 $(SIMAPP) 50 5 TestAppSimulationAfterImport
|
2018-11-26 04:21:23 -08:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_custom_genesis_multi_seed: runsim
|
2019-01-29 14:53:42 -08:00
|
|
|
@echo "Running multi-seed custom genesis simulation..."
|
|
|
|
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
|
2019-05-18 01:42:24 -07:00
|
|
|
$(BINDIR)/runsim -g ${HOME}/.gaiad/config/genesis.json $(SIMAPP) 400 5 TestFullAppSimulation
|
2019-01-29 14:53:42 -08:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_multi_seed_long: runsim
|
|
|
|
@echo "Running multi-seed application simulation. This may take awhile!"
|
|
|
|
$(BINDIR)/runsim -j 4 $(SIMAPP) 500 50 TestFullAppSimulation
|
|
|
|
|
|
|
|
test_sim_multi_seed_short: runsim
|
2019-05-18 01:42:24 -07:00
|
|
|
@echo "Running multi-seed application simulation. This may take awhile!"
|
2019-07-25 11:21:42 -07:00
|
|
|
$(BINDIR)/runsim -j 4 $(SIMAPP) 50 10 TestFullAppSimulation
|
2018-07-11 10:43:25 -07:00
|
|
|
|
2019-04-12 15:52:16 -07:00
|
|
|
test_sim_benchmark_invariants:
|
|
|
|
@echo "Running simulation invariant benchmarks..."
|
2019-05-18 01:42:24 -07:00
|
|
|
@go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \
|
2019-07-19 09:59:04 -07:00
|
|
|
-Enabled=true -NumBlocks=1000 -BlockSize=200 \
|
|
|
|
-Commit=true -Seed=57 -v -timeout 24h
|
2019-04-12 15:52:16 -07:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: test \
|
|
|
|
test_sim_nondeterminism \
|
|
|
|
test_sim_custom_genesis_fast \
|
|
|
|
test_sim_fast \
|
|
|
|
test_sim_import_export \
|
|
|
|
test_sim_after_import \
|
|
|
|
test_sim_custom_genesis_multi_seed \
|
|
|
|
test_sim_multi_seed \
|
|
|
|
test_sim_multi_seed_short \
|
|
|
|
test_sim_benchmark_invariants
|
2019-04-23 06:01:59 -07:00
|
|
|
|
2018-10-29 16:10:39 -07:00
|
|
|
SIM_NUM_BLOCKS ?= 500
|
2018-09-01 19:04:44 -07:00
|
|
|
SIM_BLOCK_SIZE ?= 200
|
|
|
|
SIM_COMMIT ?= true
|
2019-05-18 01:42:24 -07:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_benchmark:
|
2019-05-18 01:42:24 -07:00
|
|
|
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
|
|
|
|
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
|
2019-07-19 09:59:04 -07:00
|
|
|
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h
|
2018-09-01 19:04:44 -07:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
test_sim_profile:
|
2019-05-18 01:42:24 -07:00
|
|
|
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
|
|
|
|
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
|
2019-07-19 09:59:04 -07:00
|
|
|
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out
|
2018-09-01 19:04:44 -07:00
|
|
|
|
2018-01-17 17:00:48 -08:00
|
|
|
test_cover:
|
2019-02-06 14:45:15 -08:00
|
|
|
@export VERSION=$(VERSION); bash -x tests/test_cover.sh
|
2018-01-17 17:00:48 -08:00
|
|
|
|
2019-06-28 07:11:26 -07:00
|
|
|
lint: golangci-lint
|
2019-07-25 11:21:42 -07:00
|
|
|
$(BINDIR)/golangci-lint run
|
2018-06-27 17:32:06 -07:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
|
2019-03-18 05:45:25 -07:00
|
|
|
go mod verify
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: lint
|
2018-04-27 12:20:12 -07:00
|
|
|
|
2019-03-19 09:52:43 -07:00
|
|
|
format: tools
|
2018-10-04 04:00:24 -07:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
|
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
|
2018-11-26 11:20:43 -08:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: format
|
2018-06-29 00:37:16 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
benchmark:
|
2019-03-19 09:52:43 -07:00
|
|
|
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: benchmark
|
2017-03-14 00:25:42 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Devdoc
|
|
|
|
|
|
|
|
DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
|
|
|
|
|
|
|
|
devdoc_init:
|
|
|
|
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" tendermint/devdoc echo
|
|
|
|
# TODO make this safer
|
|
|
|
$(call DEVDOC_SAVE)
|
|
|
|
|
|
|
|
devdoc:
|
|
|
|
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" devdoc:local bash
|
|
|
|
|
|
|
|
devdoc_save:
|
|
|
|
# TODO make this safer
|
|
|
|
$(call DEVDOC_SAVE)
|
|
|
|
|
|
|
|
devdoc_clean:
|
|
|
|
docker rmi -f $$(docker images -f "dangling=true" -q)
|
2017-06-02 09:06:48 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
devdoc_update:
|
|
|
|
docker pull tendermint/devdoc
|
2017-03-14 00:25:42 -07:00
|
|
|
|
2019-07-25 11:21:42 -07:00
|
|
|
.PHONY: devdoc devdoc_clean devdoc_init devdoc_save devdoc_update
|