Browse Source

libs: Remove usage of custom Fmt, in favor of fmt.Sprintf (#2199)

* libs: Remove usage of custom Fmt, in favor of fmt.Sprintf

Closes #2193

* Fix bug that was masked by custom Fmt!
pull/2200/head
Dev Ojha 6 years ago
committed by Anton Kaliaev
parent
commit
2756be5a59
88 changed files with 270 additions and 275 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +3
    -2
      Gopkg.lock
  3. +5
    -6
      abci/example/counter/counter.go
  4. +3
    -2
      abci/example/kvstore/kvstore_test.go
  5. +1
    -2
      abci/example/kvstore/persistent_kvstore.go
  6. +1
    -1
      benchmarks/simu/counter.go
  7. +3
    -3
      blockchain/pool.go
  8. +7
    -7
      blockchain/reactor.go
  9. +4
    -4
      blockchain/store.go
  10. +1
    -1
      cmd/tendermint/commands/gen_node_key.go
  11. +3
    -2
      cmd/tendermint/commands/init.go
  12. +1
    -1
      cmd/tendermint/commands/reset_priv_validator.go
  13. +6
    -6
      cmd/tendermint/commands/testnet.go
  14. +4
    -3
      consensus/byzantine_test.go
  15. +2
    -2
      consensus/common_test.go
  16. +3
    -4
      consensus/mempool_test.go
  17. +8
    -8
      consensus/reactor.go
  18. +1
    -1
      consensus/reactor_test.go
  19. +2
    -2
      consensus/replay.go
  20. +6
    -6
      consensus/replay_file.go
  21. +6
    -8
      consensus/replay_test.go
  22. +34
    -34
      consensus/state.go
  23. +3
    -4
      consensus/state_test.go
  24. +3
    -3
      consensus/types/height_vote_set.go
  25. +2
    -2
      consensus/types/height_vote_set_test.go
  26. +1
    -1
      consensus/types/peer_round_state.go
  27. +1
    -1
      consensus/types/round_state.go
  28. +2
    -4
      consensus/version.go
  29. +3
    -3
      consensus/wal.go
  30. +4
    -4
      consensus/wal_generator.go
  31. +4
    -4
      consensus/wal_test.go
  32. +2
    -1
      crypto/merkle/simple_tree_test.go
  33. +3
    -2
      crypto/xsalsa20symmetric/symmetric.go
  34. +1
    -1
      docs/app-dev/app-development.md
  35. +1
    -1
      evidence/pool_test.go
  36. +1
    -1
      evidence/store.go
  37. +1
    -1
      evidence/store_test.go
  38. +2
    -2
      libs/autofile/group.go
  39. +2
    -1
      libs/common/bit_array_test.go
  40. +1
    -1
      libs/common/colors.go
  41. +7
    -7
      libs/common/errors.go
  42. +2
    -2
      libs/common/os.go
  43. +1
    -1
      libs/common/random.go
  44. +6
    -6
      libs/common/service.go
  45. +0
    -8
      libs/common/string.go
  46. +3
    -3
      libs/db/backend_test.go
  47. +2
    -2
      libs/db/c_level_db_test.go
  48. +1
    -1
      libs/db/go_level_db_test.go
  49. +1
    -1
      lite/provider.go
  50. +2
    -2
      lite/provider_test.go
  51. +2
    -2
      lite/proxy/verifier.go
  52. +1
    -1
      mempool/mempool.go
  53. +1
    -2
      mempool/mempool_test.go
  54. +9
    -9
      node/node.go
  55. +1
    -1
      p2p/base_reactor.go
  56. +3
    -3
      p2p/conn/connection.go
  57. +1
    -1
      p2p/listener.go
  58. +1
    -1
      p2p/netaddress.go
  59. +1
    -1
      p2p/peer.go
  60. +2
    -1
      p2p/peer_set_test.go
  61. +8
    -7
      p2p/pex/addrbook.go
  62. +3
    -2
      p2p/pex/file.go
  63. +2
    -2
      p2p/test_util.go
  64. +2
    -1
      p2p/trust/store.go
  65. +12
    -13
      p2p/upnp/probe.go
  66. +2
    -2
      privval/priv_validator.go
  67. +5
    -4
      proxy/app_conn_test.go
  68. +1
    -1
      rpc/client/event_test.go
  69. +1
    -1
      rpc/client/httpclient.go
  70. +1
    -1
      rpc/client/interface.go
  71. +1
    -1
      rpc/client/mock/abci.go
  72. +1
    -1
      rpc/client/mock/abci_test.go
  73. +1
    -1
      rpc/client/mock/client.go
  74. +1
    -1
      rpc/client/mock/status_test.go
  75. +1
    -1
      rpc/core/mempool.go
  76. +2
    -2
      rpc/core/pipe.go
  77. +1
    -1
      rpc/lib/client/ws_client.go
  78. +1
    -1
      rpc/lib/server/handlers_test.go
  79. +1
    -1
      rpc/lib/server/http_server.go
  80. +1
    -1
      rpc/lib/test/main.go
  81. +9
    -11
      state/errors.go
  82. +4
    -4
      state/state_test.go
  83. +7
    -7
      state/store.go
  84. +1
    -1
      state/validation.go
  85. +2
    -1
      types/genesis.go
  86. +4
    -4
      types/proto3_test.go
  87. +3
    -3
      types/protobuf_test.go
  88. +3
    -2
      types/validator_set_test.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -9,6 +9,7 @@ BREAKING CHANGES:
top-level top-level
- [abci] Added address of the original proposer of the block to Header. - [abci] Added address of the original proposer of the block to Header.
- [abci] Change ABCI Header to match Tendermint exactly - [abci] Change ABCI Header to match Tendermint exactly
- [libs] Remove cmn.Fmt, in favor of fmt.Sprintf
FEATURES: FEATURES:


+ 3
- 2
Gopkg.lock View File

@ -244,7 +244,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:63b68062b8968092eb86bedc4e68894bd096ea6b24920faca8b9dcf451f54bb5"
digest = "1:dad2e5a2153ee7a6c9ab8fc13673a16ee4fb64434a7da980965a3741b0c981a3"
name = "github.com/prometheus/common" name = "github.com/prometheus/common"
packages = [ packages = [
"expfmt", "expfmt",
@ -426,7 +426,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:bb0fe59917bdd5b89f49b9a8b26e5f465e325d9223b3a8e32254314bdf51e0f1"
digest = "1:70656e26ab4a96e683a21d677630edb5239a3d60b2d54bdc861c808ab5aa42c7"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = [ packages = [
"cpu", "cpu",
@ -527,6 +527,7 @@
"github.com/gogo/protobuf/gogoproto", "github.com/gogo/protobuf/gogoproto",
"github.com/gogo/protobuf/jsonpb", "github.com/gogo/protobuf/jsonpb",
"github.com/gogo/protobuf/proto", "github.com/gogo/protobuf/proto",
"github.com/gogo/protobuf/types",
"github.com/golang/protobuf/proto", "github.com/golang/protobuf/proto",
"github.com/golang/protobuf/ptypes/timestamp", "github.com/golang/protobuf/ptypes/timestamp",
"github.com/gorilla/websocket", "github.com/gorilla/websocket",


+ 5
- 6
abci/example/counter/counter.go View File

@ -6,7 +6,6 @@ import (
"github.com/tendermint/tendermint/abci/example/code" "github.com/tendermint/tendermint/abci/example/code"
"github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
type CounterApplication struct { type CounterApplication struct {
@ -22,7 +21,7 @@ func NewCounterApplication(serial bool) *CounterApplication {
} }
func (app *CounterApplication) Info(req types.RequestInfo) types.ResponseInfo { func (app *CounterApplication) Info(req types.RequestInfo) types.ResponseInfo {
return types.ResponseInfo{Data: cmn.Fmt("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)}
return types.ResponseInfo{Data: fmt.Sprintf("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)}
} }
func (app *CounterApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption { func (app *CounterApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption {
@ -34,7 +33,7 @@ func (app *CounterApplication) SetOption(req types.RequestSetOption) types.Respo
TODO Panic and have the ABCI server pass an exception. TODO Panic and have the ABCI server pass an exception.
The client can call SetOptionSync() and get an `error`. The client can call SetOptionSync() and get an `error`.
return types.ResponseSetOption{ return types.ResponseSetOption{
Error: cmn.Fmt("Unknown key (%s) or value (%s)", key, value),
Error: fmt.Sprintf("Unknown key (%s) or value (%s)", key, value),
} }
*/ */
return types.ResponseSetOption{} return types.ResponseSetOption{}
@ -95,10 +94,10 @@ func (app *CounterApplication) Commit() (resp types.ResponseCommit) {
func (app *CounterApplication) Query(reqQuery types.RequestQuery) types.ResponseQuery { func (app *CounterApplication) Query(reqQuery types.RequestQuery) types.ResponseQuery {
switch reqQuery.Path { switch reqQuery.Path {
case "hash": case "hash":
return types.ResponseQuery{Value: []byte(cmn.Fmt("%v", app.hashCount))}
return types.ResponseQuery{Value: []byte(fmt.Sprintf("%v", app.hashCount))}
case "tx": case "tx":
return types.ResponseQuery{Value: []byte(cmn.Fmt("%v", app.txCount))}
return types.ResponseQuery{Value: []byte(fmt.Sprintf("%v", app.txCount))}
default: default:
return types.ResponseQuery{Log: cmn.Fmt("Invalid query path. Expected hash or tx, got %v", reqQuery.Path)}
return types.ResponseQuery{Log: fmt.Sprintf("Invalid query path. Expected hash or tx, got %v", reqQuery.Path)}
} }
} }

+ 3
- 2
abci/example/kvstore/kvstore_test.go View File

@ -2,6 +2,7 @@ package kvstore
import ( import (
"bytes" "bytes"
"fmt"
"io/ioutil" "io/ioutil"
"sort" "sort"
"testing" "testing"
@ -207,7 +208,7 @@ func valsEqual(t *testing.T, vals1, vals2 []types.Validator) {
func makeSocketClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) { func makeSocketClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
// Start the listener // Start the listener
socket := cmn.Fmt("unix://%s.sock", name)
socket := fmt.Sprintf("unix://%s.sock", name)
logger := log.TestingLogger() logger := log.TestingLogger()
server := abciserver.NewSocketServer(socket, app) server := abciserver.NewSocketServer(socket, app)
@ -229,7 +230,7 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) { func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
// Start the listener // Start the listener
socket := cmn.Fmt("unix://%s.sock", name)
socket := fmt.Sprintf("unix://%s.sock", name)
logger := log.TestingLogger() logger := log.TestingLogger()
gapp := types.NewGRPCApplication(app) gapp := types.NewGRPCApplication(app)


+ 1
- 2
abci/example/kvstore/persistent_kvstore.go View File

@ -9,7 +9,6 @@ import (
"github.com/tendermint/tendermint/abci/example/code" "github.com/tendermint/tendermint/abci/example/code"
"github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
) )
@ -130,7 +129,7 @@ func (app *PersistentKVStoreApplication) Validators() (validators []types.Valida
} }
func MakeValSetChangeTx(pubkey types.PubKey, power int64) []byte { func MakeValSetChangeTx(pubkey types.PubKey, power int64) []byte {
return []byte(cmn.Fmt("val:%X/%d", pubkey.Data, power))
return []byte(fmt.Sprintf("val:%X/%d", pubkey.Data, power))
} }
func isValidatorTx(tx []byte) bool { func isValidatorTx(tx []byte) bool {


+ 1
- 1
benchmarks/simu/counter.go View File

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"time" "time"
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
) )
func main() { func main() {


+ 3
- 3
blockchain/pool.go View File

@ -365,10 +365,10 @@ func (pool *BlockPool) debug() string {
nextHeight := pool.height + pool.requestersLen() nextHeight := pool.height + pool.requestersLen()
for h := pool.height; h < nextHeight; h++ { for h := pool.height; h < nextHeight; h++ {
if pool.requesters[h] == nil { if pool.requesters[h] == nil {
str += cmn.Fmt("H(%v):X ", h)
str += fmt.Sprintf("H(%v):X ", h)
} else { } else {
str += cmn.Fmt("H(%v):", h)
str += cmn.Fmt("B?(%v) ", pool.requesters[h].block != nil)
str += fmt.Sprintf("H(%v):", h)
str += fmt.Sprintf("B?(%v) ", pool.requesters[h].block != nil)
} }
} }
return str return str


+ 7
- 7
blockchain/reactor.go View File

@ -201,7 +201,7 @@ func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
// Got a peer status. Unverified. // Got a peer status. Unverified.
bcR.pool.SetPeerHeight(src.ID(), msg.Height) bcR.pool.SetPeerHeight(src.ID(), msg.Height)
default: default:
bcR.Logger.Error(cmn.Fmt("Unknown message type %v", reflect.TypeOf(msg)))
bcR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
} }
} }
@ -321,7 +321,7 @@ FOR_LOOP:
state, err = bcR.blockExec.ApplyBlock(state, firstID, first) state, err = bcR.blockExec.ApplyBlock(state, firstID, first)
if err != nil { if err != nil {
// TODO This is bad, are we zombie? // TODO This is bad, are we zombie?
cmn.PanicQ(cmn.Fmt("Failed to process committed block (%d:%X): %v",
cmn.PanicQ(fmt.Sprintf("Failed to process committed block (%d:%X): %v",
first.Height, first.Hash(), err)) first.Height, first.Hash(), err))
} }
blocksSynced++ blocksSynced++
@ -378,7 +378,7 @@ type bcBlockRequestMessage struct {
} }
func (m *bcBlockRequestMessage) String() string { func (m *bcBlockRequestMessage) String() string {
return cmn.Fmt("[bcBlockRequestMessage %v]", m.Height)
return fmt.Sprintf("[bcBlockRequestMessage %v]", m.Height)
} }
type bcNoBlockResponseMessage struct { type bcNoBlockResponseMessage struct {
@ -386,7 +386,7 @@ type bcNoBlockResponseMessage struct {
} }
func (brm *bcNoBlockResponseMessage) String() string { func (brm *bcNoBlockResponseMessage) String() string {
return cmn.Fmt("[bcNoBlockResponseMessage %d]", brm.Height)
return fmt.Sprintf("[bcNoBlockResponseMessage %d]", brm.Height)
} }
//------------------------------------- //-------------------------------------
@ -396,7 +396,7 @@ type bcBlockResponseMessage struct {
} }
func (m *bcBlockResponseMessage) String() string { func (m *bcBlockResponseMessage) String() string {
return cmn.Fmt("[bcBlockResponseMessage %v]", m.Block.Height)
return fmt.Sprintf("[bcBlockResponseMessage %v]", m.Block.Height)
} }
//------------------------------------- //-------------------------------------
@ -406,7 +406,7 @@ type bcStatusRequestMessage struct {
} }
func (m *bcStatusRequestMessage) String() string { func (m *bcStatusRequestMessage) String() string {
return cmn.Fmt("[bcStatusRequestMessage %v]", m.Height)
return fmt.Sprintf("[bcStatusRequestMessage %v]", m.Height)
} }
//------------------------------------- //-------------------------------------
@ -416,5 +416,5 @@ type bcStatusResponseMessage struct {
} }
func (m *bcStatusResponseMessage) String() string { func (m *bcStatusResponseMessage) String() string {
return cmn.Fmt("[bcStatusResponseMessage %v]", m.Height)
return fmt.Sprintf("[bcStatusResponseMessage %v]", m.Height)
} }

+ 4
- 4
blockchain/store.go View File

@ -148,10 +148,10 @@ func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, s
} }
height := block.Height height := block.Height
if g, w := height, bs.Height()+1; g != w { if g, w := height, bs.Height()+1; g != w {
cmn.PanicSanity(cmn.Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", w, g))
cmn.PanicSanity(fmt.Sprintf("BlockStore can only save contiguous blocks. Wanted %v, got %v", w, g))
} }
if !blockParts.IsComplete() { if !blockParts.IsComplete() {
cmn.PanicSanity(cmn.Fmt("BlockStore can only save complete block part sets"))
cmn.PanicSanity(fmt.Sprintf("BlockStore can only save complete block part sets"))
} }
// Save block meta // Save block meta
@ -188,7 +188,7 @@ func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, s
func (bs *BlockStore) saveBlockPart(height int64, index int, part *types.Part) { func (bs *BlockStore) saveBlockPart(height int64, index int, part *types.Part) {
if height != bs.Height()+1 { if height != bs.Height()+1 {
cmn.PanicSanity(cmn.Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.Height()+1, height))
cmn.PanicSanity(fmt.Sprintf("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.Height()+1, height))
} }
partBytes := cdc.MustMarshalBinaryBare(part) partBytes := cdc.MustMarshalBinaryBare(part)
bs.db.Set(calcBlockPartKey(height, index), partBytes) bs.db.Set(calcBlockPartKey(height, index), partBytes)
@ -224,7 +224,7 @@ type BlockStoreStateJSON struct {
func (bsj BlockStoreStateJSON) Save(db dbm.DB) { func (bsj BlockStoreStateJSON) Save(db dbm.DB) {
bytes, err := cdc.MarshalJSON(bsj) bytes, err := cdc.MarshalJSON(bsj)
if err != nil { if err != nil {
cmn.PanicSanity(cmn.Fmt("Could not marshal state bytes: %v", err))
cmn.PanicSanity(fmt.Sprintf("Could not marshal state bytes: %v", err))
} }
db.SetSync(blockStoreKey, bytes) db.SetSync(blockStoreKey, bytes)
} }


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

@ -5,8 +5,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/tendermint/p2p"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p"
) )
// GenNodeKeyCmd allows the generation of a node key. It prints node's ID to // GenNodeKeyCmd allows the generation of a node key. It prints node's ID to


+ 3
- 2
cmd/tendermint/commands/init.go View File

@ -1,15 +1,16 @@
package commands package commands
import ( import (
"fmt"
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
// InitFilesCmd initialises a fresh Tendermint Core instance. // InitFilesCmd initialises a fresh Tendermint Core instance.
@ -52,7 +53,7 @@ func initFilesWithConfig(config *cfg.Config) error {
logger.Info("Found genesis file", "path", genFile) logger.Info("Found genesis file", "path", genFile)
} else { } else {
genDoc := types.GenesisDoc{ genDoc := types.GenesisDoc{
ChainID: cmn.Fmt("test-chain-%v", cmn.RandStr(6)),
ChainID: fmt.Sprintf("test-chain-%v", cmn.RandStr(6)),
GenesisTime: time.Now(), GenesisTime: time.Now(),
ConsensusParams: types.DefaultConsensusParams(), ConsensusParams: types.DefaultConsensusParams(),
} }


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

@ -5,8 +5,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/privval"
) )
// ResetAllCmd removes the database of this Tendermint core // ResetAllCmd removes the database of this Tendermint core


+ 6
- 6
cmd/tendermint/commands/testnet.go View File

@ -11,10 +11,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
var ( var (
@ -76,7 +76,7 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
genVals := make([]types.GenesisValidator, nValidators) genVals := make([]types.GenesisValidator, nValidators)
for i := 0; i < nValidators; i++ { for i := 0; i < nValidators; i++ {
nodeDirName := cmn.Fmt("%s%d", nodeDirPrefix, i)
nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
nodeDir := filepath.Join(outputDir, nodeDirName) nodeDir := filepath.Join(outputDir, nodeDirName)
config.SetRoot(nodeDir) config.SetRoot(nodeDir)
@ -98,7 +98,7 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
} }
for i := 0; i < nNonValidators; i++ { for i := 0; i < nNonValidators; i++ {
nodeDir := filepath.Join(outputDir, cmn.Fmt("%s%d", nodeDirPrefix, i+nValidators))
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i+nValidators))
config.SetRoot(nodeDir) config.SetRoot(nodeDir)
err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm) err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm)
@ -119,7 +119,7 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
// Write genesis file. // Write genesis file.
for i := 0; i < nValidators+nNonValidators; i++ { for i := 0; i < nValidators+nNonValidators; i++ {
nodeDir := filepath.Join(outputDir, cmn.Fmt("%s%d", nodeDirPrefix, i))
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
if err := genDoc.SaveAs(filepath.Join(nodeDir, config.BaseConfig.Genesis)); err != nil { if err := genDoc.SaveAs(filepath.Join(nodeDir, config.BaseConfig.Genesis)); err != nil {
_ = os.RemoveAll(outputDir) _ = os.RemoveAll(outputDir)
return err return err
@ -159,7 +159,7 @@ func hostnameOrIP(i int) string {
func populatePersistentPeersInConfigAndWriteIt(config *cfg.Config) error { func populatePersistentPeersInConfigAndWriteIt(config *cfg.Config) error {
persistentPeers := make([]string, nValidators+nNonValidators) persistentPeers := make([]string, nValidators+nNonValidators)
for i := 0; i < nValidators+nNonValidators; i++ { for i := 0; i < nValidators+nNonValidators; i++ {
nodeDir := filepath.Join(outputDir, cmn.Fmt("%s%d", nodeDirPrefix, i))
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
config.SetRoot(nodeDir) config.SetRoot(nodeDir)
nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile()) nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
if err != nil { if err != nil {
@ -170,7 +170,7 @@ func populatePersistentPeersInConfigAndWriteIt(config *cfg.Config) error {
persistentPeersList := strings.Join(persistentPeers, ",") persistentPeersList := strings.Join(persistentPeers, ",")
for i := 0; i < nValidators+nNonValidators; i++ { for i := 0; i < nValidators+nNonValidators; i++ {
nodeDir := filepath.Join(outputDir, cmn.Fmt("%s%d", nodeDirPrefix, i))
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
config.SetRoot(nodeDir) config.SetRoot(nodeDir)
config.P2P.PersistentPeers = persistentPeersList config.P2P.PersistentPeers = persistentPeersList
config.P2P.AddrBookStrict = false config.P2P.AddrBookStrict = false


+ 4
- 3
consensus/byzantine_test.go View File

@ -2,14 +2,15 @@ package consensus
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
func init() { func init() {
@ -156,8 +157,8 @@ func TestByzantine(t *testing.T) {
case <-done: case <-done:
case <-tick.C: case <-tick.C:
for i, reactor := range reactors { for i, reactor := range reactors {
t.Log(cmn.Fmt("Consensus Reactor %v", i))
t.Log(cmn.Fmt("%v", reactor))
t.Log(fmt.Sprintf("Consensus Reactor %v", i))
t.Log(fmt.Sprintf("%v", reactor))
} }
t.Fatalf("Timed out waiting for all validators to commit first block") t.Fatalf("Timed out waiting for all validators to commit first block")
} }


+ 2
- 2
consensus/common_test.go View File

@ -348,7 +348,7 @@ func randConsensusNet(nValidators int, testName string, tickerFunc func() Timeou
for i := 0; i < nValidators; i++ { for i := 0; i < nValidators; i++ {
stateDB := dbm.NewMemDB() // each state needs its own db stateDB := dbm.NewMemDB() // each state needs its own db
state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc) state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc)
thisConfig := ResetConfig(cmn.Fmt("%s_%d", testName, i))
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
for _, opt := range configOpts { for _, opt := range configOpts {
opt(thisConfig) opt(thisConfig)
} }
@ -372,7 +372,7 @@ func randConsensusNetWithPeers(nValidators, nPeers int, testName string, tickerF
for i := 0; i < nPeers; i++ { for i := 0; i < nPeers; i++ {
stateDB := dbm.NewMemDB() // each state needs its own db stateDB := dbm.NewMemDB() // each state needs its own db
state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc) state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc)
thisConfig := ResetConfig(cmn.Fmt("%s_%d", testName, i))
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
var privVal types.PrivValidator var privVal types.PrivValidator
if i < nValidators { if i < nValidators {


+ 3
- 4
consensus/mempool_test.go View File

@ -10,7 +10,6 @@ import (
"github.com/tendermint/tendermint/abci/example/code" "github.com/tendermint/tendermint/abci/example/code"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
@ -89,7 +88,7 @@ func deliverTxsRange(cs *ConsensusState, start, end int) {
binary.BigEndian.PutUint64(txBytes, uint64(i)) binary.BigEndian.PutUint64(txBytes, uint64(i))
err := cs.mempool.CheckTx(txBytes, nil) err := cs.mempool.CheckTx(txBytes, nil)
if err != nil { if err != nil {
panic(cmn.Fmt("Error after CheckTx: %v", err))
panic(fmt.Sprintf("Error after CheckTx: %v", err))
} }
} }
} }
@ -126,7 +125,7 @@ func TestMempoolRmBadTx(t *testing.T) {
binary.BigEndian.PutUint64(txBytes, uint64(0)) binary.BigEndian.PutUint64(txBytes, uint64(0))
resDeliver := app.DeliverTx(txBytes) resDeliver := app.DeliverTx(txBytes)
assert.False(t, resDeliver.IsErr(), cmn.Fmt("expected no error. got %v", resDeliver))
assert.False(t, resDeliver.IsErr(), fmt.Sprintf("expected no error. got %v", resDeliver))
resCommit := app.Commit() resCommit := app.Commit()
assert.True(t, len(resCommit.Data) > 0) assert.True(t, len(resCommit.Data) > 0)
@ -190,7 +189,7 @@ func NewCounterApplication() *CounterApplication {
} }
func (app *CounterApplication) Info(req abci.RequestInfo) abci.ResponseInfo { func (app *CounterApplication) Info(req abci.RequestInfo) abci.ResponseInfo {
return abci.ResponseInfo{Data: cmn.Fmt("txs:%v", app.txCount)}
return abci.ResponseInfo{Data: fmt.Sprintf("txs:%v", app.txCount)}
} }
func (app *CounterApplication) DeliverTx(tx []byte) abci.ResponseDeliverTx { func (app *CounterApplication) DeliverTx(tx []byte) abci.ResponseDeliverTx {


+ 8
- 8
consensus/reactor.go View File

@ -241,7 +241,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
"height", hb.Height, "round", hb.Round, "sequence", hb.Sequence, "height", hb.Height, "round", hb.Round, "sequence", hb.Sequence,
"valIdx", hb.ValidatorIndex, "valAddr", hb.ValidatorAddress) "valIdx", hb.ValidatorIndex, "valAddr", hb.ValidatorAddress)
default: default:
conR.Logger.Error(cmn.Fmt("Unknown message type %v", reflect.TypeOf(msg)))
conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
} }
case DataChannel: case DataChannel:
@ -262,7 +262,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
} }
conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()} conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()}
default: default:
conR.Logger.Error(cmn.Fmt("Unknown message type %v", reflect.TypeOf(msg)))
conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
} }
case VoteChannel: case VoteChannel:
@ -287,7 +287,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
default: default:
// don't punish (leave room for soft upgrades) // don't punish (leave room for soft upgrades)
conR.Logger.Error(cmn.Fmt("Unknown message type %v", reflect.TypeOf(msg)))
conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
} }
case VoteSetBitsChannel: case VoteSetBitsChannel:
@ -319,11 +319,11 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
} }
default: default:
// don't punish (leave room for soft upgrades) // don't punish (leave room for soft upgrades)
conR.Logger.Error(cmn.Fmt("Unknown message type %v", reflect.TypeOf(msg)))
conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
} }
default: default:
conR.Logger.Error(cmn.Fmt("Unknown chId %X", chID))
conR.Logger.Error(fmt.Sprintf("Unknown chId %X", chID))
} }
if err != nil { if err != nil {
@ -482,7 +482,7 @@ OUTER_LOOP:
if prs.ProposalBlockParts == nil { if prs.ProposalBlockParts == nil {
blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height) blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
if blockMeta == nil { if blockMeta == nil {
cmn.PanicCrisis(cmn.Fmt("Failed to load block %d when blockStore is at %d",
cmn.PanicCrisis(fmt.Sprintf("Failed to load block %d when blockStore is at %d",
prs.Height, conR.conS.blockStore.Height())) prs.Height, conR.conS.blockStore.Height()))
} }
ps.InitProposalBlockParts(blockMeta.BlockID.PartsHeader) ps.InitProposalBlockParts(blockMeta.BlockID.PartsHeader)
@ -1034,7 +1034,7 @@ func (ps *PeerState) ensureCatchupCommitRound(height int64, round int, numValida
NOTE: This is wrong, 'round' could change. NOTE: This is wrong, 'round' could change.
e.g. if orig round is not the same as block LastCommit round. e.g. if orig round is not the same as block LastCommit round.
if ps.CatchupCommitRound != -1 && ps.CatchupCommitRound != round { if ps.CatchupCommitRound != -1 && ps.CatchupCommitRound != round {
cmn.PanicSanity(cmn.Fmt("Conflicting CatchupCommitRound. Height: %v, Orig: %v, New: %v", height, ps.CatchupCommitRound, round))
cmn.PanicSanity(fmt.Sprintf("Conflicting CatchupCommitRound. Height: %v, Orig: %v, New: %v", height, ps.CatchupCommitRound, round))
} }
*/ */
if ps.PRS.CatchupCommitRound == round { if ps.PRS.CatchupCommitRound == round {
@ -1138,7 +1138,7 @@ func (ps *PeerState) SetHasVote(vote *types.Vote) {
} }
func (ps *PeerState) setHasVote(height int64, round int, type_ byte, index int) { func (ps *PeerState) setHasVote(height int64, round int, type_ byte, index int) {
logger := ps.logger.With("peerH/R", cmn.Fmt("%d/%d", ps.PRS.Height, ps.PRS.Round), "H/R", cmn.Fmt("%d/%d", height, round))
logger := ps.logger.With("peerH/R", fmt.Sprintf("%d/%d", ps.PRS.Height, ps.PRS.Round), "H/R", fmt.Sprintf("%d/%d", height, round))
logger.Debug("setHasVote", "type", type_, "index", index) logger.Debug("setHasVote", "type", type_, "index", index)
// NOTE: some may be nil BitArrays -> no side effects. // NOTE: some may be nil BitArrays -> no side effects.


+ 1
- 1
consensus/reactor_test.go View File

@ -115,7 +115,7 @@ func TestReactorWithEvidence(t *testing.T) {
for i := 0; i < nValidators; i++ { for i := 0; i < nValidators; i++ {
stateDB := dbm.NewMemDB() // each state needs its own db stateDB := dbm.NewMemDB() // each state needs its own db
state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc) state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc)
thisConfig := ResetConfig(cmn.Fmt("%s_%d", testName, i))
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal
app := appFunc() app := appFunc()
vals := types.TM2PB.Validators(state.Validators) vals := types.TM2PB.Validators(state.Validators)


+ 2
- 2
consensus/replay.go View File

@ -304,11 +304,11 @@ func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight
} else if storeBlockHeight < stateBlockHeight { } else if storeBlockHeight < stateBlockHeight {
// the state should never be ahead of the store (this is under tendermint's control) // the state should never be ahead of the store (this is under tendermint's control)
cmn.PanicSanity(cmn.Fmt("StateBlockHeight (%d) > StoreBlockHeight (%d)", stateBlockHeight, storeBlockHeight))
cmn.PanicSanity(fmt.Sprintf("StateBlockHeight (%d) > StoreBlockHeight (%d)", stateBlockHeight, storeBlockHeight))
} else if storeBlockHeight > stateBlockHeight+1 { } else if storeBlockHeight > stateBlockHeight+1 {
// store should be at most one ahead of the state (this is under tendermint's control) // store should be at most one ahead of the state (this is under tendermint's control)
cmn.PanicSanity(cmn.Fmt("StoreBlockHeight (%d) > StateBlockHeight + 1 (%d)", storeBlockHeight, stateBlockHeight+1))
cmn.PanicSanity(fmt.Sprintf("StoreBlockHeight (%d) > StateBlockHeight + 1 (%d)", storeBlockHeight, stateBlockHeight+1))
} }
var err error var err error


+ 6
- 6
consensus/replay_file.go View File

@ -13,12 +13,12 @@ import (
bc "github.com/tendermint/tendermint/blockchain" bc "github.com/tendermint/tendermint/blockchain"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
) )
const ( const (
@ -34,7 +34,7 @@ func RunReplayFile(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig, console
consensusState := newConsensusStateForReplay(config, csConfig) consensusState := newConsensusStateForReplay(config, csConfig)
if err := consensusState.ReplayFile(csConfig.WalFile(), console); err != nil { if err := consensusState.ReplayFile(csConfig.WalFile(), console); err != nil {
cmn.Exit(cmn.Fmt("Error during consensus replay: %v", err))
cmn.Exit(fmt.Sprintf("Error during consensus replay: %v", err))
} }
} }
@ -302,12 +302,12 @@ func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusCo
NewHandshaker(stateDB, state, blockStore, gdoc)) NewHandshaker(stateDB, state, blockStore, gdoc))
err = proxyApp.Start() err = proxyApp.Start()
if err != nil { if err != nil {
cmn.Exit(cmn.Fmt("Error starting proxy app conns: %v", err))
cmn.Exit(fmt.Sprintf("Error starting proxy app conns: %v", err))
} }
eventBus := types.NewEventBus() eventBus := types.NewEventBus()
if err := eventBus.Start(); err != nil { if err := eventBus.Start(); err != nil {
cmn.Exit(cmn.Fmt("Failed to start event bus: %v", err))
cmn.Exit(fmt.Sprintf("Failed to start event bus: %v", err))
} }
mempool, evpool := sm.MockMempool{}, sm.MockEvidencePool{} mempool, evpool := sm.MockMempool{}, sm.MockEvidencePool{}


+ 6
- 8
consensus/replay_test.go View File

@ -3,7 +3,6 @@ package consensus
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -20,15 +19,14 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
crypto "github.com/tendermint/tendermint/crypto" crypto "github.com/tendermint/tendermint/crypto"
auto "github.com/tendermint/tendermint/libs/autofile" auto "github.com/tendermint/tendermint/libs/autofile"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/libs/log"
) )
var consensusReplayConfig *cfg.Config var consensusReplayConfig *cfg.Config
@ -494,7 +492,7 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) {
return nil, nil, err return nil, nil, err
} }
if !found { if !found {
return nil, nil, errors.New(cmn.Fmt("WAL does not contain height %d.", 1))
return nil, nil, fmt.Errorf("WAL does not contain height %d.", 1)
} }
defer gr.Close() // nolint: errcheck defer gr.Close() // nolint: errcheck
@ -531,11 +529,11 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) {
panic(err) panic(err)
} }
if block.Height != height+1 { if block.Height != height+1 {
panic(cmn.Fmt("read bad block from wal. got height %d, expected %d", block.Height, height+1))
panic(fmt.Sprintf("read bad block from wal. got height %d, expected %d", block.Height, height+1))
} }
commitHeight := thisBlockCommit.Precommits[0].Height commitHeight := thisBlockCommit.Precommits[0].Height
if commitHeight != height+1 { if commitHeight != height+1 {
panic(cmn.Fmt("commit doesnt match. got height %d, expected %d", commitHeight, height+1))
panic(fmt.Sprintf("commit doesnt match. got height %d, expected %d", commitHeight, height+1))
} }
blocks = append(blocks, block) blocks = append(blocks, block)
commits = append(commits, thisBlockCommit) commits = append(commits, thisBlockCommit)
@ -564,11 +562,11 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) {
panic(err) panic(err)
} }
if block.Height != height+1 { if block.Height != height+1 {
panic(cmn.Fmt("read bad block from wal. got height %d, expected %d", block.Height, height+1))
panic(fmt.Sprintf("read bad block from wal. got height %d, expected %d", block.Height, height+1))
} }
commitHeight := thisBlockCommit.Precommits[0].Height commitHeight := thisBlockCommit.Precommits[0].Height
if commitHeight != height+1 { if commitHeight != height+1 {
panic(cmn.Fmt("commit doesnt match. got height %d, expected %d", commitHeight, height+1))
panic(fmt.Sprintf("commit doesnt match. got height %d, expected %d", commitHeight, height+1))
} }
blocks = append(blocks, block) blocks = append(blocks, block)
commits = append(commits, thisBlockCommit) commits = append(commits, thisBlockCommit)


+ 34
- 34
consensus/state.go View File

@ -186,7 +186,7 @@ func WithMetrics(metrics *Metrics) CSOption {
// String returns a string. // String returns a string.
func (cs *ConsensusState) String() string { func (cs *ConsensusState) String() string {
// better not to access shared variables // better not to access shared variables
return cmn.Fmt("ConsensusState") //(H:%v R:%v S:%v", cs.Height, cs.Round, cs.Step)
return fmt.Sprintf("ConsensusState") //(H:%v R:%v S:%v", cs.Height, cs.Round, cs.Step)
} }
// GetState returns a copy of the chain state. // GetState returns a copy of the chain state.
@ -459,7 +459,7 @@ func (cs *ConsensusState) reconstructLastCommit(state sm.State) {
} }
added, err := lastPrecommits.AddVote(precommit) added, err := lastPrecommits.AddVote(precommit)
if !added || err != nil { if !added || err != nil {
cmn.PanicCrisis(cmn.Fmt("Failed to reconstruct LastCommit: %v", err))
cmn.PanicCrisis(fmt.Sprintf("Failed to reconstruct LastCommit: %v", err))
} }
} }
if !lastPrecommits.HasTwoThirdsMajority() { if !lastPrecommits.HasTwoThirdsMajority() {
@ -472,13 +472,13 @@ func (cs *ConsensusState) reconstructLastCommit(state sm.State) {
// The round becomes 0 and cs.Step becomes cstypes.RoundStepNewHeight. // The round becomes 0 and cs.Step becomes cstypes.RoundStepNewHeight.
func (cs *ConsensusState) updateToState(state sm.State) { func (cs *ConsensusState) updateToState(state sm.State) {
if cs.CommitRound > -1 && 0 < cs.Height && cs.Height != state.LastBlockHeight { if cs.CommitRound > -1 && 0 < cs.Height && cs.Height != state.LastBlockHeight {
cmn.PanicSanity(cmn.Fmt("updateToState() expected state height of %v but found %v",
cmn.PanicSanity(fmt.Sprintf("updateToState() expected state height of %v but found %v",
cs.Height, state.LastBlockHeight)) cs.Height, state.LastBlockHeight))
} }
if !cs.state.IsEmpty() && cs.state.LastBlockHeight+1 != cs.Height { if !cs.state.IsEmpty() && cs.state.LastBlockHeight+1 != cs.Height {
// This might happen when someone else is mutating cs.state. // This might happen when someone else is mutating cs.state.
// Someone forgot to pass in state.Copy() somewhere?! // Someone forgot to pass in state.Copy() somewhere?!
cmn.PanicSanity(cmn.Fmt("Inconsistent cs.state.LastBlockHeight+1 %v vs cs.Height %v",
cmn.PanicSanity(fmt.Sprintf("Inconsistent cs.state.LastBlockHeight+1 %v vs cs.Height %v",
cs.state.LastBlockHeight+1, cs.Height)) cs.state.LastBlockHeight+1, cs.Height))
} }
@ -698,7 +698,7 @@ func (cs *ConsensusState) handleTimeout(ti timeoutInfo, rs cstypes.RoundState) {
cs.eventBus.PublishEventTimeoutWait(cs.RoundStateEvent()) cs.eventBus.PublishEventTimeoutWait(cs.RoundStateEvent())
cs.enterNewRound(ti.Height, ti.Round+1) cs.enterNewRound(ti.Height, ti.Round+1)
default: default:
panic(cmn.Fmt("Invalid timeout step: %v", ti.Step))
panic(fmt.Sprintf("Invalid timeout step: %v", ti.Step))
} }
} }
@ -724,7 +724,7 @@ func (cs *ConsensusState) enterNewRound(height int64, round int) {
logger := cs.Logger.With("height", height, "round", round) logger := cs.Logger.With("height", height, "round", round)
if cs.Height != height || round < cs.Round || (cs.Round == round && cs.Step != cstypes.RoundStepNewHeight) { if cs.Height != height || round < cs.Round || (cs.Round == round && cs.Step != cstypes.RoundStepNewHeight) {
logger.Debug(cmn.Fmt("enterNewRound(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Debug(fmt.Sprintf("enterNewRound(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
return return
} }
@ -732,7 +732,7 @@ func (cs *ConsensusState) enterNewRound(height int64, round int) {
logger.Info("Need to set a buffer and log message here for sanity.", "startTime", cs.StartTime, "now", now) logger.Info("Need to set a buffer and log message here for sanity.", "startTime", cs.StartTime, "now", now)
} }
logger.Info(cmn.Fmt("enterNewRound(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Info(fmt.Sprintf("enterNewRound(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
// Increment validators if necessary // Increment validators if necessary
validators := cs.Validators validators := cs.Validators
@ -819,10 +819,10 @@ func (cs *ConsensusState) enterPropose(height int64, round int) {
logger := cs.Logger.With("height", height, "round", round) logger := cs.Logger.With("height", height, "round", round)
if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPropose <= cs.Step) { if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPropose <= cs.Step) {
logger.Debug(cmn.Fmt("enterPropose(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Debug(fmt.Sprintf("enterPropose(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
return return
} }
logger.Info(cmn.Fmt("enterPropose(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Info(fmt.Sprintf("enterPropose(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
defer func() { defer func() {
// Done enterPropose: // Done enterPropose:
@ -902,7 +902,7 @@ func (cs *ConsensusState) defaultDecideProposal(height int64, round int) {
cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""}) cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""})
} }
cs.Logger.Info("Signed proposal", "height", height, "round", round, "proposal", proposal) cs.Logger.Info("Signed proposal", "height", height, "round", round, "proposal", proposal)
cs.Logger.Debug(cmn.Fmt("Signed proposal block: %v", block))
cs.Logger.Debug(fmt.Sprintf("Signed proposal block: %v", block))
} else { } else {
if !cs.replayMode { if !cs.replayMode {
cs.Logger.Error("enterPropose: Error signing proposal", "height", height, "round", round, "err", err) cs.Logger.Error("enterPropose: Error signing proposal", "height", height, "round", round, "err", err)
@ -961,7 +961,7 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts
// Otherwise vote nil. // Otherwise vote nil.
func (cs *ConsensusState) enterPrevote(height int64, round int) { func (cs *ConsensusState) enterPrevote(height int64, round int) {
if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevote <= cs.Step) { if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevote <= cs.Step) {
cs.Logger.Debug(cmn.Fmt("enterPrevote(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
cs.Logger.Debug(fmt.Sprintf("enterPrevote(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
return return
} }
@ -979,7 +979,7 @@ func (cs *ConsensusState) enterPrevote(height int64, round int) {
// TODO: catchup event? // TODO: catchup event?
} }
cs.Logger.Info(cmn.Fmt("enterPrevote(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
cs.Logger.Info(fmt.Sprintf("enterPrevote(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
// Sign and broadcast vote as necessary // Sign and broadcast vote as necessary
cs.doPrevote(height, round) cs.doPrevote(height, round)
@ -1025,13 +1025,13 @@ func (cs *ConsensusState) enterPrevoteWait(height int64, round int) {
logger := cs.Logger.With("height", height, "round", round) logger := cs.Logger.With("height", height, "round", round)
if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevoteWait <= cs.Step) { if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrevoteWait <= cs.Step) {
logger.Debug(cmn.Fmt("enterPrevoteWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Debug(fmt.Sprintf("enterPrevoteWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
return return
} }
if !cs.Votes.Prevotes(round).HasTwoThirdsAny() { if !cs.Votes.Prevotes(round).HasTwoThirdsAny() {
cmn.PanicSanity(cmn.Fmt("enterPrevoteWait(%v/%v), but Prevotes does not have any +2/3 votes", height, round))
cmn.PanicSanity(fmt.Sprintf("enterPrevoteWait(%v/%v), but Prevotes does not have any +2/3 votes", height, round))
} }
logger.Info(cmn.Fmt("enterPrevoteWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Info(fmt.Sprintf("enterPrevoteWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
defer func() { defer func() {
// Done enterPrevoteWait: // Done enterPrevoteWait:
@ -1053,11 +1053,11 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) {
logger := cs.Logger.With("height", height, "round", round) logger := cs.Logger.With("height", height, "round", round)
if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommit <= cs.Step) { if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommit <= cs.Step) {
logger.Debug(cmn.Fmt("enterPrecommit(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Debug(fmt.Sprintf("enterPrecommit(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
return return
} }
logger.Info(cmn.Fmt("enterPrecommit(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Info(fmt.Sprintf("enterPrecommit(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
defer func() { defer func() {
// Done enterPrecommit: // Done enterPrecommit:
@ -1085,7 +1085,7 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) {
// the latest POLRound should be this round. // the latest POLRound should be this round.
polRound, _ := cs.Votes.POLInfo() polRound, _ := cs.Votes.POLInfo()
if polRound < round { if polRound < round {
cmn.PanicSanity(cmn.Fmt("This POLRound should be %v but got %", round, polRound))
cmn.PanicSanity(fmt.Sprintf("This POLRound should be %v but got %v", round, polRound))
} }
// +2/3 prevoted nil. Unlock and precommit nil. // +2/3 prevoted nil. Unlock and precommit nil.
@ -1119,7 +1119,7 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) {
logger.Info("enterPrecommit: +2/3 prevoted proposal block. Locking", "hash", blockID.Hash) logger.Info("enterPrecommit: +2/3 prevoted proposal block. Locking", "hash", blockID.Hash)
// Validate the block. // Validate the block.
if err := cs.blockExec.ValidateBlock(cs.state, cs.ProposalBlock); err != nil { if err := cs.blockExec.ValidateBlock(cs.state, cs.ProposalBlock); err != nil {
cmn.PanicConsensus(cmn.Fmt("enterPrecommit: +2/3 prevoted for an invalid block: %v", err))
cmn.PanicConsensus(fmt.Sprintf("enterPrecommit: +2/3 prevoted for an invalid block: %v", err))
} }
cs.LockedRound = round cs.LockedRound = round
cs.LockedBlock = cs.ProposalBlock cs.LockedBlock = cs.ProposalBlock
@ -1149,13 +1149,13 @@ func (cs *ConsensusState) enterPrecommitWait(height int64, round int) {
logger := cs.Logger.With("height", height, "round", round) logger := cs.Logger.With("height", height, "round", round)
if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommitWait <= cs.Step) { if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommitWait <= cs.Step) {
logger.Debug(cmn.Fmt("enterPrecommitWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Debug(fmt.Sprintf("enterPrecommitWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
return return
} }
if !cs.Votes.Precommits(round).HasTwoThirdsAny() { if !cs.Votes.Precommits(round).HasTwoThirdsAny() {
cmn.PanicSanity(cmn.Fmt("enterPrecommitWait(%v/%v), but Precommits does not have any +2/3 votes", height, round))
cmn.PanicSanity(fmt.Sprintf("enterPrecommitWait(%v/%v), but Precommits does not have any +2/3 votes", height, round))
} }
logger.Info(cmn.Fmt("enterPrecommitWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
logger.Info(fmt.Sprintf("enterPrecommitWait(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
defer func() { defer func() {
// Done enterPrecommitWait: // Done enterPrecommitWait:
@ -1173,10 +1173,10 @@ func (cs *ConsensusState) enterCommit(height int64, commitRound int) {
logger := cs.Logger.With("height", height, "commitRound", commitRound) logger := cs.Logger.With("height", height, "commitRound", commitRound)
if cs.Height != height || cstypes.RoundStepCommit <= cs.Step { if cs.Height != height || cstypes.RoundStepCommit <= cs.Step {
logger.Debug(cmn.Fmt("enterCommit(%v/%v): Invalid args. Current step: %v/%v/%v", height, commitRound, cs.Height, cs.Round, cs.Step))
logger.Debug(fmt.Sprintf("enterCommit(%v/%v): Invalid args. Current step: %v/%v/%v", height, commitRound, cs.Height, cs.Round, cs.Step))
return return
} }
logger.Info(cmn.Fmt("enterCommit(%v/%v). Current: %v/%v/%v", height, commitRound, cs.Height, cs.Round, cs.Step))
logger.Info(fmt.Sprintf("enterCommit(%v/%v). Current: %v/%v/%v", height, commitRound, cs.Height, cs.Round, cs.Step))
defer func() { defer func() {
// Done enterCommit: // Done enterCommit:
@ -1223,7 +1223,7 @@ func (cs *ConsensusState) tryFinalizeCommit(height int64) {
logger := cs.Logger.With("height", height) logger := cs.Logger.With("height", height)
if cs.Height != height { if cs.Height != height {
cmn.PanicSanity(cmn.Fmt("tryFinalizeCommit() cs.Height: %v vs height: %v", cs.Height, height))
cmn.PanicSanity(fmt.Sprintf("tryFinalizeCommit() cs.Height: %v vs height: %v", cs.Height, height))
} }
blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority() blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority()
@ -1245,7 +1245,7 @@ func (cs *ConsensusState) tryFinalizeCommit(height int64) {
// Increment height and goto cstypes.RoundStepNewHeight // Increment height and goto cstypes.RoundStepNewHeight
func (cs *ConsensusState) finalizeCommit(height int64) { func (cs *ConsensusState) finalizeCommit(height int64) {
if cs.Height != height || cs.Step != cstypes.RoundStepCommit { if cs.Height != height || cs.Step != cstypes.RoundStepCommit {
cs.Logger.Debug(cmn.Fmt("finalizeCommit(%v): Invalid args. Current step: %v/%v/%v", height, cs.Height, cs.Round, cs.Step))
cs.Logger.Debug(fmt.Sprintf("finalizeCommit(%v): Invalid args. Current step: %v/%v/%v", height, cs.Height, cs.Round, cs.Step))
return return
} }
@ -1253,21 +1253,21 @@ func (cs *ConsensusState) finalizeCommit(height int64) {
block, blockParts := cs.ProposalBlock, cs.ProposalBlockParts block, blockParts := cs.ProposalBlock, cs.ProposalBlockParts
if !ok { if !ok {
cmn.PanicSanity(cmn.Fmt("Cannot finalizeCommit, commit does not have two thirds majority"))
cmn.PanicSanity(fmt.Sprintf("Cannot finalizeCommit, commit does not have two thirds majority"))
} }
if !blockParts.HasHeader(blockID.PartsHeader) { if !blockParts.HasHeader(blockID.PartsHeader) {
cmn.PanicSanity(cmn.Fmt("Expected ProposalBlockParts header to be commit header"))
cmn.PanicSanity(fmt.Sprintf("Expected ProposalBlockParts header to be commit header"))
} }
if !block.HashesTo(blockID.Hash) { if !block.HashesTo(blockID.Hash) {
cmn.PanicSanity(cmn.Fmt("Cannot finalizeCommit, ProposalBlock does not hash to commit hash"))
cmn.PanicSanity(fmt.Sprintf("Cannot finalizeCommit, ProposalBlock does not hash to commit hash"))
} }
if err := cs.blockExec.ValidateBlock(cs.state, block); err != nil { if err := cs.blockExec.ValidateBlock(cs.state, block); err != nil {
cmn.PanicConsensus(cmn.Fmt("+2/3 committed an invalid block: %v", err))
cmn.PanicConsensus(fmt.Sprintf("+2/3 committed an invalid block: %v", err))
} }
cs.Logger.Info(cmn.Fmt("Finalizing commit of block with %d txs", block.NumTxs),
cs.Logger.Info(fmt.Sprintf("Finalizing commit of block with %d txs", block.NumTxs),
"height", block.Height, "hash", block.Hash(), "root", block.AppHash) "height", block.Height, "hash", block.Hash(), "root", block.AppHash)
cs.Logger.Info(cmn.Fmt("%v", block))
cs.Logger.Info(fmt.Sprintf("%v", block))
fail.Fail() // XXX fail.Fail() // XXX
@ -1519,7 +1519,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
return added, err return added, err
} }
cs.Logger.Info(cmn.Fmt("Added to lastPrecommits: %v", cs.LastCommit.StringShort()))
cs.Logger.Info(fmt.Sprintf("Added to lastPrecommits: %v", cs.LastCommit.StringShort()))
cs.eventBus.PublishEventVote(types.EventDataVote{vote}) cs.eventBus.PublishEventVote(types.EventDataVote{vote})
cs.evsw.FireEvent(types.EventVote, vote) cs.evsw.FireEvent(types.EventVote, vote)
@ -1635,7 +1635,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
cs.enterPrecommitWait(height, vote.Round) cs.enterPrecommitWait(height, vote.Round)
} }
default: default:
panic(cmn.Fmt("Unexpected vote type %X", vote.Type)) // go-wire should prevent this.
panic(fmt.Sprintf("Unexpected vote type %X", vote.Type)) // go-wire should prevent this.
} }
return return


+ 3
- 4
consensus/state_test.go View File

@ -8,7 +8,6 @@ import (
"time" "time"
cstypes "github.com/tendermint/tendermint/consensus/types" cstypes "github.com/tendermint/tendermint/consensus/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub" tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
@ -84,7 +83,7 @@ func TestStateProposerSelection0(t *testing.T) {
prop = cs1.GetRoundState().Validators.GetProposer() prop = cs1.GetRoundState().Validators.GetProposer()
if !bytes.Equal(prop.Address, vss[1].GetAddress()) { if !bytes.Equal(prop.Address, vss[1].GetAddress()) {
panic(cmn.Fmt("expected proposer to be validator %d. Got %X", 1, prop.Address))
panic(fmt.Sprintf("expected proposer to be validator %d. Got %X", 1, prop.Address))
} }
} }
@ -106,7 +105,7 @@ func TestStateProposerSelection2(t *testing.T) {
prop := cs1.GetRoundState().Validators.GetProposer() prop := cs1.GetRoundState().Validators.GetProposer()
correctProposer := vss[(i+2)%len(vss)].GetAddress() correctProposer := vss[(i+2)%len(vss)].GetAddress()
if !bytes.Equal(prop.Address, correctProposer) { if !bytes.Equal(prop.Address, correctProposer) {
panic(cmn.Fmt("expected RoundState.Validators.GetProposer() to be validator %d. Got %X", (i+2)%len(vss), prop.Address))
panic(fmt.Sprintf("expected RoundState.Validators.GetProposer() to be validator %d. Got %X", (i+2)%len(vss), prop.Address))
} }
rs := cs1.GetRoundState() rs := cs1.GetRoundState()
@ -445,7 +444,7 @@ func TestStateLockNoPOL(t *testing.T) {
// now we're on a new round and are the proposer // now we're on a new round and are the proposer
if !bytes.Equal(rs.ProposalBlock.Hash(), rs.LockedBlock.Hash()) { if !bytes.Equal(rs.ProposalBlock.Hash(), rs.LockedBlock.Hash()) {
panic(cmn.Fmt("Expected proposal block to be locked block. Got %v, Expected %v", rs.ProposalBlock, rs.LockedBlock))
panic(fmt.Sprintf("Expected proposal block to be locked block. Got %v, Expected %v", rs.ProposalBlock, rs.LockedBlock))
} }
<-voteCh // prevote <-voteCh // prevote


+ 3
- 3
consensus/types/height_vote_set.go View File

@ -6,9 +6,9 @@ import (
"strings" "strings"
"sync" "sync"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
type RoundVoteSet struct { type RoundVoteSet struct {
@ -169,7 +169,7 @@ func (hvs *HeightVoteSet) getVoteSet(round int, type_ byte) *types.VoteSet {
case types.VoteTypePrecommit: case types.VoteTypePrecommit:
return rvs.Precommits return rvs.Precommits
default: default:
cmn.PanicSanity(cmn.Fmt("Unexpected vote type %X", type_))
cmn.PanicSanity(fmt.Sprintf("Unexpected vote type %X", type_))
return nil return nil
} }
} }
@ -219,7 +219,7 @@ func (hvs *HeightVoteSet) StringIndented(indent string) string {
voteSetString = roundVoteSet.Precommits.StringShort() voteSetString = roundVoteSet.Precommits.StringShort()
vsStrings = append(vsStrings, voteSetString) vsStrings = append(vsStrings, voteSetString)
} }
return cmn.Fmt(`HeightVoteSet{H:%v R:0~%v
return fmt.Sprintf(`HeightVoteSet{H:%v R:0~%v
%s %v %s %v
%s}`, %s}`,
hvs.height, hvs.round, hvs.height, hvs.round,


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

@ -1,12 +1,12 @@
package types package types
import ( import (
"fmt"
"testing" "testing"
"time" "time"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
var config *cfg.Config // NOTE: must be reset for each _test.go file var config *cfg.Config // NOTE: must be reset for each _test.go file
@ -62,7 +62,7 @@ func makeVoteHR(t *testing.T, height int64, round int, privVals []types.PrivVali
chainID := config.ChainID() chainID := config.ChainID()
err := privVal.SignVote(chainID, vote) err := privVal.SignVote(chainID, vote)
if err != nil { if err != nil {
panic(cmn.Fmt("Error signing vote: %v", err))
panic(fmt.Sprintf("Error signing vote: %v", err))
return nil return nil
} }
return vote return vote


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

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/types"
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------


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

@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/types"
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------


+ 2
- 4
consensus/version.go View File

@ -1,8 +1,6 @@
package consensus package consensus
import (
cmn "github.com/tendermint/tendermint/libs/common"
)
import "fmt"
// kind of arbitrary // kind of arbitrary
var Spec = "1" // async var Spec = "1" // async
@ -10,4 +8,4 @@ var Major = "0" //
var Minor = "2" // replay refactor var Minor = "2" // replay refactor
var Revision = "2" // validation -> commit var Revision = "2" // validation -> commit
var Version = cmn.Fmt("v%s/%s.%s.%s", Spec, Major, Minor, Revision)
var Version = fmt.Sprintf("v%s/%s.%s.%s", Spec, Major, Minor, Revision)

+ 3
- 3
consensus/wal.go View File

@ -11,9 +11,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
amino "github.com/tendermint/go-amino" amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/types"
auto "github.com/tendermint/tendermint/libs/autofile" auto "github.com/tendermint/tendermint/libs/autofile"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/types"
) )
const ( const (
@ -120,7 +120,7 @@ func (wal *baseWAL) Write(msg WALMessage) {
// Write the wal message // Write the wal message
if err := wal.enc.Encode(&TimedWALMessage{time.Now(), msg}); err != nil { if err := wal.enc.Encode(&TimedWALMessage{time.Now(), msg}); err != nil {
panic(cmn.Fmt("Error writing msg to consensus wal: %v \n\nMessage: %v", err, msg))
panic(fmt.Sprintf("Error writing msg to consensus wal: %v \n\nMessage: %v", err, msg))
} }
} }
@ -134,7 +134,7 @@ func (wal *baseWAL) WriteSync(msg WALMessage) {
wal.Write(msg) wal.Write(msg)
if err := wal.group.Flush(); err != nil { if err := wal.group.Flush(); err != nil {
panic(cmn.Fmt("Error flushing consensus wal buf to file. Error: %v \n", err))
panic(fmt.Sprintf("Error flushing consensus wal buf to file. Error: %v \n", err))
} }
} }


+ 4
- 4
consensus/wal_generator.go View File

@ -13,14 +13,14 @@ import (
"github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/abci/example/kvstore"
bc "github.com/tendermint/tendermint/blockchain" bc "github.com/tendermint/tendermint/blockchain"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
auto "github.com/tendermint/tendermint/libs/autofile" auto "github.com/tendermint/tendermint/libs/autofile"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db" "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
) )
// WALWithNBlocks generates a consensus WAL. It does this by spining up a // WALWithNBlocks generates a consensus WAL. It does this by spining up a


+ 4
- 4
consensus/wal_test.go View File

@ -3,13 +3,13 @@ package consensus
import ( import (
"bytes" "bytes"
"crypto/rand" "crypto/rand"
"fmt"
// "sync" // "sync"
"testing" "testing"
"time" "time"
"github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/consensus/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -54,8 +54,8 @@ func TestWALSearchForEndHeight(t *testing.T) {
h := int64(3) h := int64(3)
gr, found, err := wal.SearchForEndHeight(h, &WALSearchOptions{}) gr, found, err := wal.SearchForEndHeight(h, &WALSearchOptions{})
assert.NoError(t, err, cmn.Fmt("expected not to err on height %d", h))
assert.True(t, found, cmn.Fmt("expected to find end height for %d", h))
assert.NoError(t, err, fmt.Sprintf("expected not to err on height %d", h))
assert.True(t, found, fmt.Sprintf("expected to find end height for %d", h))
assert.NotNil(t, gr, "expected group not to be nil") assert.NotNil(t, gr, "expected group not to be nil")
defer gr.Close() defer gr.Close()
@ -64,7 +64,7 @@ func TestWALSearchForEndHeight(t *testing.T) {
assert.NoError(t, err, "expected to decode a message") assert.NoError(t, err, "expected to decode a message")
rs, ok := msg.Msg.(tmtypes.EventDataRoundState) rs, ok := msg.Msg.(tmtypes.EventDataRoundState)
assert.True(t, ok, "expected message of type EventDataRoundState") assert.True(t, ok, "expected message of type EventDataRoundState")
assert.Equal(t, rs.Height, h+1, cmn.Fmt("wrong height"))
assert.Equal(t, rs.Height, h+1, fmt.Sprintf("wrong height"))
} }
/* /*


+ 2
- 1
crypto/merkle/simple_tree_test.go View File

@ -6,8 +6,9 @@ import (
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
. "github.com/tendermint/tendermint/libs/test" . "github.com/tendermint/tendermint/libs/test"
"github.com/tendermint/tendermint/crypto/tmhash"
"testing" "testing"
"github.com/tendermint/tendermint/crypto/tmhash"
) )
type testItem []byte type testItem []byte


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

@ -2,6 +2,7 @@ package xsalsa20symmetric
import ( import (
"errors" "errors"
"fmt"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
@ -18,7 +19,7 @@ const secretLen = 32
// NOTE: call crypto.MixEntropy() first. // NOTE: call crypto.MixEntropy() first.
func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) { func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) {
if len(secret) != secretLen { if len(secret) != secretLen {
cmn.PanicSanity(cmn.Fmt("Secret must be 32 bytes long, got len %v", len(secret)))
cmn.PanicSanity(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret)))
} }
nonce := crypto.CRandBytes(nonceLen) nonce := crypto.CRandBytes(nonceLen)
nonceArr := [nonceLen]byte{} nonceArr := [nonceLen]byte{}
@ -35,7 +36,7 @@ func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) {
// The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. // The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error) { func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error) {
if len(secret) != secretLen { if len(secret) != secretLen {
cmn.PanicSanity(cmn.Fmt("Secret must be 32 bytes long, got len %v", len(secret)))
cmn.PanicSanity(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret)))
} }
if len(ciphertext) <= secretbox.Overhead+nonceLen { if len(ciphertext) <= secretbox.Overhead+nonceLen {
return nil, errors.New("Ciphertext is too short") return nil, errors.New("Ciphertext is too short")


+ 1
- 1
docs/app-dev/app-development.md View File

@ -502,7 +502,7 @@ In go:
``` ```
func (app *KVStoreApplication) Info(req types.RequestInfo) (resInfo types.ResponseInfo) { func (app *KVStoreApplication) Info(req types.RequestInfo) (resInfo types.ResponseInfo) {
return types.ResponseInfo{Data: cmn.Fmt("{\"size\":%v}", app.state.Size())}
return types.ResponseInfo{Data: fmt.Sprintf("{\"size\":%v}", app.state.Size())}
} }
``` ```


+ 1
- 1
evidence/pool_test.go View File

@ -7,9 +7,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
dbm "github.com/tendermint/tendermint/libs/db"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tendermint/libs/db"
) )
var mockState = sm.State{} var mockState = sm.State{}


+ 1
- 1
evidence/store.go View File

@ -3,8 +3,8 @@ package evidence
import ( import (
"fmt" "fmt"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types"
) )
/* /*


+ 1
- 1
evidence/store_test.go View File

@ -4,8 +4,8 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types"
) )
//------------------------------------------- //-------------------------------------------


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

@ -724,11 +724,11 @@ func (gr *GroupReader) SetIndex(index int) error {
func MakeSimpleSearchFunc(prefix string, target int) SearchFunc { func MakeSimpleSearchFunc(prefix string, target int) SearchFunc {
return func(line string) (int, error) { return func(line string) (int, error) {
if !strings.HasPrefix(line, prefix) { if !strings.HasPrefix(line, prefix) {
return -1, errors.New(cmn.Fmt("Marker line did not have prefix: %v", prefix))
return -1, fmt.Errorf("Marker line did not have prefix: %v", prefix)
} }
i, err := strconv.Atoi(line[len(prefix):]) i, err := strconv.Atoi(line[len(prefix):])
if err != nil { if err != nil {
return -1, errors.New(cmn.Fmt("Failed to parse marker line: %v", err.Error()))
return -1, fmt.Errorf("Failed to parse marker line: %v", err.Error())
} }
if target < i { if target < i {
return 1, nil return 1, nil


+ 2
- 1
libs/common/bit_array_test.go View File

@ -3,6 +3,7 @@ package common
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -149,7 +150,7 @@ func TestBytes(t *testing.T) {
bA.SetIndex(0, true) bA.SetIndex(0, true)
check := func(bA *BitArray, bz []byte) { check := func(bA *BitArray, bz []byte) {
if !bytes.Equal(bA.Bytes(), bz) { if !bytes.Equal(bA.Bytes(), bz) {
panic(Fmt("Expected %X but got %X", bz, bA.Bytes()))
panic(fmt.Sprintf("Expected %X but got %X", bz, bA.Bytes()))
} }
} }
check(bA, []byte{0x01}) check(bA, []byte{0x01})


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

@ -88,7 +88,7 @@ func ColoredBytes(data []byte, textColor, bytesColor func(...interface{}) string
if 0x21 <= b && b < 0x7F { if 0x21 <= b && b < 0x7F {
s += textColor(string(b)) s += textColor(string(b))
} else { } else {
s += bytesColor(Fmt("%02X", b))
s += bytesColor(fmt.Sprintf("%02X", b))
} }
} }
return s return s


+ 7
- 7
libs/common/errors.go View File

@ -10,13 +10,13 @@ import (
func ErrorWrap(cause interface{}, format string, args ...interface{}) Error { func ErrorWrap(cause interface{}, format string, args ...interface{}) Error {
if causeCmnError, ok := cause.(*cmnError); ok { if causeCmnError, ok := cause.(*cmnError); ok {
msg := Fmt(format, args...)
msg := fmt.Sprintf(format, args...)
return causeCmnError.Stacktrace().Trace(1, msg) return causeCmnError.Stacktrace().Trace(1, msg)
} else if cause == nil { } else if cause == nil {
return newCmnError(FmtError{format, args}).Stacktrace() return newCmnError(FmtError{format, args}).Stacktrace()
} else { } else {
// NOTE: causeCmnError is a typed nil here. // NOTE: causeCmnError is a typed nil here.
msg := Fmt(format, args...)
msg := fmt.Sprintf(format, args...)
return newCmnError(cause).Stacktrace().Trace(1, msg) return newCmnError(cause).Stacktrace().Trace(1, msg)
} }
} }
@ -98,7 +98,7 @@ func (err *cmnError) Stacktrace() Error {
// Add tracing information with msg. // Add tracing information with msg.
// Set n=0 unless wrapped with some function, then n > 0. // Set n=0 unless wrapped with some function, then n > 0.
func (err *cmnError) Trace(offset int, format string, args ...interface{}) Error { func (err *cmnError) Trace(offset int, format string, args ...interface{}) Error {
msg := Fmt(format, args...)
msg := fmt.Sprintf(format, args...)
return err.doTrace(msg, offset) return err.doTrace(msg, offset)
} }
@ -221,7 +221,7 @@ func (fe FmtError) Format() string {
// and some guarantee is not satisfied. // and some guarantee is not satisfied.
// XXX DEPRECATED // XXX DEPRECATED
func PanicSanity(v interface{}) { func PanicSanity(v interface{}) {
panic(Fmt("Panicked on a Sanity Check: %v", v))
panic(fmt.Sprintf("Panicked on a Sanity Check: %v", v))
} }
// A panic here means something has gone horribly wrong, in the form of data corruption or // A panic here means something has gone horribly wrong, in the form of data corruption or
@ -229,18 +229,18 @@ func PanicSanity(v interface{}) {
// If they do, it's indicative of a much more serious problem. // If they do, it's indicative of a much more serious problem.
// XXX DEPRECATED // XXX DEPRECATED
func PanicCrisis(v interface{}) { func PanicCrisis(v interface{}) {
panic(Fmt("Panicked on a Crisis: %v", v))
panic(fmt.Sprintf("Panicked on a Crisis: %v", v))
} }
// Indicates a failure of consensus. Someone was malicious or something has // Indicates a failure of consensus. Someone was malicious or something has
// gone horribly wrong. These should really boot us into an "emergency-recover" mode // gone horribly wrong. These should really boot us into an "emergency-recover" mode
// XXX DEPRECATED // XXX DEPRECATED
func PanicConsensus(v interface{}) { func PanicConsensus(v interface{}) {
panic(Fmt("Panicked on a Consensus Failure: %v", v))
panic(fmt.Sprintf("Panicked on a Consensus Failure: %v", v))
} }
// For those times when we're not sure if we should panic // For those times when we're not sure if we should panic
// XXX DEPRECATED // XXX DEPRECATED
func PanicQ(v interface{}) { func PanicQ(v interface{}) {
panic(Fmt("Panicked questionably: %v", v))
panic(fmt.Sprintf("Panicked questionably: %v", v))
} }

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

@ -106,7 +106,7 @@ func ReadFile(filePath string) ([]byte, error) {
func MustReadFile(filePath string) []byte { func MustReadFile(filePath string) []byte {
fileBytes, err := ioutil.ReadFile(filePath) fileBytes, err := ioutil.ReadFile(filePath)
if err != nil { if err != nil {
Exit(Fmt("MustReadFile failed: %v", err))
Exit(fmt.Sprintf("MustReadFile failed: %v", err))
return nil return nil
} }
return fileBytes return fileBytes
@ -119,7 +119,7 @@ func WriteFile(filePath string, contents []byte, mode os.FileMode) error {
func MustWriteFile(filePath string, contents []byte, mode os.FileMode) { func MustWriteFile(filePath string, contents []byte, mode os.FileMode) {
err := WriteFile(filePath, contents, mode) err := WriteFile(filePath, contents, mode)
if err != nil { if err != nil {
Exit(Fmt("MustWriteFile failed: %v", err))
Exit(fmt.Sprintf("MustWriteFile failed: %v", err))
} }
} }


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

@ -295,7 +295,7 @@ func (r *Rand) Perm(n int) []int {
// NOTE: This relies on the os's random number generator. // NOTE: This relies on the os's random number generator.
// For real security, we should salt that with some seed. // For real security, we should salt that with some seed.
// See github.com/tendermint/go-crypto for a more secure reader.
// See github.com/tendermint/tendermint/crypto for a more secure reader.
func cRandBytes(numBytes int) []byte { func cRandBytes(numBytes int) []byte {
b := make([]byte, numBytes) b := make([]byte, numBytes)
_, err := crand.Read(b) _, err := crand.Read(b)


+ 6
- 6
libs/common/service.go View File

@ -123,10 +123,10 @@ func (bs *BaseService) SetLogger(l log.Logger) {
func (bs *BaseService) Start() error { func (bs *BaseService) Start() error {
if atomic.CompareAndSwapUint32(&bs.started, 0, 1) { if atomic.CompareAndSwapUint32(&bs.started, 0, 1) {
if atomic.LoadUint32(&bs.stopped) == 1 { if atomic.LoadUint32(&bs.stopped) == 1 {
bs.Logger.Error(Fmt("Not starting %v -- already stopped", bs.name), "impl", bs.impl)
bs.Logger.Error(fmt.Sprintf("Not starting %v -- already stopped", bs.name), "impl", bs.impl)
return ErrAlreadyStopped return ErrAlreadyStopped
} }
bs.Logger.Info(Fmt("Starting %v", bs.name), "impl", bs.impl)
bs.Logger.Info(fmt.Sprintf("Starting %v", bs.name), "impl", bs.impl)
err := bs.impl.OnStart() err := bs.impl.OnStart()
if err != nil { if err != nil {
// revert flag // revert flag
@ -135,7 +135,7 @@ func (bs *BaseService) Start() error {
} }
return nil return nil
} }
bs.Logger.Debug(Fmt("Not starting %v -- already started", bs.name), "impl", bs.impl)
bs.Logger.Debug(fmt.Sprintf("Not starting %v -- already started", bs.name), "impl", bs.impl)
return ErrAlreadyStarted return ErrAlreadyStarted
} }
@ -148,12 +148,12 @@ func (bs *BaseService) OnStart() error { return nil }
// channel. An error will be returned if the service is already stopped. // channel. An error will be returned if the service is already stopped.
func (bs *BaseService) Stop() error { func (bs *BaseService) Stop() error {
if atomic.CompareAndSwapUint32(&bs.stopped, 0, 1) { if atomic.CompareAndSwapUint32(&bs.stopped, 0, 1) {
bs.Logger.Info(Fmt("Stopping %v", bs.name), "impl", bs.impl)
bs.Logger.Info(fmt.Sprintf("Stopping %v", bs.name), "impl", bs.impl)
bs.impl.OnStop() bs.impl.OnStop()
close(bs.quit) close(bs.quit)
return nil return nil
} }
bs.Logger.Debug(Fmt("Stopping %v (ignoring: already stopped)", bs.name), "impl", bs.impl)
bs.Logger.Debug(fmt.Sprintf("Stopping %v (ignoring: already stopped)", bs.name), "impl", bs.impl)
return ErrAlreadyStopped return ErrAlreadyStopped
} }
@ -166,7 +166,7 @@ func (bs *BaseService) OnStop() {}
// will be returned if the service is running. // will be returned if the service is running.
func (bs *BaseService) Reset() error { func (bs *BaseService) Reset() error {
if !atomic.CompareAndSwapUint32(&bs.stopped, 1, 0) { if !atomic.CompareAndSwapUint32(&bs.stopped, 1, 0) {
bs.Logger.Debug(Fmt("Can't reset %v. Not stopped", bs.name), "impl", bs.impl)
bs.Logger.Debug(fmt.Sprintf("Can't reset %v. Not stopped", bs.name), "impl", bs.impl)
return fmt.Errorf("can't reset running %s", bs.name) return fmt.Errorf("can't reset running %s", bs.name)
} }


+ 0
- 8
libs/common/string.go View File

@ -6,14 +6,6 @@ import (
"strings" "strings"
) )
// Like fmt.Sprintf, but skips formatting if args are empty.
var Fmt = func(format string, a ...interface{}) string {
if len(a) == 0 {
return format
}
return fmt.Sprintf(format, a...)
}
// IsHex returns true for non-empty hex-string prefixed with "0x" // IsHex returns true for non-empty hex-string prefixed with "0x"
func IsHex(s string) bool { func IsHex(s string) bool {
if len(s) > 2 && strings.EqualFold(s[:2], "0x") { if len(s) > 2 && strings.EqualFold(s[:2], "0x") {


+ 3
- 3
libs/db/backend_test.go View File

@ -54,7 +54,7 @@ func TestBackendsGetSetDelete(t *testing.T) {
} }
func withDB(t *testing.T, creator dbCreator, fn func(DB)) { func withDB(t *testing.T, creator dbCreator, fn func(DB)) {
name := cmn.Fmt("test_%x", cmn.RandStr(12))
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db, err := creator(name, "") db, err := creator(name, "")
defer cleanupDBDir("", name) defer cleanupDBDir("", name)
assert.Nil(t, err) assert.Nil(t, err)
@ -143,7 +143,7 @@ func TestBackendsNilKeys(t *testing.T) {
} }
func TestGoLevelDBBackend(t *testing.T) { func TestGoLevelDBBackend(t *testing.T) {
name := cmn.Fmt("test_%x", cmn.RandStr(12))
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db := NewDB(name, GoLevelDBBackend, "") db := NewDB(name, GoLevelDBBackend, "")
defer cleanupDBDir("", name) defer cleanupDBDir("", name)
@ -160,7 +160,7 @@ func TestDBIterator(t *testing.T) {
} }
func testDBIterator(t *testing.T, backend DBBackendType) { func testDBIterator(t *testing.T, backend DBBackendType) {
name := cmn.Fmt("test_%x", cmn.RandStr(12))
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db := NewDB(name, backend, "") db := NewDB(name, backend, "")
defer cleanupDBDir("", name) defer cleanupDBDir("", name)


+ 2
- 2
libs/db/c_level_db_test.go View File

@ -19,7 +19,7 @@ func BenchmarkRandomReadsWrites2(b *testing.B) {
for i := 0; i < int(numItems); i++ { for i := 0; i < int(numItems); i++ {
internal[int64(i)] = int64(0) internal[int64(i)] = int64(0)
} }
db, err := NewCLevelDB(cmn.Fmt("test_%x", cmn.RandStr(12)), "")
db, err := NewCLevelDB(fmt.Sprintf("test_%x", cmn.RandStr(12)), "")
if err != nil { if err != nil {
b.Fatal(err.Error()) b.Fatal(err.Error())
return return
@ -87,7 +87,7 @@ func bytes2Int64(buf []byte) int64 {
*/ */
func TestCLevelDBBackend(t *testing.T) { func TestCLevelDBBackend(t *testing.T) {
name := cmn.Fmt("test_%x", cmn.RandStr(12))
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db := NewDB(name, LevelDBBackend, "") db := NewDB(name, LevelDBBackend, "")
defer cleanupDBDir("", name) defer cleanupDBDir("", name)


+ 1
- 1
libs/db/go_level_db_test.go View File

@ -17,7 +17,7 @@ func BenchmarkRandomReadsWrites(b *testing.B) {
for i := 0; i < int(numItems); i++ { for i := 0; i < int(numItems); i++ {
internal[int64(i)] = int64(0) internal[int64(i)] = int64(0)
} }
db, err := NewGoLevelDB(cmn.Fmt("test_%x", cmn.RandStr(12)), "")
db, err := NewGoLevelDB(fmt.Sprintf("test_%x", cmn.RandStr(12)), "")
if err != nil { if err != nil {
b.Fatal(err.Error()) b.Fatal(err.Error())
return return


+ 1
- 1
lite/provider.go View File

@ -1,8 +1,8 @@
package lite package lite
import ( import (
"github.com/tendermint/tendermint/types"
log "github.com/tendermint/tendermint/libs/log" log "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/types"
) )
// Provider provides information for the lite client to sync validators. // Provider provides information for the lite client to sync validators.


+ 2
- 2
lite/provider_test.go View File

@ -7,10 +7,10 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
lerr "github.com/tendermint/tendermint/lite/errors"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
log "github.com/tendermint/tendermint/libs/log" log "github.com/tendermint/tendermint/libs/log"
lerr "github.com/tendermint/tendermint/lite/errors"
"github.com/tendermint/tendermint/types"
) )
// missingProvider doesn't store anything, always a miss. // missingProvider doesn't store anything, always a miss.


+ 2
- 2
lite/proxy/verifier.go View File

@ -1,11 +1,11 @@
package proxy package proxy
import ( import (
"github.com/tendermint/tendermint/lite"
lclient "github.com/tendermint/tendermint/lite/client"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
log "github.com/tendermint/tendermint/libs/log" log "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/lite"
lclient "github.com/tendermint/tendermint/lite/client"
) )
func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logger log.Logger) (*lite.DynamicVerifier, error) { func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logger log.Logger) (*lite.DynamicVerifier, error) {


+ 1
- 1
mempool/mempool.go View File

@ -312,7 +312,7 @@ func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) {
case *abci.Response_CheckTx: case *abci.Response_CheckTx:
memTx := mem.recheckCursor.Value.(*mempoolTx) memTx := mem.recheckCursor.Value.(*mempoolTx)
if !bytes.Equal(req.GetCheckTx().Tx, memTx.tx) { if !bytes.Equal(req.GetCheckTx().Tx, memTx.tx) {
cmn.PanicSanity(cmn.Fmt("Unexpected tx response from proxy during recheck\n"+
cmn.PanicSanity(fmt.Sprintf("Unexpected tx response from proxy during recheck\n"+
"Expected %X, got %X", r.CheckTx.Data, memTx.tx)) "Expected %X, got %X", r.CheckTx.Data, memTx.tx))
} }
if r.CheckTx.Code == abci.CodeTypeOK { if r.CheckTx.Code == abci.CodeTypeOK {


+ 1
- 2
mempool/mempool_test.go View File

@ -14,7 +14,6 @@ import (
"github.com/tendermint/tendermint/abci/example/counter" "github.com/tendermint/tendermint/abci/example/counter"
"github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
@ -151,7 +150,7 @@ func TestSerialReap(t *testing.T) {
reapCheck := func(exp int) { reapCheck := func(exp int) {
txs := mempool.Reap(-1) txs := mempool.Reap(-1)
require.Equal(t, len(txs), exp, cmn.Fmt("Expected to reap %v txs but got %v", exp, len(txs)))
require.Equal(t, len(txs), exp, fmt.Sprintf("Expected to reap %v txs but got %v", exp, len(txs)))
} }
updateRange := func(start, end int) { updateRange := func(start, end int) {


+ 9
- 9
node/node.go View File

@ -327,7 +327,7 @@ func NewNode(config *cfg.Config,
if config.FilterPeers { if config.FilterPeers {
// NOTE: addr is ip:port // NOTE: addr is ip:port
sw.SetAddrFilter(func(addr net.Addr) error { sw.SetAddrFilter(func(addr net.Addr) error {
resQuery, err := proxyApp.Query().QuerySync(abci.RequestQuery{Path: cmn.Fmt("/p2p/filter/addr/%s", addr.String())})
resQuery, err := proxyApp.Query().QuerySync(abci.RequestQuery{Path: fmt.Sprintf("/p2p/filter/addr/%s", addr.String())})
if err != nil { if err != nil {
return err return err
} }
@ -337,7 +337,7 @@ func NewNode(config *cfg.Config,
return nil return nil
}) })
sw.SetIDFilter(func(id p2p.ID) error { sw.SetIDFilter(func(id p2p.ID) error {
resQuery, err := proxyApp.Query().QuerySync(abci.RequestQuery{Path: cmn.Fmt("/p2p/filter/id/%s", id)})
resQuery, err := proxyApp.Query().QuerySync(abci.RequestQuery{Path: fmt.Sprintf("/p2p/filter/id/%s", id)})
if err != nil { if err != nil {
return err return err
} }
@ -683,11 +683,11 @@ func (n *Node) makeNodeInfo(nodeID p2p.ID) p2p.NodeInfo {
}, },
Moniker: n.config.Moniker, Moniker: n.config.Moniker,
Other: []string{ Other: []string{
cmn.Fmt("amino_version=%v", amino.Version),
cmn.Fmt("p2p_version=%v", p2p.Version),
cmn.Fmt("consensus_version=%v", cs.Version),
cmn.Fmt("rpc_version=%v/%v", rpc.Version, rpccore.Version),
cmn.Fmt("tx_index=%v", txIndexerStatus),
fmt.Sprintf("amino_version=%v", amino.Version),
fmt.Sprintf("p2p_version=%v", p2p.Version),
fmt.Sprintf("consensus_version=%v", cs.Version),
fmt.Sprintf("rpc_version=%v/%v", rpc.Version, rpccore.Version),
fmt.Sprintf("tx_index=%v", txIndexerStatus),
}, },
} }
@ -696,7 +696,7 @@ func (n *Node) makeNodeInfo(nodeID p2p.ID) p2p.NodeInfo {
} }
rpcListenAddr := n.config.RPC.ListenAddress rpcListenAddr := n.config.RPC.ListenAddress
nodeInfo.Other = append(nodeInfo.Other, cmn.Fmt("rpc_addr=%v", rpcListenAddr))
nodeInfo.Other = append(nodeInfo.Other, fmt.Sprintf("rpc_addr=%v", rpcListenAddr))
if !n.sw.IsListening() { if !n.sw.IsListening() {
return nodeInfo return nodeInfo
@ -705,7 +705,7 @@ func (n *Node) makeNodeInfo(nodeID p2p.ID) p2p.NodeInfo {
p2pListener := n.sw.Listeners()[0] p2pListener := n.sw.Listeners()[0]
p2pHost := p2pListener.ExternalAddressHost() p2pHost := p2pListener.ExternalAddressHost()
p2pPort := p2pListener.ExternalAddress().Port p2pPort := p2pListener.ExternalAddress().Port
nodeInfo.ListenAddr = cmn.Fmt("%v:%v", p2pHost, p2pPort)
nodeInfo.ListenAddr = fmt.Sprintf("%v:%v", p2pHost, p2pPort)
return nodeInfo return nodeInfo
} }


+ 1
- 1
p2p/base_reactor.go View File

@ -1,8 +1,8 @@
package p2p package p2p
import ( import (
"github.com/tendermint/tendermint/p2p/conn"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p/conn"
) )
type Reactor interface { type Reactor interface {


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

@ -257,7 +257,7 @@ func (c *MConnection) Send(chID byte, msgBytes []byte) bool {
// Send message to channel. // Send message to channel.
channel, ok := c.channelsIdx[chID] channel, ok := c.channelsIdx[chID]
if !ok { if !ok {
c.Logger.Error(cmn.Fmt("Cannot send bytes, unknown channel %X", chID))
c.Logger.Error(fmt.Sprintf("Cannot send bytes, unknown channel %X", chID))
return false return false
} }
@ -286,7 +286,7 @@ func (c *MConnection) TrySend(chID byte, msgBytes []byte) bool {
// Send message to channel. // Send message to channel.
channel, ok := c.channelsIdx[chID] channel, ok := c.channelsIdx[chID]
if !ok { if !ok {
c.Logger.Error(cmn.Fmt("Cannot send bytes, unknown channel %X", chID))
c.Logger.Error(fmt.Sprintf("Cannot send bytes, unknown channel %X", chID))
return false return false
} }
@ -311,7 +311,7 @@ func (c *MConnection) CanSend(chID byte) bool {
channel, ok := c.channelsIdx[chID] channel, ok := c.channelsIdx[chID]
if !ok { if !ok {
c.Logger.Error(cmn.Fmt("Unknown channel %X", chID))
c.Logger.Error(fmt.Sprintf("Unknown channel %X", chID))
return false return false
} }
return channel.canSend() return channel.canSend()


+ 1
- 1
p2p/listener.go View File

@ -259,7 +259,7 @@ func isIpv6(ip net.IP) bool {
func getNaiveExternalAddress(defaultToIPv4 bool, port int, settleForLocal bool, logger log.Logger) *NetAddress { func getNaiveExternalAddress(defaultToIPv4 bool, port int, settleForLocal bool, logger log.Logger) *NetAddress {
addrs, err := net.InterfaceAddrs() addrs, err := net.InterfaceAddrs()
if err != nil { if err != nil {
panic(cmn.Fmt("Could not fetch interface addresses: %v", err))
panic(fmt.Sprintf("Could not fetch interface addresses: %v", err))
} }
for _, a := range addrs { for _, a := range addrs {


+ 1
- 1
p2p/netaddress.go View File

@ -44,7 +44,7 @@ func NewNetAddress(id ID, addr net.Addr) *NetAddress {
tcpAddr, ok := addr.(*net.TCPAddr) tcpAddr, ok := addr.(*net.TCPAddr)
if !ok { if !ok {
if flag.Lookup("test.v") == nil { // normal run if flag.Lookup("test.v") == nil { // normal run
cmn.PanicSanity(cmn.Fmt("Only TCPAddrs are supported. Got: %v", addr))
cmn.PanicSanity(fmt.Sprintf("Only TCPAddrs are supported. Got: %v", addr))
} else { // in testing } else { // in testing
netAddr := NewNetAddressIPPort(net.IP("0.0.0.0"), 0) netAddr := NewNetAddressIPPort(net.IP("0.0.0.0"), 0)
netAddr.ID = id netAddr.ID = id


+ 1
- 1
p2p/peer.go View File

@ -425,7 +425,7 @@ func createMConnection(
if reactor == nil { if reactor == nil {
// Note that its ok to panic here as it's caught in the conn._recover, // Note that its ok to panic here as it's caught in the conn._recover,
// which does onPeerError. // which does onPeerError.
panic(cmn.Fmt("Unknown channel %X", chID))
panic(fmt.Sprintf("Unknown channel %X", chID))
} }
reactor.Receive(chID, p, msgBytes) reactor.Receive(chID, p, msgBytes)
} }


+ 2
- 1
p2p/peer_set_test.go View File

@ -1,6 +1,7 @@
package p2p package p2p
import ( import (
"fmt"
"net" "net"
"sync" "sync"
"testing" "testing"
@ -21,7 +22,7 @@ func randPeer(ip net.IP) *peer {
p := &peer{ p := &peer{
nodeInfo: NodeInfo{ nodeInfo: NodeInfo{
ID: nodeKey.ID(), ID: nodeKey.ID(),
ListenAddr: cmn.Fmt("%v.%v.%v.%v:26656", cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256),
ListenAddr: fmt.Sprintf("%v.%v.%v.%v:26656", cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256),
}, },
} }


+ 8
- 7
p2p/pex/addrbook.go View File

@ -7,6 +7,7 @@ package pex
import ( import (
"crypto/sha256" "crypto/sha256"
"encoding/binary" "encoding/binary"
"fmt"
"math" "math"
"net" "net"
"sync" "sync"
@ -559,11 +560,11 @@ func (a *addrBook) addToNewBucket(ka *knownAddress, bucketIdx int) {
func (a *addrBook) addToOldBucket(ka *knownAddress, bucketIdx int) bool { func (a *addrBook) addToOldBucket(ka *knownAddress, bucketIdx int) bool {
// Sanity check // Sanity check
if ka.isNew() { if ka.isNew() {
a.Logger.Error(cmn.Fmt("Cannot add new address to old bucket: %v", ka))
a.Logger.Error(fmt.Sprintf("Cannot add new address to old bucket: %v", ka))
return false return false
} }
if len(ka.Buckets) != 0 { if len(ka.Buckets) != 0 {
a.Logger.Error(cmn.Fmt("Cannot add already old address to another old bucket: %v", ka))
a.Logger.Error(fmt.Sprintf("Cannot add already old address to another old bucket: %v", ka))
return false return false
} }
@ -594,7 +595,7 @@ func (a *addrBook) addToOldBucket(ka *knownAddress, bucketIdx int) bool {
func (a *addrBook) removeFromBucket(ka *knownAddress, bucketType byte, bucketIdx int) { func (a *addrBook) removeFromBucket(ka *knownAddress, bucketType byte, bucketIdx int) {
if ka.BucketType != bucketType { if ka.BucketType != bucketType {
a.Logger.Error(cmn.Fmt("Bucket type mismatch: %v", ka))
a.Logger.Error(fmt.Sprintf("Bucket type mismatch: %v", ka))
return return
} }
bucket := a.getBucket(bucketType, bucketIdx) bucket := a.getBucket(bucketType, bucketIdx)
@ -690,7 +691,7 @@ func (a *addrBook) expireNew(bucketIdx int) {
for addrStr, ka := range a.bucketsNew[bucketIdx] { for addrStr, ka := range a.bucketsNew[bucketIdx] {
// If an entry is bad, throw it away // If an entry is bad, throw it away
if ka.isBad() { if ka.isBad() {
a.Logger.Info(cmn.Fmt("expiring bad address %v", addrStr))
a.Logger.Info(fmt.Sprintf("expiring bad address %v", addrStr))
a.removeFromBucket(ka, bucketTypeNew, bucketIdx) a.removeFromBucket(ka, bucketTypeNew, bucketIdx)
return return
} }
@ -707,11 +708,11 @@ func (a *addrBook) expireNew(bucketIdx int) {
func (a *addrBook) moveToOld(ka *knownAddress) { func (a *addrBook) moveToOld(ka *knownAddress) {
// Sanity check // Sanity check
if ka.isOld() { if ka.isOld() {
a.Logger.Error(cmn.Fmt("Cannot promote address that is already old %v", ka))
a.Logger.Error(fmt.Sprintf("Cannot promote address that is already old %v", ka))
return return
} }
if len(ka.Buckets) == 0 { if len(ka.Buckets) == 0 {
a.Logger.Error(cmn.Fmt("Cannot promote address that isn't in any new buckets %v", ka))
a.Logger.Error(fmt.Sprintf("Cannot promote address that isn't in any new buckets %v", ka))
return return
} }
@ -733,7 +734,7 @@ func (a *addrBook) moveToOld(ka *knownAddress) {
// Finally, add our ka to old bucket again. // Finally, add our ka to old bucket again.
added = a.addToOldBucket(ka, oldBucketIdx) added = a.addToOldBucket(ka, oldBucketIdx)
if !added { if !added {
a.Logger.Error(cmn.Fmt("Could not re-add ka %v to oldBucketIdx %v", ka, oldBucketIdx))
a.Logger.Error(fmt.Sprintf("Could not re-add ka %v to oldBucketIdx %v", ka, oldBucketIdx))
} }
} }
} }


+ 3
- 2
p2p/pex/file.go View File

@ -2,6 +2,7 @@ package pex
import ( import (
"encoding/json" "encoding/json"
"fmt"
"os" "os"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
@ -53,14 +54,14 @@ func (a *addrBook) loadFromFile(filePath string) bool {
// Load addrBookJSON{} // Load addrBookJSON{}
r, err := os.Open(filePath) r, err := os.Open(filePath)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error opening file %s: %v", filePath, err))
cmn.PanicCrisis(fmt.Sprintf("Error opening file %s: %v", filePath, err))
} }
defer r.Close() // nolint: errcheck defer r.Close() // nolint: errcheck
aJSON := &addrBookJSON{} aJSON := &addrBookJSON{}
dec := json.NewDecoder(r) dec := json.NewDecoder(r)
err = dec.Decode(aJSON) err = dec.Decode(aJSON)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Error reading file %s: %v", filePath, err))
cmn.PanicCrisis(fmt.Sprintf("Error reading file %s: %v", filePath, err))
} }
// Restore all the fields... // Restore all the fields...


+ 2
- 2
p2p/test_util.go View File

@ -35,7 +35,7 @@ func CreateRandomPeer(outbound bool) *peer {
func CreateRoutableAddr() (addr string, netAddr *NetAddress) { func CreateRoutableAddr() (addr string, netAddr *NetAddress) {
for { for {
var err error var err error
addr = cmn.Fmt("%X@%v.%v.%v.%v:26656", cmn.RandBytes(20), cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256)
addr = fmt.Sprintf("%X@%v.%v.%v.%v:26656", cmn.RandBytes(20), cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256, cmn.RandInt()%256)
netAddr, err = NewNetAddressString(addr) netAddr, err = NewNetAddressString(addr)
if err != nil { if err != nil {
panic(err) panic(err)
@ -142,7 +142,7 @@ func MakeSwitch(cfg *config.P2PConfig, i int, network, version string, initSwitc
sw = initSwitch(i, sw) sw = initSwitch(i, sw)
ni := NodeInfo{ ni := NodeInfo{
ID: nodeKey.ID(), ID: nodeKey.ID(),
Moniker: cmn.Fmt("switch%d", i),
Moniker: fmt.Sprintf("switch%d", i),
Network: network, Network: network,
Version: version, Version: version,
ListenAddr: fmt.Sprintf("127.0.0.1:%d", cmn.RandIntn(64512)+1023), ListenAddr: fmt.Sprintf("127.0.0.1:%d", cmn.RandIntn(64512)+1023),


+ 2
- 1
p2p/trust/store.go View File

@ -5,6 +5,7 @@ package trust
import ( import (
"encoding/json" "encoding/json"
"fmt"
"sync" "sync"
"time" "time"
@ -155,7 +156,7 @@ func (tms *TrustMetricStore) loadFromDB() bool {
peers := make(map[string]MetricHistoryJSON) peers := make(map[string]MetricHistoryJSON)
err := json.Unmarshal(bytes, &peers) err := json.Unmarshal(bytes, &peers)
if err != nil { if err != nil {
cmn.PanicCrisis(cmn.Fmt("Could not unmarshal Trust Metric Store DB data: %v", err))
cmn.PanicCrisis(fmt.Sprintf("Could not unmarshal Trust Metric Store DB data: %v", err))
} }
// If history data exists in the file, // If history data exists in the file,


+ 12
- 13
p2p/upnp/probe.go View File

@ -5,7 +5,6 @@ import (
"net" "net"
"time" "time"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
) )
@ -19,19 +18,19 @@ func makeUPNPListener(intPort int, extPort int, logger log.Logger) (NAT, net.Lis
if err != nil { 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(cmn.Fmt("ourIP: %v", nat.(*upnpNAT).ourIP))
logger.Info(fmt.Sprintf("ourIP: %v", nat.(*upnpNAT).ourIP))
ext, err := nat.GetExternalAddress() ext, err := nat.GetExternalAddress()
if err != nil { 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(cmn.Fmt("External address: %v", ext))
logger.Info(fmt.Sprintf("External address: %v", ext))
port, err := nat.AddPortMapping("tcp", extPort, intPort, "Tendermint UPnP Probe", 0) port, err := nat.AddPortMapping("tcp", extPort, intPort, "Tendermint UPnP Probe", 0)
if err != nil { 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(cmn.Fmt("Port mapping mapped: %v", port))
logger.Info(fmt.Sprintf("Port mapping mapped: %v", port))
// also run the listener, open for all remote addresses. // also run the listener, open for all remote addresses.
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", intPort)) listener, err := net.Listen("tcp", fmt.Sprintf(":%v", intPort))
@ -46,17 +45,17 @@ func testHairpin(listener net.Listener, extAddr string, logger log.Logger) (supp
go func() { go func() {
inConn, err := listener.Accept() inConn, err := listener.Accept()
if err != nil { if err != nil {
logger.Info(cmn.Fmt("Listener.Accept() error: %v", err))
logger.Info(fmt.Sprintf("Listener.Accept() error: %v", err))
return return
} }
logger.Info(cmn.Fmt("Accepted incoming connection: %v -> %v", inConn.LocalAddr(), inConn.RemoteAddr()))
logger.Info(fmt.Sprintf("Accepted incoming connection: %v -> %v", inConn.LocalAddr(), inConn.RemoteAddr()))
buf := make([]byte, 1024) buf := make([]byte, 1024)
n, err := inConn.Read(buf) n, err := inConn.Read(buf)
if err != nil { if err != nil {
logger.Info(cmn.Fmt("Incoming connection read error: %v", err))
logger.Info(fmt.Sprintf("Incoming connection read error: %v", err))
return return
} }
logger.Info(cmn.Fmt("Incoming connection read %v bytes: %X", n, buf))
logger.Info(fmt.Sprintf("Incoming connection read %v bytes: %X", n, buf))
if string(buf) == "test data" { if string(buf) == "test data" {
supportsHairpin = true supportsHairpin = true
return return
@ -66,16 +65,16 @@ func testHairpin(listener net.Listener, extAddr string, logger log.Logger) (supp
// Establish outgoing // Establish outgoing
outConn, err := net.Dial("tcp", extAddr) outConn, err := net.Dial("tcp", extAddr)
if err != nil { if err != nil {
logger.Info(cmn.Fmt("Outgoing connection dial error: %v", err))
logger.Info(fmt.Sprintf("Outgoing connection dial error: %v", err))
return return
} }
n, err := outConn.Write([]byte("test data")) n, err := outConn.Write([]byte("test data"))
if err != nil { if err != nil {
logger.Info(cmn.Fmt("Outgoing connection write error: %v", err))
logger.Info(fmt.Sprintf("Outgoing connection write error: %v", err))
return return
} }
logger.Info(cmn.Fmt("Outgoing connection wrote %v bytes", n))
logger.Info(fmt.Sprintf("Outgoing connection wrote %v bytes", n))
// Wait for data receipt // Wait for data receipt
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
@ -96,10 +95,10 @@ func Probe(logger log.Logger) (caps UPNPCapabilities, err error) {
// Deferred cleanup // Deferred cleanup
defer func() { defer func() {
if err := nat.DeletePortMapping("tcp", intPort, extPort); err != nil { if err := nat.DeletePortMapping("tcp", intPort, extPort); err != nil {
logger.Error(cmn.Fmt("Port mapping delete error: %v", err))
logger.Error(fmt.Sprintf("Port mapping delete error: %v", err))
} }
if err := listener.Close(); err != nil { if err := listener.Close(); err != nil {
logger.Error(cmn.Fmt("Listener closing error: %v", err))
logger.Error(fmt.Sprintf("Listener closing error: %v", err))
} }
}() }()


+ 2
- 2
privval/priv_validator.go View File

@ -89,7 +89,7 @@ func LoadFilePV(filePath string) *FilePV {
pv := &FilePV{} pv := &FilePV{}
err = cdc.UnmarshalJSON(pvJSONBytes, &pv) err = cdc.UnmarshalJSON(pvJSONBytes, &pv)
if err != nil { if err != nil {
cmn.Exit(cmn.Fmt("Error reading PrivValidator from %v: %v\n", filePath, err))
cmn.Exit(fmt.Sprintf("Error reading PrivValidator from %v: %v\n", filePath, err))
} }
// overwrite pubkey and address for convenience // overwrite pubkey and address for convenience
@ -153,7 +153,7 @@ func (pv *FilePV) SignVote(chainID string, vote *types.Vote) error {
pv.mtx.Lock() pv.mtx.Lock()
defer pv.mtx.Unlock() defer pv.mtx.Unlock()
if err := pv.signVote(chainID, vote); err != nil { if err := pv.signVote(chainID, vote); err != nil {
return errors.New(cmn.Fmt("Error signing vote: %v", err))
return fmt.Errorf("Error signing vote: %v", err)
} }
return nil return nil
} }


+ 5
- 4
proxy/app_conn_test.go View File

@ -1,6 +1,7 @@
package proxy package proxy
import ( import (
"fmt"
"strings" "strings"
"testing" "testing"
@ -45,7 +46,7 @@ func (app *appConnTest) InfoSync(req types.RequestInfo) (*types.ResponseInfo, er
var SOCKET = "socket" var SOCKET = "socket"
func TestEcho(t *testing.T) { func TestEcho(t *testing.T) {
sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true)
// Start server // Start server
@ -70,7 +71,7 @@ func TestEcho(t *testing.T) {
t.Log("Connected") t.Log("Connected")
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
proxy.EchoAsync(cmn.Fmt("echo-%v", i))
proxy.EchoAsync(fmt.Sprintf("echo-%v", i))
} }
if err := proxy.FlushSync(); err != nil { if err := proxy.FlushSync(); err != nil {
t.Error(err) t.Error(err)
@ -79,7 +80,7 @@ func TestEcho(t *testing.T) {
func BenchmarkEcho(b *testing.B) { func BenchmarkEcho(b *testing.B) {
b.StopTimer() // Initialize b.StopTimer() // Initialize
sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true)
// Start server // Start server
@ -118,7 +119,7 @@ func BenchmarkEcho(b *testing.B) {
} }
func TestInfo(t *testing.T) { func TestInfo(t *testing.T) {
sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true)
// Start server // Start server


+ 1
- 1
rpc/client/event_test.go View File

@ -8,9 +8,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
var waitForEventTimeout = 5 * time.Second var waitForEventTimeout = 5 * time.Second


+ 1
- 1
rpc/client/httpclient.go View File

@ -7,11 +7,11 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
amino "github.com/tendermint/go-amino" amino "github.com/tendermint/go-amino"
cmn "github.com/tendermint/tendermint/libs/common"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub" tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclient "github.com/tendermint/tendermint/rpc/lib/client" rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
/* /*


+ 1
- 1
rpc/client/interface.go View File

@ -21,9 +21,9 @@ implementation.
*/ */
import ( import (
cmn "github.com/tendermint/tendermint/libs/common"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
// ABCIClient groups together the functionality that principally // ABCIClient groups together the functionality that principally


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

@ -2,11 +2,11 @@ package mock
import ( import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version" "github.com/tendermint/tendermint/version"
cmn "github.com/tendermint/tendermint/libs/common"
) )
// ABCIApp will send all abci related request to the named app, // ABCIApp will send all abci related request to the named app,


+ 1
- 1
rpc/client/mock/abci_test.go View File

@ -11,11 +11,11 @@ import (
"github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/mock" "github.com/tendermint/tendermint/rpc/client/mock"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
func TestABCIMock(t *testing.T) { func TestABCIMock(t *testing.T) {


+ 1
- 1
rpc/client/mock/client.go View File

@ -16,11 +16,11 @@ package mock
import ( import (
"reflect" "reflect"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/core" "github.com/tendermint/tendermint/rpc/core"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
// Client wraps arbitrary implementations of the various interfaces. // Client wraps arbitrary implementations of the various interfaces.


+ 1
- 1
rpc/client/mock/status_test.go View File

@ -6,9 +6,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/rpc/client/mock" "github.com/tendermint/tendermint/rpc/client/mock"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
func TestStatus(t *testing.T) { func TestStatus(t *testing.T) {


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

@ -8,9 +8,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common"
) )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------


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

@ -5,13 +5,13 @@ import (
"github.com/tendermint/tendermint/consensus" "github.com/tendermint/tendermint/consensus"
crypto "github.com/tendermint/tendermint/crypto" crypto "github.com/tendermint/tendermint/crypto"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/state/txindex" "github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
) )
const ( const (


+ 1
- 1
rpc/lib/client/ws_client.go View File

@ -14,8 +14,8 @@ import (
metrics "github.com/rcrowley/go-metrics" metrics "github.com/rcrowley/go-metrics"
"github.com/tendermint/go-amino" "github.com/tendermint/go-amino"
types "github.com/tendermint/tendermint/rpc/lib/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
types "github.com/tendermint/tendermint/rpc/lib/types"
) )
const ( const (


+ 1
- 1
rpc/lib/server/handlers_test.go View File

@ -14,9 +14,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
amino "github.com/tendermint/go-amino" amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/log"
rs "github.com/tendermint/tendermint/rpc/lib/server" rs "github.com/tendermint/tendermint/rpc/lib/server"
types "github.com/tendermint/tendermint/rpc/lib/types" types "github.com/tendermint/tendermint/rpc/lib/types"
"github.com/tendermint/tendermint/libs/log"
) )
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////


+ 1
- 1
rpc/lib/server/http_server.go View File

@ -14,8 +14,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/net/netutil" "golang.org/x/net/netutil"
types "github.com/tendermint/tendermint/rpc/lib/types"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
types "github.com/tendermint/tendermint/rpc/lib/types"
) )
// Config is an RPC server configuration. // Config is an RPC server configuration.


+ 1
- 1
rpc/lib/test/main.go View File

@ -6,9 +6,9 @@ import (
"os" "os"
amino "github.com/tendermint/go-amino" amino "github.com/tendermint/go-amino"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
) )
var routes = map[string]*rpcserver.RPCFunc{ var routes = map[string]*rpcserver.RPCFunc{


+ 9
- 11
state/errors.go View File

@ -1,8 +1,6 @@
package state package state
import (
cmn "github.com/tendermint/tendermint/libs/common"
)
import "fmt"
type ( type (
ErrInvalidBlock error ErrInvalidBlock error
@ -48,32 +46,32 @@ type (
) )
func (e ErrUnknownBlock) Error() string { func (e ErrUnknownBlock) Error() string {
return cmn.Fmt("Could not find block #%d", e.Height)
return fmt.Sprintf("Could not find block #%d", e.Height)
} }
func (e ErrBlockHashMismatch) Error() string { func (e ErrBlockHashMismatch) Error() string {
return cmn.Fmt("App block hash (%X) does not match core block hash (%X) for height %d", e.AppHash, e.CoreHash, e.Height)
return fmt.Sprintf("App block hash (%X) does not match core block hash (%X) for height %d", e.AppHash, e.CoreHash, e.Height)
} }
func (e ErrAppBlockHeightTooHigh) Error() string { func (e ErrAppBlockHeightTooHigh) Error() string {
return cmn.Fmt("App block height (%d) is higher than core (%d)", e.AppHeight, e.CoreHeight)
return fmt.Sprintf("App block height (%d) is higher than core (%d)", e.AppHeight, e.CoreHeight)
} }
func (e ErrLastStateMismatch) Error() string { func (e ErrLastStateMismatch) Error() string {
return cmn.Fmt("Latest tendermint block (%d) LastAppHash (%X) does not match app's AppHash (%X)", e.Height, e.Core, e.App)
return fmt.Sprintf("Latest tendermint block (%d) LastAppHash (%X) does not match app's AppHash (%X)", e.Height, e.Core, e.App)
} }
func (e ErrStateMismatch) Error() string { func (e ErrStateMismatch) Error() string {
return cmn.Fmt("State after replay does not match saved state. Got ----\n%v\nExpected ----\n%v\n", e.Got, e.Expected)
return fmt.Sprintf("State after replay does not match saved state. Got ----\n%v\nExpected ----\n%v\n", e.Got, e.Expected)
} }
func (e ErrNoValSetForHeight) Error() string { func (e ErrNoValSetForHeight) Error() string {
return cmn.Fmt("Could not find validator set for height #%d", e.Height)
return fmt.Sprintf("Could not find validator set for height #%d", e.Height)
} }
func (e ErrNoConsensusParamsForHeight) Error() string { func (e ErrNoConsensusParamsForHeight) Error() string {
return cmn.Fmt("Could not find consensus params for height #%d", e.Height)
return fmt.Sprintf("Could not find consensus params for height #%d", e.Height)
} }
func (e ErrNoABCIResponsesForHeight) Error() string { func (e ErrNoABCIResponsesForHeight) Error() string {
return cmn.Fmt("Could not find results for height #%d", e.Height)
return fmt.Sprintf("Could not find results for height #%d", e.Height)
} }

+ 4
- 4
state/state_test.go View File

@ -40,11 +40,11 @@ func TestStateCopy(t *testing.T) {
stateCopy := state.Copy() stateCopy := state.Copy()
assert.True(state.Equals(stateCopy), assert.True(state.Equals(stateCopy),
cmn.Fmt("expected state and its copy to be identical.\ngot: %v\nexpected: %v\n",
fmt.Sprintf("expected state and its copy to be identical.\ngot: %v\nexpected: %v\n",
stateCopy, state)) stateCopy, state))
stateCopy.LastBlockHeight++ stateCopy.LastBlockHeight++
assert.False(state.Equals(stateCopy), cmn.Fmt(`expected states to be different. got same
assert.False(state.Equals(stateCopy), fmt.Sprintf(`expected states to be different. got same
%v`, state)) %v`, state))
} }
@ -60,7 +60,7 @@ func TestStateSaveLoad(t *testing.T) {
loadedState := LoadState(stateDB) loadedState := LoadState(stateDB)
assert.True(state.Equals(loadedState), assert.True(state.Equals(loadedState),
cmn.Fmt("expected state and its copy to be identical.\ngot: %v\nexpected: %v\n",
fmt.Sprintf("expected state and its copy to be identical.\ngot: %v\nexpected: %v\n",
loadedState, state)) loadedState, state))
} }
@ -86,7 +86,7 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
loadedABCIResponses, err := LoadABCIResponses(stateDB, block.Height) loadedABCIResponses, err := LoadABCIResponses(stateDB, block.Height)
assert.Nil(err) assert.Nil(err)
assert.Equal(abciResponses, loadedABCIResponses, assert.Equal(abciResponses, loadedABCIResponses,
cmn.Fmt("ABCIResponses don't match:\ngot: %v\nexpected: %v\n",
fmt.Sprintf("ABCIResponses don't match:\ngot: %v\nexpected: %v\n",
loadedABCIResponses, abciResponses)) loadedABCIResponses, abciResponses))
} }


+ 7
- 7
state/store.go View File

@ -12,15 +12,15 @@ import (
//------------------------------------------------------------------------ //------------------------------------------------------------------------
func calcValidatorsKey(height int64) []byte { func calcValidatorsKey(height int64) []byte {
return []byte(cmn.Fmt("validatorsKey:%v", height))
return []byte(fmt.Sprintf("validatorsKey:%v", height))
} }
func calcConsensusParamsKey(height int64) []byte { func calcConsensusParamsKey(height int64) []byte {
return []byte(cmn.Fmt("consensusParamsKey:%v", height))
return []byte(fmt.Sprintf("consensusParamsKey:%v", height))
} }
func calcABCIResponsesKey(height int64) []byte { func calcABCIResponsesKey(height int64) []byte {
return []byte(cmn.Fmt("abciResponsesKey:%v", height))
return []byte(fmt.Sprintf("abciResponsesKey:%v", height))
} }
// LoadStateFromDBOrGenesisFile loads the most recent state from the database, // LoadStateFromDBOrGenesisFile loads the most recent state from the database,
@ -71,7 +71,7 @@ func loadState(db dbm.DB, key []byte) (state State) {
err := cdc.UnmarshalBinaryBare(buf, &state) err := cdc.UnmarshalBinaryBare(buf, &state)
if err != nil { if err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt(`LoadState: Data has been corrupted or its spec has changed:
cmn.Exit(fmt.Sprintf(`LoadState: Data has been corrupted or its spec has changed:
%v\n`, err)) %v\n`, err))
} }
// TODO: ensure that buf is completely read. // TODO: ensure that buf is completely read.
@ -144,7 +144,7 @@ func LoadABCIResponses(db dbm.DB, height int64) (*ABCIResponses, error) {
err := cdc.UnmarshalBinaryBare(buf, abciResponses) err := cdc.UnmarshalBinaryBare(buf, abciResponses)
if err != nil { if err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt(`LoadABCIResponses: Data has been corrupted or its spec has
cmn.Exit(fmt.Sprintf(`LoadABCIResponses: Data has been corrupted or its spec has
changed: %v\n`, err)) changed: %v\n`, err))
} }
// TODO: ensure that buf is completely read. // TODO: ensure that buf is completely read.
@ -207,7 +207,7 @@ func loadValidatorsInfo(db dbm.DB, height int64) *ValidatorsInfo {
err := cdc.UnmarshalBinaryBare(buf, v) err := cdc.UnmarshalBinaryBare(buf, v)
if err != nil { if err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt(`LoadValidators: Data has been corrupted or its spec has changed:
cmn.Exit(fmt.Sprintf(`LoadValidators: Data has been corrupted or its spec has changed:
%v\n`, err)) %v\n`, err))
} }
// TODO: ensure that buf is completely read. // TODO: ensure that buf is completely read.
@ -278,7 +278,7 @@ func loadConsensusParamsInfo(db dbm.DB, height int64) *ConsensusParamsInfo {
err := cdc.UnmarshalBinaryBare(buf, paramsInfo) err := cdc.UnmarshalBinaryBare(buf, paramsInfo)
if err != nil { if err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
cmn.Exit(cmn.Fmt(`LoadConsensusParams: Data has been corrupted or its spec has changed:
cmn.Exit(fmt.Sprintf(`LoadConsensusParams: Data has been corrupted or its spec has changed:
%v\n`, err)) %v\n`, err))
} }
// TODO: ensure that buf is completely read. // TODO: ensure that buf is completely read.


+ 1
- 1
state/validation.go View File

@ -5,7 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/tendermint/go-crypto/tmhash"
"github.com/tendermint/tendermint/crypto/tmhash"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 2
- 1
types/genesis.go View File

@ -2,6 +2,7 @@ package types
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io/ioutil" "io/ioutil"
"time" "time"
@ -107,7 +108,7 @@ func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error) {
} }
genDoc, err := GenesisDocFromJSON(jsonBlob) genDoc, err := GenesisDocFromJSON(jsonBlob)
if err != nil { if err != nil {
return nil, cmn.ErrorWrap(err, cmn.Fmt("Error reading GenesisDoc at %v", genDocFile))
return nil, cmn.ErrorWrap(err, fmt.Sprintf("Error reading GenesisDoc at %v", genDocFile))
} }
return genDoc, nil return genDoc, nil
} }

+ 4
- 4
types/proto3_test.go View File

@ -63,10 +63,10 @@ func TestProto3Compatibility(t *testing.T) {
assert.Equal(t, ab, pb, "encoding doesn't match") assert.Equal(t, ab, pb, "encoding doesn't match")
emptyLastBlockPb := proto3.Header{ emptyLastBlockPb := proto3.Header{
ChainID: "cosmos",
Height: 150,
Time: &proto3.Timestamp{Seconds: seconds, Nanos: nanos},
NumTxs: 7,
ChainID: "cosmos",
Height: 150,
Time: &proto3.Timestamp{Seconds: seconds, Nanos: nanos},
NumTxs: 7,
TotalTxs: 100, TotalTxs: 100,
LastCommitHash: []byte("commit hash"), LastCommitHash: []byte("commit hash"),
DataHash: []byte("data hash"), DataHash: []byte("data hash"),


+ 3
- 3
types/protobuf_test.go View File

@ -111,10 +111,10 @@ func TestABCIEvidence(t *testing.T) {
type pubKeyEddie struct{} type pubKeyEddie struct{}
func (pubKeyEddie) Address() Address { return []byte{} }
func (pubKeyEddie) Bytes() []byte { return []byte{} }
func (pubKeyEddie) Address() Address { return []byte{} }
func (pubKeyEddie) Bytes() []byte { return []byte{} }
func (pubKeyEddie) VerifyBytes(msg []byte, sig []byte) bool { return false } func (pubKeyEddie) VerifyBytes(msg []byte, sig []byte) bool { return false }
func (pubKeyEddie) Equals(crypto.PubKey) bool { return false }
func (pubKeyEddie) Equals(crypto.PubKey) bool { return false }
func TestABCIValidatorFromPubKeyAndPower(t *testing.T) { func TestABCIValidatorFromPubKeyAndPower(t *testing.T) {
pubkey := ed25519.GenPrivKey().PubKey() pubkey := ed25519.GenPrivKey().PubKey()


+ 3
- 2
types/validator_set_test.go View File

@ -2,6 +2,7 @@ package types
import ( import (
"bytes" "bytes"
"fmt"
"math" "math"
"strings" "strings"
"testing" "testing"
@ -219,7 +220,7 @@ func TestProposerSelection3(t *testing.T) {
got := vset.GetProposer().Address got := vset.GetProposer().Address
expected := proposerOrder[j%4].Address expected := proposerOrder[j%4].Address
if !bytes.Equal(got, expected) { if !bytes.Equal(got, expected) {
t.Fatalf(cmn.Fmt("vset.Proposer (%X) does not match expected proposer (%X) for (%d, %d)", got, expected, i, j))
t.Fatalf(fmt.Sprintf("vset.Proposer (%X) does not match expected proposer (%X) for (%d, %d)", got, expected, i, j))
} }
// serialize, deserialize, check proposer // serialize, deserialize, check proposer
@ -229,7 +230,7 @@ func TestProposerSelection3(t *testing.T) {
computed := vset.GetProposer() // findGetProposer() computed := vset.GetProposer() // findGetProposer()
if i != 0 { if i != 0 {
if !bytes.Equal(got, computed.Address) { if !bytes.Equal(got, computed.Address) {
t.Fatalf(cmn.Fmt("vset.Proposer (%X) does not match computed proposer (%X) for (%d, %d)", got, computed.Address, i, j))
t.Fatalf(fmt.Sprintf("vset.Proposer (%X) does not match computed proposer (%X) for (%d, %d)", got, computed.Address, i, j))
} }
} }


Loading…
Cancel
Save