Merge pull request #374 from nspcc-dev/makefile-and-gofmt

Makefile convenience targets and gofmt
This commit is contained in:
Roman Khimov 2019-09-09 15:05:12 +03:00 committed by GitHub
commit a039ae6cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 68 additions and 35 deletions

View file

@ -13,6 +13,11 @@ executors:
- image: circleci/golang:1.12
environment:
GO111MODULE: "on"
go1_13:
docker:
- image: circleci/golang:1.13
environment:
GO111MODULE: "on"
commands:
gomod:
@ -29,7 +34,7 @@ commands:
jobs:
lint:
working_directory: /go/src/github.com/CityOfZion/neo-go
executor: go1_12
executor: go1_13
steps:
- checkout
- gomod
@ -41,7 +46,7 @@ jobs:
vet:
working_directory: /go/src/github.com/CityOfZion/neo-go
executor: go1_12
executor: go1_13
steps:
- checkout
- gomod
@ -60,6 +65,14 @@ jobs:
test_1_12:
working_directory: /go/src/github.com/CityOfZion/neo-go
executor: go1_12
steps:
- checkout
- gomod
- run: go test -v -race ./...
test_1_13:
working_directory: /go/src/github.com/CityOfZion/neo-go
executor: go1_13
steps:
- checkout
- gomod
@ -118,6 +131,10 @@ workflows:
filters:
tags:
only: v/[0-9]+\.[0-9]+\.[0-9]+/
- test_1_13:
filters:
tags:
only: v/[0-9]+\.[0-9]+\.[0-9]+/
- build_cli:
filters:
tags:

4
.gitignore vendored
View file

@ -40,3 +40,7 @@ blockchains/
# patch
*.orig
*.rej
# Coverage
coverage.txt
coverage.html

View file

@ -7,6 +7,11 @@ REPO ?= "$(shell go list -m)"
VERSION ?= "$(shell git describe --tags 2>/dev/null | sed 's/^v//')"
BUILD_FLAGS = "-X $(REPO)/config.Version=$(VERSION)"
# All of the targets are phony here because we don't really use make dependency
# tracking for files
.PHONY: build deps image check-version clean-cluster push-tag push-to-registry \
run run-cluster test vet lint fmt cover
build: deps
@echo "=> Building binary"
@set -x \
@ -60,3 +65,13 @@ test:
vet:
@go vet ./...
lint:
@go list ./... | xargs -L1 golint -set_exit_status
fmt:
@gofmt -l -w -s $$(find . -type f -name '*.go'| grep -v "/vendor/")
cover:
@go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
@go tool cover -html=coverage.txt -o coverage.html

View file

@ -176,7 +176,7 @@ func TestBinBlockDecodeEncode(t *testing.T) {
func TestBlockSizeCalculation(t *testing.T) {
// block taken from mainnet: 0006d3ff96e269f599eb1b5c5a527c218439e498dcc65b63794591bbcdc0516b
// The Size in golang is given by counting the number of bytes of an object. (len(Bytes))
// its implementation is different from the corresponding C# and python implentation. But the result should
// its implementation is different from the corresponding C# and python implementations. But the result should
// should be the same.In this test we provide more details then necessary because in case of failure we can easily debug the
// root cause of the size calculation missmatch.
@ -250,7 +250,6 @@ func TestBlockSizeCalculation(t *testing.T) {
assert.Equal(t, "552102486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a7021024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d2102aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e2103b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c2103b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a2102ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba5542102df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e89509357ae", hex.EncodeToString(b.Script.VerificationScript))
assert.Equal(t, "0006d3ff96e269f599eb1b5c5a527c218439e498dcc65b63794591bbcdc0516b", b.Hash().ReverseString())
buf := new(bytes.Buffer)
err = b.EncodeBinary(buf)

View file

@ -36,7 +36,7 @@ func NewInvocationTX(script []byte) *Transaction {
func (tx *InvocationTX) DecodeBinary(r io.Reader) error {
br := util.BinReader{R: r}
tx.Script = br.ReadBytes()
if (tx.Version >= 1) {
if tx.Version >= 1 {
br.ReadLE(&tx.Gas)
} else {
tx.Gas = util.Fixed8FromInt64(0)
@ -48,7 +48,7 @@ func (tx *InvocationTX) DecodeBinary(r io.Reader) error {
func (tx *InvocationTX) EncodeBinary(w io.Writer) error {
bw := util.BinWriter{W: w}
bw.WriteBytes(tx.Script)
if (tx.Version >= 1) {
if tx.Version >= 1 {
bw.WriteLE(tx.Gas)
}
return bw.Err
@ -57,7 +57,7 @@ func (tx *InvocationTX) EncodeBinary(w io.Writer) error {
// Size returns serialized binary size for this transaction.
func (tx *InvocationTX) Size() int {
sz := util.GetVarSize(tx.Script)
if (tx.Version >= 1) {
if tx.Version >= 1 {
sz += tx.Gas.Size()
}
return sz

View file

@ -40,7 +40,6 @@ func NEP2ScryptParams() ScryptParams {
}
}
// NEP2Encrypt encrypts a the PrivateKey using a given passphrase
// under the NEP-2 standard.
func NEP2Encrypt(priv *PrivateKey, passphrase string) (s string, err error) {

View file

@ -5,11 +5,10 @@ import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/CityOfZion/neo-go/pkg/internal/keytestcases"
"github.com/stretchr/testify/assert"
)
func TestPrivateKey(t *testing.T) {
for _, testCase := range keytestcases.Arr {
privKey, err := NewPrivateKeyFromHex(testCase.PrivateKey)

View file

@ -11,8 +11,8 @@ import (
"io"
"math/big"
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
"github.com/CityOfZion/neo-go/pkg/crypto"
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
"github.com/pkg/errors"
)

View file

@ -7,8 +7,8 @@ package rpc
import (
"github.com/CityOfZion/neo-go/pkg/core/transaction"
"github.com/CityOfZion/neo-go/pkg/util"
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
"github.com/CityOfZion/neo-go/pkg/util"
)
type (

View file

@ -170,7 +170,7 @@ func TestVarSize(t *testing.T) {
"test_string_3",
41,
},
{[]*smthSerializable{&smthSerializable{}, &smthSerializable{}},
{[]*smthSerializable{{}, {}},
"test_Serializable",
2*42 + 1,
},

View file

@ -7,8 +7,8 @@ import (
"log"
"math/big"
"os"
"text/tabwriter"
"reflect"
"text/tabwriter"
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
"github.com/CityOfZion/neo-go/pkg/util"

View file

@ -1,8 +1,8 @@
package wallet
import (
"github.com/CityOfZion/neo-go/pkg/util"
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
"github.com/CityOfZion/neo-go/pkg/util"
)
// Account represents a NEO account. It holds the private and public key