Skip to content

Commit

Permalink
Merge pull request #1785 from Roasbeef/btcutil-move
Browse files Browse the repository at this point in the history
multi: move the btcutil repo into btcd as a sub-module
  • Loading branch information
Roasbeef committed Jan 11, 2022
2 parents a1f43e4 + 3cacbd4 commit 97732e5
Show file tree
Hide file tree
Showing 191 changed files with 18,538 additions and 150 deletions.
72 changes: 53 additions & 19 deletions .github/workflows/go.yml
@@ -1,35 +1,69 @@
name: Build and Test
on: [push, pull_request]

env:
# go needs absolute directories, using the $HOME variable doesn't work here.
GOCACHE: /home/runner/work/go/pkg/build
GOPATH: /home/runner/work/go
GO_VERSION: 1.17.5

jobs:
build:
# https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/
permissions:
contents: read
name: Go CI
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.16.8, 1.17.1]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
go-version: ${{ env.GO_VERSION }}

- name: Check out source
uses: actions/checkout@v2
- name: Install Linters
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0"

- name: Build
env:
GO111MODULE: "on"
run: go build ./...
run: make build

test-cover:
name: Unit coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out source
uses: actions/checkout@v2

- name: Test
env:
GO111MODULE: "on"
run: |
sh ./goclean.sh
run: make unit-cover

- name: Send coverage
- name: Send top-level coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
path-to-profile: coverage.txt

- name: Send btcutil coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: btcutil/coverage.txt

- name: Send btcutil coverage for psbt package
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: btcutil/psbt/coverage.txt

test-race:
name: Unit race
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out source
uses: actions/checkout@v2

- name: Test
run: make unit-race
124 changes: 124 additions & 0 deletions Makefile
@@ -0,0 +1,124 @@
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
LINT_BIN := $(GO_BIN)/golangci-lint
GOACC_BIN := $(GO_BIN)/go-acc

LINT_COMMIT := v1.18.0
GOACC_COMMIT := 80342ae2e0fcf265e99e76bcc4efd022c7c3811b

DEPGET := cd /tmp && GO111MODULE=on go get -v
GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
DEV_TAGS := rpctest
GOTEST := GO111MODULE=on go test -v -tags=$(DEV_TAGS)

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 = $(LINT_BIN) run -v $(LINT_WORKERS)

GREEN := "\\033[0;32m"
NC := "\\033[0m"
define print
echo $(GREEN)$1$(NC)
endef

default: build

all: build check

# ============
# DEPENDENCIES
# ============

$(LINT_BIN):
@$(call print, "Fetching linter")
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)

$(GOACC_BIN):
@$(call print, "Fetching go-acc")
$(DEPGET) $(GOACC_PKG)@$(GOACC_COMMIT)

goimports:
@$(call print, "Installing goimports.")
$(DEPGET) $(GOIMPORTS_PKG)

# ============
# INSTALLATION
# ============

build:
@$(call print, "Building all binaries")
$(GOBUILD) $(PKG)
$(GOBUILD) $(PKG)/cmd/btcctl
$(GOBUILD) $(PKG)/cmd/gencerts
$(GOBUILD) $(PKG)/cmd/findcheckpoint
$(GOBUILD) $(PKG)/cmd/addblock

# =======
# TESTING
# =======

check: unit

unit:
@$(call print, "Running unit tests.")
$(GOTEST) ./... -test.timeout=20m
cd btcutil; $(GOTEST) ./... -test.timeout=20m
cd btcutil/psbt; $(GOTEST) ./... -test.timeout=20m

unit-cover: $(GOACC_BIN)
@$(call print, "Running unit coverage tests.")
$(GOACC_BIN) ./...
cd btcutil; $(GOACC_BIN) ./...
cd btcutil/psbt; $(GOACC_BIN) ./...

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 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
# =========

fmt: goimports
@$(call print, "Fixing imports.")
goimports -w $(GOFILES_NOVENDOR)
@$(call print, "Formatting source.")
gofmt -l -w -s $(GOFILES_NOVENDOR)

lint: $(LINT_BIN)
@$(call print, "Linting source.")
$(LINT)

clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt

.PHONY: all \
default \
build \
check \
unit \
unit-cover \
unit-race \
fmt \
lint \
clean
2 changes: 1 addition & 1 deletion blockchain/accept.go
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"

"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// maybeAcceptBlock potentially accepts a block into the block chain and, if
Expand Down
2 changes: 1 addition & 1 deletion blockchain/bench_test.go
Expand Up @@ -7,7 +7,7 @@ package blockchain
import (
"testing"

"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase
Expand Down
2 changes: 1 addition & 1 deletion blockchain/chain.go
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/chain_test.go
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// TestHaveBlock tests the HaveBlock API to ensure proper functionality.
Expand Down
2 changes: 1 addition & 1 deletion blockchain/chainio.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/checkpoints.go
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// CheckpointConfirmations is the number of blocks before the end of the current
Expand Down
2 changes: 1 addition & 1 deletion blockchain/common_test.go
Expand Up @@ -20,7 +20,7 @@ import (
_ "github.com/btcsuite/btcd/database/ffldb"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/example_test.go
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ffldb"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// This example demonstrates how to create a new chain instance and use
Expand Down
2 changes: 1 addition & 1 deletion blockchain/fullblocks_test.go
Expand Up @@ -20,7 +20,7 @@ import (
_ "github.com/btcsuite/btcd/database/ffldb"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/fullblocktests/generate.go
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/indexers/addrindex.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/indexers/blocklogger.go
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/btcsuite/btclog"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// blockProgressLogger provides periodic logging for other services in order
Expand Down
6 changes: 3 additions & 3 deletions blockchain/indexers/cfindex.go
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/gcs"
"github.com/btcsuite/btcutil/gcs/builder"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/gcs"
"github.com/btcsuite/btcd/btcutil/gcs/builder"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/indexers/common.go
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/indexers/manager.go
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/indexers/txindex.go
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/merkle.go
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion blockchain/merkle_test.go
Expand Up @@ -7,7 +7,7 @@ package blockchain
import (
"testing"

"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// TestMerkle tests the BuildMerkleTreeStore API.
Expand Down
2 changes: 1 addition & 1 deletion blockchain/process.go
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// BehaviorFlags is a bitmask defining tweaks to the normal behavior when
Expand Down
2 changes: 1 addition & 1 deletion blockchain/scriptval.go
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)

// txValidateItem holds a transaction along with which input to validate.
Expand Down

0 comments on commit 97732e5

Please sign in to comment.