diff --git a/Makefile b/Makefile index d935833ba..9b07cd5cb 100644 --- a/Makefile +++ b/Makefile @@ -84,4 +84,8 @@ metalinter: ensure_tools @gometalinter --install gometalinter --vendor --deadline=600s --enable-all --disable=lll ./... +metalinter_test: ensure_tools + @gometalinter --install + gometalinter --vendor --deadline=600s --disable-all --enable=deadcode dupl ./... + .PHONY: install build build_race dist test test_race test_integrations test100 draw_deps list_deps get_deps get_vendor_deps update_deps revision tools diff --git a/circle.yml b/circle.yml index 50ffbd01b..6a5e2feae 100644 --- a/circle.yml +++ b/circle.yml @@ -25,6 +25,7 @@ dependencies: test: override: - cd "$PROJECT_PATH" && set -o pipefail && make test_integrations 2>&1 | tee test_integrations.log: + - cd "$PROJECT_PATH" && make metalinter_test timeout: 1800 post: - cd "$PROJECT_PATH" && mv test_integrations.log "${CIRCLE_ARTIFACTS}" diff --git a/consensus/common.go b/consensus/common.go new file mode 100644 index 000000000..836b68f5a --- /dev/null +++ b/consensus/common.go @@ -0,0 +1,18 @@ +package consensus + +import ( + "github.com/tendermint/tendermint/types" +) + +// XXX: WARNING: this function can halt the consensus as firing events is synchronous. +// Make sure to read off the channels, and in the case of subscribeToEventRespond, to write back on it + +// NOTE: if chanCap=0, this blocks on the event being consumed +func subscribeToEvent(evsw types.EventSwitch, receiver, eventID string, chanCap int) chan interface{} { + // listen for event + ch := make(chan interface{}, chanCap) + types.AddListenerForEvent(evsw, receiver, eventID, func(data types.TMEventData) { + ch <- data + }) + return ch +} diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 2d27cdd87..a45ebfd13 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -389,3 +389,17 @@ func timeoutWaitGroup(t *testing.T, n int, f func(*sync.WaitGroup, int), css []* panic("Timed out waiting for all validators to commit a block") } } + +// XXX: WARNING: this function can halt the consensus as firing events is synchronous. +// Make sure to read off the channels, and in the case of subscribeToEventRespond, to write back on it + +// NOTE: this blocks on receiving a response after the event is consumed +func subscribeToEventRespond(evsw types.EventSwitch, receiver, eventID string) chan interface{} { + // listen for event + ch := make(chan interface{}) + types.AddListenerForEvent(evsw, receiver, eventID, func(data types.TMEventData) { + ch <- data + <-ch + }) + return ch +} diff --git a/state/execution.go b/state/execution.go index 495b70c87..0c870095b 100644 --- a/state/execution.go +++ b/state/execution.go @@ -160,6 +160,7 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci. // return a bit array of validators that signed the last commit // NOTE: assumes commits have already been authenticated +/* function is currently unused func commitBitArrayFromBlock(block *types.Block) *cmn.BitArray { signed := cmn.NewBitArray(len(block.LastCommit.Precommits)) for i, precommit := range block.LastCommit.Precommits { @@ -169,6 +170,7 @@ func commitBitArrayFromBlock(block *types.Block) *cmn.BitArray { } return signed } +*/ //----------------------------------------------------- // Validate block