Browse Source

linter: address deadcode, implement incremental lint testing

pull/703/head
Zach Ramsay 7 years ago
committed by Ethan Buchman
parent
commit
48aca642e3
5 changed files with 39 additions and 0 deletions
  1. +4
    -0
      Makefile
  2. +1
    -0
      circle.yml
  3. +18
    -0
      consensus/common.go
  4. +14
    -0
      consensus/reactor_test.go
  5. +2
    -0
      state/execution.go

+ 4
- 0
Makefile View File

@ -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

+ 1
- 0
circle.yml View File

@ -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}"


+ 18
- 0
consensus/common.go View File

@ -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
}

+ 14
- 0
consensus/reactor_test.go View File

@ -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
}

+ 2
- 0
state/execution.go View File

@ -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


Loading…
Cancel
Save