Skip to content

Commit

Permalink
Merge pull request #18 from libsv/update/tidy_code_new_make
Browse files Browse the repository at this point in the history
Tidy code, new makefile
  • Loading branch information
theflyingcodr authored Sep 30, 2021
2 parents 80f2df6 + 17667be commit 240be81
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 219 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
golangci:
strategy:
matrix:
go-version: [1.15.x,1.16.x]
go-version: [1.15.x,1.16.x,1.17.x]
os: [macos-latest, ubuntu-latest]
name: lint
runs-on: ${{ matrix.os }}
Expand All @@ -26,7 +26,7 @@ jobs:
build:
strategy:
matrix:
go-version: [ 1.13.x,1.14.x,1.15.x, 1.16.x ]
go-version: [ 1.15.x, 1.16.x, 1.17.x ]
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -38,7 +38,7 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: Tests
run: make test-unit
run: make run-unit-tests
- name: Update code coverage
run: bash <(curl -s https://codecov.io/bash)
- name: Build
Expand Down
72 changes: 0 additions & 72 deletions .make/common.mk

This file was deleted.

94 changes: 0 additions & 94 deletions .make/go.mk

This file was deleted.

53 changes: 32 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
# Common makefile commands & variables between projects
include .make/common.mk
SHELL=/bin/bash

# Common Golang makefile commands & variables between projects
include .make/go.mk
help:
@egrep -h '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'

## Not defined? Use default repo name which is the application
ifeq ($(REPO_NAME),)
REPO_NAME="go-bc"
endif
run-all-tests: run-linter run-unit-tests

## Not defined? Use default repo owner
ifeq ($(REPO_OWNER),)
REPO_OWNER="libsv"
endif
pre-commit: vendor-deps run-all-tests

.PHONY: clean
run-unit-tests:
@go clean -testcache && go test -v ./... -race

all: ## Runs multiple commands
@$(MAKE) test
run-unit-tests-cover:
@go test ./... -race -v -coverprofile cover.out && \
go tool cover -html=cover.out -o cover.html && \
open file:///$(shell pwd)/cover.html

clean: ## Remove previous builds and any test cache data
@go clean -cache -testcache -i -r
@test $(DISTRIBUTIONS_DIR)
@if [ -d $(DISTRIBUTIONS_DIR) ]; then rm -r $(DISTRIBUTIONS_DIR); fi
run-linter:
@golangci-lint run --deadline=480s --skip-dirs=vendor --tests

release:: ## Runs common.release then runs godocs
@$(MAKE) godocs
install-linter:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.2

go-doc-mac:
@open http://localhost:6060 && \
godoc -http=:6060

go-doc-linux:
@xdg-open http://localhost:6060 && \
godoc -http=:6060

vendor-deps:
@go mod tidy && go mod vendor

tag: ## Generate a new tag and push (tag version=0.0.0)
@run-all-tests
@git tag -a v$(version) -m "Pending full release..."
@git push origin v$(version)
@git fetch --tags -f
3 changes: 2 additions & 1 deletion block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"errors"
"testing"

"github.com/libsv/go-bc"
"github.com/libsv/go-bt/v2"
"github.com/stretchr/testify/assert"

"github.com/libsv/go-bc"
)

func TestNewBlock(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion blockheader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"errors"
"testing"

"github.com/libsv/go-bc"
"github.com/stretchr/testify/assert"

"github.com/libsv/go-bc"
)

func TestNewBlockHeader(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion bytemanipulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"encoding/hex"
"testing"

"github.com/libsv/go-bc"
"github.com/libsv/go-bk/crypto"
"github.com/libsv/go-bt/v2"

"github.com/libsv/go-bc"
)

func TestGenesisHash(t *testing.T) {
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/libsv/go-bk v0.0.0-20210430094342-ff08e691962b h1:NJkme7OR8Mz8emNPiG0Ix2gSBqZyQRasE1LVCp5SvhE=
github.com/libsv/go-bk v0.0.0-20210430094342-ff08e691962b/go.mod h1:xbDkeFFpP0uyFaPLnP6TwaLpAsHaslZ0LftTdWlB6HI=
github.com/libsv/go-bk v0.1.4 h1:bTxlerGeibh8RRmyhFK03wSAEp6EAJxGR4vXuRT0LCE=
github.com/libsv/go-bk v0.1.4/go.mod h1:xbDkeFFpP0uyFaPLnP6TwaLpAsHaslZ0LftTdWlB6HI=
github.com/libsv/go-bt/v2 v2.0.0-20210730150403-97fd3b293e05 h1:rRANK7Nc+bp0odO2zvDdHZBloGuwopGIx54yXypuR9k=
github.com/libsv/go-bt/v2 v2.0.0-20210730150403-97fd3b293e05/go.mod h1:62PATaSIMQ3omXVr9D4S7uMKaQByCJjNkrNzFpYThco=
github.com/libsv/go-bt/v2 v2.0.0-beta.7 h1:ccJXfmO2i+79oP/mDYYqvqa5DH1QV+2a1eh8+HUKhic=
github.com/libsv/go-bt/v2 v2.0.0-beta.7/go.mod h1:6Vk1qMlMoFJFNm7rR7NmFx4VwHNMCi4+V9WBqTd37rQ=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -25,7 +21,6 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand Down
2 changes: 1 addition & 1 deletion merklebranches.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func getHashes(txHashes []string) []string {
hashes := make([]string, 0, len(txHashes))

for i, tx := range txHashes {
hashes[i] = (ReverseHexString(tx))
hashes[i] = ReverseHexString(tx)
}

return hashes
Expand Down
6 changes: 3 additions & 3 deletions merkleproof.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ func (mp *MerkleProof) ToBytes() ([]byte, error) {
var txLength []byte
if len(mp.TxOrID) > 64 { // tx bytes instead of txid
// set bit at index 0
flags |= (1 << 0)
flags |= 1 << 0

txLength = bt.VarInt(uint64(len(txOrID)))
}

if mp.TargetType == "header" {
// set bit at index 1
flags |= (1 << 1)
flags |= 1 << 1
} else if mp.TargetType == "merkleRoot" {
// set bit at index 2
flags |= (1 << 2)
flags |= 1 << 2
}

// ignore proofType and compositeType for this version
Expand Down
3 changes: 2 additions & 1 deletion merkleproof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"encoding/hex"
"testing"

"github.com/libsv/go-bc"
"github.com/stretchr/testify/assert"

"github.com/libsv/go-bc"
)

func TestMerkleProofToBytes(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion merkleroot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package bc_test
import (
"testing"

"github.com/libsv/go-bc"
"github.com/stretchr/testify/assert"

"github.com/libsv/go-bc"
)

func TestBuildMerkleRoot(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion merkletreeparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"encoding/hex"
"testing"

"github.com/libsv/go-bc"
"github.com/stretchr/testify/assert"

"github.com/libsv/go-bc"
)

func TestGetMerkleTreeParentStr(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions spv/createenvelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"fmt"
"testing"

"github.com/libsv/go-bc"
"github.com/libsv/go-bc/spv"
"github.com/libsv/go-bt/v2"
"github.com/stretchr/testify/assert"

"github.com/libsv/go-bc"
"github.com/libsv/go-bc/spv"
)

type mockTxMerkleGetter struct {
Expand Down
Loading

0 comments on commit 240be81

Please sign in to comment.