mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 05:25:35 +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:
@@ -9,7 +9,7 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
@@ -64,7 +64,7 @@ func makeAndApplyGoodBlock(state sm.State, height int64, lastCommit *types.Commi
|
||||
return state, types.BlockID{}, err
|
||||
}
|
||||
blockID := types.BlockID{Hash: block.Hash(),
|
||||
PartsHeader: types.PartSetHeader{Total: 3, Hash: cmn.RandBytes(32)}}
|
||||
PartsHeader: types.PartSetHeader{Total: 3, Hash: rand.RandBytes(32)}}
|
||||
state, err := blockExec.ApplyBlock(state, blockID, block)
|
||||
if err != nil {
|
||||
return state, types.BlockID{}, err
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
@@ -316,17 +316,17 @@ func TestProposerFrequency(t *testing.T) {
|
||||
maxPower := 1000
|
||||
nTestCases := 5
|
||||
for i := 0; i < nTestCases; i++ {
|
||||
N := cmn.RandInt()%maxVals + 1
|
||||
N := rand.RandInt()%maxVals + 1
|
||||
vals := make([]*types.Validator, N)
|
||||
totalVotePower := int64(0)
|
||||
for j := 0; j < N; j++ {
|
||||
// make sure votePower > 0
|
||||
votePower := int64(cmn.RandInt()%maxPower) + 1
|
||||
votePower := int64(rand.RandInt()%maxPower) + 1
|
||||
totalVotePower += votePower
|
||||
privVal := types.NewMockPV()
|
||||
pubKey := privVal.GetPubKey()
|
||||
val := types.NewValidator(pubKey, votePower)
|
||||
val.ProposerPriority = cmn.RandInt64()
|
||||
val.ProposerPriority = rand.RandInt64()
|
||||
vals[j] = val
|
||||
}
|
||||
valSet := types.NewValidatorSet(vals)
|
||||
@@ -343,7 +343,7 @@ func genValSetWithPowers(powers []int64) *types.ValidatorSet {
|
||||
for i := 0; i < size; i++ {
|
||||
totalVotePower += powers[i]
|
||||
val := types.NewValidator(ed25519.GenPrivKey().PubKey(), powers[i])
|
||||
val.ProposerPriority = cmn.RandInt64()
|
||||
val.ProposerPriority = rand.RandInt64()
|
||||
vals[i] = val
|
||||
}
|
||||
valSet := types.NewValidatorSet(vals)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
@@ -23,12 +23,12 @@ func TestTxFilter(t *testing.T) {
|
||||
tx types.Tx
|
||||
isErr bool
|
||||
}{
|
||||
{types.Tx(cmn.RandBytes(250)), false},
|
||||
{types.Tx(cmn.RandBytes(1811)), false},
|
||||
{types.Tx(cmn.RandBytes(1831)), false},
|
||||
{types.Tx(cmn.RandBytes(1838)), true},
|
||||
{types.Tx(cmn.RandBytes(1839)), true},
|
||||
{types.Tx(cmn.RandBytes(3000)), true},
|
||||
{types.Tx(rand.RandBytes(250)), false},
|
||||
{types.Tx(rand.RandBytes(1811)), false},
|
||||
{types.Tx(rand.RandBytes(1831)), false},
|
||||
{types.Tx(rand.RandBytes(1838)), true},
|
||||
{types.Tx(rand.RandBytes(1839)), true},
|
||||
{types.Tx(rand.RandBytes(3000)), true},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
db "github.com/tendermint/tm-db"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
"github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
@@ -325,7 +325,7 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) {
|
||||
batch := txindex.NewBatch(txsCount)
|
||||
txIndex := uint32(0)
|
||||
for i := int64(0); i < txsCount; i++ {
|
||||
tx := cmn.RandBytes(250)
|
||||
tx := rand.RandBytes(250)
|
||||
txResult := &types.TxResult{
|
||||
Height: 1,
|
||||
Index: txIndex,
|
||||
|
||||
Reference in New Issue
Block a user