cleanup: unused parameters (#8372)

This commit is contained in:
Sam Kleinman
2022-04-18 16:45:21 -04:00
committed by GitHub
parent c372390fea
commit efd4f4a40b
17 changed files with 54 additions and 59 deletions

View File

@@ -50,7 +50,6 @@ func setup(
genDoc *types.GenesisDoc,
privVal types.PrivValidator,
maxBlockHeights []int64,
chBuf uint,
) *reactorTestSuite {
t.Helper()
@@ -228,7 +227,7 @@ func TestReactor_AbruptDisconnect(t *testing.T) {
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams())
maxBlockHeight := int64(64)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0})
require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
@@ -268,7 +267,7 @@ func TestReactor_SyncTime(t *testing.T) {
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams())
maxBlockHeight := int64(101)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0})
require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
rts.start(ctx, t)
@@ -296,7 +295,7 @@ func TestReactor_NoBlockResponse(t *testing.T) {
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams())
maxBlockHeight := int64(65)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0}, 0)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0})
require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())
@@ -348,7 +347,7 @@ func TestReactor_BadBlockStopsPeer(t *testing.T) {
valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, factory.ConsensusParams())
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0, 0, 0, 0}, 1000)
rts := setup(ctx, t, genDoc, privVals[0], []int64{maxBlockHeight, 0, 0, 0, 0})
require.Equal(t, maxBlockHeight, rts.reactors[rts.nodes[0]].store.Height())

View File

@@ -429,7 +429,7 @@ func (h *Handshaker) ReplayBlocks(
if err != nil {
return nil, err
}
mockApp, err := newMockProxyApp(ctx, h.logger, appHash, abciResponses)
mockApp, err := newMockProxyApp(h.logger, appHash, abciResponses)
if err != nil {
return nil, err
}

View File

@@ -57,7 +57,6 @@ func (emptyMempool) CloseWAL() {}
// the real app.
func newMockProxyApp(
ctx context.Context,
logger log.Logger,
appHash []byte,
abciResponses *tmstate.ABCIResponses,

View File

@@ -46,7 +46,7 @@ type reactorTestSuite struct {
numStateStores int
}
func setup(ctx context.Context, t *testing.T, stateStores []sm.Store, chBuf uint) *reactorTestSuite {
func setup(ctx context.Context, t *testing.T, stateStores []sm.Store) *reactorTestSuite {
t.Helper()
pID := make([]byte, 16)
@@ -245,7 +245,7 @@ func TestReactorMultiDisconnect(t *testing.T) {
stateDB1 := initializeValidatorState(ctx, t, val, height)
stateDB2 := initializeValidatorState(ctx, t, val, height)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 20)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2})
primary := rts.nodes[0]
secondary := rts.nodes[1]
@@ -290,7 +290,7 @@ func TestReactorBroadcastEvidence(t *testing.T) {
stateDBs[i] = initializeValidatorState(ctx, t, val, height)
}
rts := setup(ctx, t, stateDBs, 0)
rts := setup(ctx, t, stateDBs)
rts.start(ctx, t)
@@ -348,7 +348,7 @@ func TestReactorBroadcastEvidence_Lagging(t *testing.T) {
stateDB1 := initializeValidatorState(ctx, t, val, height1)
stateDB2 := initializeValidatorState(ctx, t, val, height2)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 100)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2})
rts.start(ctx, t)
primary := rts.nodes[0]
@@ -382,7 +382,7 @@ func TestReactorBroadcastEvidence_Pending(t *testing.T) {
stateDB1 := initializeValidatorState(ctx, t, val, height)
stateDB2 := initializeValidatorState(ctx, t, val, height)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 100)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2})
primary := rts.nodes[0]
secondary := rts.nodes[1]
@@ -423,7 +423,7 @@ func TestReactorBroadcastEvidence_Committed(t *testing.T) {
stateDB1 := initializeValidatorState(ctx, t, val, height)
stateDB2 := initializeValidatorState(ctx, t, val, height)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2}, 0)
rts := setup(ctx, t, []sm.Store{stateDB1, stateDB2})
primary := rts.nodes[0]
secondary := rts.nodes[1]
@@ -482,7 +482,7 @@ func TestReactorBroadcastEvidence_FullyConnected(t *testing.T) {
stateDBs[i] = initializeValidatorState(ctx, t, val, height)
}
rts := setup(ctx, t, stateDBs, 0)
rts := setup(ctx, t, stateDBs)
rts.start(ctx, t)
evList := createEvidenceList(ctx, t, rts.pools[rts.network.RandomNode().NodeID], val, numEvidence)

View File

@@ -228,7 +228,7 @@ func TestDeriveSecretsAndChallengeGolden(t *testing.T) {
goldenFilepath := filepath.Join("testdata", t.Name()+".golden")
if *update {
t.Logf("Updating golden test vector file %s", goldenFilepath)
data := createGoldenTestVectors(t)
data := createGoldenTestVectors()
require.NoError(t, os.WriteFile(goldenFilepath, []byte(data), 0644))
}
f, err := os.Open(goldenFilepath)
@@ -306,7 +306,7 @@ func readLots(t *testing.T, wg *sync.WaitGroup, conn io.Reader, n int) {
// Creates the data for a test vector file.
// The file format is:
// Hex(diffie_hellman_secret), loc_is_least, Hex(recvSecret), Hex(sendSecret), Hex(challenge)
func createGoldenTestVectors(t *testing.T) string {
func createGoldenTestVectors() string {
data := ""
for i := 0; i < 32; i++ {
randSecretVector := tmrand.Bytes(32)

View File

@@ -151,14 +151,14 @@ func TestReactorErrorsOnReceivingTooManyPeers(t *testing.T) {
defer cancel()
r := setupSingle(ctx, t)
peer := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID(t)}
peer := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID()}
added, err := r.manager.Add(peer)
require.NoError(t, err)
require.True(t, added)
addresses := make([]p2pproto.PexAddress, 101)
for i := 0; i < len(addresses); i++ {
nodeAddress := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID(t)}
nodeAddress := p2p.NodeAddress{Protocol: p2p.MemoryProtocol, NodeID: randomNodeID()}
addresses[i] = p2pproto.PexAddress{
URL: nodeAddress.String(),
}
@@ -730,6 +730,6 @@ func newNodeID(t *testing.T, id string) types.NodeID {
return nodeID
}
func randomNodeID(t *testing.T) types.NodeID {
func randomNodeID() types.NodeID {
return types.NodeIDFromPubKey(ed25519.GenPrivKey().PubKey())
}

View File

@@ -54,8 +54,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) {
assert.False(t, indexer.IndexingEnabled([]indexer.EventSink{}))
// event sink setup
pool, err := setupDB(t)
assert.NoError(t, err)
pool := setupDB(t)
store := dbm.NewMemDB()
eventSinks := []indexer.EventSink{kv.NewEventSink(store), pSink}
@@ -133,7 +132,7 @@ func resetDB(t *testing.T) {
assert.NoError(t, err)
}
func setupDB(t *testing.T) (*dockertest.Pool, error) {
func setupDB(t *testing.T) *dockertest.Pool {
t.Helper()
pool, err := dockertest.NewPool(os.Getenv("DOCKER_URL"))
assert.NoError(t, err)
@@ -187,7 +186,7 @@ func setupDB(t *testing.T) (*dockertest.Pool, error) {
err = migrator.Apply(psqldb, sm)
assert.NoError(t, err)
return pool, nil
return pool
}
func teardown(t *testing.T, pool *dockertest.Pool) error {

View File

@@ -379,7 +379,7 @@ func (s *stateProviderP2P) consensusParams(ctx context.Context, height int64) (t
}
wg.Add(1)
go func(p *BlockProvider, peer types.NodeID) {
go func(peer types.NodeID) {
defer wg.Done()
timer := time.NewTimer(0)
@@ -424,7 +424,7 @@ func (s *stateProviderP2P) consensusParams(ctx context.Context, height int64) (t
}
}
}(p, peer)
}(peer)
}
sig := make(chan struct{})
go func() { wg.Wait(); close(sig) }()

View File

@@ -17,7 +17,6 @@ import (
"github.com/tendermint/tendermint/crypto"
sm "github.com/tendermint/tendermint/internal/state"
"github.com/tendermint/tendermint/internal/state/test/factory"
"github.com/tendermint/tendermint/libs/log"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmtime "github.com/tendermint/tendermint/libs/time"
"github.com/tendermint/tendermint/types"
@@ -46,7 +45,7 @@ func makeTestCommit(height int64, timestamp time.Time) *types.Commit {
commitSigs)
}
func makeStateAndBlockStore(dir string, logger log.Logger) (sm.State, *BlockStore, cleanupFunc, error) {
func makeStateAndBlockStore(dir string) (sm.State, *BlockStore, cleanupFunc, error) {
cfg, err := config.ResetTestRoot(dir, "blockchain_reactor_test")
if err != nil {
return sm.State{}, nil, nil, err
@@ -81,7 +80,7 @@ func TestMain(m *testing.M) {
}
var cleanup cleanupFunc
state, _, cleanup, err = makeStateAndBlockStore(dir, log.NewNopLogger())
state, _, cleanup, err = makeStateAndBlockStore(dir)
if err != nil {
stdlog.Fatal(err)
}
@@ -103,7 +102,7 @@ func TestMain(m *testing.M) {
// TODO: This test should be simplified ...
func TestBlockStoreSaveLoadBlock(t *testing.T) {
state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir(), log.NewNopLogger())
state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir())
defer cleanup()
require.NoError(t, err)
require.Equal(t, bs.Base(), int64(0), "initially the base should be zero")
@@ -492,7 +491,7 @@ func TestLoadBlockMeta(t *testing.T) {
}
func TestBlockFetchAtHeight(t *testing.T) {
state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir(), log.NewNopLogger())
state, bs, cleanup, err := makeStateAndBlockStore(t.TempDir())
defer cleanup()
require.NoError(t, err)
require.Equal(t, bs.Height(), int64(0), "initially the height should be zero")