mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-25 01:01:56 +00:00
Compare commits
3 Commits
tessr/nil-
...
updateconf
Author | SHA1 | Date | |
---|---|---|---|
|
85f2e0bb14 | ||
|
1d7cdd6c76 | ||
|
57523ce1b7 |
@@ -51,22 +51,6 @@ jobs:
|
||||
paths:
|
||||
- /go/src/github.com/tendermint/tendermint
|
||||
|
||||
build_slate:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- restore_cache:
|
||||
key: v4-pkg-cache
|
||||
- restore_cache:
|
||||
key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
name: slate docs
|
||||
command: |
|
||||
set -ex
|
||||
export PATH="$GOBIN:$PATH"
|
||||
make build-slate
|
||||
|
||||
test_abci_apps:
|
||||
<<: *defaults
|
||||
steps:
|
||||
|
21
Makefile
21
Makefile
@@ -16,6 +16,9 @@ BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
|
||||
|
||||
all: check build test install
|
||||
|
||||
# The below include contains the tools.
|
||||
include scripts/Makefile
|
||||
|
||||
check: check_tools
|
||||
|
||||
########################################
|
||||
@@ -79,13 +82,13 @@ check_tools:
|
||||
@echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
|
||||
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
|
||||
|
||||
get_tools:
|
||||
@echo "--> Installing tools"
|
||||
./scripts/get_tools.sh
|
||||
# get_tools:
|
||||
# @echo "--> Installing tools"
|
||||
# ./scripts/get_tools.sh
|
||||
|
||||
update_tools:
|
||||
@echo "--> Updating tools"
|
||||
./scripts/get_tools.sh
|
||||
# update_tools:
|
||||
# @echo "--> Updating tools"
|
||||
# ./scripts/get_tools.sh
|
||||
|
||||
#For ABCI and libs
|
||||
get_protoc:
|
||||
@@ -304,10 +307,6 @@ sentry-stop:
|
||||
@if [ -z "$(DO_API_TOKEN)" ]; then echo "DO_API_TOKEN environment variable not set." ; false ; fi
|
||||
cd networks/remote/terraform && terraform destroy -var DO_API_TOKEN="$(DO_API_TOKEN)" -var SSH_KEY_FILE="$(HOME)/.ssh/id_rsa.pub"
|
||||
|
||||
# meant for the CI, inspect script & adapt accordingly
|
||||
build-slate:
|
||||
bash scripts/slate.sh
|
||||
|
||||
# Build hooks for dredd, to skip or add information on some steps
|
||||
build-contract-tests-hooks:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@@ -327,4 +326,4 @@ contract-tests:
|
||||
# To avoid unintended conflicts with file names, always add to .PHONY
|
||||
# unless there is a reason not to.
|
||||
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
|
||||
.PHONY: check build build_race build_abci dist install install_abci check_tools get_tools update_tools draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests
|
||||
.PHONY: check build build_race build_abci dist install install_abci check_tools get_tools update_tools draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests
|
||||
|
@@ -2,7 +2,6 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -386,7 +385,7 @@ func DefaultRPCConfig() *RPCConfig {
|
||||
return &RPCConfig{
|
||||
ListenAddress: "tcp://127.0.0.1:26657",
|
||||
CORSAllowedOrigins: []string{},
|
||||
CORSAllowedMethods: []string{http.MethodHead, http.MethodGet, http.MethodPost},
|
||||
CORSAllowedMethods: []string{"HEAD", "GET", "POST"},
|
||||
CORSAllowedHeaders: []string{"Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"},
|
||||
GRPCListenAddress: "",
|
||||
GRPCMaxOpenConnections: 900,
|
||||
|
4
go.mod
4
go.mod
@@ -11,7 +11,7 @@ require (
|
||||
github.com/go-kit/kit v0.6.0
|
||||
github.com/go-logfmt/logfmt v0.3.0
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.0
|
||||
github.com/gogo/protobuf v1.2.1
|
||||
github.com/golang/protobuf v1.3.2
|
||||
github.com/google/gofuzz v1.0.0 // indirect
|
||||
github.com/gorilla/websocket v1.2.0
|
||||
@@ -19,7 +19,7 @@ require (
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.0.1
|
||||
github.com/magiconair/properties v1.8.1
|
||||
github.com/magiconair/properties v1.8.0
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.1.2 // indirect
|
||||
github.com/pelletier/go-toml v1.2.0 // indirect
|
||||
|
6
go.sum
6
go.sum
@@ -35,8 +35,6 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE=
|
||||
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
@@ -61,7 +59,6 @@ github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U
|
||||
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
|
||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=
|
||||
@@ -70,8 +67,6 @@ github.com/libp2p/go-buffer-pool v0.0.1 h1:9Rrn/H46cXjaA2HQ5Y8lyhOS1NhTkZ4yuEs2r
|
||||
github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ=
|
||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
@@ -145,7 +140,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
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/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/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=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
|
88
scripts/Makefile
Normal file
88
scripts/Makefile
Normal file
@@ -0,0 +1,88 @@
|
||||
###
|
||||
# Find OS and Go environment
|
||||
# GO contains the Go binary
|
||||
# FS contains the OS file separator
|
||||
###
|
||||
ifeq ($(OS),Windows_NT)
|
||||
GO := $(shell where go.exe 2> NUL)
|
||||
FS := "\\"
|
||||
else
|
||||
GO := $(shell command -v go 2> /dev/null)
|
||||
FS := "/"
|
||||
endif
|
||||
|
||||
ifeq ($(GO),)
|
||||
$(error could not find go. Is it in PATH? $(GO))
|
||||
endif
|
||||
|
||||
GOPATH ?= $(shell $(GO) env GOPATH)
|
||||
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com
|
||||
GOLANGCI_LINT_VERSION := v1.17.1
|
||||
GOLANGCI_LINT_HASHSUM := f5fa647a12f658924d9f7d6b9628d505ab118e8e049e43272de6526053ebe08d
|
||||
|
||||
###
|
||||
# Functions
|
||||
###
|
||||
|
||||
go_get = $(if $(findstring Windows_NT,$(OS)),\
|
||||
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\
|
||||
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\
|
||||
,\
|
||||
mkdir -p $(GITHUBDIR)$(FS)$(1) &&\
|
||||
(test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\
|
||||
)\
|
||||
cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3)
|
||||
|
||||
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd)
|
||||
|
||||
###
|
||||
# tools
|
||||
###
|
||||
|
||||
TOOLS_DESTDIR ?= $(GOPATH)/bin
|
||||
|
||||
GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint
|
||||
GOIMPORTS = $(TOOLS_DESTDIR)/goimports
|
||||
CERTSTRAP = $(TOOLS_DESTDIR)/certstrap
|
||||
PROTOBUF = $(TOOLS_DESTDIR)/protoc
|
||||
GOX = $(TOOLS_DESTDIR)/gox
|
||||
|
||||
all: get_tools
|
||||
|
||||
get_tools: golangci-lint goimports certstrap protobuf gox
|
||||
|
||||
golangci-lint: $(GOLANGCI_LINT)
|
||||
$(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh
|
||||
bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_HASHSUM)
|
||||
|
||||
goimports: $(GOIMPORTS)
|
||||
$(GOIMPORTS):
|
||||
@echo "Get goimports@v0.0.0-20190628034336-212fb13d595e"
|
||||
@go get golang.org/x/tools/cmd/goimports@v0.0.0-20190628034336-212fb13d595e
|
||||
|
||||
certstrap: $(CERTSTRAP)
|
||||
$(CERTSTRAP):
|
||||
@echo "Get Certstrap"
|
||||
@go get github.com/square/certstrap@338204a88c4349b1c135eac1e8c14c693ad007da
|
||||
|
||||
protobuf: $(PROTOBUF)
|
||||
$(PROTOBUF):
|
||||
@echo "Get Protobuf"
|
||||
## protobuf v1.3.0
|
||||
@go get github.com/gogo/protobuf/protoc-gen-gogo@0ca988a254f991240804bf9821f3450d87ccbb1b
|
||||
|
||||
gox: $(GOX)
|
||||
$(GOX):
|
||||
@echo "Get Gox"
|
||||
# used to build tm-monitor & tm-bench binaries
|
||||
## gox v1.0.1
|
||||
@go get github.com/mitchellh/gox@d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
|
||||
|
||||
|
||||
|
||||
tools-clean:
|
||||
rm -f $(CERTSTRAP) $(GOIMPORTS) $(GOLANGCI_LINT) $(PROTOBUF) $(GOX)
|
||||
rm -f tools-stamp
|
||||
|
||||
.PHONY: all get_tools tools-clean
|
@@ -49,25 +49,19 @@ installFromGithub() {
|
||||
}
|
||||
|
||||
######################## DEVELOPER TOOLS #####################################
|
||||
## protobuf v1.3.0
|
||||
installFromGithub gogo/protobuf 0ca988a254f991240804bf9821f3450d87ccbb1b protoc-gen-gogo
|
||||
installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo
|
||||
|
||||
installFromGithub square/certstrap 338204a88c4349b1c135eac1e8c14c693ad007da
|
||||
installFromGithub square/certstrap e27060a3643e814151e65b9807b6b06d169580a7
|
||||
|
||||
# used to build tm-monitor & tm-bench binaries
|
||||
## gox v1.0.1
|
||||
installFromGithub mitchellh/gox d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
|
||||
installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8
|
||||
|
||||
## Trying to install golangci with Go 1.13 gives:
|
||||
## go: github.com/go-critic/go-critic@v0.0.0-20181204210945-1df300866540: invalid pseudo-version: does not match version-control timestamp (2019-05-26T07:48:19Z)
|
||||
## golangci-lint v1.17.1
|
||||
# installFromGithub golangci/golangci-lint 4ba2155996359eabd8800d1fbf3e3a9777c80490 cmd/golangci-lint
|
||||
## golangci-lint v1.13.2
|
||||
installFromGithub golangci/golangci-lint 7b2421d55194c9dc385eff7720a037aa9244ca3c cmd/golangci-lint
|
||||
|
||||
## Trying to install golangci with Go 1.13 gives:
|
||||
## go: cannot find main module, but found .git/config in /go/src/github.com/petermattis/goid
|
||||
## make test_with_deadlock
|
||||
## XXX: https://github.com/tendermint/tendermint/issues/3242
|
||||
# installFromGithub petermattis/goid b0b1615b78e5ee59739545bb38426383b2cda4c9
|
||||
# installFromGithub sasha-s/go-deadlock d68e2bc52ae3291765881b9056f2c1527f245f1e
|
||||
# go get golang.org/x/tools/cmd/goimports
|
||||
# installFromGithub snikch/goodman 10e37e294daa3c9a90abded60ff9924bafab3888 cmd/goodman
|
||||
installFromGithub petermattis/goid b0b1615b78e5ee59739545bb38426383b2cda4c9
|
||||
installFromGithub sasha-s/go-deadlock d68e2bc52ae3291765881b9056f2c1527f245f1e
|
||||
go get golang.org/x/tools/cmd/goimports
|
||||
installFromGithub snikch/goodman 10e37e294daa3c9a90abded60ff9924bafab3888 cmd/goodman
|
||||
|
27
scripts/install-golangci-lint.sh
Normal file
27
scripts/install-golangci-lint.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
f_sha256() {
|
||||
local l_file
|
||||
l_file=$1
|
||||
python -sBc "import hashlib;print(hashlib.sha256(open('$l_file','rb').read()).hexdigest())"
|
||||
}
|
||||
|
||||
installer="$(mktemp)"
|
||||
trap "rm -f ${installer}" EXIT
|
||||
|
||||
GOBIN="${1}"
|
||||
VERSION="${2}"
|
||||
HASHSUM="${3}"
|
||||
CURL="$(which curl)"
|
||||
|
||||
echo "Downloading golangci-lint ${VERSION} installer ..." >&2
|
||||
"${CURL}" -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/${VERSION}/install.sh" > "${installer}"
|
||||
|
||||
echo "Checking hashsum ..." >&2
|
||||
[ "${HASHSUM}" = "$(f_sha256 ${installer})" ]
|
||||
chmod +x "${installer}"
|
||||
|
||||
echo "Launching installer ..." >&2
|
||||
exec "${installer}" -d -b "${GOBIN}" "${VERSION}"
|
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
@@ -368,104 +367,6 @@ func TestCommitToVoteSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommitToVoteSetWithBadVotes(t *testing.T) {
|
||||
lastID := makeBlockIDRandom()
|
||||
height := int64(3)
|
||||
round := 1
|
||||
numValidators := 10
|
||||
|
||||
voteSet, valSet, vals := randVoteSet(height-1, 1, PrecommitType, numValidators, 1)
|
||||
|
||||
// > 2/3 sign for this block
|
||||
numBlockValidators := numValidators*2/3 + 1
|
||||
for i := 0; i < numBlockValidators; i++ {
|
||||
addr := vals[i].GetPubKey().Address()
|
||||
vote := &Vote{
|
||||
ValidatorAddress: addr,
|
||||
ValidatorIndex: i,
|
||||
Height: height - 1,
|
||||
Round: round,
|
||||
Type: PrecommitType,
|
||||
BlockID: lastID,
|
||||
Timestamp: tmtime.Now(),
|
||||
}
|
||||
|
||||
_, err := signAddVote(vals[i], vote, voteSet)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
// 1/3 vote for a different block
|
||||
for i := numBlockValidators; i < numValidators; i++ {
|
||||
addr := vals[i].GetPubKey().Address()
|
||||
vote := &Vote{
|
||||
ValidatorAddress: addr,
|
||||
ValidatorIndex: i,
|
||||
Height: height - 1,
|
||||
Round: round,
|
||||
Type: PrecommitType,
|
||||
BlockID: makeBlockIDRandom(),
|
||||
Timestamp: tmtime.Now(),
|
||||
}
|
||||
|
||||
_, err := signAddVote(vals[i], vote, voteSet)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
commit := voteSet.MakeCommit()
|
||||
|
||||
chainID := voteSet.ChainID()
|
||||
voteSet2 := CommitToVoteSet(chainID, commit, valSet)
|
||||
assert.NotNil(t, voteSet2)
|
||||
}
|
||||
|
||||
func TestCommitToVoteSetWithNil(t *testing.T) {
|
||||
lastID := makeBlockIDRandom()
|
||||
height := int64(3)
|
||||
round := 1
|
||||
numValidators := 10
|
||||
|
||||
voteSet, valSet, vals := randVoteSet(height-1, 1, PrecommitType, numValidators, 1)
|
||||
|
||||
// > 2/3 sign for this block
|
||||
numBlockValidators := numValidators*2/3 + 1
|
||||
for i := 0; i < numBlockValidators; i++ {
|
||||
addr := vals[i].GetPubKey().Address()
|
||||
vote := &Vote{
|
||||
ValidatorAddress: addr,
|
||||
ValidatorIndex: i,
|
||||
Height: height - 1,
|
||||
Round: round,
|
||||
Type: PrecommitType,
|
||||
BlockID: lastID,
|
||||
Timestamp: tmtime.Now(),
|
||||
}
|
||||
|
||||
_, err := signAddVote(vals[i], vote, voteSet)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
// 1/3 vote for a nil block
|
||||
for i := numBlockValidators; i < numValidators; i++ {
|
||||
addr := vals[i].GetPubKey().Address()
|
||||
vote := &Vote{
|
||||
ValidatorAddress: addr,
|
||||
ValidatorIndex: i,
|
||||
Height: height - 1,
|
||||
Round: round,
|
||||
Type: PrecommitType,
|
||||
BlockID: BlockID{}, // "nil"
|
||||
Timestamp: tmtime.Now(),
|
||||
}
|
||||
|
||||
_, err := signAddVote(vals[i], vote, voteSet)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
commit := voteSet.MakeCommit()
|
||||
|
||||
chainID := voteSet.ChainID()
|
||||
voteSet2 := CommitToVoteSet(chainID, commit, valSet)
|
||||
assert.NotNil(t, voteSet2)
|
||||
}
|
||||
|
||||
func TestSignedHeaderValidateBasic(t *testing.T) {
|
||||
commit := randCommit()
|
||||
chainID := "𠜎"
|
||||
|
Reference in New Issue
Block a user