mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 13:51:21 +00:00
address linting FIXMEs
This commit is contained in:
@ -5,6 +5,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
@ -120,14 +122,10 @@ func TestRmBadTx(t *testing.T) {
|
|||||||
binary.BigEndian.PutUint64(txBytes, uint64(0))
|
binary.BigEndian.PutUint64(txBytes, uint64(0))
|
||||||
|
|
||||||
resDeliver := app.DeliverTx(txBytes)
|
resDeliver := app.DeliverTx(txBytes)
|
||||||
if resDeliver.Error != nil {
|
assert.False(t, resDeliver.IsErr(), cmn.Fmt("expected no error. got %v", resDeliver))
|
||||||
// t.Error(resDeliver.Error()) // FIXME: fails
|
|
||||||
}
|
|
||||||
|
|
||||||
resCommit := app.Commit()
|
resCommit := app.Commit()
|
||||||
if resCommit.Error != nil {
|
assert.False(t, resCommit.IsErr(), cmn.Fmt("expected no error. got %v", resCommit))
|
||||||
// t.Error(resCommit.Error()) // FIXME: fails
|
|
||||||
}
|
|
||||||
|
|
||||||
emptyMempoolCh := make(chan struct{})
|
emptyMempoolCh := make(chan struct{})
|
||||||
checkTxRespCh := make(chan struct{})
|
checkTxRespCh := make(chan struct{})
|
||||||
|
@ -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")
|
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
|
|
||||||
}
|
|
||||||
|
@ -117,13 +117,11 @@ func (cs *ConsensusState) catchupReplay(csHeight int) error {
|
|||||||
cs.Logger.Error("Replay: wal.group.Search returned EOF", "#ENDHEIGHT", csHeight-1)
|
cs.Logger.Error("Replay: wal.group.Search returned EOF", "#ENDHEIGHT", csHeight-1)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
defer gr.Close() // nolint: errcheck
|
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
return errors.New(cmn.Fmt("Cannot replay height %d. WAL does not contain #ENDHEIGHT for %d.", csHeight, csHeight-1))
|
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)
|
cs.Logger.Info("Catchup by replaying consensus messages", "height", csHeight)
|
||||||
|
|
||||||
|
@ -291,7 +291,8 @@ func (sw *Switch) SetPubKeyFilter(f func(crypto.PubKeyEd25519) error) {
|
|||||||
func (sw *Switch) startInitPeer(peer *peer) {
|
func (sw *Switch) startInitPeer(peer *peer) {
|
||||||
_, err := peer.Start() // spawn send/recv routines
|
_, err := peer.Start() // spawn send/recv routines
|
||||||
if err != nil {
|
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 {
|
for _, reactor := range sw.reactors {
|
||||||
|
@ -10,11 +10,12 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
wire "github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
|
|
||||||
cfg "github.com/tendermint/tendermint/config"
|
cfg "github.com/tendermint/tendermint/config"
|
||||||
"github.com/tendermint/tmlibs/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -171,14 +172,12 @@ func TestConnAddrFilter(t *testing.T) {
|
|||||||
|
|
||||||
// connect to good peer
|
// connect to good peer
|
||||||
go func() {
|
go func() {
|
||||||
if err := s1.addPeerWithConnection(c1); err != nil {
|
err := s1.addPeerWithConnection(c1)
|
||||||
// t.Error(err) FIXME: fails
|
assert.NotNil(t, err, "expected err")
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
if err := s2.addPeerWithConnection(c2); err != nil {
|
err := s2.addPeerWithConnection(c2)
|
||||||
// t.Error(err) FIXME: fails
|
assert.NotNil(t, err, "expected err")
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
assertNoPeersAfterTimeout(t, s1, 400*time.Millisecond)
|
assertNoPeersAfterTimeout(t, s1, 400*time.Millisecond)
|
||||||
@ -210,14 +209,12 @@ func TestConnPubKeyFilter(t *testing.T) {
|
|||||||
|
|
||||||
// connect to good peer
|
// connect to good peer
|
||||||
go func() {
|
go func() {
|
||||||
if err := s1.addPeerWithConnection(c1); err != nil {
|
err := s1.addPeerWithConnection(c1)
|
||||||
// t.Error(err) FIXME: fails
|
assert.NotNil(t, err, "expected error")
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
if err := s2.addPeerWithConnection(c2); err != nil {
|
err := s2.addPeerWithConnection(c2)
|
||||||
// t.Error(err) FIXME: fails
|
assert.NotNil(t, err, "expected error")
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
assertNoPeersAfterTimeout(t, s1, 400*time.Millisecond)
|
assertNoPeersAfterTimeout(t, s1, 400*time.Millisecond)
|
||||||
|
@ -79,6 +79,8 @@ func TestABCIMock(t *testing.T) {
|
|||||||
|
|
||||||
func TestABCIRecorder(t *testing.T) {
|
func TestABCIRecorder(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
assert, require := assert.New(t), require.New(t)
|
||||||
|
|
||||||
|
// This mock returns errors on everything but Query
|
||||||
m := mock.ABCIMock{
|
m := mock.ABCIMock{
|
||||||
Info: mock.Call{Response: abci.ResponseInfo{
|
Info: mock.Call{Response: abci.ResponseInfo{
|
||||||
Data: "data",
|
Data: "data",
|
||||||
@ -92,15 +94,13 @@ func TestABCIRecorder(t *testing.T) {
|
|||||||
|
|
||||||
require.Equal(0, len(r.Calls))
|
require.Equal(0, len(r.Calls))
|
||||||
|
|
||||||
r.ABCIInfo()
|
|
||||||
_, err := r.ABCIInfo()
|
_, err := r.ABCIInfo()
|
||||||
if err != nil {
|
assert.Nil(err, "expected no err on info")
|
||||||
t.Error(err)
|
_, err = r.ABCIInfo()
|
||||||
}
|
assert.Nil(err, "expected no err on info")
|
||||||
_, err = r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false})
|
|
||||||
if err != nil {
|
_, err := r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false})
|
||||||
// t.Errorf(err) FIXME: fails
|
assert.NotNil(err, "expected error on query")
|
||||||
}
|
|
||||||
require.Equal(2, len(r.Calls))
|
require.Equal(2, len(r.Calls))
|
||||||
|
|
||||||
info := r.Calls[0]
|
info := r.Calls[0]
|
||||||
@ -125,20 +125,14 @@ func TestABCIRecorder(t *testing.T) {
|
|||||||
assert.EqualValues("data", qa.Data)
|
assert.EqualValues("data", qa.Data)
|
||||||
assert.False(qa.Trusted)
|
assert.False(qa.Trusted)
|
||||||
|
|
||||||
// now add some broadcasts
|
// now add some broadcasts (should all err)
|
||||||
txs := []types.Tx{{1}, {2}, {3}}
|
txs := []types.Tx{{1}, {2}, {3}}
|
||||||
_, err = r.BroadcastTxCommit(txs[0])
|
_, err = r.BroadcastTxCommit(txs[0])
|
||||||
if err != nil {
|
assert.NotNil(err, "expected err on broadcast")
|
||||||
// t.Error(err) FIXME: fails
|
|
||||||
}
|
|
||||||
_, err = r.BroadcastTxSync(txs[1])
|
_, err = r.BroadcastTxSync(txs[1])
|
||||||
if err != nil {
|
assert.NotNil(err, "expected err on broadcast")
|
||||||
// t.Error(err) FIXME: fails
|
|
||||||
}
|
|
||||||
_, err = r.BroadcastTxAsync(txs[2])
|
_, err = r.BroadcastTxAsync(txs[2])
|
||||||
if err != nil {
|
assert.NotNil(err, "expected err on broadcast")
|
||||||
// t.Error(err) FIXME: fails
|
|
||||||
}
|
|
||||||
|
|
||||||
require.Equal(5, len(r.Calls))
|
require.Equal(5, len(r.Calls))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user