Browse Source

linters: enable stylecheck (#4153)

Refs #3262
pull/4155/head
Anton Kaliaev 5 years ago
committed by GitHub
parent
commit
3e1516b624
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
137 changed files with 590 additions and 589 deletions
  1. +1
    -1
      .golangci.yml
  2. +2
    -1
      CHANGELOG_PENDING.md
  3. +1
    -1
      abci/client/client.go
  4. +4
    -4
      abci/client/socket_client.go
  5. +4
    -4
      abci/cmd/abci-cli/abci-cli.go
  6. +1
    -1
      abci/server/server.go
  7. +3
    -3
      abci/server/socket_server.go
  8. +1
    -1
      abci/tests/benchmarks/simple/simple.go
  9. +5
    -5
      abci/tests/server/client.go
  10. +3
    -3
      behaviour/reporter_test.go
  11. +7
    -7
      blockchain/v0/reactor.go
  12. +5
    -5
      blockchain/v2/routine_test.go
  13. +17
    -17
      blockchain/v2/schedule.go
  14. +2
    -2
      cmd/tendermint/commands/codec.go
  15. +1
    -1
      cmd/tendermint/commands/root.go
  16. +2
    -2
      cmd/tendermint/commands/run_node.go
  17. +3
    -3
      consensus/mempool_test.go
  18. +30
    -30
      consensus/reactor.go
  19. +14
    -14
      consensus/reactor_test.go
  20. +10
    -10
      consensus/replay.go
  21. +1
    -1
      consensus/replay_test.go
  22. +6
    -6
      consensus/state.go
  23. +2
    -2
      consensus/state_test.go
  24. +11
    -10
      consensus/types/height_vote_set.go
  25. +2
    -2
      consensus/types/height_vote_set_test.go
  26. +8
    -8
      consensus/types/peer_round_state.go
  27. +2
    -2
      consensus/types/round_state.go
  28. +1
    -1
      crypto/encoding/amino/amino.go
  29. +1
    -1
      crypto/encoding/amino/encode_test.go
  30. +4
    -4
      crypto/merkle/proof.go
  31. +2
    -2
      crypto/merkle/proof_test.go
  32. +3
    -3
      crypto/merkle/rfc6962_test.go
  33. +2
    -2
      crypto/merkle/simple_proof.go
  34. +1
    -1
      crypto/multisig/bitarray/compact_bit_array.go
  35. +3
    -3
      crypto/xchacha20poly1305/vector_test.go
  36. +5
    -5
      crypto/xchacha20poly1305/xchachapoly_test.go
  37. +2
    -2
      crypto/xsalsa20symmetric/symmetric.go
  38. +2
    -2
      docs/spec/scripts/crypto.go
  39. +2
    -2
      evidence/codec.go
  40. +2
    -2
      evidence/reactor.go
  41. +9
    -9
      evidence/reactor_test.go
  42. +2
    -2
      libs/autofile/autofile_test.go
  43. +2
    -2
      libs/autofile/group_test.go
  44. +3
    -3
      libs/cli/flags/log_level.go
  45. +1
    -1
      libs/cli/setup.go
  46. +2
    -2
      libs/clist/clist_test.go
  47. +2
    -2
      libs/common/async.go
  48. +15
    -15
      libs/common/async_test.go
  49. +1
    -1
      libs/common/bit_array.go
  50. +1
    -1
      libs/common/bytes.go
  51. +1
    -1
      libs/common/os.go
  52. +1
    -1
      libs/common/random_test.go
  53. +1
    -1
      libs/common/tempfile.go
  54. +6
    -6
      libs/events/events_test.go
  55. +1
    -1
      libs/log/filter.go
  56. +1
    -1
      libs/log/tm_logger_test.go
  57. +2
    -2
      libs/log/tracing_logger_test.go
  58. +1
    -1
      libs/pubsub/pubsub_test.go
  59. +2
    -2
      lite/dbprovider.go
  60. +3
    -3
      lite/proxy/block.go
  61. +8
    -8
      lite/proxy/validate_test.go
  62. +4
    -4
      mempool/clist_mempool_test.go
  63. +1
    -1
      mempool/errors.go
  64. +1
    -1
      mempool/mempool.go
  65. +5
    -5
      mempool/reactor_test.go
  66. +2
    -2
      node/codec.go
  67. +2
    -2
      node/node.go
  68. +2
    -2
      p2p/codec.go
  69. +2
    -2
      p2p/conn/codec.go
  70. +6
    -6
      p2p/conn/connection.go
  71. +12
    -13
      p2p/conn/secret_connection.go
  72. +34
    -34
      p2p/conn/secret_connection_test.go
  73. +1
    -1
      p2p/key.go
  74. +5
    -5
      p2p/netaddress.go
  75. +3
    -3
      p2p/node_info.go
  76. +5
    -5
      p2p/node_info_test.go
  77. +4
    -4
      p2p/peer_set_test.go
  78. +2
    -2
      p2p/pex/pex_reactor.go
  79. +2
    -2
      p2p/switch_test.go
  80. +2
    -2
      p2p/test_util.go
  81. +1
    -1
      p2p/transport.go
  82. +7
    -7
      p2p/transport_test.go
  83. +1
    -1
      p2p/trust/store_test.go
  84. +4
    -4
      p2p/upnp/probe.go
  85. +9
    -9
      p2p/upnp/upnp.go
  86. +2
    -2
      privval/codec.go
  87. +2
    -2
      privval/signer_listener_endpoint_test.go
  88. +1
    -1
      proxy/app_conn_test.go
  89. +2
    -2
      rpc/core/blocks.go
  90. +2
    -2
      rpc/core/mempool.go
  91. +2
    -2
      rpc/core/net.go
  92. +3
    -3
      rpc/core/tx.go
  93. +1
    -1
      rpc/core/types/codec.go
  94. +1
    -1
      rpc/core/types/responses.go
  95. +1
    -1
      rpc/core/types/responses_test.go
  96. +1
    -1
      rpc/grpc/api.go
  97. +1
    -1
      rpc/grpc/client_server.go
  98. +1
    -1
      rpc/grpc/grpc_test.go
  99. +1
    -1
      rpc/grpc/types.pb.go
  100. +1
    -1
      rpc/grpc/typespb_test.go

+ 1
- 1
.golangci.yml View File

@ -29,7 +29,7 @@ linters:
- scopelint
- staticcheck
- structcheck
# - stylecheck
- stylecheck
- typecheck
- unconvert
# - unparam


+ 2
- 1
CHANGELOG_PENDING.md View File

@ -3,7 +3,7 @@
\*\*
Special thanks to external contributors on this release:
@erikgrinaker
@erikgrinaker, @PSalant726
Friendly reminder, we have a [bug bounty
program](https://hackerone.com/tendermint).
@ -45,6 +45,7 @@ program](https://hackerone.com/tendermint).
- Go API
- [libs/pubsub] [\#4070](https://github.com/tendermint/tendermint/pull/4070) `Query#(Matches|Conditions)` returns an error.
- [rpc/client] \#3471 `Validators` now requires two more args: `page` and `perPage`
- [libs/common] \#3262 Make error the last parameter of `Task` (@PSalant726)
- Blockchain Protocol
- [abci] \#2521 Remove `TotalTxs` and `NumTxs` from `Header`


+ 1
- 1
abci/client/client.go View File

@ -60,7 +60,7 @@ func NewClient(addr, transport string, mustConnect bool) (client Client, err err
case "grpc":
client = NewGRPCClient(addr, mustConnect)
default:
err = fmt.Errorf("Unknown abci transport %s", transport)
err = fmt.Errorf("unknown abci transport %s", transport)
}
return
}


+ 4
- 4
abci/client/socket_client.go View File

@ -137,14 +137,14 @@ func (cli *socketClient) sendRequestsRoutine(conn io.Writer) {
cli.willSendReq(reqres)
err := types.WriteMessage(reqres.Request, w)
if err != nil {
cli.StopForError(fmt.Errorf("Error writing msg: %v", err))
cli.StopForError(fmt.Errorf("error writing msg: %v", err))
return
}
// cli.Logger.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
if _, ok := reqres.Request.Value.(*types.Request_Flush); ok {
err = w.Flush()
if err != nil {
cli.StopForError(fmt.Errorf("Error flushing writer: %v", err))
cli.StopForError(fmt.Errorf("error flushing writer: %v", err))
return
}
}
@ -191,11 +191,11 @@ func (cli *socketClient) didRecvResponse(res *types.Response) error {
// Get the first ReqRes
next := cli.reqSent.Front()
if next == nil {
return fmt.Errorf("Unexpected result type %v when nothing expected", reflect.TypeOf(res.Value))
return fmt.Errorf("unexpected result type %v when nothing expected", reflect.TypeOf(res.Value))
}
reqres := next.Value.(*ReqRes)
if !resMatchesReq(reqres.Request, res) {
return fmt.Errorf("Unexpected result type %v when response to %v expected",
return fmt.Errorf("unexpected result type %v when response to %v expected",
reflect.TypeOf(res.Value), reflect.TypeOf(reqres.Request.Value))
}


+ 4
- 4
abci/cmd/abci-cli/abci-cli.go View File

@ -350,7 +350,7 @@ LOOP:
line, more, err := bufReader.ReadLine()
switch {
case more:
return errors.New("Input line is too long")
return errors.New("input line is too long")
case err == io.EOF:
break LOOP
case len(line) == 0:
@ -374,7 +374,7 @@ func cmdConsole(cmd *cobra.Command, args []string) error {
bufReader := bufio.NewReader(os.Stdin)
line, more, err := bufReader.ReadLine()
if more {
return errors.New("Input is too long")
return errors.New("input is too long")
} else if err != nil {
return err
}
@ -730,14 +730,14 @@ func stringOrHexToBytes(s string) ([]byte, error) {
if len(s) > 2 && strings.ToLower(s[:2]) == "0x" {
b, err := hex.DecodeString(s[2:])
if err != nil {
err = fmt.Errorf("Error decoding hex argument: %s", err.Error())
err = fmt.Errorf("error decoding hex argument: %s", err.Error())
return nil, err
}
return b, nil
}
if !strings.HasPrefix(s, "\"") || !strings.HasSuffix(s, "\"") {
err := fmt.Errorf("Invalid string arg: \"%s\". Must be quoted or a \"0x\"-prefixed hex string", s)
err := fmt.Errorf("invalid string arg: \"%s\". Must be quoted or a \"0x\"-prefixed hex string", s)
return nil, err
}


+ 1
- 1
abci/server/server.go View File

@ -25,7 +25,7 @@ func NewServer(protoAddr, transport string, app types.Application) (cmn.Service,
case "grpc":
s = NewGRPCServer(protoAddr, types.NewGRPCApplication(app))
default:
err = fmt.Errorf("Unknown server type %s", transport)
err = fmt.Errorf("unknown server type %s", transport)
}
return s, err
}

+ 3
- 3
abci/server/socket_server.go View File

@ -88,7 +88,7 @@ func (s *SocketServer) rmConn(connID int) error {
conn, ok := s.conns[connID]
if !ok {
return fmt.Errorf("Connection %d does not exist", connID)
return fmt.Errorf("connection %d does not exist", connID)
}
delete(s.conns, connID)
@ -222,13 +222,13 @@ func (s *SocketServer) handleResponses(closeConn chan error, conn io.Writer, res
var res = <-responses
err := types.WriteMessage(res, bufWriter)
if err != nil {
closeConn <- fmt.Errorf("Error writing message: %v", err.Error())
closeConn <- fmt.Errorf("error writing message: %v", err.Error())
return
}
if _, ok := res.Value.(*types.Response_Flush); ok {
err = bufWriter.Flush()
if err != nil {
closeConn <- fmt.Errorf("Error flushing write buffer: %v", err.Error())
closeConn <- fmt.Errorf("error flushing write buffer: %v", err.Error())
return
}
}


+ 1
- 1
abci/tests/benchmarks/simple/simple.go View File

@ -62,7 +62,7 @@ func makeRequest(conn io.ReadWriter, req *types.Request) (*types.Response, error
return nil, err
}
if _, ok := resFlush.Value.(*types.Response_Flush); !ok {
return nil, fmt.Errorf("Expected flush response but got something else: %v", reflect.TypeOf(resFlush))
return nil, fmt.Errorf("expected flush response but got something else: %v", reflect.TypeOf(resFlush))
}
return res, nil


+ 5
- 5
abci/tests/server/client.go View File

@ -51,7 +51,7 @@ func Commit(client abcicli.Client, hashExp []byte) error {
if !bytes.Equal(data, hashExp) {
fmt.Println("Failed test: Commit")
fmt.Printf("Commit hash was unexpected. Got %X expected %X\n", data, hashExp)
return errors.New("CommitTx failed")
return errors.New("commitTx failed")
}
fmt.Println("Passed test: Commit")
return nil
@ -64,13 +64,13 @@ func DeliverTx(client abcicli.Client, txBytes []byte, codeExp uint32, dataExp []
fmt.Println("Failed test: DeliverTx")
fmt.Printf("DeliverTx response code was unexpected. Got %v expected %v. Log: %v\n",
code, codeExp, log)
return errors.New("DeliverTx error")
return errors.New("deliverTx error")
}
if !bytes.Equal(data, dataExp) {
fmt.Println("Failed test: DeliverTx")
fmt.Printf("DeliverTx response data was unexpected. Got %X expected %X\n",
data, dataExp)
return errors.New("DeliverTx error")
return errors.New("deliverTx error")
}
fmt.Println("Passed test: DeliverTx")
return nil
@ -83,13 +83,13 @@ func CheckTx(client abcicli.Client, txBytes []byte, codeExp uint32, dataExp []by
fmt.Println("Failed test: CheckTx")
fmt.Printf("CheckTx response code was unexpected. Got %v expected %v. Log: %v\n",
code, codeExp, log)
return errors.New("CheckTx")
return errors.New("checkTx")
}
if !bytes.Equal(data, dataExp) {
fmt.Println("Failed test: CheckTx")
fmt.Printf("CheckTx response data was unexpected. Got %X expected %X\n",
data, dataExp)
return errors.New("CheckTx")
return errors.New("checkTx")
}
fmt.Println("Passed test: CheckTx")
return nil


+ 3
- 3
behaviour/reporter_test.go View File

@ -108,13 +108,13 @@ func TestEqualPeerBehaviours(t *testing.T) {
for _, test := range equals {
if !equalBehaviours(test.left, test.right) {
t.Errorf("Expected %#v and %#v to be equal", test.left, test.right)
t.Errorf("expected %#v and %#v to be equal", test.left, test.right)
}
}
for _, test := range unequals {
if equalBehaviours(test.left, test.right) {
t.Errorf("Expected %#v and %#v to be unequal", test.left, test.right)
t.Errorf("expected %#v and %#v to be unequal", test.left, test.right)
}
}
}
@ -194,7 +194,7 @@ func TestMockPeerBehaviourReporterConcurrency(t *testing.T) {
for _, items := range behaviourScript {
reported := pr.GetBehaviours(items.peerID)
if !equalBehaviours(reported, items.behaviours) {
t.Errorf("Expected peer %s to have behaved \nExpected: %#v \nGot %#v \n",
t.Errorf("expected peer %s to have behaved \nExpected: %#v \nGot %#v \n",
items.peerID, items.behaviours, reported)
}
}


+ 7
- 7
blockchain/v0/reactor.go View File

@ -319,14 +319,14 @@ FOR_LOOP:
if peer != nil {
// NOTE: we've already removed the peer's request, but we
// still need to clean up the rest.
bcR.Switch.StopPeerForError(peer, fmt.Errorf("BlockchainReactor validation error: %v", err))
bcR.Switch.StopPeerForError(peer, fmt.Errorf("blockchainReactor validation error: %v", err))
}
peerID2 := bcR.pool.RedoRequest(second.Height)
peer2 := bcR.Switch.Peers().Get(peerID2)
if peer2 != nil && peer2 != peer {
// NOTE: we've already removed the peer's request, but we
// still need to clean up the rest.
bcR.Switch.StopPeerForError(peer2, fmt.Errorf("BlockchainReactor validation error: %v", err))
bcR.Switch.StopPeerForError(peer2, fmt.Errorf("blockchainReactor validation error: %v", err))
}
continue FOR_LOOP
} else {
@ -387,7 +387,7 @@ func RegisterBlockchainMessages(cdc *amino.Codec) {
func decodeMsg(bz []byte) (msg BlockchainMessage, err error) {
if len(bz) > maxMsgSize {
return msg, fmt.Errorf("Msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
return msg, fmt.Errorf("msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
}
err = cdc.UnmarshalBinaryBare(bz, &msg)
return
@ -402,7 +402,7 @@ type bcBlockRequestMessage struct {
// ValidateBasic performs basic validation.
func (m *bcBlockRequestMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
return nil
}
@ -418,7 +418,7 @@ type bcNoBlockResponseMessage struct {
// ValidateBasic performs basic validation.
func (m *bcNoBlockResponseMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
return nil
}
@ -451,7 +451,7 @@ type bcStatusRequestMessage struct {
// ValidateBasic performs basic validation.
func (m *bcStatusRequestMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
return nil
}
@ -469,7 +469,7 @@ type bcStatusResponseMessage struct {
// ValidateBasic performs basic validation.
func (m *bcStatusResponseMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
return nil
}


+ 5
- 5
blockchain/v2/routine_test.go View File

@ -12,11 +12,11 @@ type eventA struct {
priorityNormal
}
var done = fmt.Errorf("done")
var errDone = fmt.Errorf("done")
func simpleHandler(event Event) (Event, error) {
if _, ok := event.(eventA); ok {
return noOp, done
return noOp, errDone
}
return noOp, nil
}
@ -37,7 +37,7 @@ func TestRoutineFinal(t *testing.T) {
assert.True(t, routine.send(eventA{}),
"expected sending to a ready routine to succeed")
assert.Equal(t, done, <-routine.final(),
assert.Equal(t, errDone, <-routine.final(),
"expected the final event to be done")
assert.False(t, routine.isRunning(),
@ -131,7 +131,7 @@ func handleWithPriority(event Event) (Event, error) {
case lowPriorityEvent:
return noOp, nil
case highPriorityEvent:
return noOp, done
return noOp, errDone
}
return noOp, nil
}
@ -157,7 +157,7 @@ func TestPriority(t *testing.T) {
assert.True(t, routine.send(highPriorityEvent{}),
"expected send to succeed even when saturated")
assert.Equal(t, done, <-routine.final())
assert.Equal(t, errDone, <-routine.final())
assert.False(t, routine.isRunning(),
"expected an started routine")
}

+ 17
- 17
blockchain/v2/schedule.go View File

@ -113,7 +113,7 @@ func newSchedule(initHeight int64) *schedule {
func (sc *schedule) addPeer(peerID p2p.ID) error {
if _, ok := sc.peers[peerID]; ok {
return fmt.Errorf("Cannot add duplicate peer %s", peerID)
return fmt.Errorf("cannot add duplicate peer %s", peerID)
}
sc.peers[peerID] = newScPeer(peerID)
return nil
@ -122,11 +122,11 @@ func (sc *schedule) addPeer(peerID p2p.ID) error {
func (sc *schedule) touchPeer(peerID p2p.ID, time time.Time) error {
peer, ok := sc.peers[peerID]
if !ok {
return fmt.Errorf("Couldn't find peer %s", peerID)
return fmt.Errorf("couldn't find peer %s", peerID)
}
if peer.state == peerStateRemoved {
return fmt.Errorf("Tried to touch peer in peerStateRemoved")
return fmt.Errorf("tried to touch peer in peerStateRemoved")
}
peer.lastTouched = time
@ -137,11 +137,11 @@ func (sc *schedule) touchPeer(peerID p2p.ID, time time.Time) error {
func (sc *schedule) removePeer(peerID p2p.ID) error {
peer, ok := sc.peers[peerID]
if !ok {
return fmt.Errorf("Couldn't find peer %s", peerID)
return fmt.Errorf("couldn't find peer %s", peerID)
}
if peer.state == peerStateRemoved {
return fmt.Errorf("Tried to remove peer %s in peerStateRemoved", peerID)
return fmt.Errorf("tried to remove peer %s in peerStateRemoved", peerID)
}
for height, pendingPeerID := range sc.pendingBlocks {
@ -168,15 +168,15 @@ func (sc *schedule) removePeer(peerID p2p.ID) error {
func (sc *schedule) setPeerHeight(peerID p2p.ID, height int64) error {
peer, ok := sc.peers[peerID]
if !ok {
return fmt.Errorf("Can't find peer %s", peerID)
return fmt.Errorf("can't find peer %s", peerID)
}
if peer.state == peerStateRemoved {
return fmt.Errorf("Cannot set peer height for a peer in peerStateRemoved")
return fmt.Errorf("cannot set peer height for a peer in peerStateRemoved")
}
if height < peer.height {
return fmt.Errorf("Cannot move peer height lower. from %d to %d", peer.height, height)
return fmt.Errorf("cannot move peer height lower. from %d to %d", peer.height, height)
}
peer.height = height
@ -240,20 +240,20 @@ func (sc *schedule) setStateAtHeight(height int64, state blockState) {
func (sc *schedule) markReceived(peerID p2p.ID, height int64, size int64, now time.Time) error {
peer, ok := sc.peers[peerID]
if !ok {
return fmt.Errorf("Can't find peer %s", peerID)
return fmt.Errorf("can't find peer %s", peerID)
}
if peer.state == peerStateRemoved {
return fmt.Errorf("Cannot receive blocks from removed peer %s", peerID)
return fmt.Errorf("cannot receive blocks from removed peer %s", peerID)
}
if state := sc.getStateAtHeight(height); state != blockStatePending || sc.pendingBlocks[height] != peerID {
return fmt.Errorf("Received block %d from peer %s without being requested", height, peerID)
return fmt.Errorf("received block %d from peer %s without being requested", height, peerID)
}
pendingTime, ok := sc.pendingTime[height]
if !ok || now.Sub(pendingTime) <= 0 {
return fmt.Errorf("Clock error. Block %d received at %s but requested at %s",
return fmt.Errorf("clock error. Block %d received at %s but requested at %s",
height, pendingTime, now)
}
@ -271,20 +271,20 @@ func (sc *schedule) markReceived(peerID p2p.ID, height int64, size int64, now ti
func (sc *schedule) markPending(peerID p2p.ID, height int64, time time.Time) error {
peer, ok := sc.peers[peerID]
if !ok {
return fmt.Errorf("Can't find peer %s", peerID)
return fmt.Errorf("can't find peer %s", peerID)
}
state := sc.getStateAtHeight(height)
if state != blockStateNew {
return fmt.Errorf("Block %d should be in blockStateNew but was %s", height, state)
return fmt.Errorf("block %d should be in blockStateNew but was %s", height, state)
}
if peer.state != peerStateReady {
return fmt.Errorf("Cannot schedule %d from %s in %s", height, peerID, peer.state)
return fmt.Errorf("cannot schedule %d from %s in %s", height, peerID, peer.state)
}
if height > peer.height {
return fmt.Errorf("Cannot request height %d from peer %s who is at height %d",
return fmt.Errorf("cannot request height %d from peer %s who is at height %d",
height, peerID, peer.height)
}
@ -300,7 +300,7 @@ func (sc *schedule) markPending(peerID p2p.ID, height int64, time time.Time) err
func (sc *schedule) markProcessed(height int64) error {
state := sc.getStateAtHeight(height)
if state != blockStateReceived {
return fmt.Errorf("Can't mark height %d received from block state %s", height, state)
return fmt.Errorf("can't mark height %d received from block state %s", height, state)
}
delete(sc.receivedBlocks, height)


+ 2
- 2
cmd/tendermint/commands/codec.go View File

@ -2,11 +2,11 @@ package commands
import (
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
}

+ 1
- 1
cmd/tendermint/commands/root.go View File

@ -37,7 +37,7 @@ func ParseConfig() (*cfg.Config, error) {
conf.SetRoot(conf.RootDir)
cfg.EnsureRoot(conf.RootDir)
if err = conf.ValidateBasic(); err != nil {
return nil, fmt.Errorf("Error in config file: %v", err)
return nil, fmt.Errorf("error in config file: %v", err)
}
return conf, err
}


+ 2
- 2
cmd/tendermint/commands/run_node.go View File

@ -70,7 +70,7 @@ func NewRunNodeCmd(nodeProvider nm.NodeProvider) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
n, err := nodeProvider(config, logger)
if err != nil {
return fmt.Errorf("Failed to create node: %v", err)
return fmt.Errorf("failed to create node: %v", err)
}
// Stop upon receiving SIGTERM or CTRL-C.
@ -81,7 +81,7 @@ func NewRunNodeCmd(nodeProvider nm.NodeProvider) *cobra.Command {
})
if err := n.Start(); err != nil {
return fmt.Errorf("Failed to start node: %v", err)
return fmt.Errorf("failed to start node: %v", err)
}
logger.Info("Started node", "nodeInfo", n.Switch().NodeInfo())


+ 3
- 3
consensus/mempool_test.go View File

@ -161,7 +161,7 @@ func TestMempoolRmBadTx(t *testing.T) {
checkTxRespCh <- struct{}{}
}, mempl.TxInfo{})
if err != nil {
t.Errorf("Error after CheckTx: %v", err)
t.Errorf("error after CheckTx: %v", err)
return
}
@ -182,7 +182,7 @@ func TestMempoolRmBadTx(t *testing.T) {
case <-checkTxRespCh:
// success
case <-ticker:
t.Errorf("Timed out waiting for tx to return")
t.Errorf("timed out waiting for tx to return")
return
}
@ -192,7 +192,7 @@ func TestMempoolRmBadTx(t *testing.T) {
case <-emptyMempoolCh:
// success
case <-ticker:
t.Errorf("Timed out waiting for tx to be removed")
t.Errorf("timed out waiting for tx to be removed")
return
}
}


+ 30
- 30
consensus/reactor.go View File

@ -898,8 +898,8 @@ func ReactorMetrics(metrics *Metrics) ReactorOption {
//-----------------------------------------------------------------------------
var (
ErrPeerStateHeightRegression = errors.New("Error peer state height regression")
ErrPeerStateInvalidStartTime = errors.New("Error peer state invalid startTime")
ErrPeerStateHeightRegression = errors.New("error peer state height regression")
ErrPeerStateInvalidStartTime = errors.New("error peer state invalid startTime")
)
// PeerState contains the known state of a peer, including its connection and
@ -1399,7 +1399,7 @@ func RegisterConsensusMessages(cdc *amino.Codec) {
func decodeMsg(bz []byte) (msg ConsensusMessage, err error) {
if len(bz) > maxMsgSize {
return msg, fmt.Errorf("Msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
return msg, fmt.Errorf("msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
}
err = cdc.UnmarshalBinaryBare(bz, &msg)
return
@ -1420,20 +1420,20 @@ type NewRoundStepMessage struct {
// ValidateBasic performs basic validation.
func (m *NewRoundStepMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.Round < 0 {
return errors.New("Negative Round")
return errors.New("negative Round")
}
if !m.Step.IsValid() {
return errors.New("Invalid Step")
return errors.New("invalid Step")
}
// NOTE: SecondsSinceStartTime may be negative
if (m.Height == 1 && m.LastCommitRound != -1) ||
(m.Height > 1 && m.LastCommitRound < -1) { // TODO: #2737 LastCommitRound should always be >= 0 for heights > 1
return errors.New("Invalid LastCommitRound (for 1st block: -1, for others: >= 0)")
return errors.New("invalid LastCommitRound (for 1st block: -1, for others: >= 0)")
}
return nil
}
@ -1460,19 +1460,19 @@ type NewValidBlockMessage struct {
// ValidateBasic performs basic validation.
func (m *NewValidBlockMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.Round < 0 {
return errors.New("Negative Round")
return errors.New("negative Round")
}
if err := m.BlockPartsHeader.ValidateBasic(); err != nil {
return fmt.Errorf("Wrong BlockPartsHeader: %v", err)
return fmt.Errorf("wrong BlockPartsHeader: %v", err)
}
if m.BlockParts.Size() == 0 {
return errors.New("Empty BlockParts")
}
if m.BlockParts.Size() != m.BlockPartsHeader.Total {
return fmt.Errorf("BlockParts bit array size %d not equal to BlockPartsHeader.Total %d",
return fmt.Errorf("blockParts bit array size %d not equal to BlockPartsHeader.Total %d",
m.BlockParts.Size(),
m.BlockPartsHeader.Total)
}
@ -1517,13 +1517,13 @@ type ProposalPOLMessage struct {
// ValidateBasic performs basic validation.
func (m *ProposalPOLMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.ProposalPOLRound < 0 {
return errors.New("Negative ProposalPOLRound")
return errors.New("negative ProposalPOLRound")
}
if m.ProposalPOL.Size() == 0 {
return errors.New("Empty ProposalPOL bit array")
return errors.New("empty ProposalPOL bit array")
}
if m.ProposalPOL.Size() > types.MaxVotesCount {
return errors.Errorf("ProposalPOL bit array is too big: %d, max: %d", m.ProposalPOL.Size(), types.MaxVotesCount)
@ -1548,13 +1548,13 @@ type BlockPartMessage struct {
// ValidateBasic performs basic validation.
func (m *BlockPartMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.Round < 0 {
return errors.New("Negative Round")
return errors.New("negative Round")
}
if err := m.Part.ValidateBasic(); err != nil {
return fmt.Errorf("Wrong Part: %v", err)
return fmt.Errorf("wrong Part: %v", err)
}
return nil
}
@ -1594,16 +1594,16 @@ type HasVoteMessage struct {
// ValidateBasic performs basic validation.
func (m *HasVoteMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.Round < 0 {
return errors.New("Negative Round")
return errors.New("negative Round")
}
if !types.IsVoteTypeValid(m.Type) {
return errors.New("Invalid Type")
return errors.New("invalid Type")
}
if m.Index < 0 {
return errors.New("Negative Index")
return errors.New("negative Index")
}
return nil
}
@ -1626,16 +1626,16 @@ type VoteSetMaj23Message struct {
// ValidateBasic performs basic validation.
func (m *VoteSetMaj23Message) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.Round < 0 {
return errors.New("Negative Round")
return errors.New("negative Round")
}
if !types.IsVoteTypeValid(m.Type) {
return errors.New("Invalid Type")
return errors.New("invalid Type")
}
if err := m.BlockID.ValidateBasic(); err != nil {
return fmt.Errorf("Wrong BlockID: %v", err)
return fmt.Errorf("wrong BlockID: %v", err)
}
return nil
}
@ -1659,20 +1659,20 @@ type VoteSetBitsMessage struct {
// ValidateBasic performs basic validation.
func (m *VoteSetBitsMessage) ValidateBasic() error {
if m.Height < 0 {
return errors.New("Negative Height")
return errors.New("negative Height")
}
if m.Round < 0 {
return errors.New("Negative Round")
return errors.New("negative Round")
}
if !types.IsVoteTypeValid(m.Type) {
return errors.New("Invalid Type")
return errors.New("invalid Type")
}
if err := m.BlockID.ValidateBasic(); err != nil {
return fmt.Errorf("Wrong BlockID: %v", err)
return fmt.Errorf("wrong BlockID: %v", err)
}
// NOTE: Votes.Size() can be zero if the node does not have any
if m.Votes.Size() > types.MaxVotesCount {
return fmt.Errorf("Votes bit array is too big: %d, max: %d", m.Votes.Size(), types.MaxVotesCount)
return fmt.Errorf("votes bit array is too big: %d, max: %d", m.Votes.Size(), types.MaxVotesCount)
}
return nil
}


+ 14
- 14
consensus/reactor_test.go View File

@ -608,14 +608,14 @@ func waitForBlockWithUpdatedValsAndValidateIt(
func validateBlock(block *types.Block, activeVals map[string]struct{}) error {
if block.LastCommit.Size() != len(activeVals) {
return fmt.Errorf(
"Commit size doesn't match number of active validators. Got %d, expected %d",
"commit size doesn't match number of active validators. Got %d, expected %d",
block.LastCommit.Size(),
len(activeVals))
}
for _, vote := range block.LastCommit.Precommits {
if _, ok := activeVals[string(vote.ValidatorAddress)]; !ok {
return fmt.Errorf("Found vote for unactive validator %X", vote.ValidatorAddress)
return fmt.Errorf("found vote for unactive validator %X", vote.ValidatorAddress)
}
}
return nil
@ -704,11 +704,11 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) {
expErr string
}{
{func(msg *NewValidBlockMessage) {}, ""},
{func(msg *NewValidBlockMessage) { msg.Height = -1 }, "Negative Height"},
{func(msg *NewValidBlockMessage) { msg.Round = -1 }, "Negative Round"},
{func(msg *NewValidBlockMessage) { msg.Height = -1 }, "negative Height"},
{func(msg *NewValidBlockMessage) { msg.Round = -1 }, "negative Round"},
{
func(msg *NewValidBlockMessage) { msg.BlockPartsHeader.Total = 2 },
"BlockParts bit array size 1 not equal to BlockPartsHeader.Total 2",
"blockParts bit array size 1 not equal to BlockPartsHeader.Total 2",
},
{
func(msg *NewValidBlockMessage) { msg.BlockPartsHeader.Total = 0; msg.BlockParts = cmn.NewBitArray(0) },
@ -716,7 +716,7 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) {
},
{
func(msg *NewValidBlockMessage) { msg.BlockParts = cmn.NewBitArray(types.MaxBlockPartsCount + 1) },
"BlockParts bit array size 1602 not equal to BlockPartsHeader.Total 1",
"blockParts bit array size 1602 not equal to BlockPartsHeader.Total 1",
},
}
@ -747,9 +747,9 @@ func TestProposalPOLMessageValidateBasic(t *testing.T) {
expErr string
}{
{func(msg *ProposalPOLMessage) {}, ""},
{func(msg *ProposalPOLMessage) { msg.Height = -1 }, "Negative Height"},
{func(msg *ProposalPOLMessage) { msg.ProposalPOLRound = -1 }, "Negative ProposalPOLRound"},
{func(msg *ProposalPOLMessage) { msg.ProposalPOL = cmn.NewBitArray(0) }, "Empty ProposalPOL bit array"},
{func(msg *ProposalPOLMessage) { msg.Height = -1 }, "negative Height"},
{func(msg *ProposalPOLMessage) { msg.ProposalPOLRound = -1 }, "negative ProposalPOLRound"},
{func(msg *ProposalPOLMessage) { msg.ProposalPOL = cmn.NewBitArray(0) }, "empty ProposalPOL bit array"},
{func(msg *ProposalPOLMessage) { msg.ProposalPOL = cmn.NewBitArray(types.MaxVotesCount + 1) },
"ProposalPOL bit array is too big: 10001, max: 10000"},
}
@ -893,9 +893,9 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) {
expErr string
}{
{func(msg *VoteSetBitsMessage) {}, ""},
{func(msg *VoteSetBitsMessage) { msg.Height = -1 }, "Negative Height"},
{func(msg *VoteSetBitsMessage) { msg.Round = -1 }, "Negative Round"},
{func(msg *VoteSetBitsMessage) { msg.Type = 0x03 }, "Invalid Type"},
{func(msg *VoteSetBitsMessage) { msg.Height = -1 }, "negative Height"},
{func(msg *VoteSetBitsMessage) { msg.Round = -1 }, "negative Round"},
{func(msg *VoteSetBitsMessage) { msg.Type = 0x03 }, "invalid Type"},
{func(msg *VoteSetBitsMessage) {
msg.BlockID = types.BlockID{
Hash: cmn.HexBytes{},
@ -904,9 +904,9 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) {
Hash: cmn.HexBytes{},
},
}
}, "Wrong BlockID: Wrong PartsHeader: Negative Total"},
}, "wrong BlockID: wrong PartsHeader: negative Total"},
{func(msg *VoteSetBitsMessage) { msg.Votes = cmn.NewBitArray(types.MaxVotesCount + 1) },
"Votes bit array is too big: 10001, max: 10000"},
"votes bit array is too big: 10001, max: 10000"},
}
for i, tc := range testCases {


+ 10
- 10
consensus/replay.go View File

@ -59,12 +59,12 @@ func (cs *ConsensusState) readReplayMessage(msg *TimedWALMessage, newStepSub typ
case stepMsg := <-newStepSub.Out():
m2 := stepMsg.Data().(types.EventDataRoundState)
if m.Height != m2.Height || m.Round != m2.Round || m.Step != m2.Step {
return fmt.Errorf("RoundState mismatch. Got %v; Expected %v", m2, m)
return fmt.Errorf("roundState mismatch. Got %v; Expected %v", m2, m)
}
case <-newStepSub.Cancelled():
return fmt.Errorf("Failed to read off newStepSub.Out(). newStepSub was cancelled")
return fmt.Errorf("failed to read off newStepSub.Out(). newStepSub was cancelled")
case <-ticker:
return fmt.Errorf("Failed to read off newStepSub.Out()")
return fmt.Errorf("failed to read off newStepSub.Out()")
}
}
case msgInfo:
@ -90,7 +90,7 @@ func (cs *ConsensusState) readReplayMessage(msg *TimedWALMessage, newStepSub typ
cs.Logger.Info("Replay: Timeout", "height", m.Height, "round", m.Round, "step", m.Step, "dur", m.Duration)
cs.handleTimeout(m, cs.RoundState)
default:
return fmt.Errorf("Replay: Unknown TimedWALMessage type: %v", reflect.TypeOf(msg.Msg))
return fmt.Errorf("replay: Unknown TimedWALMessage type: %v", reflect.TypeOf(msg.Msg))
}
return nil
}
@ -119,7 +119,7 @@ func (cs *ConsensusState) catchupReplay(csHeight int64) error {
}
}
if found {
return fmt.Errorf("WAL should not contain #ENDHEIGHT %d", csHeight)
return fmt.Errorf("wal should not contain #ENDHEIGHT %d", csHeight)
}
// Search for last height marker.
@ -132,7 +132,7 @@ func (cs *ConsensusState) catchupReplay(csHeight int64) error {
return err
}
if !found {
return fmt.Errorf("Cannot replay height %d. WAL does not contain #ENDHEIGHT for %d", csHeight, csHeight-1)
return fmt.Errorf("cannot replay height %d. WAL does not contain #ENDHEIGHT for %d", csHeight, csHeight-1)
}
defer gr.Close() // nolint: errcheck
@ -175,11 +175,11 @@ func makeHeightSearchFunc(height int64) auto.SearchFunc {
line = strings.TrimRight(line, "\n")
parts := strings.Split(line, " ")
if len(parts) != 2 {
return -1, errors.New("Line did not have 2 parts")
return -1, errors.New("line did not have 2 parts")
}
i, err := strconv.Atoi(parts[1])
if err != nil {
return -1, errors.New("Failed to parse INFO: " + err.Error())
return -1, errors.New("failed to parse INFO: " + err.Error())
}
if height < i {
return 1, nil
@ -243,12 +243,12 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
// Handshake is done via ABCI Info on the query conn.
res, err := proxyApp.Query().InfoSync(proxy.RequestInfo)
if err != nil {
return fmt.Errorf("Error calling Info: %v", err)
return fmt.Errorf("error calling Info: %v", err)
}
blockHeight := res.LastBlockHeight
if blockHeight < 0 {
return fmt.Errorf("Got a negative last block height (%d) from the app", blockHeight)
return fmt.Errorf("got a negative last block height (%d) from the app", blockHeight)
}
appHash := res.LastBlockAppHash


+ 1
- 1
consensus/replay_test.go View File

@ -932,7 +932,7 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) {
return nil, nil, err
}
if !found {
return nil, nil, fmt.Errorf("WAL does not contain height %d", height)
return nil, nil, fmt.Errorf("wal does not contain height %d", height)
}
defer gr.Close() // nolint: errcheck


+ 6
- 6
consensus/state.go View File

@ -27,10 +27,10 @@ import (
// Errors
var (
ErrInvalidProposalSignature = errors.New("Error invalid proposal signature")
ErrInvalidProposalPOLRound = errors.New("Error invalid proposal POL round")
ErrAddingVote = errors.New("Error adding vote")
ErrVoteHeightMismatch = errors.New("Error vote height mismatch")
ErrInvalidProposalSignature = errors.New("error invalid proposal signature")
ErrInvalidProposalPOLRound = errors.New("error invalid proposal POL round")
ErrAddingVote = errors.New("error adding vote")
ErrVoteHeightMismatch = errors.New("error vote height mismatch")
)
//-----------------------------------------------------------------------------
@ -969,8 +969,8 @@ func (cs *ConsensusState) defaultDecideProposal(height int64, round int) {
cs.wal.FlushAndSync()
// Make proposal
propBlockId := types.BlockID{Hash: block.Hash(), PartsHeader: blockParts.Header()}
proposal := types.NewProposal(height, round, cs.ValidRound, propBlockId)
propBlockID := types.BlockID{Hash: block.Hash(), PartsHeader: blockParts.Header()}
proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID)
if err := cs.privValidator.SignProposal(cs.state.ChainID, proposal); err == nil {
// send proposal and block parts on internal msg queue


+ 2
- 2
consensus/state_test.go View File

@ -1594,7 +1594,7 @@ func TestStateOutputsBlockPartsStats(t *testing.T) {
select {
case <-cs.statsMsgQueue:
t.Errorf("Should not output stats message after receiving the known block part!")
t.Errorf("should not output stats message after receiving the known block part!")
case <-time.After(50 * time.Millisecond):
}
@ -1625,7 +1625,7 @@ func TestStateOutputVoteStats(t *testing.T) {
select {
case <-cs.statsMsgQueue:
t.Errorf("Should not output stats message after receiving the known vote or vote from bigger height")
t.Errorf("should not output stats message after receiving the known vote or vote from bigger height")
case <-time.After(50 * time.Millisecond):
}


+ 11
- 10
consensus/types/height_vote_set.go View File

@ -16,8 +16,9 @@ type RoundVoteSet struct {
}
var (
GotVoteFromUnwantedRoundError = errors.New(
"Peer has sent a vote that does not match our round for more than one round")
ErrGotVoteFromUnwantedRound = errors.New(
"peer has sent a vote that does not match our round for more than one round",
)
)
/*
@ -123,7 +124,7 @@ func (hvs *HeightVoteSet) AddVote(vote *types.Vote, peerID p2p.ID) (added bool,
hvs.peerCatchupRounds[peerID] = append(rndz, vote.Round)
} else {
// punish peer
err = GotVoteFromUnwantedRoundError
err = ErrGotVoteFromUnwantedRound
return
}
}
@ -158,18 +159,18 @@ func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID types.BlockID) {
return -1, types.BlockID{}
}
func (hvs *HeightVoteSet) getVoteSet(round int, type_ types.SignedMsgType) *types.VoteSet {
func (hvs *HeightVoteSet) getVoteSet(round int, voteType types.SignedMsgType) *types.VoteSet {
rvs, ok := hvs.roundVoteSets[round]
if !ok {
return nil
}
switch type_ {
switch voteType {
case types.PrevoteType:
return rvs.Prevotes
case types.PrecommitType:
return rvs.Precommits
default:
panic(fmt.Sprintf("Unexpected vote type %X", type_))
panic(fmt.Sprintf("Unexpected vote type %X", voteType))
}
}
@ -179,15 +180,15 @@ func (hvs *HeightVoteSet) getVoteSet(round int, type_ types.SignedMsgType) *type
// TODO: implement ability to remove peers too
func (hvs *HeightVoteSet) SetPeerMaj23(
round int,
type_ types.SignedMsgType,
voteType types.SignedMsgType,
peerID p2p.ID,
blockID types.BlockID) error {
hvs.mtx.Lock()
defer hvs.mtx.Unlock()
if !types.IsVoteTypeValid(type_) {
return fmt.Errorf("SetPeerMaj23: Invalid vote type %v", type_)
if !types.IsVoteTypeValid(voteType) {
return fmt.Errorf("setPeerMaj23: Invalid vote type %X", voteType)
}
voteSet := hvs.getVoteSet(round, type_)
voteSet := hvs.getVoteSet(round, voteType)
if voteSet == nil {
return nil // something we don't know about yet
}


+ 2
- 2
consensus/types/height_vote_set_test.go View File

@ -38,8 +38,8 @@ func TestPeerCatchupRounds(t *testing.T) {
vote1001_0 := makeVoteHR(t, 1, 1001, privVals, 0)
added, err = hvs.AddVote(vote1001_0, "peer1")
if err != GotVoteFromUnwantedRoundError {
t.Errorf("Expected GotVoteFromUnwantedRoundError, but got %v", err)
if err != ErrGotVoteFromUnwantedRound {
t.Errorf("expected GotVoteFromUnwantedRoundError, but got %v", err)
}
if added {
t.Error("Expected to *not* add vote from peer, too many catchup rounds.")


+ 8
- 8
consensus/types/peer_round_state.go View File

@ -70,19 +70,19 @@ func (prs PeerRoundState) StringIndented(indent string) string {
// These methods are for Protobuf Compatibility
// Size returns the size of the amino encoding, in bytes.
func (ps *PeerRoundState) Size() int {
bs, _ := ps.Marshal()
func (prs *PeerRoundState) Size() int {
bs, _ := prs.Marshal()
return len(bs)
}
// Marshal returns the amino encoding.
func (ps *PeerRoundState) Marshal() ([]byte, error) {
return cdc.MarshalBinaryBare(ps)
func (prs *PeerRoundState) Marshal() ([]byte, error) {
return cdc.MarshalBinaryBare(prs)
}
// MarshalTo calls Marshal and copies to the given buffer.
func (ps *PeerRoundState) MarshalTo(data []byte) (int, error) {
bs, err := ps.Marshal()
func (prs *PeerRoundState) MarshalTo(data []byte) (int, error) {
bs, err := prs.Marshal()
if err != nil {
return -1, err
}
@ -90,6 +90,6 @@ func (ps *PeerRoundState) MarshalTo(data []byte) (int, error) {
}
// Unmarshal deserializes from amino encoded form.
func (ps *PeerRoundState) Unmarshal(bs []byte) error {
return cdc.UnmarshalBinaryBare(bs, ps)
func (prs *PeerRoundState) Unmarshal(bs []byte) error {
return cdc.UnmarshalBinaryBare(bs, prs)
}

+ 2
- 2
consensus/types/round_state.go View File

@ -139,7 +139,7 @@ func (rs *RoundState) NewRoundEvent() types.EventDataNewRound {
func (rs *RoundState) CompleteProposalEvent() types.EventDataCompleteProposal {
// We must construct BlockID from ProposalBlock and ProposalBlockParts
// cs.Proposal is not guaranteed to be set when this function is called
blockId := types.BlockID{
blockID := types.BlockID{
Hash: rs.ProposalBlock.Hash(),
PartsHeader: rs.ProposalBlockParts.Header(),
}
@ -148,7 +148,7 @@ func (rs *RoundState) CompleteProposalEvent() types.EventDataCompleteProposal {
Height: rs.Height,
Round: rs.Round,
Step: rs.Step.String(),
BlockID: blockId,
BlockID: blockID,
}
}


+ 1
- 1
crypto/encoding/amino/amino.go View File

@ -1,4 +1,4 @@
package cryptoAmino
package cryptoamino
import (
"reflect"


+ 1
- 1
crypto/encoding/amino/encode_test.go View File

@ -1,4 +1,4 @@
package cryptoAmino
package cryptoamino
import (
"os"


+ 4
- 4
crypto/merkle/proof.go View File

@ -44,11 +44,11 @@ func (poz ProofOperators) Verify(root []byte, keypath string, args [][]byte) (er
key := op.GetKey()
if len(key) != 0 {
if len(keys) == 0 {
return errors.Errorf("Key path has insufficient # of parts: expected no more keys but got %+v", string(key))
return errors.Errorf("key path has insufficient # of parts: expected no more keys but got %+v", string(key))
}
lastKey := keys[len(keys)-1]
if !bytes.Equal(lastKey, key) {
return errors.Errorf("Key mismatch on operation #%d: expected %+v but got %+v", i, string(lastKey), string(key))
return errors.Errorf("key mismatch on operation #%d: expected %+v but got %+v", i, string(lastKey), string(key))
}
keys = keys[:len(keys)-1]
}
@ -58,10 +58,10 @@ func (poz ProofOperators) Verify(root []byte, keypath string, args [][]byte) (er
}
}
if !bytes.Equal(root, args[0]) {
return errors.Errorf("Calculated root hash is invalid: expected %+v but got %+v", root, args[0])
return errors.Errorf("calculated root hash is invalid: expected %+v but got %+v", root, args[0])
}
if len(keys) != 0 {
return errors.New("Keypath not consumed all")
return errors.New("keypath not consumed all")
}
return nil
}


+ 2
- 2
crypto/merkle/proof_test.go View File

@ -50,10 +50,10 @@ func (dop DominoOp) ProofOp() ProofOp {
func (dop DominoOp) Run(input [][]byte) (output [][]byte, err error) {
if len(input) != 1 {
return nil, errors.New("Expected input of length 1")
return nil, errors.New("expected input of length 1")
}
if string(input[0]) != dop.Input {
return nil, errors.Errorf("Expected input %v, got %v",
return nil, errors.Errorf("expected input %v, got %v",
dop.Input, string(input[0]))
}
return [][]byte{[]byte(dop.Output)}, nil


+ 3
- 3
crypto/merkle/rfc6962_test.go View File

@ -77,7 +77,7 @@ func TestRFC6962HasherCollisions(t *testing.T) {
_, leafHashTrail = trailsFromByteSlices([][]byte{leaf2})
hash2 := leafHashTrail.Hash
if bytes.Equal(hash1, hash2) {
t.Errorf("Leaf hashes should differ, but both are %x", hash1)
t.Errorf("leaf hashes should differ, but both are %x", hash1)
}
// Compute an intermediate subtree hash.
_, subHash1Trail := trailsFromByteSlices([][]byte{hash1, hash2})
@ -87,12 +87,12 @@ func TestRFC6962HasherCollisions(t *testing.T) {
_, forgedHashTrail := trailsFromByteSlices([][]byte{preimage})
forgedHash := forgedHashTrail.Hash
if bytes.Equal(subHash1, forgedHash) {
t.Errorf("Hasher is not second-preimage resistant")
t.Errorf("hasher is not second-preimage resistant")
}
// Swap the order of nodes and check that the hash is different.
_, subHash2Trail := trailsFromByteSlices([][]byte{hash2, hash1})
subHash2 := subHash2Trail.Hash
if bytes.Equal(subHash1, subHash2) {
t.Errorf("Subtree hash does not depend on the order of leaves")
t.Errorf("subtree hash does not depend on the order of leaves")
}
}

+ 2
- 2
crypto/merkle/simple_proof.go View File

@ -76,10 +76,10 @@ func SimpleProofsFromMap(m map[string][]byte) (rootHash []byte, proofs map[strin
func (sp *SimpleProof) Verify(rootHash []byte, leaf []byte) error {
leafHash := leafHash(leaf)
if sp.Total < 0 {
return errors.New("Proof total must be positive")
return errors.New("proof total must be positive")
}
if sp.Index < 0 {
return errors.New("Proof index cannot be negative")
return errors.New("proof index cannot be negative")
}
if !bytes.Equal(sp.LeafHash, leafHash) {
return errors.Errorf("invalid leaf hash: wanted %X got %X", leafHash, sp.LeafHash)


+ 1
- 1
crypto/multisig/bitarray/compact_bit_array.go View File

@ -176,7 +176,7 @@ func (bA *CompactBitArray) UnmarshalJSON(bz []byte) error {
// Validate 'b'.
match := bitArrayJSONRegexp.FindStringSubmatch(b)
if match == nil {
return fmt.Errorf("BitArray in JSON should be a string of format %q but got %s", bitArrayJSONRegexp.String(), b)
return fmt.Errorf("bitArray in JSON should be a string of format %q but got %s", bitArrayJSONRegexp.String(), b)
}
bits := match[1]


+ 3
- 3
crypto/xchacha20poly1305/vector_test.go View File

@ -27,7 +27,7 @@ func TestHChaCha20(t *testing.T) {
HChaCha20(&key, &nonce, &key)
if !bytes.Equal(key[:], v.keystream) {
t.Errorf("Test %d: keystream mismatch:\n \t got: %s\n \t want: %s", i, toHex(key[:]), toHex(v.keystream))
t.Errorf("test %d: keystream mismatch:\n \t got: %s\n \t want: %s", i, toHex(key[:]), toHex(v.keystream))
}
}
}
@ -78,14 +78,14 @@ func TestVectors(t *testing.T) {
dst := aead.Seal(nil, nonce[:], v.plaintext, v.ad)
if !bytes.Equal(dst, v.ciphertext) {
t.Errorf("Test %d: ciphertext mismatch:\n \t got: %s\n \t want: %s", i, toHex(dst), toHex(v.ciphertext))
t.Errorf("test %d: ciphertext mismatch:\n \t got: %s\n \t want: %s", i, toHex(dst), toHex(v.ciphertext))
}
open, err := aead.Open(nil, nonce[:], dst, v.ad)
if err != nil {
t.Error(err)
}
if !bytes.Equal(open, v.plaintext) {
t.Errorf("Test %d: plaintext mismatch:\n \t got: %s\n \t want: %s", i, string(open), string(v.plaintext))
t.Errorf("test %d: plaintext mismatch:\n \t got: %s\n \t want: %s", i, string(open), string(v.plaintext))
}
}
}


+ 5
- 5
crypto/xchacha20poly1305/xchachapoly_test.go View File

@ -37,12 +37,12 @@ func TestRandom(t *testing.T) {
plaintext2, err := aead.Open(nil, nonce[:], ct, ad)
if err != nil {
t.Errorf("Random #%d: Open failed", i)
t.Errorf("random #%d: Open failed", i)
continue
}
if !bytes.Equal(plaintext, plaintext2) {
t.Errorf("Random #%d: plaintext's don't match: got %x vs %x", i, plaintext2, plaintext)
t.Errorf("random #%d: plaintext's don't match: got %x vs %x", i, plaintext2, plaintext)
continue
}
@ -50,7 +50,7 @@ func TestRandom(t *testing.T) {
alterAdIdx := mr.Intn(len(ad))
ad[alterAdIdx] ^= 0x80
if _, err := aead.Open(nil, nonce[:], ct, ad); err == nil {
t.Errorf("Random #%d: Open was successful after altering additional data", i)
t.Errorf("random #%d: Open was successful after altering additional data", i)
}
ad[alterAdIdx] ^= 0x80
}
@ -58,14 +58,14 @@ func TestRandom(t *testing.T) {
alterNonceIdx := mr.Intn(aead.NonceSize())
nonce[alterNonceIdx] ^= 0x80
if _, err := aead.Open(nil, nonce[:], ct, ad); err == nil {
t.Errorf("Random #%d: Open was successful after altering nonce", i)
t.Errorf("random #%d: Open was successful after altering nonce", i)
}
nonce[alterNonceIdx] ^= 0x80
alterCtIdx := mr.Intn(len(ct))
ct[alterCtIdx] ^= 0x80
if _, err := aead.Open(nil, nonce[:], ct, ad); err == nil {
t.Errorf("Random #%d: Open was successful after altering ciphertext", i)
t.Errorf("random #%d: Open was successful after altering ciphertext", i)
}
ct[alterCtIdx] ^= 0x80
}


+ 2
- 2
crypto/xsalsa20symmetric/symmetric.go View File

@ -38,7 +38,7 @@ func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err e
panic(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret)))
}
if len(ciphertext) <= secretbox.Overhead+nonceLen {
return nil, errors.New("Ciphertext is too short")
return nil, errors.New("ciphertext is too short")
}
nonce := ciphertext[:nonceLen]
nonceArr := [nonceLen]byte{}
@ -48,7 +48,7 @@ func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err e
plaintext = make([]byte, len(ciphertext)-nonceLen-secretbox.Overhead)
_, ok := secretbox.Open(plaintext[:0], ciphertext[nonceLen:], &nonceArr, &secretArr)
if !ok {
return nil, errors.New("Ciphertext decryption failed")
return nil, errors.New("ciphertext decryption failed")
}
return plaintext, nil
}

+ 2
- 2
docs/spec/scripts/crypto.go View File

@ -5,12 +5,12 @@ import (
"os"
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
)
func main() {
cdc := amino.NewCodec()
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
cdc.PrintTypes(os.Stdout)
fmt.Println("")
}

+ 2
- 2
evidence/codec.go View File

@ -2,7 +2,7 @@ package evidence
import (
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/types"
)
@ -10,7 +10,7 @@ var cdc = amino.NewCodec()
func init() {
RegisterEvidenceMessages(cdc)
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
types.RegisterEvidences(cdc)
}


+ 2
- 2
evidence/reactor.go View File

@ -218,7 +218,7 @@ func RegisterEvidenceMessages(cdc *amino.Codec) {
func decodeMsg(bz []byte) (msg EvidenceMessage, err error) {
if len(bz) > maxMsgSize {
return msg, fmt.Errorf("Msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
return msg, fmt.Errorf("msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
}
err = cdc.UnmarshalBinaryBare(bz, &msg)
return
@ -235,7 +235,7 @@ type EvidenceListMessage struct {
func (m *EvidenceListMessage) ValidateBasic() error {
for i, ev := range m.Evidence {
if err := ev.ValidateBasic(); err != nil {
return fmt.Errorf("Invalid evidence (#%d): %v", i, err)
return fmt.Errorf("invalid evidence (#%d): %v", i, err)
}
}
return nil


+ 9
- 9
evidence/reactor_test.go View File

@ -66,7 +66,7 @@ func waitForEvidence(t *testing.T, evs types.EvidenceList, reactors []*EvidenceR
close(done)
}()
timer := time.After(TIMEOUT)
timer := time.After(Timeout)
select {
case <-timer:
t.Fatal("Timed out waiting for evidence")
@ -115,8 +115,8 @@ func sendEvidence(t *testing.T, evpool *EvidencePool, valAddr []byte, n int) typ
}
var (
NUM_EVIDENCE = 10
TIMEOUT = 120 * time.Second // ridiculously high because CircleCI is slow
NumEvidence = 10
Timeout = 120 * time.Second // ridiculously high because CircleCI is slow
)
func TestReactorBroadcastEvidence(t *testing.T) {
@ -127,7 +127,7 @@ func TestReactorBroadcastEvidence(t *testing.T) {
stateDBs := make([]dbm.DB, N)
valAddr := []byte("myval")
// we need validators saved for heights at least as high as we have evidence for
height := int64(NUM_EVIDENCE) + 10
height := int64(NumEvidence) + 10
for i := 0; i < N; i++ {
stateDBs[i] = initializeValidatorState(valAddr, height)
}
@ -145,7 +145,7 @@ func TestReactorBroadcastEvidence(t *testing.T) {
// send a bunch of valid evidence to the first reactor's evpool
// and wait for them all to be received in the others
evList := sendEvidence(t, reactors[0].evpool, valAddr, NUM_EVIDENCE)
evList := sendEvidence(t, reactors[0].evpool, valAddr, NumEvidence)
waitForEvidence(t, evList, reactors)
}
@ -161,8 +161,8 @@ func TestReactorSelectiveBroadcast(t *testing.T) {
config := cfg.TestConfig()
valAddr := []byte("myval")
height1 := int64(NUM_EVIDENCE) + 10
height2 := int64(NUM_EVIDENCE) / 2
height1 := int64(NumEvidence) + 10
height2 := int64(NumEvidence) / 2
// DB1 is ahead of DB2
stateDB1 := initializeValidatorState(valAddr, height1)
@ -185,10 +185,10 @@ func TestReactorSelectiveBroadcast(t *testing.T) {
peer.Set(types.PeerStateKey, ps)
// send a bunch of valid evidence to the first reactor's evpool
evList := sendEvidence(t, reactors[0].evpool, valAddr, NUM_EVIDENCE)
evList := sendEvidence(t, reactors[0].evpool, valAddr, NumEvidence)
// only ones less than the peers height should make it through
waitForEvidence(t, evList[:NUM_EVIDENCE/2], reactors[1:2])
waitForEvidence(t, evList[:NumEvidence/2], reactors[1:2])
// peers should still be connected
peers := reactors[1].Switch.Peers().List()


+ 2
- 2
libs/autofile/autofile_test.go View File

@ -50,10 +50,10 @@ func TestSIGHUP(t *testing.T) {
// Both files should exist
if body := cmn.MustReadFile(name + "_old"); string(body) != "Line 1\nLine 2\n" {
t.Errorf("Unexpected body %s", body)
t.Errorf("unexpected body %s", body)
}
if body := cmn.MustReadFile(name); string(body) != "Line 3\nLine 4\n" {
t.Errorf("Unexpected body %s", body)
t.Errorf("unexpected body %s", body)
}
}


+ 2
- 2
libs/autofile/group_test.go View File

@ -118,14 +118,14 @@ func TestRotateFile(t *testing.T) {
body1, err := ioutil.ReadFile(g.Head.Path + ".000")
assert.NoError(t, err, "Failed to read first rolled file")
if string(body1) != "Line 1\nLine 2\nLine 3\n" {
t.Errorf("Got unexpected contents: [%v]", string(body1))
t.Errorf("got unexpected contents: [%v]", string(body1))
}
// Read g.Head.Path
body2, err := ioutil.ReadFile(g.Head.Path)
assert.NoError(t, err, "Failed to read first rolled file")
if string(body2) != "Line 4\nLine 5\nLine 6\n" {
t.Errorf("Got unexpected contents: [%v]", string(body2))
t.Errorf("got unexpected contents: [%v]", string(body2))
}
// Cleanup


+ 3
- 3
libs/cli/flags/log_level.go View File

@ -21,7 +21,7 @@ const (
// ParseLogLevel("consensus:debug,mempool:debug,*:error", log.NewTMLogger(os.Stdout), "info")
func ParseLogLevel(lvl string, logger log.Logger, defaultLogLevelValue string) (log.Logger, error) {
if lvl == "" {
return nil, errors.New("Empty log level")
return nil, errors.New("empty log level")
}
l := lvl
@ -42,7 +42,7 @@ func ParseLogLevel(lvl string, logger log.Logger, defaultLogLevelValue string) (
moduleAndLevel := strings.Split(item, ":")
if len(moduleAndLevel) != 2 {
return nil, fmt.Errorf("Expected list in a form of \"module:level\" pairs, given pair %s, list %s", item, list)
return nil, fmt.Errorf("expected list in a form of \"module:level\" pairs, given pair %s, list %s", item, list)
}
module := moduleAndLevel[0]
@ -67,7 +67,7 @@ func ParseLogLevel(lvl string, logger log.Logger, defaultLogLevelValue string) (
option = log.AllowNoneWith("module", module)
default:
return nil,
fmt.Errorf("Expected either \"info\", \"debug\", \"error\" or \"none\" log level, given %s (pair %s, list %s)",
fmt.Errorf("expected either \"info\", \"debug\", \"error\" or \"none\" log level, given %s (pair %s, list %s)",
level,
item,
list)


+ 1
- 1
libs/cli/setup.go View File

@ -151,7 +151,7 @@ func validateOutput(cmd *cobra.Command, args []string) error {
switch output {
case "text", "json":
default:
return errors.Errorf("Unsupported output format: %s", output)
return errors.Errorf("unsupported output format: %s", output)
}
return nil
}

+ 2
- 2
libs/clist/clist_test.go View File

@ -109,7 +109,7 @@ func _TestGCFifo(t *testing.T) {
_ = done
if *gcCount != numElements {
t.Errorf("Expected gcCount to be %v, got %v", numElements,
t.Errorf("expected gcCount to be %v, got %v", numElements,
*gcCount)
}
}
@ -157,7 +157,7 @@ func _TestGCRandom(t *testing.T) {
time.Sleep(time.Second * 3)
if gcCount != numElements {
t.Errorf("Expected gcCount to be %v, got %v", numElements,
t.Errorf("expected gcCount to be %v, got %v", numElements,
gcCount)
}
}


+ 2
- 2
libs/common/async.go View File

@ -10,7 +10,7 @@ import (
// val: the value returned after task execution.
// err: the error returned during task completion.
// abort: tells Parallel to return, whether or not all tasks have completed.
type Task func(i int) (val interface{}, err error, abort bool)
type Task func(i int) (val interface{}, abort bool, err error)
type TaskResult struct {
Value interface{}
@ -150,7 +150,7 @@ func Parallel(tasks ...Task) (trs *TaskResultSet, ok bool) {
}
}()
// Run the task.
var val, err, abort = task(i)
var val, abort, err = task(i)
// Send val/err to taskResultCh.
// NOTE: Below this line, nothing must panic/
taskResultCh <- TaskResult{val, err}


+ 15
- 15
libs/common/async_test.go View File

@ -16,9 +16,9 @@ func TestParallel(t *testing.T) {
var counter = new(int32)
var tasks = make([]Task, 100*1000)
for i := 0; i < len(tasks); i++ {
tasks[i] = func(i int) (res interface{}, err error, abort bool) {
tasks[i] = func(i int) (res interface{}, abort bool, err error) {
atomic.AddInt32(counter, 1)
return -1 * i, nil, false
return -1 * i, false, nil
}
}
@ -60,25 +60,25 @@ func TestParallelAbort(t *testing.T) {
// Create tasks.
var tasks = []Task{
func(i int) (res interface{}, err error, abort bool) {
func(i int) (res interface{}, abort bool, err error) {
assert.Equal(t, i, 0)
flow1 <- struct{}{}
return 0, nil, false
return 0, false, nil
},
func(i int) (res interface{}, err error, abort bool) {
func(i int) (res interface{}, abort bool, err error) {
assert.Equal(t, i, 1)
flow2 <- <-flow1
return 1, errors.New("some error"), false
return 1, false, errors.New("some error")
},
func(i int) (res interface{}, err error, abort bool) {
func(i int) (res interface{}, abort bool, err error) {
assert.Equal(t, i, 2)
flow3 <- <-flow2
return 2, nil, true
return 2, true, nil
},
func(i int) (res interface{}, err error, abort bool) {
func(i int) (res interface{}, abort bool, err error) {
assert.Equal(t, i, 3)
<-flow4
return 3, nil, false
return 3, false, nil
},
}
@ -107,13 +107,13 @@ func TestParallelRecover(t *testing.T) {
// Create tasks.
var tasks = []Task{
func(i int) (res interface{}, err error, abort bool) {
return 0, nil, false
func(i int) (res interface{}, abort bool, err error) {
return 0, false, nil
},
func(i int) (res interface{}, err error, abort bool) {
return 1, errors.New("some error"), false
func(i int) (res interface{}, abort bool, err error) {
return 1, false, errors.New("some error")
},
func(i int) (res interface{}, err error, abort bool) {
func(i int) (res interface{}, abort bool, err error) {
panic(2)
},
}


+ 1
- 1
libs/common/bit_array.go View File

@ -400,7 +400,7 @@ func (bA *BitArray) UnmarshalJSON(bz []byte) error {
// Validate 'b'.
match := bitArrayJSONRegexp.FindStringSubmatch(b)
if match == nil {
return fmt.Errorf("BitArray in JSON should be a string of format %q but got %s", bitArrayJSONRegexp.String(), b)
return fmt.Errorf("bitArray in JSON should be a string of format %q but got %s", bitArrayJSONRegexp.String(), b)
}
bits := match[1]


+ 1
- 1
libs/common/bytes.go View File

@ -33,7 +33,7 @@ func (bz HexBytes) MarshalJSON() ([]byte, error) {
// This is the point of Bytes.
func (bz *HexBytes) UnmarshalJSON(data []byte) error {
if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
return fmt.Errorf("Invalid hex string: %s", data)
return fmt.Errorf("invalid hex string: %s", data)
}
bz2, err := hex.DecodeString(string(data[1 : len(data)-1]))
if err != nil {


+ 1
- 1
libs/common/os.go View File

@ -46,7 +46,7 @@ func EnsureDir(dir string, mode os.FileMode) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, mode)
if err != nil {
return fmt.Errorf("Could not create directory %v. %v", dir, err)
return fmt.Errorf("could not create directory %v. %v", dir, err)
}
}
return nil


+ 1
- 1
libs/common/random_test.go View File

@ -46,7 +46,7 @@ func TestDeterminism(t *testing.T) {
if i == 0 {
firstOutput = output
} else if firstOutput != output {
t.Errorf("Run #%d's output was different from first run.\nfirst: %v\nlast: %v",
t.Errorf("run #%d's output was different from first run.\nfirst: %v\nlast: %v",
i, firstOutput, output)
}
}


+ 1
- 1
libs/common/tempfile.go View File

@ -108,7 +108,7 @@ func WriteFileAtomic(filename string, data []byte, perm os.FileMode) (err error)
break
}
if i == atomicWriteFileMaxNumWriteAttempts {
return fmt.Errorf("Could not create atomic write file after %d attempts", i)
return fmt.Errorf("could not create atomic write file after %d attempts", i)
}
// Clean up in any case. Defer stacking order is last-in-first-out.


+ 6
- 6
libs/events/events_test.go View File

@ -29,7 +29,7 @@ func TestAddListenerForEventFireOnce(t *testing.T) {
go evsw.FireEvent("event", "data")
received := <-messages
if received != "data" {
t.Errorf("Message received does not match: %v", received)
t.Errorf("message received does not match: %v", received)
}
}
@ -57,7 +57,7 @@ func TestAddListenerForEventFireMany(t *testing.T) {
close(numbers)
eventSum := <-doneSum
if checkSum != eventSum {
t.Errorf("Not all messages sent were received.\n")
t.Errorf("not all messages sent were received.\n")
}
}
@ -101,7 +101,7 @@ func TestAddListenerForDifferentEvents(t *testing.T) {
close(numbers)
eventSum := <-doneSum
if checkSum != eventSum {
t.Errorf("Not all messages sent were received.\n")
t.Errorf("not all messages sent were received.\n")
}
}
@ -162,7 +162,7 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) {
eventSum2 := <-doneSum2
if checkSum1 != eventSum1 ||
checkSum2 != eventSum2 {
t.Errorf("Not all messages sent were received for different listeners to different events.\n")
t.Errorf("not all messages sent were received for different listeners to different events.\n")
}
}
@ -255,7 +255,7 @@ func TestAddAndRemoveListener(t *testing.T) {
// correct value asserted by preceding tests, suffices to be non-zero
checkSumEvent2 == uint64(0) ||
eventSum2 != uint64(0) {
t.Errorf("Not all messages sent were received or unsubscription did not register.\n")
t.Errorf("not all messages sent were received or unsubscription did not register.\n")
}
}
@ -390,7 +390,7 @@ func TestRemoveListenersAsync(t *testing.T) {
eventSum2 := <-doneSum2
if checkSum != eventSum1 ||
checkSum != eventSum2 {
t.Errorf("Not all messages sent were received.\n")
t.Errorf("not all messages sent were received.\n")
}
}


+ 1
- 1
libs/log/filter.go View File

@ -141,7 +141,7 @@ func AllowLevel(lvl string) (Option, error) {
case "none":
return AllowNone(), nil
default:
return nil, fmt.Errorf("Expected either \"info\", \"debug\", \"error\" or \"none\" level, given %s", lvl)
return nil, fmt.Errorf("expected either \"info\", \"debug\", \"error\" or \"none\" level, given %s", lvl)
}
}


+ 1
- 1
libs/log/tm_logger_test.go View File

@ -16,7 +16,7 @@ func TestLoggerLogsItsErrors(t *testing.T) {
logger.Info("foo", "baz baz", "bar")
msg := strings.TrimSpace(buf.String())
if !strings.Contains(msg, "foo") {
t.Errorf("Expected logger msg to contain ErrInvalidKey, got %s", msg)
t.Errorf("expected logger msg to contain ErrInvalidKey, got %s", msg)
}
}


+ 2
- 2
libs/log/tracing_logger_test.go View File

@ -17,8 +17,8 @@ func TestTracingLogger(t *testing.T) {
logger := log.NewTMJSONLogger(&buf)
logger1 := log.NewTracingLogger(logger)
err1 := errors.New("Courage is grace under pressure.")
err2 := errors.New("It does not matter how slowly you go, so long as you do not stop.")
err1 := errors.New("courage is grace under pressure.")
err2 := errors.New("it does not matter how slowly you go, so long as you do not stop.")
logger1.With("err1", err1).Info("foo", "err2", err2)
want := strings.Replace(


+ 1
- 1
libs/pubsub/pubsub_test.go View File

@ -427,7 +427,7 @@ func assertReceive(t *testing.T, expected interface{}, ch <-chan pubsub.Message,
case actual := <-ch:
assert.Equal(t, expected, actual.Data(), msgAndArgs...)
case <-time.After(1 * time.Second):
t.Errorf("Expected to receive %v from the channel, got nothing after 1s", expected)
t.Errorf("expected to receive %v from the channel, got nothing after 1s", expected)
debug.PrintStack()
}
}


+ 2
- 2
lite/dbprovider.go View File

@ -6,7 +6,7 @@ import (
"strconv"
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
log "github.com/tendermint/tendermint/libs/log"
lerr "github.com/tendermint/tendermint/lite/errors"
"github.com/tendermint/tendermint/types"
@ -30,7 +30,7 @@ func NewDBProvider(label string, db dbm.DB) *DBProvider {
//db = dbm.NewDebugDB("db provider "+cmn.RandStr(4), db)
cdc := amino.NewCodec()
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
dbp := &DBProvider{
logger: log.NewNopLogger(),
label: label,


+ 3
- 3
lite/proxy/block.go View File

@ -24,7 +24,7 @@ func ValidateBlock(meta *types.Block, sh types.SignedHeader) error {
return err
}
if !bytes.Equal(meta.Data.Hash(), meta.Header.DataHash) {
return errors.New("Data hash doesn't match header")
return errors.New("data hash doesn't match header")
}
return nil
}
@ -38,11 +38,11 @@ func ValidateHeader(head *types.Header, sh types.SignedHeader) error {
}
// Make sure they are for the same height (obvious fail).
if head.Height != sh.Height {
return errors.New("Header heights mismatched")
return errors.New("header heights mismatched")
}
// Check if they are equal by using hashes.
if !bytes.Equal(head.Hash(), sh.Hash()) {
return errors.New("Headers don't match")
return errors.New("headers don't match")
}
return nil
}

+ 8
- 8
lite/proxy/validate_test.go View File

@ -40,7 +40,7 @@ func TestValidateBlock(t *testing.T) {
{
block: &types.Block{Header: types.Header{Height: 10}},
signedHeader: types.SignedHeader{Header: &types.Header{Height: 11}},
wantErr: "Header heights mismatched",
wantErr: "header heights mismatched",
},
{
@ -53,7 +53,7 @@ func TestValidateBlock(t *testing.T) {
{
block: &types.Block{Header: hdrHeight11},
signedHeader: types.SignedHeader{Header: &types.Header{Height: 11}},
wantErr: "Headers don't match",
wantErr: "headers don't match",
},
{
@ -72,7 +72,7 @@ func TestValidateBlock(t *testing.T) {
Header: &types.Header{Height: 11},
Commit: types.NewCommit(types.BlockID{Hash: []byte("0xDEADBEEF")}, nil),
},
wantErr: "Data hash doesn't match header",
wantErr: "data hash doesn't match header",
},
{
block: &types.Block{
@ -119,7 +119,7 @@ func TestValidateBlockMeta(t *testing.T) {
{
meta: &types.BlockMeta{Header: types.Header{Height: 10}},
signedHeader: types.SignedHeader{Header: &types.Header{Height: 11}},
wantErr: "Header heights mismatched",
wantErr: "header heights mismatched",
},
{
@ -132,7 +132,7 @@ func TestValidateBlockMeta(t *testing.T) {
{
meta: &types.BlockMeta{Header: hdrHeight11},
signedHeader: types.SignedHeader{Header: &types.Header{Height: 11}},
wantErr: "Headers don't match",
wantErr: "headers don't match",
},
{
@ -152,7 +152,7 @@ func TestValidateBlockMeta(t *testing.T) {
signedHeader: types.SignedHeader{
Header: &types.Header{Height: 11, DataHash: deadBeefHash},
},
wantErr: "Headers don't match",
wantErr: "headers don't match",
},
{
@ -171,7 +171,7 @@ func TestValidateBlockMeta(t *testing.T) {
},
Commit: types.NewCommit(types.BlockID{Hash: []byte("DEADBEEF")}, nil),
},
wantErr: "Headers don't match",
wantErr: "headers don't match",
},
{
@ -190,7 +190,7 @@ func TestValidateBlockMeta(t *testing.T) {
},
Commit: types.NewCommit(types.BlockID{Hash: []byte("DEADBEEF")}, nil),
},
wantErr: "Headers don't match",
wantErr: "headers don't match",
},
// End Headers don't match test
}


+ 4
- 4
mempool/clist_mempool_test.go View File

@ -316,19 +316,19 @@ func TestSerialReap(t *testing.T) {
binary.BigEndian.PutUint64(txBytes, uint64(i))
res, err := appConnCon.DeliverTxSync(abci.RequestDeliverTx{Tx: txBytes})
if err != nil {
t.Errorf("Client error committing tx: %v", err)
t.Errorf("client error committing tx: %v", err)
}
if res.IsErr() {
t.Errorf("Error committing tx. Code:%v result:%X log:%v",
t.Errorf("error committing tx. Code:%v result:%X log:%v",
res.Code, res.Data, res.Log)
}
}
res, err := appConnCon.CommitSync()
if err != nil {
t.Errorf("Client error committing: %v", err)
t.Errorf("client error committing: %v", err)
}
if len(res.Data) != 8 {
t.Errorf("Error committing. Hash:%X", res.Data)
t.Errorf("error committing. Hash:%X", res.Data)
}
}


+ 1
- 1
mempool/errors.go View File

@ -8,7 +8,7 @@ import (
var (
// ErrTxInCache is returned to the client if we saw tx earlier
ErrTxInCache = errors.New("Tx already exists in cache")
ErrTxInCache = errors.New("tx already exists in cache")
)
// ErrTxTooLarge means the tx is too big to be sent in a message to other peers


+ 1
- 1
mempool/mempool.go View File

@ -112,7 +112,7 @@ func PreCheckAminoMaxBytes(maxBytes int64) PreCheckFunc {
aminoOverhead := types.ComputeAminoOverhead(tx, 1)
txSize := int64(len(tx)) + aminoOverhead
if txSize > maxBytes {
return fmt.Errorf("Tx size (including amino overhead) is too big: %d, max: %d",
return fmt.Errorf("tx size (including amino overhead) is too big: %d, max: %d",
txSize, maxBytes)
}
return nil


+ 5
- 5
mempool/reactor_test.go View File

@ -80,7 +80,7 @@ func waitForTxsOnReactors(t *testing.T, txs types.Txs, reactors []*Reactor) {
close(done)
}()
timer := time.After(TIMEOUT)
timer := time.After(Timeout)
select {
case <-timer:
t.Fatal("Timed out waiting for txs")
@ -108,8 +108,8 @@ func ensureNoTxs(t *testing.T, reactor *Reactor, timeout time.Duration) {
}
const (
NUM_TXS = 1000
TIMEOUT = 120 * time.Second // ridiculously high because CircleCI is slow
NumTxs = 1000
Timeout = 120 * time.Second // ridiculously high because CircleCI is slow
)
func TestReactorBroadcastTxMessage(t *testing.T) {
@ -129,7 +129,7 @@ func TestReactorBroadcastTxMessage(t *testing.T) {
// send a bunch of txs to the first reactor's mempool
// and wait for them all to be received in the others
txs := checkTxs(t, reactors[0].mempool, NUM_TXS, UnknownPeerID)
txs := checkTxs(t, reactors[0].mempool, NumTxs, UnknownPeerID)
waitForTxsOnReactors(t, txs, reactors)
}
@ -145,7 +145,7 @@ func TestReactorNoBroadcastToSender(t *testing.T) {
// send a bunch of txs to the first reactor's mempool, claiming it came from peer
// ensure peer gets no txs
checkTxs(t, reactors[0].mempool, NUM_TXS, 1)
checkTxs(t, reactors[0].mempool, NumTxs, 1)
ensureNoTxs(t, reactors[1], 100*time.Millisecond)
}


+ 2
- 2
node/codec.go View File

@ -2,11 +2,11 @@ package node
import (
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
}

+ 2
- 2
node/node.go View File

@ -99,7 +99,7 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
if _, err := os.Stat(oldPrivVal); !os.IsNotExist(err) {
oldPV, err := privval.LoadOldFilePV(oldPrivVal)
if err != nil {
return nil, fmt.Errorf("error reading OldPrivValidator from %v: %v\n", oldPrivVal, err)
return nil, fmt.Errorf("error reading OldPrivValidator from %v: %v", oldPrivVal, err)
}
logger.Info("Upgrading PrivValidator file",
"old", oldPrivVal,
@ -1154,7 +1154,7 @@ func LoadStateFromDBOrGenesisDocProvider(
func loadGenesisDoc(db dbm.DB) (*types.GenesisDoc, error) {
b := db.Get(genesisDocKey)
if len(b) == 0 {
return nil, errors.New("Genesis doc not found")
return nil, errors.New("genesis doc not found")
}
var genDoc *types.GenesisDoc
err := cdc.UnmarshalJSON(b, &genDoc)


+ 2
- 2
p2p/codec.go View File

@ -2,11 +2,11 @@ package p2p
import (
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
}

+ 2
- 2
p2p/conn/codec.go View File

@ -2,12 +2,12 @@ package conn
import (
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc *amino.Codec = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
RegisterPacket(cdc)
}

+ 6
- 6
p2p/conn/connection.go View File

@ -617,7 +617,7 @@ FOR_LOOP:
case PacketMsg:
channel, ok := c.channelsIdx[pkt.ChannelID]
if !ok || channel == nil {
err := fmt.Errorf("Unknown channel %X", pkt.ChannelID)
err := fmt.Errorf("unknown channel %X", pkt.ChannelID)
c.Logger.Error("Connection failed @ recvRoutine", "conn", c, "err", err)
c.stopForError(err)
break FOR_LOOP
@ -637,7 +637,7 @@ FOR_LOOP:
c.onReceive(pkt.ChannelID, msgBytes)
}
default:
err := fmt.Errorf("Unknown message type %v", reflect.TypeOf(packet))
err := fmt.Errorf("unknown message type %v", reflect.TypeOf(packet))
c.Logger.Error("Connection failed @ recvRoutine", "conn", c, "err", err)
c.stopForError(err)
break FOR_LOOP
@ -844,7 +844,7 @@ func (ch *Channel) recvPacketMsg(packet PacketMsg) ([]byte, error) {
ch.Logger.Debug("Read PacketMsg", "conn", ch.conn, "packet", packet)
var recvCap, recvReceived = ch.desc.RecvMessageCapacity, len(ch.recving) + len(packet.Bytes)
if recvCap < recvReceived {
return nil, fmt.Errorf("Received message exceeds available capacity: %v < %v", recvCap, recvReceived)
return nil, fmt.Errorf("received message exceeds available capacity: %v < %v", recvCap, recvReceived)
}
ch.recving = append(ch.recving, packet.Bytes...)
if packet.EOF == byte(0x01) {
@ -882,9 +882,9 @@ func RegisterPacket(cdc *amino.Codec) {
cdc.RegisterConcrete(PacketMsg{}, "tendermint/p2p/PacketMsg", nil)
}
func (_ PacketPing) AssertIsPacket() {}
func (_ PacketPong) AssertIsPacket() {}
func (_ PacketMsg) AssertIsPacket() {}
func (PacketPing) AssertIsPacket() {}
func (PacketPong) AssertIsPacket() {}
func (PacketMsg) AssertIsPacket() {}
type PacketPing struct {
}


+ 12
- 13
p2p/conn/secret_connection.go View File

@ -296,21 +296,20 @@ func shareEphPubKey(conn io.ReadWriter, locEphPub *[32]byte) (remEphPub *[32]byt
// Send our pubkey and receive theirs in tandem.
var trs, _ = cmn.Parallel(
func(_ int) (val interface{}, err error, abort bool) {
func(_ int) (val interface{}, abort bool, err error) {
var _, err1 = cdc.MarshalBinaryLengthPrefixedWriter(conn, locEphPub)
if err1 != nil {
return nil, err1, true // abort
return nil, true, err1 // abort
}
return nil, nil, false
return nil, false, nil
},
func(_ int) (val interface{}, err error, abort bool) {
func(_ int) (val interface{}, abort bool, err error) {
var _remEphPub [32]byte
var _, err2 = cdc.UnmarshalBinaryLengthPrefixedReader(conn, &_remEphPub, 1024*1024) // TODO
if err2 != nil {
return nil, err2, true // abort
return nil, true, err2 // abort
}
return _remEphPub, nil, false
return _remEphPub, false, nil
},
)
@ -405,20 +404,20 @@ func shareAuthSignature(sc io.ReadWriter, pubKey crypto.PubKey, signature []byte
// Send our info and receive theirs in tandem.
var trs, _ = cmn.Parallel(
func(_ int) (val interface{}, err error, abort bool) {
func(_ int) (val interface{}, abort bool, err error) {
var _, err1 = cdc.MarshalBinaryLengthPrefixedWriter(sc, authSigMessage{pubKey, signature})
if err1 != nil {
return nil, err1, true // abort
return nil, true, err1 // abort
}
return nil, nil, false
return nil, false, nil
},
func(_ int) (val interface{}, err error, abort bool) {
func(_ int) (val interface{}, abort bool, err error) {
var _recvMsg authSigMessage
var _, err2 = cdc.UnmarshalBinaryLengthPrefixedReader(sc, &_recvMsg, 1024*1024) // TODO
if err2 != nil {
return nil, err2, true // abort
return nil, true, err2 // abort
}
return _recvMsg, nil, false
return _recvMsg, false, nil
},
)


+ 34
- 34
p2p/conn/secret_connection_test.go View File

@ -53,35 +53,35 @@ func makeSecretConnPair(tb testing.TB) (fooSecConn, barSecConn *SecretConnection
// Make connections from both sides in parallel.
var trs, ok = cmn.Parallel(
func(_ int) (val interface{}, err error, abort bool) {
func(_ int) (val interface{}, abort bool, err error) {
fooSecConn, err = MakeSecretConnection(fooConn, fooPrvKey)
if err != nil {
tb.Errorf("Failed to establish SecretConnection for foo: %v", err)
return nil, err, true
tb.Errorf("failed to establish SecretConnection for foo: %v", err)
return nil, true, err
}
remotePubBytes := fooSecConn.RemotePubKey()
if !remotePubBytes.Equals(barPubKey) {
err = fmt.Errorf("Unexpected fooSecConn.RemotePubKey. Expected %v, got %v",
err = fmt.Errorf("unexpected fooSecConn.RemotePubKey. Expected %v, got %v",
barPubKey, fooSecConn.RemotePubKey())
tb.Error(err)
return nil, err, false
return nil, false, err
}
return nil, nil, false
return nil, false, nil
},
func(_ int) (val interface{}, err error, abort bool) {
func(_ int) (val interface{}, abort bool, err error) {
barSecConn, err = MakeSecretConnection(barConn, barPrvKey)
if barSecConn == nil {
tb.Errorf("Failed to establish SecretConnection for bar: %v", err)
return nil, err, true
tb.Errorf("failed to establish SecretConnection for bar: %v", err)
return nil, true, err
}
remotePubBytes := barSecConn.RemotePubKey()
if !remotePubBytes.Equals(fooPubKey) {
err = fmt.Errorf("Unexpected barSecConn.RemotePubKey. Expected %v, got %v",
err = fmt.Errorf("unexpected barSecConn.RemotePubKey. Expected %v, got %v",
fooPubKey, barSecConn.RemotePubKey())
tb.Error(err)
return nil, nil, false
return nil, false, nil
}
return nil, nil, false
return nil, false, nil
},
)
@ -150,7 +150,7 @@ func writeLots(t *testing.T, wg *sync.WaitGroup, conn io.Writer, txt string, n i
for i := 0; i < n; i++ {
_, err := conn.Write([]byte(txt))
if err != nil {
t.Errorf("Failed to write to fooSecConn: %v", err)
t.Errorf("failed to write to fooSecConn: %v", err)
return
}
}
@ -178,37 +178,37 @@ func TestSecretConnectionReadWrite(t *testing.T) {
// A helper that will run with (fooConn, fooWrites, fooReads) and vice versa
genNodeRunner := func(id string, nodeConn kvstoreConn, nodeWrites []string, nodeReads *[]string) cmn.Task {
return func(_ int) (interface{}, error, bool) {
return func(_ int) (interface{}, bool, error) {
// Initiate cryptographic private key and secret connection trhough nodeConn.
nodePrvKey := ed25519.GenPrivKey()
nodeSecretConn, err := MakeSecretConnection(nodeConn, nodePrvKey)
if err != nil {
t.Errorf("Failed to establish SecretConnection for node: %v", err)
return nil, err, true
t.Errorf("failed to establish SecretConnection for node: %v", err)
return nil, true, err
}
// In parallel, handle some reads and writes.
var trs, ok = cmn.Parallel(
func(_ int) (interface{}, error, bool) {
func(_ int) (interface{}, bool, error) {
// Node writes:
for _, nodeWrite := range nodeWrites {
n, err := nodeSecretConn.Write([]byte(nodeWrite))
if err != nil {
t.Errorf("Failed to write to nodeSecretConn: %v", err)
return nil, err, true
t.Errorf("failed to write to nodeSecretConn: %v", err)
return nil, true, err
}
if n != len(nodeWrite) {
err = fmt.Errorf("Failed to write all bytes. Expected %v, wrote %v", len(nodeWrite), n)
err = fmt.Errorf("failed to write all bytes. Expected %v, wrote %v", len(nodeWrite), n)
t.Error(err)
return nil, err, true
return nil, true, err
}
}
if err := nodeConn.PipeWriter.Close(); err != nil {
t.Error(err)
return nil, err, true
return nil, true, err
}
return nil, nil, false
return nil, false, nil
},
func(_ int) (interface{}, error, bool) {
func(_ int) (interface{}, bool, error) {
// Node reads:
readBuffer := make([]byte, dataMaxSize)
for {
@ -216,12 +216,12 @@ func TestSecretConnectionReadWrite(t *testing.T) {
if err == io.EOF {
if err := nodeConn.PipeReader.Close(); err != nil {
t.Error(err)
return nil, err, true
return nil, true, err
}
return nil, nil, false
return nil, false, nil
} else if err != nil {
t.Errorf("Failed to read from nodeSecretConn: %v", err)
return nil, err, true
t.Errorf("failed to read from nodeSecretConn: %v", err)
return nil, true, err
}
*nodeReads = append(*nodeReads, string(readBuffer[:n]))
}
@ -231,11 +231,11 @@ func TestSecretConnectionReadWrite(t *testing.T) {
// If error:
if trs.FirstError() != nil {
return nil, trs.FirstError(), true
return nil, true, trs.FirstError()
}
// Otherwise:
return nil, nil, false
return nil, false, nil
}
}
@ -266,7 +266,7 @@ func TestSecretConnectionReadWrite(t *testing.T) {
}
// Compare
if write != read {
t.Errorf("Expected to read %X, got %X", write, read)
t.Errorf("expected to read %X, got %X", write, read)
}
// Iterate
writes = writes[1:]
@ -412,7 +412,7 @@ func BenchmarkWriteSecretConnection(b *testing.B) {
if err == io.EOF {
return
} else if err != nil {
b.Errorf("Failed to read from barSecConn: %v", err)
b.Errorf("failed to read from barSecConn: %v", err)
return
}
}
@ -423,7 +423,7 @@ func BenchmarkWriteSecretConnection(b *testing.B) {
idx := cmn.RandIntn(len(fooWriteBytes))
_, err := fooSecConn.Write(fooWriteBytes[idx])
if err != nil {
b.Errorf("Failed to write to fooSecConn: %v", err)
b.Errorf("failed to write to fooSecConn: %v", err)
return
}
}
@ -457,7 +457,7 @@ func BenchmarkReadSecretConnection(b *testing.B) {
idx := cmn.RandIntn(len(fooWriteBytes))
_, err := fooSecConn.Write(fooWriteBytes[idx])
if err != nil {
b.Errorf("Failed to write to fooSecConn: %v, %v,%v", err, i, b.N)
b.Errorf("failed to write to fooSecConn: %v, %v,%v", err, i, b.N)
return
}
}


+ 1
- 1
p2p/key.go View File

@ -65,7 +65,7 @@ func LoadNodeKey(filePath string) (*NodeKey, error) {
nodeKey := new(NodeKey)
err = cdc.UnmarshalJSON(jsonBytes, nodeKey)
if err != nil {
return nil, fmt.Errorf("Error reading NodeKey from %v: %v", filePath, err)
return nil, fmt.Errorf("error reading NodeKey from %v: %v", filePath, err)
}
return nodeKey, nil
}


+ 5
- 5
p2p/netaddress.go View File

@ -246,9 +246,9 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
Unreachable = 0
Default = iota
Teredo
Ipv6_weak
Ipv6Weak
Ipv4
Ipv6_strong
Ipv6Strong
)
switch {
case !na.Routable():
@ -262,7 +262,7 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
case o.IP.To4() != nil:
return Ipv4
default: // ipv6
return Ipv6_weak
return Ipv6Weak
}
case na.IP.To4() != nil:
if o.Routable() && o.IP.To4() != nil {
@ -284,9 +284,9 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
return Ipv4
case tunnelled:
// only prioritise ipv6 if we aren't tunnelling it.
return Ipv6_weak
return Ipv6Weak
}
return Ipv6_strong
return Ipv6Strong
}
}


+ 3
- 3
p2p/node_info.go View File

@ -179,13 +179,13 @@ func (info DefaultNodeInfo) CompatibleWith(other_ NodeInfo) error {
}
if info.ProtocolVersion.Block != other.ProtocolVersion.Block {
return fmt.Errorf("Peer is on a different Block version. Got %v, expected %v",
return fmt.Errorf("peer is on a different Block version. Got %v, expected %v",
other.ProtocolVersion.Block, info.ProtocolVersion.Block)
}
// nodes must be on the same network
if info.Network != other.Network {
return fmt.Errorf("Peer is on a different network. Got %v, expected %v", other.Network, info.Network)
return fmt.Errorf("peer is on a different network. Got %v, expected %v", other.Network, info.Network)
}
// if we have no channels, we're just testing
@ -205,7 +205,7 @@ OUTER_LOOP:
}
}
if !found {
return fmt.Errorf("Peer has no common channels. Our channels: %v ; Peer channels: %v", info.Channels, other.Channels)
return fmt.Errorf("peer has no common channels. Our channels: %v ; Peer channels: %v", info.Channels, other.Channels)
}
return nil
}


+ 5
- 5
p2p/node_info_test.go View File

@ -22,7 +22,7 @@ func TestNodeInfoValidate(t *testing.T) {
copy(dupChannels, channels[:5])
dupChannels = append(dupChannels, testCh)
nonAscii := "¢§µ"
nonASCII := "¢§µ"
emptyTab := fmt.Sprintf("\t")
emptySpace := fmt.Sprintf(" ")
@ -42,24 +42,24 @@ func TestNodeInfoValidate(t *testing.T) {
{"Invalid NetAddress", func(ni *DefaultNodeInfo) { ni.ListenAddr = "not-an-address" }, true},
{"Good NetAddress", func(ni *DefaultNodeInfo) { ni.ListenAddr = "0.0.0.0:26656" }, false},
{"Non-ASCII Version", func(ni *DefaultNodeInfo) { ni.Version = nonAscii }, true},
{"Non-ASCII Version", func(ni *DefaultNodeInfo) { ni.Version = nonASCII }, true},
{"Empty tab Version", func(ni *DefaultNodeInfo) { ni.Version = emptyTab }, true},
{"Empty space Version", func(ni *DefaultNodeInfo) { ni.Version = emptySpace }, true},
{"Empty Version", func(ni *DefaultNodeInfo) { ni.Version = "" }, false},
{"Non-ASCII Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = nonAscii }, true},
{"Non-ASCII Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = nonASCII }, true},
{"Empty tab Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = emptyTab }, true},
{"Empty space Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = emptySpace }, true},
{"Empty Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = "" }, true},
{"Good Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = "hey its me" }, false},
{"Non-ASCII TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = nonAscii }, true},
{"Non-ASCII TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = nonASCII }, true},
{"Empty tab TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = emptyTab }, true},
{"Empty space TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = emptySpace }, true},
{"Empty TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = "" }, false},
{"Off TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = "off" }, false},
{"Non-ASCII RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = nonAscii }, true},
{"Non-ASCII RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = nonASCII }, true},
{"Empty tab RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = emptyTab }, true},
{"Empty space RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = emptySpace }, true},
{"Empty RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = "" }, false},


+ 4
- 4
p2p/peer_set_test.go View File

@ -101,10 +101,10 @@ func TestPeerSetAddRemoveMany(t *testing.T) {
for i := 0; i < N; i++ {
peer := newMockPeer(net.IP{127, 0, 0, byte(i)})
if err := peerSet.Add(peer); err != nil {
t.Errorf("Failed to add new peer")
t.Errorf("failed to add new peer")
}
if peerSet.Size() != i+1 {
t.Errorf("Failed to add new peer and increment size")
t.Errorf("failed to add new peer and increment size")
}
peers = append(peers, peer)
}
@ -113,10 +113,10 @@ func TestPeerSetAddRemoveMany(t *testing.T) {
removed := peerSet.Remove(peer)
assert.True(t, removed)
if peerSet.Has(peer.ID()) {
t.Errorf("Failed to remove peer")
t.Errorf("failed to remove peer")
}
if peerSet.Size() != len(peers)-i-1 {
t.Errorf("Failed to remove peer and decrement size")
t.Errorf("failed to remove peer and decrement size")
}
}
}


+ 2
- 2
p2p/pex/pex_reactor.go View File

@ -145,7 +145,7 @@ func (r *PEXReactor) OnStart() error {
if err != nil {
return err
} else if numOnline == 0 && r.book.Empty() {
return errors.New("Address book is empty and couldn't resolve any seed nodes")
return errors.New("address book is empty and couldn't resolve any seed nodes")
}
r.seedAddrs = seedAddrs
@ -745,7 +745,7 @@ func RegisterPexMessage(cdc *amino.Codec) {
func decodeMsg(bz []byte) (msg PexMessage, err error) {
if len(bz) > maxMsgSize {
return msg, fmt.Errorf("Msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
return msg, fmt.Errorf("msg exceeds max size (%d > %d)", len(bz), maxMsgSize)
}
err = cdc.UnmarshalBinaryBare(bz, &msg)
return


+ 2
- 2
p2p/switch_test.go View File

@ -121,10 +121,10 @@ func TestSwitches(t *testing.T) {
defer s2.Stop()
if s1.Peers().Size() != 1 {
t.Errorf("Expected exactly 1 peer in s1, got %v", s1.Peers().Size())
t.Errorf("expected exactly 1 peer in s1, got %v", s1.Peers().Size())
}
if s2.Peers().Size() != 1 {
t.Errorf("Expected exactly 1 peer in s2, got %v", s2.Peers().Size())
t.Errorf("expected exactly 1 peer in s2, got %v", s2.Peers().Size())
}
// Lets send some messages


+ 2
- 2
p2p/test_util.go View File

@ -71,7 +71,7 @@ func CreateRoutableAddr() (addr string, netAddr *NetAddress) {
//------------------------------------------------------------------
// Connects switches via arbitrary net.Conn. Used for testing.
const TEST_HOST = "localhost"
const TestHost = "localhost"
// MakeConnectedSwitches returns n switches, connected according to the connect func.
// If connect==Connect2Switches, the switches will be fully connected.
@ -84,7 +84,7 @@ func MakeConnectedSwitches(cfg *config.P2PConfig,
) []*Switch {
switches := make([]*Switch, n)
for i := 0; i < n; i++ {
switches[i] = MakeSwitch(cfg, i, TEST_HOST, "123.123.123", initSwitch)
switches[i] = MakeSwitch(cfg, i, TestHost, "123.123.123", initSwitch)
}
if err := StartSwitches(switches); err != nil {


+ 1
- 1
p2p/transport.go View File

@ -87,7 +87,7 @@ func ConnDuplicateIPFilter() ConnFilterFunc {
if cs.HasIP(ip) {
return ErrRejected{
conn: c,
err: fmt.Errorf("IP<%v> already connected", ip),
err: fmt.Errorf("ip<%v> already connected", ip),
isDuplicate: true,
}
}


+ 7
- 7
p2p/transport_test.go View File

@ -237,7 +237,7 @@ func TestTransportMultiplexAcceptNonBlocking(t *testing.T) {
// Fast peer connected.
case <-time.After(50 * time.Millisecond):
// We error if the fast peer didn't succeed.
errc <- fmt.Errorf("Fast peer timed out")
errc <- fmt.Errorf("fast peer timed out")
}
sc, err := upgradeSecretConn(c, 20*time.Millisecond, ed25519.GenPrivKey())
@ -592,7 +592,7 @@ func (a *testTransportAddr) String() string { return "test.local:1234" }
type testTransportConn struct{}
func (c *testTransportConn) Close() error {
return fmt.Errorf("Close() not implemented")
return fmt.Errorf("close() not implemented")
}
func (c *testTransportConn) LocalAddr() net.Addr {
@ -604,21 +604,21 @@ func (c *testTransportConn) RemoteAddr() net.Addr {
}
func (c *testTransportConn) Read(_ []byte) (int, error) {
return -1, fmt.Errorf("Read() not implemented")
return -1, fmt.Errorf("read() not implemented")
}
func (c *testTransportConn) SetDeadline(_ time.Time) error {
return fmt.Errorf("SetDeadline() not implemented")
return fmt.Errorf("setDeadline() not implemented")
}
func (c *testTransportConn) SetReadDeadline(_ time.Time) error {
return fmt.Errorf("SetReadDeadline() not implemented")
return fmt.Errorf("setReadDeadline() not implemented")
}
func (c *testTransportConn) SetWriteDeadline(_ time.Time) error {
return fmt.Errorf("SetWriteDeadline() not implemented")
return fmt.Errorf("setWriteDeadline() not implemented")
}
func (c *testTransportConn) Write(_ []byte) (int, error) {
return -1, fmt.Errorf("Write() not implemented")
return -1, fmt.Errorf("write() not implemented")
}

+ 1
- 1
p2p/trust/store_test.go View File

@ -141,7 +141,7 @@ func TestTrustMetricStorePeerScore(t *testing.T) {
second := tm.TrustScore()
if second > first {
t.Errorf("A greater number of bad events should lower the trust score")
t.Errorf("a greater number of bad events should lower the trust score")
}
store.PeerDisconnected(key)


+ 4
- 4
p2p/upnp/probe.go View File

@ -16,26 +16,26 @@ type UPNPCapabilities struct {
func makeUPNPListener(intPort int, extPort int, logger log.Logger) (NAT, net.Listener, net.IP, error) {
nat, err := Discover()
if err != nil {
return nil, nil, nil, fmt.Errorf("NAT upnp could not be discovered: %v", err)
return nil, nil, nil, fmt.Errorf("nat upnp could not be discovered: %v", err)
}
logger.Info(fmt.Sprintf("ourIP: %v", nat.(*upnpNAT).ourIP))
ext, err := nat.GetExternalAddress()
if err != nil {
return nat, nil, nil, fmt.Errorf("External address error: %v", err)
return nat, nil, nil, fmt.Errorf("external address error: %v", err)
}
logger.Info(fmt.Sprintf("External address: %v", ext))
port, err := nat.AddPortMapping("tcp", extPort, intPort, "Tendermint UPnP Probe", 0)
if err != nil {
return nat, nil, ext, fmt.Errorf("Port mapping error: %v", err)
return nat, nil, ext, fmt.Errorf("port mapping error: %v", err)
}
logger.Info(fmt.Sprintf("Port mapping mapped: %v", port))
// also run the listener, open for all remote addresses.
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", intPort))
if err != nil {
return nat, nil, ext, fmt.Errorf("Error establishing listener: %v", err)
return nat, nil, ext, fmt.Errorf("error establishing listener: %v", err)
}
return nat, listener, ext, nil
}


+ 9
- 9
p2p/upnp/upnp.go View File

@ -109,7 +109,7 @@ func Discover() (nat NAT, err error) {
return
}
}
err = errors.New("UPnP port discovery failed")
err = errors.New("upnp port discovery failed")
return nat, err
}
@ -219,17 +219,17 @@ func getServiceURL(rootURL string) (url, urnDomain string, err error) {
}
a := &root.Device
if !strings.Contains(a.DeviceType, "InternetGatewayDevice:1") {
err = errors.New("No InternetGatewayDevice")
err = errors.New("no InternetGatewayDevice")
return
}
b := getChildDevice(a, "WANDevice:1")
if b == nil {
err = errors.New("No WANDevice")
err = errors.New("no WANDevice")
return
}
c := getChildDevice(b, "WANConnectionDevice:1")
if c == nil {
err = errors.New("No WANConnectionDevice")
err = errors.New("no WANConnectionDevice")
return
}
d := getChildService(c, "WANIPConnection:1")
@ -239,7 +239,7 @@ func getServiceURL(rootURL string) (url, urnDomain string, err error) {
d = getChildService(b, "WANIPConnection:1")
if d == nil {
err = errors.New("No WANIPConnection")
err = errors.New("no WANIPConnection")
return
}
}
@ -287,7 +287,7 @@ func soapRequest(url, function, message, domain string) (r *http.Response, err e
if r.StatusCode >= 400 {
// log.Stderr(function, r.StatusCode)
err = errors.New("Error " + strconv.Itoa(r.StatusCode) + " for " + function)
err = errors.New("error " + strconv.Itoa(r.StatusCode) + " for " + function)
r = nil
return
}
@ -295,7 +295,7 @@ func soapRequest(url, function, message, domain string) (r *http.Response, err e
}
type statusInfo struct {
externalIpAddress string
externalIPAddress string
}
func (n *upnpNAT) getExternalIPAddress() (info statusInfo, err error) {
@ -338,9 +338,9 @@ func (n *upnpNAT) GetExternalAddress() (addr net.IP, err error) {
if err != nil {
return
}
addr = net.ParseIP(info.externalIpAddress)
addr = net.ParseIP(info.externalIPAddress)
if addr == nil {
err = fmt.Errorf("Failed to parse IP: %v", info.externalIpAddress)
err = fmt.Errorf("failed to parse IP: %v", info.externalIPAddress)
}
return
}


+ 2
- 2
privval/codec.go View File

@ -2,12 +2,12 @@ package privval
import (
amino "github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
cryptoamino.RegisterAmino(cdc)
RegisterRemoteSignerMsg(cdc)
}

+ 2
- 2
privval/signer_listener_endpoint_test.go View File

@ -66,9 +66,9 @@ func TestSignerRemoteRetryTCPOnly(t *testing.T) {
SignerDialerEndpointTimeoutReadWrite(time.Millisecond)(dialerEndpoint)
SignerDialerEndpointConnRetries(retries)(dialerEndpoint)
chainId := cmn.RandStr(12)
chainID := cmn.RandStr(12)
mockPV := types.NewMockPV()
signerServer := NewSignerServer(dialerEndpoint, chainId, mockPV)
signerServer := NewSignerServer(dialerEndpoint, chainID, mockPV)
err = signerServer.Start()
require.NoError(t, err)


+ 1
- 1
proxy/app_conn_test.go View File

@ -145,7 +145,7 @@ func TestInfo(t *testing.T) {
resInfo, err := proxy.InfoSync(RequestInfo)
if err != nil {
t.Errorf("Unexpected error: %v", err)
t.Errorf("unexpected error: %v", err)
}
if resInfo.Data != "{\"size\":0}" {
t.Error("Expected ResponseInfo with one element '{\"size\":0}' but got something else")


+ 2
- 2
rpc/core/blocks.go View File

@ -138,10 +138,10 @@ func getHeight(currentHeight int64, heightPtr *int64) (int64, error) {
if heightPtr != nil {
height := *heightPtr
if height <= 0 {
return 0, fmt.Errorf("Height must be greater than 0")
return 0, fmt.Errorf("height must be greater than 0")
}
if height > currentHeight {
return 0, fmt.Errorf("Height must be less than or equal to the current blockchain height")
return 0, fmt.Errorf("height must be less than or equal to the current blockchain height")
}
return height, nil
}


+ 2
- 2
rpc/core/mempool.go View File

@ -80,7 +80,7 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc
}, mempl.TxInfo{})
if err != nil {
logger.Error("Error on broadcastTxCommit", "err", err)
return nil, fmt.Errorf("Error on broadcastTxCommit: %v", err)
return nil, fmt.Errorf("error on broadcastTxCommit: %v", err)
}
checkTxResMsg := <-checkTxResCh
checkTxRes := checkTxResMsg.GetCheckTx()
@ -117,7 +117,7 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc
Hash: tx.Hash(),
}, err
case <-time.After(config.TimeoutBroadcastTxCommit):
err = errors.New("Timed out waiting for tx to be included in a block")
err = errors.New("timed out waiting for tx to be included in a block")
logger.Error("Error on broadcastTxCommit", "err", err)
return &ctypes.ResultBroadcastTxCommit{
CheckTx: *checkTxRes,


+ 2
- 2
rpc/core/net.go View File

@ -41,7 +41,7 @@ func NetInfo(ctx *rpctypes.Context) (*ctypes.ResultNetInfo, error) {
// UnsafeDialSeeds dials the given seeds (comma-separated id@IP:PORT).
func UnsafeDialSeeds(ctx *rpctypes.Context, seeds []string) (*ctypes.ResultDialSeeds, error) {
if len(seeds) == 0 {
return &ctypes.ResultDialSeeds{}, errors.New("No seeds provided")
return &ctypes.ResultDialSeeds{}, errors.New("no seeds provided")
}
logger.Info("DialSeeds", "seeds", seeds)
if err := p2pPeers.DialPeersAsync(seeds); err != nil {
@ -54,7 +54,7 @@ func UnsafeDialSeeds(ctx *rpctypes.Context, seeds []string) (*ctypes.ResultDialS
// optionally making them persistent.
func UnsafeDialPeers(ctx *rpctypes.Context, peers []string, persistent bool) (*ctypes.ResultDialPeers, error) {
if len(peers) == 0 {
return &ctypes.ResultDialPeers{}, errors.New("No peers provided")
return &ctypes.ResultDialPeers{}, errors.New("no peers provided")
}
logger.Info("DialPeers", "peers", peers, "persistent", persistent)
if persistent {


+ 3
- 3
rpc/core/tx.go View File

@ -20,7 +20,7 @@ func Tx(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error
// if index is disabled, return error
if _, ok := txIndexer.(*null.TxIndex); ok {
return nil, fmt.Errorf("Transaction indexing is disabled")
return nil, fmt.Errorf("transaction indexing is disabled")
}
r, err := txIndexer.Get(hash)
@ -29,7 +29,7 @@ func Tx(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error
}
if r == nil {
return nil, fmt.Errorf("Tx (%X) not found", hash)
return nil, fmt.Errorf("tx (%X) not found", hash)
}
height := r.Height
@ -57,7 +57,7 @@ func Tx(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error
func TxSearch(ctx *rpctypes.Context, query string, prove bool, page, perPage int) (*ctypes.ResultTxSearch, error) {
// if index is disabled, return error
if _, ok := txIndexer.(*null.TxIndex); ok {
return nil, fmt.Errorf("Transaction indexing is disabled")
return nil, fmt.Errorf("transaction indexing is disabled")
}
q, err := tmquery.New(query)


+ 1
- 1
rpc/core/types/codec.go View File

@ -1,4 +1,4 @@
package core_types
package coretypes
import (
amino "github.com/tendermint/go-amino"


+ 1
- 1
rpc/core/types/responses.go View File

@ -1,4 +1,4 @@
package core_types
package coretypes
import (
"encoding/json"


+ 1
- 1
rpc/core/types/responses_test.go View File

@ -1,4 +1,4 @@
package core_types
package coretypes
import (
"testing"


+ 1
- 1
rpc/grpc/api.go View File

@ -1,4 +1,4 @@
package core_grpc
package coregrpc
import (
"context"


+ 1
- 1
rpc/grpc/client_server.go View File

@ -1,4 +1,4 @@
package core_grpc
package coregrpc
import (
"net"


+ 1
- 1
rpc/grpc/grpc_test.go View File

@ -1,4 +1,4 @@
package core_grpc_test
package coregrpc_test
import (
"context"


+ 1
- 1
rpc/grpc/types.pb.go View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: rpc/grpc/types.proto
package core_grpc
package coregrpc
import (
bytes "bytes"


+ 1
- 1
rpc/grpc/typespb_test.go View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: rpc/grpc/types.proto
package core_grpc
package coregrpc
import (
fmt "fmt"


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save