Browse Source

address linting FIXMEs

pull/703/head
Ethan Buchman 7 years ago
parent
commit
55b81cc1a1
6 changed files with 29 additions and 55 deletions
  1. +4
    -6
      consensus/mempool_test.go
  2. +0
    -14
      consensus/reactor_test.go
  3. +1
    -3
      consensus/replay.go
  4. +2
    -1
      p2p/switch.go
  5. +10
    -13
      p2p/switch_test.go
  6. +12
    -18
      rpc/client/mock/abci_test.go

+ 4
- 6
consensus/mempool_test.go View File

@ -5,6 +5,8 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
abci "github.com/tendermint/abci/types"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common"
@ -120,14 +122,10 @@ func TestRmBadTx(t *testing.T) {
binary.BigEndian.PutUint64(txBytes, uint64(0))
resDeliver := app.DeliverTx(txBytes)
if resDeliver.Error != nil {
// t.Error(resDeliver.Error()) // FIXME: fails
}
assert.False(t, resDeliver.IsErr(), cmn.Fmt("expected no error. got %v", resDeliver))
resCommit := app.Commit()
if resCommit.Error != nil {
// t.Error(resCommit.Error()) // FIXME: fails
}
assert.False(t, resCommit.IsErr(), cmn.Fmt("expected no error. got %v", resCommit))
emptyMempoolCh := make(chan struct{})
checkTxRespCh := make(chan struct{})


+ 0
- 14
consensus/reactor_test.go View File

@ -389,17 +389,3 @@ 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
}

+ 1
- 3
consensus/replay.go View File

@ -117,13 +117,11 @@ func (cs *ConsensusState) catchupReplay(csHeight int) error {
cs.Logger.Error("Replay: wal.group.Search returned EOF", "#ENDHEIGHT", csHeight-1)
} else if err != nil {
return err
} else {
defer gr.Close() // nolint: errcheck
}
if !found {
return errors.New(cmn.Fmt("Cannot replay height %d. WAL does not contain #ENDHEIGHT for %d.", csHeight, csHeight-1))
}
defer gr.Close()
defer gr.Close() // nolint: errcheck
cs.Logger.Info("Catchup by replaying consensus messages", "height", csHeight)


+ 2
- 1
p2p/switch.go View File

@ -291,7 +291,8 @@ func (sw *Switch) SetPubKeyFilter(f func(crypto.PubKeyEd25519) error) {
func (sw *Switch) startInitPeer(peer *peer) {
_, err := peer.Start() // spawn send/recv routines
if err != nil {
sw.Logger.Error("Error starting peer", "err", err)
// Should never happen
sw.Logger.Error("Error starting peer", "peer", peer, "err", err)
}
for _, reactor := range sw.reactors {


+ 10
- 13
p2p/switch_test.go View File

@ -10,11 +10,12 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
crypto "github.com/tendermint/go-crypto"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/tmlibs/log"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tmlibs/log"
)
var (
@ -171,14 +172,12 @@ func TestConnAddrFilter(t *testing.T) {
// connect to good peer
go func() {
if err := s1.addPeerWithConnection(c1); err != nil {
// t.Error(err) FIXME: fails
}
err := s1.addPeerWithConnection(c1)
assert.NotNil(t, err, "expected err")
}()
go func() {
if err := s2.addPeerWithConnection(c2); err != nil {
// t.Error(err) FIXME: fails
}
err := s2.addPeerWithConnection(c2)
assert.NotNil(t, err, "expected err")
}()
assertNoPeersAfterTimeout(t, s1, 400*time.Millisecond)
@ -210,14 +209,12 @@ func TestConnPubKeyFilter(t *testing.T) {
// connect to good peer
go func() {
if err := s1.addPeerWithConnection(c1); err != nil {
// t.Error(err) FIXME: fails
}
err := s1.addPeerWithConnection(c1)
assert.NotNil(t, err, "expected error")
}()
go func() {
if err := s2.addPeerWithConnection(c2); err != nil {
// t.Error(err) FIXME: fails
}
err := s2.addPeerWithConnection(c2)
assert.NotNil(t, err, "expected error")
}()
assertNoPeersAfterTimeout(t, s1, 400*time.Millisecond)


+ 12
- 18
rpc/client/mock/abci_test.go View File

@ -79,6 +79,8 @@ func TestABCIMock(t *testing.T) {
func TestABCIRecorder(t *testing.T) {
assert, require := assert.New(t), require.New(t)
// This mock returns errors on everything but Query
m := mock.ABCIMock{
Info: mock.Call{Response: abci.ResponseInfo{
Data: "data",
@ -92,15 +94,13 @@ func TestABCIRecorder(t *testing.T) {
require.Equal(0, len(r.Calls))
r.ABCIInfo()
_, err := r.ABCIInfo()
if err != nil {
t.Error(err)
}
_, err = r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false})
if err != nil {
// t.Errorf(err) FIXME: fails
}
assert.Nil(err, "expected no err on info")
_, err = r.ABCIInfo()
assert.Nil(err, "expected no err on info")
_, err := r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false})
assert.NotNil(err, "expected error on query")
require.Equal(2, len(r.Calls))
info := r.Calls[0]
@ -125,20 +125,14 @@ func TestABCIRecorder(t *testing.T) {
assert.EqualValues("data", qa.Data)
assert.False(qa.Trusted)
// now add some broadcasts
// now add some broadcasts (should all err)
txs := []types.Tx{{1}, {2}, {3}}
_, err = r.BroadcastTxCommit(txs[0])
if err != nil {
// t.Error(err) FIXME: fails
}
assert.NotNil(err, "expected err on broadcast")
_, err = r.BroadcastTxSync(txs[1])
if err != nil {
// t.Error(err) FIXME: fails
}
assert.NotNil(err, "expected err on broadcast")
_, err = r.BroadcastTxAsync(txs[2])
if err != nil {
// t.Error(err) FIXME: fails
}
assert.NotNil(err, "expected err on broadcast")
require.Equal(5, len(r.Calls))


Loading…
Cancel
Save