mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
libs/common: refactor libs/common 2 (#4231)
* libs/common: refactor libs/common 2 - move random function to there own pkg Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * change imports and usage throughout repo * fix goimports * add changelog entry
This commit is contained in:
@@ -21,8 +21,8 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
mempl "github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/mock"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
@@ -912,11 +912,11 @@ func (app *badApp) Commit() abci.ResponseCommit {
|
||||
app.height++
|
||||
if app.onlyLastHashIsWrong {
|
||||
if app.height == app.numBlocks {
|
||||
return abci.ResponseCommit{Data: cmn.RandBytes(8)}
|
||||
return abci.ResponseCommit{Data: rand.RandBytes(8)}
|
||||
}
|
||||
return abci.ResponseCommit{Data: []byte{app.height}}
|
||||
} else if app.allHashesAreWrong {
|
||||
return abci.ResponseCommit{Data: cmn.RandBytes(8)}
|
||||
return abci.ResponseCommit{Data: rand.RandBytes(8)}
|
||||
}
|
||||
|
||||
panic("either allHashesAreWrong or onlyLastHashIsWrong must be set")
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
cstypes "github.com/tendermint/tendermint/consensus/types"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
p2pmock "github.com/tendermint/tendermint/p2p/mock"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
@@ -1563,7 +1563,7 @@ func TestStateOutputsBlockPartsStats(t *testing.T) {
|
||||
peer := p2pmock.NewPeer(nil)
|
||||
|
||||
// 1) new block part
|
||||
parts := types.NewPartSetFromData(cmn.RandBytes(100), 10)
|
||||
parts := types.NewPartSetFromData(rand.RandBytes(100), 10)
|
||||
msg := &BlockPartMessage{
|
||||
Height: 1,
|
||||
Round: 0,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
@@ -18,15 +18,15 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
|
||||
vset, _ := types.RandValidatorSet(nval, 1)
|
||||
commitSigs := make([]types.CommitSig, nval)
|
||||
blockID := types.BlockID{
|
||||
Hash: cmn.RandBytes(20),
|
||||
Hash: rand.RandBytes(20),
|
||||
PartsHeader: types.PartSetHeader{
|
||||
Hash: cmn.RandBytes(20),
|
||||
Hash: rand.RandBytes(20),
|
||||
},
|
||||
}
|
||||
sig := make([]byte, ed25519.SignatureSize)
|
||||
for i := 0; i < nval; i++ {
|
||||
commitSigs[i] = (&types.Vote{
|
||||
ValidatorAddress: types.Address(cmn.RandBytes(20)),
|
||||
ValidatorAddress: types.Address(rand.RandBytes(20)),
|
||||
Timestamp: tmtime.Now(),
|
||||
BlockID: blockID,
|
||||
Signature: sig,
|
||||
@@ -34,21 +34,21 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
|
||||
}
|
||||
txs := make([]types.Tx, ntxs)
|
||||
for i := 0; i < ntxs; i++ {
|
||||
txs[i] = cmn.RandBytes(100)
|
||||
txs[i] = rand.RandBytes(100)
|
||||
}
|
||||
// Random block
|
||||
block := &types.Block{
|
||||
Header: types.Header{
|
||||
ChainID: cmn.RandStr(12),
|
||||
ChainID: rand.RandStr(12),
|
||||
Time: tmtime.Now(),
|
||||
LastBlockID: blockID,
|
||||
LastCommitHash: cmn.RandBytes(20),
|
||||
DataHash: cmn.RandBytes(20),
|
||||
ValidatorsHash: cmn.RandBytes(20),
|
||||
ConsensusHash: cmn.RandBytes(20),
|
||||
AppHash: cmn.RandBytes(20),
|
||||
LastResultsHash: cmn.RandBytes(20),
|
||||
EvidenceHash: cmn.RandBytes(20),
|
||||
LastCommitHash: rand.RandBytes(20),
|
||||
DataHash: rand.RandBytes(20),
|
||||
ValidatorsHash: rand.RandBytes(20),
|
||||
ConsensusHash: rand.RandBytes(20),
|
||||
AppHash: rand.RandBytes(20),
|
||||
LastResultsHash: rand.RandBytes(20),
|
||||
EvidenceHash: rand.RandBytes(20),
|
||||
},
|
||||
Data: types.Data{
|
||||
Txs: txs,
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/abci/example/kvstore"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/mock"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
@@ -120,7 +120,7 @@ func WALWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error) {
|
||||
func randPort() int {
|
||||
// returns between base and base + spread
|
||||
base, spread := 20000, 20000
|
||||
return base + cmn.RandIntn(spread)
|
||||
return base + rand.RandIntn(spread)
|
||||
}
|
||||
|
||||
func makeAddrs() (string, string, string) {
|
||||
|
||||
Reference in New Issue
Block a user