mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-13 11:35:52 +01:00
Merge 52363a8d05
into cba88226f4
This commit is contained in:
commit
28210e062f
4 changed files with 29 additions and 39 deletions
60
Makefile
60
Makefile
|
@ -1,37 +1,29 @@
|
|||
PKG := github.com/btcsuite/btcd
|
||||
|
||||
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
GOACC_PKG := github.com/ory/go-acc
|
||||
GOIMPORTS_PKG := golang.org/x/tools/cmd/goimports
|
||||
|
||||
GO_BIN := ${GOPATH}/bin
|
||||
GO_BIN := ${shell go env GOPATH}/bin
|
||||
LINT_BIN := $(GO_BIN)/golangci-lint
|
||||
GOACC_BIN := $(GO_BIN)/go-acc
|
||||
GOIMPORTS_BIN := $(GO_BIN)/goimports
|
||||
|
||||
LINT_COMMIT := v1.18.0
|
||||
GOACC_COMMIT := 80342ae2e0fcf265e99e76bcc4efd022c7c3811b
|
||||
GOIMPORTS_COMMIT := a24facf9e5586c95743d2f4ad15d148c7a8cf00b
|
||||
|
||||
DEPGET := cd /tmp && go install -v
|
||||
GOBUILD := go build -v
|
||||
GOINSTALL := go install -v
|
||||
DEV_TAGS := rpctest
|
||||
GOTEST_DEV = go test -v -tags=$(DEV_TAGS)
|
||||
GOTEST := go test -v
|
||||
|
||||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
|
||||
RM := rm -f
|
||||
CP := cp
|
||||
MAKE := make
|
||||
XARGS := xargs -L 1
|
||||
|
||||
# Linting uses a lot of memory, so keep it under control by limiting the number
|
||||
# of workers if requested.
|
||||
ifneq ($(workers),)
|
||||
LINT_WORKERS = --concurrency=$(workers)
|
||||
endif
|
||||
LINT_TIMEOUT := 5m
|
||||
|
||||
LINT = $(LINT_BIN) run -v $(LINT_WORKERS)
|
||||
LINT = $(LINT_BIN) run -v $(LINT_WORKERS) --timeout=$(LINT_TIMEOUT)
|
||||
|
||||
GREEN := "\\033[0;32m"
|
||||
NC := "\\033[0m"
|
||||
|
@ -51,16 +43,12 @@ all: build check
|
|||
|
||||
$(LINT_BIN):
|
||||
@$(call print, "Fetching linter")
|
||||
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
|
||||
|
||||
$(GOACC_BIN):
|
||||
@$(call print, "Fetching go-acc")
|
||||
$(DEPGET) $(GOACC_PKG)@$(GOACC_COMMIT)
|
||||
$(GOINSTALL) $(LINT_PKG)@$(LINT_COMMIT)
|
||||
|
||||
#? goimports: Install goimports
|
||||
goimports:
|
||||
@$(call print, "Installing goimports.")
|
||||
$(DEPGET) $(GOIMPORTS_PKG)
|
||||
$(GOINSTALL) $(GOIMPORTS_PKG)@$(GOIMPORTS_COMMIT)
|
||||
|
||||
# ============
|
||||
# INSTALLATION
|
||||
|
@ -101,30 +89,29 @@ check: unit
|
|||
unit:
|
||||
@$(call print, "Running unit tests.")
|
||||
$(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcec; $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcutil; $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcutil/psbt; $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcec && $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcutil && $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcutil/psbt && $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
|
||||
#? unit-cover: Run unit coverage tests
|
||||
unit-cover: $(GOACC_BIN)
|
||||
@$(call print, "Running unit coverage tests.")
|
||||
$(GOACC_BIN) ./...
|
||||
|
||||
$(GOTEST) -coverprofile=coverage.txt ./...
|
||||
|
||||
# We need to remove the /v2 pathing from the module to have it work
|
||||
# nicely with the CI tool we use to render live code coverage.
|
||||
cd btcec; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt
|
||||
cd btcec && $(GOTEST) -coverprofile=coverage.txt ./... && sed -i.bak 's/v2\///g' coverage.txt
|
||||
cd btcutil && $(GOTEST) -coverprofile=coverage.txt ./...
|
||||
cd btcutil/psbt && $(GOTEST) -coverprofile=coverage.txt ./...
|
||||
|
||||
cd btcutil; $(GOACC_BIN) ./...
|
||||
|
||||
cd btcutil/psbt; $(GOACC_BIN) ./...
|
||||
|
||||
#? unit-race: Run unit race tests
|
||||
unit-race:
|
||||
@$(call print, "Running unit race tests.")
|
||||
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcec; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcutil; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcutil/psbt; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcec && env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcutil && env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcutil/psbt && env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
|
||||
# =========
|
||||
# UTILITIES
|
||||
|
@ -133,9 +120,9 @@ unit-race:
|
|||
#? fmt: Fix imports and formatting source
|
||||
fmt: goimports
|
||||
@$(call print, "Fixing imports.")
|
||||
goimports -w $(GOFILES_NOVENDOR)
|
||||
$(GOIMPORTS_BIN) -w .
|
||||
@$(call print, "Formatting source.")
|
||||
gofmt -l -w -s $(GOFILES_NOVENDOR)
|
||||
gofmt -l -w -s .
|
||||
|
||||
#? lint: Lint source
|
||||
lint: $(LINT_BIN)
|
||||
|
@ -145,7 +132,7 @@ lint: $(LINT_BIN)
|
|||
#? clean: Clean source
|
||||
clean:
|
||||
@$(call print, "Cleaning source.$(NC)")
|
||||
$(RM) coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt
|
||||
rm -f coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt
|
||||
|
||||
#? tidy-module: Run 'go mod tidy' for all modules
|
||||
tidy-module:
|
||||
|
@ -161,11 +148,12 @@ tidy-module:
|
|||
unit-race \
|
||||
fmt \
|
||||
lint \
|
||||
clean
|
||||
clean \
|
||||
tidy-module
|
||||
|
||||
#? help: Get more info on make commands
|
||||
help: Makefile
|
||||
@echo " Choose a command run in btcd:"
|
||||
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
|
||||
|
||||
.PHONY: help
|
||||
.PHONY: help
|
|
@ -2,6 +2,7 @@ package psbt
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
)
|
||||
|
|
|
@ -146,7 +146,7 @@ func TestClientConnectedToWSServerRunner(t *testing.T) {
|
|||
}
|
||||
|
||||
testTable := []TestTableItem{
|
||||
TestTableItem{
|
||||
{
|
||||
Name: "TestGetChainTxStatsAsyncSuccessTx",
|
||||
TestCase: func(t *testing.T) {
|
||||
client, serverReceivedChannel, cleanup := makeClient(t)
|
||||
|
@ -159,7 +159,7 @@ func TestClientConnectedToWSServerRunner(t *testing.T) {
|
|||
}
|
||||
},
|
||||
},
|
||||
TestTableItem{
|
||||
{
|
||||
Name: "TestGetChainTxStatsAsyncShutdownError",
|
||||
TestCase: func(t *testing.T) {
|
||||
client, _, cleanup := makeClient(t)
|
||||
|
@ -192,7 +192,7 @@ func TestClientConnectedToWSServerRunner(t *testing.T) {
|
|||
}
|
||||
},
|
||||
},
|
||||
TestTableItem{
|
||||
{
|
||||
Name: "TestGetBestBlockHashAsync",
|
||||
TestCase: func(t *testing.T) {
|
||||
client, serverReceivedChannel, cleanup := makeClient(t)
|
||||
|
|
|
@ -6,6 +6,7 @@ package rpcclient
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcjson"
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue