Commit 80c490e4 authored by harrylee's avatar harrylee Committed by vipwzw

ajust code for go mod

parent d22fdc82
......@@ -9,11 +9,12 @@ matrix:
include:
- name: check_fmt
sudo: require
go: "1.11.x"
go: "1.12.x"
env:
- GO111MODULE=on
install:
- go get -u golang.org/x/tools/cmd/goimports
- go get -u gopkg.in/alecthomas/gometalinter.v2
- gometalinter.v2 -i
- go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1
- go get -u mvdan.cc/sh/cmd/shfmt
- go get -u mvdan.cc/sh/cmd/gosh
script:
......@@ -21,14 +22,18 @@ matrix:
- make linter
- name: unit-test
go: "1.9.x"
go: "1.12.x"
env:
- GO111MODULE=on
install: skip
script:
- make test
- name: coverage
if: branch = master
go: "1.9.x"
go: "1.12.x"
env:
- GO111MODULE=on
before_install:
- go get -t -v ./...
install: skip
......@@ -38,7 +43,9 @@ matrix:
- bash <(curl -s https://codecov.io/bash)
- name: auto-test
go: "1.9.x"
go: "1.12.x"
env:
- GO111MODULE=on
install: skip
before_script: make build_ci
script:
......@@ -49,8 +56,10 @@ matrix:
sudo: required
services:
- docker
go: "1.12.x"
env:
- DOCKER_COMPOSE_VERSION=1.21.2
- GO111MODULE=on
install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
......
# golang1.9 or latest
# golang1.12 or latest
# 1. make help
# 2. make dep
# 3. make build
......@@ -9,12 +9,12 @@ CLI := build/chain33-cli
SRC_CLI := github.com/33cn/plugin/cli
APP := build/chain33
CHAIN33=github.com/33cn/chain33
CHAIN33_PATH=vendor/${CHAIN33}
CHAIN33_VERSION=$(shell nl go.mod |grep "github.com/33cn/chain33" |awk '{print $$3}')
CHAIN33_PATH=${GOPATH}/pkg/mod/github.com/33cn/chain33@${CHAIN33_VERSION}
LDFLAGS := -ldflags "-w -s"
PKG_LIST_VET := `go list ./... | grep -v "vendor" | grep -v plugin/dapp/evm/executor/vm/common/crypto/bn256`
PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"`
PKG_LIST_INEFFASSIGN= `go list -f {{.Dir}} ./... | grep -v "vendor"`
BUILD_FLAGS = -ldflags "-X github.com/33cn/plugin/vendor/github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`"
MKPATH=$(abspath $(lastword $(MAKEFILE_LIST)))
MKDIR=$(dir $(MKPATH))
proj := "build"
......@@ -23,15 +23,15 @@ proj := "build"
default: depends build
build: depends
go build $(BUILD_FLAGS) -v -i -o $(APP)
go build $(BUILD_FLAGS) -v -i -o $(CLI) $(SRC_CLI)
go build -v -i -o $(APP)
go build -v -i -o $(CLI) $(SRC_CLI)
@cp chain33.toml $(CHAIN33_PATH)/build/system-test-rpc.sh build/
@cp chain33.para.toml build/ci/paracross/
build_ci: depends ## Build the binary file for CI
@go build -v -i -o $(CLI) $(SRC_CLI)
@go build $(BUILD_FLAGS) -v -o $(APP)
@go build -v -o $(APP)
@cp chain33.toml $(CHAIN33_PATH)/build/system-test-rpc.sh build/
@cp chain33.para.toml build/ci/paracross/
......@@ -59,23 +59,18 @@ autotest_tick: autotest ## run with ticket mining
&& cd build/autotest && bash ./copy-autotest.sh gitlabci \
&& cd gitlabci && bash ./gitlab-ci-autotest.sh build && cd ../../../
update:
rm -rf ${CHAIN33_PATH}
git clone --depth 1 -b ${b} https://${CHAIN33}.git ${CHAIN33_PATH}
rm -rf vendor/${CHAIN33}/.git
rm -rf vendor/${CHAIN33}/vendor/github.com/apache/thrift/tutorial/erl/
cp -Rf vendor/${CHAIN33}/vendor/* vendor/
rm -rf vendor/${CHAIN33}/vendor
govendor init
go build -i -o tool github.com/33cn/plugin/vendor/github.com/33cn/chain33/cmd/tools
./tool import --path "plugin" --packname "github.com/33cn/plugin/plugin" --conf ""
updatevendor:
govendor add +e
govendor fetch -v +m
updatemod:
go mod tidy
dep:
dep init -v
@go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1
@go get -u golang.org/x/tools/cmd/goimports
@go get -u github.com/mitchellh/gox
@go get -u github.com/vektra/mockery/.../
@go get -u mvdan.cc/sh/cmd/shfmt
@go get -u mvdan.cc/sh/cmd/gosh
@git checkout go.mod go.sum
@apt install clang-format
@apt install shellcheck
linter: vet ineffassign ## Use gometalinter check code, ignore some unserious warning
@./golinter.sh "filter"
......@@ -86,7 +81,7 @@ linter_test: ## Use gometalinter check code, for local test
@find . -name '*.sh' -not -path "./vendor/*" | xargs shellcheck
ineffassign:
@ineffassign -n ${PKG_LIST_INEFFASSIGN}
@golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all --enable=ineffassign -n ${PKG_LIST_INEFFASSIGN}
race: ## Run data race detector
@go test -race -short $(PKG_LIST)
......@@ -158,7 +153,6 @@ protobuf: ## Generate protbuf file of types package
depends: ## Generate depends file of types package
@find ./plugin/dapp -maxdepth 2 -type d -name cmd -exec make -C {} OUT="$(MKDIR)build/ci" FLAG= \;
@find ./vendor/github.com/33cn/chain33/system/dapp -maxdepth 2 -type d -name cmd -exec make -C {} OUT="$(MKDIR)build/ci" FLAG= \;
help: ## Display this help screen
......
......@@ -11,17 +11,18 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874
* chain33地址: https://github.com/33cn/chain33
* chain33官网: https://chain.33.cn
## 安装
## 环境
##### 1. 安装govendor 工具
** 需要 安装golang1.12 or latest **
```
go get -u -v github.com/kardianos/govendor
```
#### 支持make file的平台
```
export GO111MODULE=on
export GOPROXY=https://mirrors.aliyun.com/goproxy
make
```
就可以完成编译安装
......@@ -35,8 +36,8 @@ make
## 注意:
从头开始安装vendor 有非常大的难度,主要问题是带宽 和 翻墙问题
为了解决包依赖等问题,我们直接提供了vendor目录
使用mod管理依赖包,主要就是翻墙问题
为了解决包依赖翻墙下载问题,我们提供了阿里云代理
## 贡献代码:
......@@ -47,10 +48,10 @@ make
#### 准备阶段:
* 首先点击 右上角的 fork 图标, 把chain33 fork 到自己的分支 比如我的是 vipwzw/plugin
* `git clone https://github.com/vipwzw/chain33.git $GOPATH/src/github.com/33cn/plugin`
* `git clone https://github.com/vipwzw/plugin.git $GOPATH/src/github.com/33cn/plugin`
```
注意:这里要 clone 到 $GOPATH/src/github.com/33cn/chain33, 否则go 包路径会找不到
注意:这里要 clone 到 $GOPATH/src/github.com/33cn/plugin, 否则go 包路径会找不到
```
clone 完成后,执行
......
......@@ -2,77 +2,38 @@ module github.com/33cn/plugin
go 1.12
replace (
github.com/coreos/etcd => github.com/etcd-io/etcd v3.3.13+incompatible
go.etcd.io/bbolt => github.com/etcd-io/bbolt v1.3.1-etcd.8
go.etcd.io/etcd => github.com/etcd-io/etcd v3.3.13+incompatible
)
require (
github.com/33cn/chain33 v6.1.1-0.20190812064448-5dd036921d46+incompatible
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7 // indirect
github.com/33cn/chain33 v0.0.0-20190818024326-42774b0804be
github.com/BurntSushi/toml v0.3.1
github.com/NebulousLabs/Sia v1.3.7
github.com/NebulousLabs/entropy-mnemonics v0.0.0-20170316012907-7b01a644a636 // indirect
github.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8 // indirect
github.com/NebulousLabs/fastrand v0.0.0-20180208210444-3cf7173006a0 // indirect
github.com/NebulousLabs/merkletree v0.0.0-20181025040823-2a1d1d1dc33c // indirect
github.com/XiaoMi/pegasus-go-client v0.0.0-20181029071519-9400942c5d1c // indirect
github.com/apache/thrift v0.0.0-20171203172758-327ebb6c2b6d // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/coreos/bbolt v1.3.0 // indirect
github.com/coreos/etcd v0.0.0-00010101000000-000000000000
github.com/coreos/etcd v3.3.13+incompatible
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/davecgh/go-spew v1.1.1
github.com/dchest/blake256 v1.0.0 // indirect
github.com/decred/base58 v1.0.0 // indirect
github.com/dgraph-io/badger v1.5.4 // indirect
github.com/dgryski/go-farm v0.0.0-20180109070241-2de33835d102 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.2.1
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.3.2
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/haltingstate/secp256k1-go v0.0.0-20151224084235-572209b26df6 // indirect
github.com/hashicorp/golang-lru v0.5.0
github.com/huin/goupnp v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.1 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/mr-tron/base58 v1.1.0 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
github.com/rs/cors v1.6.0
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.3.0
github.com/syndtr/goleveldb v0.0.0-20181105012736-f9080354173f // indirect
github.com/tjfoc/gmsm v0.0.0-20171124023159-98aa888b79d8
github.com/valyala/fasthttp v1.4.0
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/grpc v1.22.1
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/33cn/chain33 v6.1.1-0.20190812064448-5dd036921d46+incompatible h1:uICiSz9bDwQ4Ky+Bh3TPsagJRiG93DGDZURArOsDyX0=
github.com/33cn/chain33 v6.1.1-0.20190812064448-5dd036921d46+incompatible/go.mod h1:khADGunPneuDRjGaLqtVPhdf3og3ci+f7f8s/FLVcS0=
github.com/33cn/chain33 v0.0.0-20190818024326-42774b0804be h1:CAwVuwS6AuKpws0EcughQYmwiplFcSF4WvAGSwtijQI=
github.com/33cn/chain33 v0.0.0-20190818024326-42774b0804be/go.mod h1:4I8n+Zyf3t0UKM5jjpqJY627Tub62oXkLsdzIv4r6rQ=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7 h1:PqzgE6kAMi81xWQA2QIVxjWkFHptGgC547vchpUbtFo=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
......@@ -41,6 +41,8 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.0 h1:HIgH5xUWXT914HCI671AxuTTqjj64UOFr7pHn48LUTI=
github.com/coreos/bbolt v1.3.0/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c=
......@@ -58,8 +60,6 @@ github.com/dgraph-io/badger v1.5.4 h1:gVTrpUTbbr/T24uvoCaqY2KSHfNLVGm0w+hbee2HMe
github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ=
github.com/dgryski/go-farm v0.0.0-20180109070241-2de33835d102 h1:afESQBXJEnj3fu+34X//E8Wg3nEbMJxJkwSc0tPePK0=
github.com/dgryski/go-farm v0.0.0-20180109070241-2de33835d102/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/etcd-io/etcd v3.3.13+incompatible h1:8jKfRV6dDsGpYdyOqvx+rmjjbX/NQrMDG+6g0wa6F1M=
github.com/etcd-io/etcd v3.3.13+incompatible/go.mod h1:cdZ77EstHBwVtD6iTgzgvogwcjo9m4iOqoijouPJ4bs=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
......@@ -181,6 +181,7 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fasthttp v1.4.0 h1:PuaTGZIw3mjYhhhbVbCQp8aciRZN9YdoB7MGX9Ko76A=
github.com/valyala/fasthttp v1.4.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5/go.mod h1:ppEjwdhyy7Y31EnHRDm1JkChoC7LXIJ7Ex0VYLWtZtQ=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
......@@ -198,6 +199,9 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2eP
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
......@@ -214,11 +218,17 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181112210238-4b1f3b6b1646/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
......@@ -230,6 +240,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-playground/webhooks.v5 v5.2.0/go.mod h1:LZbya/qLVdbqDR1aKrGuWV6qbia2zCYSR5dpom2SInQ=
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 h1:AFxeG48hTWHhDTQDk/m2gorfVHUEa9vo3tp3D7TzwjI=
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
......
......@@ -6,7 +6,8 @@ OP="${1}"
path="${2}"
function filterLinter() {
res=$(gometalinter.v2 -t --sort=linter --enable-gc --deadline=2m --disable-all \
res=$(
golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all \
--enable=gofmt \
--enable=gosimple \
--enable=deadcode \
......@@ -17,27 +18,8 @@ function filterLinter() {
--enable=goimports \
--enable=misspell \
--enable=golint \
--vendor ./...)
# --enable=staticcheck \
# --enable=gocyclo \
# --enable=staticcheck \
# --enable=golint \
# --enable=unused \
# --enable=gotype \
# --enable=gotypex \
if [[ ${#res} -gt "0" ]]; then
resNoSpace=$(echo "${res}" | tr ' ' '@')
array=($(echo "${resNoSpace}" | tr '\n' '\n'))
str=""
for var in ${array[*]}; do
if ! [[ $var =~ "underscores" ]]; then
str="${str}""${var}""\\n"
fi
done
res=""
res=$(echo "${str}" | tr '@' ' ')
fi
--exclude=underscores
)
if [[ ${#res} -gt "0" ]]; then
echo -e "${res}"
exit 1
......@@ -46,7 +28,7 @@ function filterLinter() {
function testLinter() {
cd "${path}" >/dev/null || exit
gometalinter.v2 -t --sort=linter --enable-gc --deadline=2m --disable-all \
golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all \
--enable=gofmt \
--enable=gosimple \
--enable=deadcode \
......@@ -55,10 +37,10 @@ function testLinter() {
--enable=varcheck \
--enable=structcheck \
--enable=goimports \
--enable=vet \
--enable=misspell \
--enable=golint \
--enable=ineffassign \
--vendor ./...
--exclude=underscores
cd - >/dev/null || exit
}
......
......@@ -18,9 +18,13 @@ It has these top-level messages:
*/
package echo
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
......
......@@ -8,6 +8,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
"github.com/stretchr/testify/assert"
// 因为测试程序在外层,而合约类型的初始化在里面,所以需要显示引用,否则不会加载合约插件
_ "github.com/33cn/plugin/plugin/dapp/evm/executor"
evmtypes "github.com/33cn/plugin/plugin/dapp/evm/types"
......
......@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/util/testnode"
mty "github.com/33cn/plugin/plugin/dapp/multisig/types"
"github.com/stretchr/testify/assert"
// 注册system和plugin 包
rpctypes "github.com/33cn/chain33/rpc/types"
_ "github.com/33cn/chain33/system"
......
......@@ -10,6 +10,7 @@ package rpc
import (
"testing"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/client/mocks"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
......@@ -19,13 +20,13 @@ import (
"golang.org/x/net/context"
)
func newGrpc(api *mocks.QueueProtocolAPI) *channelClient {
func newGrpc(api client.QueueProtocolAPI) *channelClient {
return &channelClient{
ChannelClient: rpctypes.ChannelClient{QueueProtocolAPI: api},
}
}
func newJrpc(api *mocks.QueueProtocolAPI) *Jrpc {
func newJrpc(api client.QueueProtocolAPI) *Jrpc {
return &Jrpc{cli: newGrpc(api)}
}
......
......@@ -164,8 +164,6 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
if Account != nil || err != nil {
if Account.Privkey == Encrypteredstr {
return
} else {
return
}
}
......
......@@ -13,6 +13,7 @@ import (
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/plugin/plugin/dapp/ticket/executor"
ty "github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
_ "github.com/33cn/chain33/system"
......@@ -131,7 +132,7 @@ func createBindMiner(t *testing.T, m, r string, priv crypto.PrivKey) *types.Tran
return tx
}
func ticketList(t *testing.T, mock33 *testnode.Chain33Mock, req *ty.TicketList) *ty.ReplyTicketList {
func ticketList(t *testing.T, mock33 *testnode.Chain33Mock, req proto.Message) *ty.ReplyTicketList {
data, err := mock33.GetAPI().Query("ticket", "TicketList", req)
assert.Nil(t, err)
return data.(*ty.ReplyTicketList)
......
......@@ -10,6 +10,7 @@ import (
"github.com/33cn/plugin/plugin/dapp/ticket/executor"
"github.com/33cn/plugin/plugin/dapp/ticket/rpc"
"github.com/33cn/plugin/plugin/dapp/ticket/types"
// init wallet
_ "github.com/33cn/plugin/plugin/dapp/ticket/wallet"
)
......
......@@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/client/mocks"
"github.com/33cn/chain33/common/version"
"github.com/33cn/chain33/rpc/jsonclient"
......@@ -41,13 +42,13 @@ targetTimespan = 2304
targetTimePerBlock = 16
`
func newGrpc(api *mocks.QueueProtocolAPI) *channelClient {
func newGrpc(api client.QueueProtocolAPI) *channelClient {
return &channelClient{
ChannelClient: rpctypes.ChannelClient{QueueProtocolAPI: api},
}
}
func newJrpc(api *mocks.QueueProtocolAPI) *Jrpc {
func newJrpc(api client.QueueProtocolAPI) *Jrpc {
return &Jrpc{cli: newGrpc(api)}
}
......
......@@ -12,9 +12,13 @@ It has these top-level messages:
*/
package signatory
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
......
......@@ -5,6 +5,7 @@ import (
"github.com/33cn/chain33/system/dapp"
pty "github.com/33cn/plugin/plugin/dapp/trade/types"
//"github.com/33cn/chain33/common/db"
//"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/util"
......
......@@ -8,17 +8,16 @@ import (
"encoding/hex"
"testing"
"github.com/stretchr/testify/mock"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/client/mocks"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/trade/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
func newTestChain33(api *mocks.QueueProtocolAPI) *Jrpc {
func newTestChain33(api client.QueueProtocolAPI) *Jrpc {
cli := &channelClient{
ChannelClient: rpctypes.ChannelClient{
QueueProtocolAPI: api,
......
......@@ -11,6 +11,7 @@ import (
"encoding/hex"
"testing"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/client/mocks"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
......@@ -19,13 +20,13 @@ import (
"golang.org/x/net/context"
)
func newGrpc(api *mocks.QueueProtocolAPI) *channelClient {
func newGrpc(api client.QueueProtocolAPI) *channelClient {
return &channelClient{
ChannelClient: rpctypes.ChannelClient{QueueProtocolAPI: api},
}
}
func newJrpc(api *mocks.QueueProtocolAPI) *Jrpc {
func newJrpc(api client.QueueProtocolAPI) *Jrpc {
return &Jrpc{cli: newGrpc(api)}
}
......
......@@ -19,9 +19,9 @@ import (
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/queue"
drivers "github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/system/store/mavl/db"
mavl "github.com/33cn/chain33/system/store/mavl/db"
"github.com/33cn/chain33/types"
"github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru"
)
var (
......
......@@ -10,7 +10,7 @@ import (
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/system/store/mavl/db"
mavl "github.com/33cn/chain33/system/store/mavl/db"
"github.com/33cn/chain33/types"
)
......
......@@ -3,9 +3,13 @@
package mpt
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
......
......@@ -70,10 +70,10 @@ func TestProof(t *testing.T) {
}
val, _, err := VerifyProof(root, kv.k, proof)
if err != nil {
t.Fatalf("prover %d: failed to verify proof for key %x: %v\nraw proof: %x", i, kv.k, err, proof)
t.Fatalf("prover %d: failed to verify proof for key %x: %v\nraw proof: %v", i, kv.k, err, proof)
}
if !bytes.Equal(val, kv.v) {
t.Fatalf("prover %d: verified value mismatch for key %x: have %x, want %x", i, kv.k, val, kv.v)
t.Fatalf("prover %d: verified value mismatch for key %x: have %v, want %x", i, kv.k, val, kv.v)
}
}
}
......@@ -102,7 +102,7 @@ func TestOneElementProof(t *testing.T) {
val, _, err := VerifyProof(trie.Hash(), []byte("k"), proof)
if err != nil {
t.Fatalf("prover %d: failed to verify proof: %v\nraw proof: %x", i, err, proof)
t.Fatalf("prover %d: failed to verify proof: %v\nraw proof: %v", i, err, proof)
}
if !bytes.Equal(val, []byte("v")) {
t.Fatalf("prover %d: verified value mismatch: have %x, want 'k'", i, val)
......@@ -164,7 +164,7 @@ func TestMissingKeyProof(t *testing.T) {
val, _, err := VerifyProof(trie.Hash(), []byte(key), proof)
if err != nil {
t.Fatalf("test %d: failed to verify proof: %v\nraw proof: %x", i, err, proof)
t.Fatalf("test %d: failed to verify proof: %v\nraw proof: %v", i, err, proof)
}
if val != nil {
t.Fatalf("test %d: verified value mismatch: have %x, want nil", i, val)
......
......@@ -72,7 +72,7 @@ func TestProof(t *testing.T) {
}
val, _, err := VerifyProof(root, kv.k, proof)
if err != nil {
t.Fatalf("prover %d: failed to verify proof for key %x: %v\nraw proof: %x", i, kv.k, err, proof)
t.Fatalf("prover %d: failed to verify proof for key %x: %v\nraw proof: %v", i, kv.k, err, proof)
}
if !bytes.Equal(val, kv.v) {
t.Fatalf("prover %d: verified value mismatch for key %x: have %x, want %x", i, kv.k, val, kv.v)
......@@ -104,7 +104,7 @@ func TestOneElementProof(t *testing.T) {
val, _, err := VerifyProof(trie.Hash(), []byte("k"), proof)
if err != nil {
t.Fatalf("prover %d: failed to verify proof: %v\nraw proof: %x", i, err, proof)
t.Fatalf("prover %d: failed to verify proof: %v\nraw proof: %v", i, err, proof)
}
if !bytes.Equal(val, []byte("v")) {
t.Fatalf("prover %d: verified value mismatch: have %x, want 'k'", i, val)
......@@ -166,7 +166,7 @@ func TestMissingKeyProof(t *testing.T) {
val, _, err := VerifyProof(trie.Hash(), []byte(key), proof)
if err != nil {
t.Fatalf("test %d: failed to verify proof: %v\nraw proof: %x", i, err, proof)
t.Fatalf("test %d: failed to verify proof: %v\nraw proof: %v", i, err, proof)
}
if val != nil {
t.Fatalf("test %d: verified value mismatch: have %x, want nil", i, val)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment