Commit 7cbdc838 authored by jiangpeng's avatar jiangpeng Committed by vipwzw

make update

parent ca7b3885
...@@ -36,7 +36,7 @@ para: ...@@ -36,7 +36,7 @@ para:
@go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI) @go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI)
autotest:## build autotest binary autotest: ## build autotest binary
@cd build/autotest && bash ./build.sh && cd ../../ @cd build/autotest && bash ./build.sh && cd ../../
@if [ -n "$(dapp)" ]; then \ @if [ -n "$(dapp)" ]; then \
rm -rf build/autotest/local \ rm -rf build/autotest/local \
......
language: go language: go
go_import_path: github.com/33cn/chain33 go_import_path: github.com/33cn/chain33
sudo: false
os: linux
dist: xenial
notifications: notifications:
email: false email: false
jobs: jobs:
include: include:
- stage: test - stage: check_fmt
sudo: require sudo: require
go:
- "1.9"
- master
install: install:
- go get -u golang.org/x/tools/cmd/goimports - go get -u golang.org/x/tools/cmd/goimports
- go get -u gopkg.in/alecthomas/gometalinter.v2 - go get -u gopkg.in/alecthomas/gometalinter.v2
- gometalinter.v2 -i - gometalinter.v2 -i
- go get -u mvdan.cc/sh/cmd/shfmt - go get -u mvdan.cc/sh/cmd/shfmt
- go get -u mvdan.cc/sh/cmd/gosh - go get -u mvdan.cc/sh/cmd/gosh
os: linux
dist: xenial
go:
- "1.9"
- master
script: script:
- make checkgofmt - make checkgofmt && make fmt_go
- make fmt_go
- make linter - make linter
- stage: unit-test
go: "1.9.x"
install: skip
script:
- make test - make test
- stage: coverage
if: branch = master
go:
- "1.9.x"
before_install:
- go get -t -v ./...
install: skip
script:
- make coverage
after_success:
- bash <(curl -s https://codecov.io/bash)
- stage: deploy
sudo: required
services:
- docker
env:
- DOCKER_COMPOSE_VERSION=1.21.2
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"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
script:
- make build_ci
- make autotest_ci
- make docker-compose && make docker-compose-down
...@@ -16,7 +16,6 @@ SIGNATORY := build/signatory-server ...@@ -16,7 +16,6 @@ SIGNATORY := build/signatory-server
MINER := build/miner_accounts MINER := build/miner_accounts
AUTOTEST := build/autotest/autotest AUTOTEST := build/autotest/autotest
SRC_AUTOTEST := github.com/33cn/chain33/cmd/autotest SRC_AUTOTEST := github.com/33cn/chain33/cmd/autotest
SRC_AUTOTEST_PLUGIN := github.com/33cn/plugin/vendor/github.com/33cn/chain33/cmd/autotest/pluginversion
LDFLAGS := -ldflags "-w -s" LDFLAGS := -ldflags "-w -s"
PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"` PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"`
PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"` PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"`
...@@ -67,12 +66,8 @@ para: ...@@ -67,12 +66,8 @@ para:
@go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI) @go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI)
autotest:## build autotest binary, prior build plugin version autotest:## build autotest binary
@if [ -d $(GOPATH)/src/$(SRC_AUTOTEST_PLUGIN) ]; then \ @go build -v -i -o $(AUTOTEST) $(SRC_AUTOTEST)
go build -v -i -o $(AUTOTEST) $(SRC_AUTOTEST_PLUGIN);\
else \
go build -v -i -o $(AUTOTEST) $(SRC_AUTOTEST);\
fi;
@if [ -n "$(dapp)" ]; then \ @if [ -n "$(dapp)" ]; then \
cd build/autotest && bash ./copy-autotest.sh local && cd local && bash ./local-autotest.sh $(dapp) && cd ../../../; \ cd build/autotest && bash ./copy-autotest.sh local && cd local && bash ./local-autotest.sh $(dapp) && cd ../../../; \
fi fi
...@@ -150,10 +145,10 @@ msan: ## Run memory sanitizer ...@@ -150,10 +145,10 @@ msan: ## Run memory sanitizer
@go test -msan -short $(PKG_LIST) @go test -msan -short $(PKG_LIST)
coverage: ## Generate global code coverage report coverage: ## Generate global code coverage report
@./build/tools/coverage.sh; @./build/tools/coverage.sh
coverhtml: ## Generate global code coverage report in HTML coverhtml: ## Generate global code coverage report in HTML
@./build/tools/coverage.sh html; @./build/tools/coverage.sh html
docker: ## build docker image for chain33 run docker: ## build docker image for chain33 run
@sudo docker build . -f ./build/Dockerfile-run -t chain33:latest @sudo docker build . -f ./build/Dockerfile-run -t chain33:latest
......
...@@ -4,6 +4,7 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874 ...@@ -4,6 +4,7 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874
[![pipeline status](https://api.travis-ci.org/33cn/chain33.svg?branch=master)](https://travis-ci.org/33cn/chain33/) [![pipeline status](https://api.travis-ci.org/33cn/chain33.svg?branch=master)](https://travis-ci.org/33cn/chain33/)
[![Go Report Card](https://goreportcard.com/badge/github.com/33cn/chain33)](https://goreportcard.com/report/github.com/33cn/chain33) [![Go Report Card](https://goreportcard.com/badge/github.com/33cn/chain33)](https://goreportcard.com/report/github.com/33cn/chain33)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/33cn/chain33?svg=true&branch=master&passingText=Windows%20-%20OK&failingText=Windows%20-%20failed&pendingText=Windows%20-%20pending)](https://ci.appveyor.com/project/33cn/chain33) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/33cn/chain33?svg=true&branch=master&passingText=Windows%20-%20OK&failingText=Windows%20-%20failed&pendingText=Windows%20-%20pending)](https://ci.appveyor.com/project/33cn/chain33)
[![codecov](https://codecov.io/gh/33cn/chain33/branch/master/graph/badge.svg)](https://codecov.io/gh/33cn/chain33) [![Join the chat at https://gitter.im/33cn/Lobby](https://badges.gitter.im/33cn/Lobby.svg)](https://gitter.im/33cn/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Chain33 区块链开发框架 # Chain33 区块链开发框架
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package account package account
import ( import (
"fmt"
"testing" "testing"
"github.com/33cn/chain33/client" "github.com/33cn/chain33/client"
...@@ -140,8 +139,8 @@ func storeProcess(q queue.Queue) { ...@@ -140,8 +139,8 @@ func storeProcess(q queue.Queue) {
for msg := range client.Recv() { for msg := range client.Recv() {
switch msg.Ty { switch msg.Ty {
case types.EventStoreGet: case types.EventStoreGet:
datas := msg.GetData().(*types.StoreGet) //datas := msg.GetData().(*types.StoreGet)
fmt.Println("EventStoreGet data = %v", datas) //fmt.Println("EventStoreGet data = %v", datas)
values := make([][]byte, 2) values := make([][]byte, 2)
account := &types.Account{ account := &types.Account{
......
...@@ -8,7 +8,7 @@ set -o pipefail ...@@ -8,7 +8,7 @@ set -o pipefail
# os: ubuntu16.04 x64 # os: ubuntu16.04 x64
#chain33 dapp autotest root directory #chain33 dapp autotest root directory
declare -a Chain33AutoTestDirs=("system" "../plugin/plugin" "vendor/github.com/33cn/chain33/system") declare -a Chain33AutoTestDirs=("system" "plugin" "vendor/github.com/33cn/chain33/system")
#copy auto test to specific directory #copy auto test to specific directory
# check args # check args
...@@ -63,9 +63,9 @@ function copyAutoTestConfig() { ...@@ -63,9 +63,9 @@ function copyAutoTestConfig() {
function copyChain33() { function copyChain33() {
echo "# copy chain33 bin to path \"$1\"" echo "# copy chain33 bin to path \"$1\", make sure build chain33"
cp ../chain33 ../chain33-cli ../chain33.toml ../../cmd/chain33/chain33.test.toml "$1" cp ../chain33 ../chain33-cli ../chain33.toml "$1"
find ../../ -path '*cmd/chain33/chain33.test.toml' -exec cp {} "$1" ';'
} }
for dir in "$@"; do for dir in "$@"; do
......
...@@ -63,17 +63,6 @@ function config_autotest() { ...@@ -63,17 +63,6 @@ function config_autotest() {
echo "# config autotest" echo "# config autotest"
sed -i $sedfix 's/^checkTimeout.*/checkTimeout='${autoTestCheckTimeout}'/' ${autoTestConfig} sed -i $sedfix 's/^checkTimeout.*/checkTimeout='${autoTestCheckTimeout}'/' ${autoTestConfig}
#only run coins if it is chain33
if [ -d ../../../../system/dapp/coins/autotest ]; then
{
echo 'cliCmd="./chain33-cli"'
echo "checkTimeout=${autoTestCheckTimeout}"
echo "[[TestCaseFile]]"
echo 'dapp="coins"'
echo 'filename="coins.toml"'
} >${autoTestConfig}
fi
} }
function start_chain33() { function start_chain33() {
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
set -e -o pipefail set -e -o pipefail
COVERAGE_DIR="${COVERAGE_DIR:-build/coverage}" COVERAGE_DIR="${COVERAGE_DIR:-build/coverage}"
PKG_LIST=$(go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mock" | grep -v "mocks" \ PKG_LIST=$(go list ./... | grep -v "vendor" | grep -v "mock" | grep -v "mocks" \
| grep -v "types" | grep -v "cmd" | grep -v "nat" | grep -v "pbft") | grep -v "cmd" | grep -v "nat" | grep -v "pbft")
# Create the coverage files directory # Create the coverage files directory
mkdir -p "$COVERAGE_DIR" mkdir -p "$COVERAGE_DIR"
......
...@@ -33,7 +33,7 @@ $ make autotest dapp="coins token" ...@@ -33,7 +33,7 @@ $ make autotest dapp="coins token"
//dapp=all,执行所有预配置用例 //dapp=all,执行所有预配置用例
$ make autotest dapp=all $ make autotest dapp=all
``` ```
目前autotest支持的dapp有,bty(coins) token trade privacy,后续有待扩展 目前autotest支持的dapp有,coins token trade privacy,后续有待扩展
### 配置文件 ### 配置文件
...@@ -115,16 +115,16 @@ type BaseCase struct { ...@@ -115,16 +115,16 @@ type BaseCase struct {
### 扩展开发 ### 扩展开发
#### 新增dapp的autotest,以系统dapp-coins为例,步骤如下: 分为以下几个步骤
1. 在coins目录名下新增autotest目录,coins/autotest > 注册dapp的AutoTest类型,以chain33/system/dapp/coins为例
1. 新增coins.go文件,注册autoest类型 增加autotest目录,并新建coins.go文件
```go ```go
package autotest package autotest
//导入autotest开发依赖,主要是types包 //导入autotest开发依赖,主要是types包
import ( import (
"reflect" "reflect"
. "gitlab.33.cn/chain33/chain33/cmd/autotest/types" . "github.com/33cn/chain33/cmd/autotest/types"
) )
//声明coins的AutoTest结构,其成员皆为coins将实现的用例类型 //声明coins的AutoTest结构,其成员皆为coins将实现的用例类型
...@@ -155,18 +155,9 @@ func (config coinsAutoTest) GetTestConfigType() reflect.Type { ...@@ -155,18 +155,9 @@ func (config coinsAutoTest) GetTestConfigType() reflect.Type {
return reflect.TypeOf(config) return reflect.TypeOf(config)
} }
``` ```
3. 实现需要测试的用例,即上述结构体中定义的用例类型,TransferCase和WithdrawCase
4. 在autotest主程序中增加匿名导入注册
```
//新增dapp的autoest需要在此处导入对应autotest包,匿名注册
_ "gitlab.33.cn/chain33/chain33/plugin/dapp/privacy/autotest"
_ "gitlab.33.cn/chain33/chain33/plugin/dapp/token/autotest"
_ "gitlab.33.cn/chain33/chain33/plugin/dapp/trade/autotest"
_ "gitlab.33.cn/chain33/chain33/system/dapp/coins/autotest"
```
#### 新增用例
可以根据测试需求,开发自定义测试用例,只需继承实现相关的接口 > 实现用例的测试行为
```go ```go
SendCommand(id string) //实现用例执行命令的行为 SendCommand(id string) //实现用例执行命令的行为
......
...@@ -146,6 +146,14 @@ enableMVCC=false ...@@ -146,6 +146,14 @@ enableMVCC=false
[exec.sub.token] [exec.sub.token]
saveTokenTxList=true saveTokenTxList=true
tokenApprs = [
"1Bsg9j6gW83sShoee1fZAt9TkUjcrCgA9S",
"1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK",
"1LY8GFia5EiyoTodMLfkB5PHNNpXRqxhyB",
"1GCzJDS6HbgTQ2emade7mEJGGWFfA15pS9",
"1JYB8sxi4He5pZWHCd3Zi2nypQ4JMB6AxN",
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv",
]
[exec.sub.relay] [exec.sub.relay]
genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" genesis="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
...@@ -157,3 +165,10 @@ enable=false ...@@ -157,3 +165,10 @@ enable=false
cryptoPath="authdir/crypto" cryptoPath="authdir/crypto"
# 带证书签名类型,支持"auth_ecdsa", "auth_sm2" # 带证书签名类型,支持"auth_ecdsa", "auth_sm2"
signType="auth_ecdsa" signType="auth_ecdsa"
[exec.sub.manage]
superManager=[
"1Bsg9j6gW83sShoee1fZAt9TkUjcrCgA9S",
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv",
"1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
]
\ No newline at end of file
...@@ -46,9 +46,9 @@ fail = true ...@@ -46,9 +46,9 @@ fail = true
[[TransferCase]] [[TransferCase]]
id = "btyTrans3" id = "btyTrans3"
command = "send bty transfer -a 1 -t 12hpJBHybh1mSyCijQ2MQJPk7z7kZ7jnQa -k 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj" command = "send bty transfer -a 1 -t 1GaHYpWmqAJsqRwrpoNcB8VvgKtSwjcHqt -k 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
from = "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj" from = "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
to = "12hpJBHybh1mSyCijQ2MQJPk7z7kZ7jnQa" to = "1GaHYpWmqAJsqRwrpoNcB8VvgKtSwjcHqt"
amount = "1" amount = "1"
checkItem = ["balance"] checkItem = ["balance"]
dep = ["btyTrans1"] dep = ["btyTrans1"]
...@@ -56,7 +56,7 @@ dep = ["btyTrans1"] ...@@ -56,7 +56,7 @@ dep = ["btyTrans1"]
[[WithdrawCase]] [[WithdrawCase]]
id = "btyWithdraw" id = "btyWithdraw"
command = "send bty withdraw -a 0.1 -e token -k 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj" command = "send bty withdraw -a 0.1 -e coins -k 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
addr = "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj" addr = "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
amount = "0.1" amount = "0.1"
checkItem = ["balance"] checkItem = ["balance"]
...@@ -66,7 +66,7 @@ dep = ["btyTrans3"] ...@@ -66,7 +66,7 @@ dep = ["btyTrans3"]
[[WithdrawCase]] [[WithdrawCase]]
id = "failWithdraw" id = "failWithdraw"
command = "send bty withdraw -a 1.1 -e token -k 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj" command = "send bty withdraw -a 1.1 -e coins -k 1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
addr = "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj" addr = "1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
amount = "1.1" amount = "1.1"
checkItem = ["balance"] checkItem = ["balance"]
......
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