context position fixup

This commit is contained in:
William Banfield
2022-01-20 17:35:05 -05:00
parent b18d06bd42
commit e2ec93350e
16 changed files with 43 additions and 43 deletions
+5 -5
View File
@@ -207,7 +207,7 @@ func TestReactor_AbruptDisconnect(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
defer os.RemoveAll(cfg.RootDir) defer os.RemoveAll(cfg.RootDir)
valSet, privVals := factory.ValidatorSet(t, ctx, 1, 30) valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
maxBlockHeight := int64(64) maxBlockHeight := int64(64)
@@ -247,7 +247,7 @@ func TestReactor_SyncTime(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
defer os.RemoveAll(cfg.RootDir) defer os.RemoveAll(cfg.RootDir)
valSet, privVals := factory.ValidatorSet(t, ctx, 1, 30) valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
maxBlockHeight := int64(101) maxBlockHeight := int64(101)
@@ -275,7 +275,7 @@ func TestReactor_NoBlockResponse(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
defer os.RemoveAll(cfg.RootDir) defer os.RemoveAll(cfg.RootDir)
valSet, privVals := factory.ValidatorSet(t, ctx, 1, 30) valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
maxBlockHeight := int64(65) maxBlockHeight := int64(65)
@@ -328,7 +328,7 @@ func TestReactor_BadBlockStopsPeer(t *testing.T) {
defer os.RemoveAll(cfg.RootDir) defer os.RemoveAll(cfg.RootDir)
maxBlockHeight := int64(48) maxBlockHeight := int64(48)
valSet, privVals := factory.ValidatorSet(t, ctx, 1, 30) valSet, privVals := factory.ValidatorSet(ctx, t, 1, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
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}, 1000)
@@ -363,7 +363,7 @@ func TestReactor_BadBlockStopsPeer(t *testing.T) {
// //
// XXX: This causes a potential race condition. // XXX: This causes a potential race condition.
// See: https://github.com/tendermint/tendermint/issues/6005 // See: https://github.com/tendermint/tendermint/issues/6005
valSet, otherPrivVals := factory.ValidatorSet(t, ctx, 1, 30) valSet, otherPrivVals := factory.ValidatorSet(ctx, t, 1, 30)
otherGenDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) otherGenDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
newNode := rts.network.MakeNode(ctx, t, p2ptest.NodeOptions{ newNode := rts.network.MakeNode(ctx, t, p2ptest.NodeOptions{
MaxPeers: uint16(len(rts.nodes) + 1), MaxPeers: uint16(len(rts.nodes) + 1),
+1 -1
View File
@@ -46,7 +46,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
tickerFunc := newMockTickerFunc(true) tickerFunc := newMockTickerFunc(true)
appFunc := newKVStore appFunc := newKVStore
valSet, privVals := factory.ValidatorSet(t, ctx, nValidators, 30) valSet, privVals := factory.ValidatorSet(ctx, t, nValidators, 30)
genDoc := factory.GenesisDoc(config, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(config, time.Now(), valSet.Validators, nil)
states := make([]*State, nValidators) states := make([]*State, nValidators)
+5 -5
View File
@@ -522,7 +522,7 @@ func loadPrivValidator(t *testing.T, cfg *config.Config) *privval.FilePV {
func makeState(ctx context.Context, t *testing.T, cfg *config.Config, logger log.Logger, nValidators int) (*State, []*validatorStub) { func makeState(ctx context.Context, t *testing.T, cfg *config.Config, logger log.Logger, nValidators int) (*State, []*validatorStub) {
t.Helper() t.Helper()
// Get State // Get State
state, privVals := makeGenesisState(t, ctx, cfg, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, cfg, genesisStateArgs{
Validators: nValidators, Validators: nValidators,
}) })
@@ -734,7 +734,7 @@ func makeConsensusState(
) ([]*State, cleanupFunc) { ) ([]*State, cleanupFunc) {
t.Helper() t.Helper()
valSet, privVals := factory.ValidatorSet(t, ctx, nValidators, 30) valSet, privVals := factory.ValidatorSet(ctx, t, nValidators, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
css := make([]*State, nValidators) css := make([]*State, nValidators)
logger := consensusLogger() logger := consensusLogger()
@@ -795,7 +795,7 @@ func randConsensusNetWithPeers(
) ([]*State, *types.GenesisDoc, *config.Config, cleanupFunc) { ) ([]*State, *types.GenesisDoc, *config.Config, cleanupFunc) {
t.Helper() t.Helper()
valSet, privVals := factory.ValidatorSet(t, ctx, nValidators, testMinPower) valSet, privVals := factory.ValidatorSet(ctx, t, nValidators, testMinPower)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
css := make([]*State, nPeers) css := make([]*State, nPeers)
t.Helper() t.Helper()
@@ -853,7 +853,7 @@ type genesisStateArgs struct {
Time time.Time Time time.Time
} }
func makeGenesisState(t *testing.T, ctx context.Context, cfg *config.Config, args genesisStateArgs) (sm.State, []types.PrivValidator) { func makeGenesisState(ctx context.Context, t *testing.T, cfg *config.Config, args genesisStateArgs) (sm.State, []types.PrivValidator) {
t.Helper() t.Helper()
if args.Power == 0 { if args.Power == 0 {
args.Power = 1 args.Power = 1
@@ -861,7 +861,7 @@ func makeGenesisState(t *testing.T, ctx context.Context, cfg *config.Config, arg
if args.Validators == 0 { if args.Validators == 0 {
args.Power = 4 args.Power = 4
} }
valSet, privValidators := factory.ValidatorSet(t, ctx, args.Validators, args.Power) valSet, privValidators := factory.ValidatorSet(ctx, t, args.Validators, args.Power)
if args.Params == nil { if args.Params == nil {
args.Params = types.DefaultConsensusParams() args.Params = types.DefaultConsensusParams()
} }
+5 -5
View File
@@ -40,7 +40,7 @@ func TestMempoolNoProgressUntilTxsAvailable(t *testing.T) {
t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) }) t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) })
config.Consensus.CreateEmptyBlocks = false config.Consensus.CreateEmptyBlocks = false
state, privVals := makeGenesisState(t, ctx, baseConfig, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, baseConfig, genesisStateArgs{
Validators: 1, Validators: 1,
Power: 10}) Power: 10})
cs := newStateWithConfig(ctx, t, log.TestingLogger(), config, state, privVals[0], NewCounterApplication()) cs := newStateWithConfig(ctx, t, log.TestingLogger(), config, state, privVals[0], NewCounterApplication())
@@ -67,7 +67,7 @@ func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) {
t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) }) t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) })
config.Consensus.CreateEmptyBlocksInterval = ensureTimeout config.Consensus.CreateEmptyBlocksInterval = ensureTimeout
state, privVals := makeGenesisState(t, ctx, baseConfig, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, baseConfig, genesisStateArgs{
Validators: 1, Validators: 1,
Power: 10}) Power: 10})
cs := newStateWithConfig(ctx, t, log.TestingLogger(), config, state, privVals[0], NewCounterApplication()) cs := newStateWithConfig(ctx, t, log.TestingLogger(), config, state, privVals[0], NewCounterApplication())
@@ -92,7 +92,7 @@ func TestMempoolProgressInHigherRound(t *testing.T) {
t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) }) t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) })
config.Consensus.CreateEmptyBlocks = false config.Consensus.CreateEmptyBlocks = false
state, privVals := makeGenesisState(t, ctx, baseConfig, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, baseConfig, genesisStateArgs{
Validators: 1, Validators: 1,
Power: 10}) Power: 10})
cs := newStateWithConfig(ctx, t, log.TestingLogger(), config, state, privVals[0], NewCounterApplication()) cs := newStateWithConfig(ctx, t, log.TestingLogger(), config, state, privVals[0], NewCounterApplication())
@@ -143,7 +143,7 @@ func TestMempoolTxConcurrentWithCommit(t *testing.T) {
config := configSetup(t) config := configSetup(t)
logger := log.TestingLogger() logger := log.TestingLogger()
state, privVals := makeGenesisState(t, ctx, config, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, config, genesisStateArgs{
Validators: 1, Validators: 1,
Power: 10}) Power: 10})
stateStore := sm.NewStore(dbm.NewMemDB()) stateStore := sm.NewStore(dbm.NewMemDB())
@@ -178,7 +178,7 @@ func TestMempoolRmBadTx(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
state, privVals := makeGenesisState(t, ctx, config, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, config, genesisStateArgs{
Validators: 1, Validators: 1,
Power: 10}) Power: 10})
app := NewCounterApplication() app := NewCounterApplication()
+1 -1
View File
@@ -104,7 +104,7 @@ func newPBTSTestHarness(ctx context.Context, t *testing.T, tc pbtsTestConfigurat
consensusParams := types.DefaultConsensusParams() consensusParams := types.DefaultConsensusParams()
consensusParams.Synchrony = tc.synchronyParams consensusParams.Synchrony = tc.synchronyParams
state, privVals := makeGenesisState(t, ctx, cfg, genesisStateArgs{ state, privVals := makeGenesisState(ctx, t, cfg, genesisStateArgs{
Params: consensusParams, Params: consensusParams,
Time: tc.genesisTime, Time: tc.genesisTime,
Validators: validators, Validators: validators,
+1 -1
View File
@@ -383,7 +383,7 @@ func TestReactorWithEvidence(t *testing.T) {
tickerFunc := newMockTickerFunc(true) tickerFunc := newMockTickerFunc(true)
appFunc := newKVStore appFunc := newKVStore
valSet, privVals := factory.ValidatorSet(t, ctx, n, 30) valSet, privVals := factory.ValidatorSet(ctx, t, n, 30)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
states := make([]*State, n) states := make([]*State, n)
logger := consensusLogger() logger := consensusLogger()
@@ -33,7 +33,7 @@ func TestPeerCatchupRounds(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
valSet, privVals := factory.ValidatorSet(t, ctx, 10, 1) valSet, privVals := factory.ValidatorSet(ctx, t, 10, 1)
hvs := NewHeightVoteSet(cfg.ChainID(), 1, valSet) hvs := NewHeightVoteSet(cfg.ChainID(), 1, valSet)
+1 -1
View File
@@ -41,7 +41,7 @@ func TestEvidencePoolBasic(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
valSet, privVals := factory.ValidatorSet(t, ctx, 1, 10) valSet, privVals := factory.ValidatorSet(ctx, t, 1, 10)
blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return( blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return(
&types.BlockMeta{Header: types.Header{Time: defaultEvidenceTime}}, &types.BlockMeta{Header: types.Header{Time: defaultEvidenceTime}},
) )
+5 -5
View File
@@ -201,7 +201,7 @@ func TestVerifyLightClientAttack_Equivocation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
conflictingVals, conflictingPrivVals := factory.ValidatorSet(t, ctx, 5, 10) conflictingVals, conflictingPrivVals := factory.ValidatorSet(ctx, t, 5, 10)
conflictingHeader := factory.MakeHeader(t, &types.Header{ conflictingHeader := factory.MakeHeader(t, &types.Header{
ChainID: evidenceChainID, ChainID: evidenceChainID,
@@ -295,7 +295,7 @@ func TestVerifyLightClientAttack_Equivocation(t *testing.T) {
func TestVerifyLightClientAttack_Amnesia(t *testing.T) { func TestVerifyLightClientAttack_Amnesia(t *testing.T) {
var height int64 = 10 var height int64 = 10
conflictingVals, conflictingPrivVals := factory.ValidatorSet(t, ctx, 5, 10) conflictingVals, conflictingPrivVals := factory.ValidatorSet(ctx, t, 5, 10)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@@ -495,14 +495,14 @@ func makeLunaticEvidence(
) (ev *types.LightClientAttackEvidence, trusted *types.LightBlock, common *types.LightBlock) { ) (ev *types.LightClientAttackEvidence, trusted *types.LightBlock, common *types.LightBlock) {
t.Helper() t.Helper()
commonValSet, commonPrivVals := factory.ValidatorSet(t, ctx, totalVals, defaultVotingPower) commonValSet, commonPrivVals := factory.ValidatorSet(ctx, t, totalVals, defaultVotingPower)
require.Greater(t, totalVals, byzVals) require.Greater(t, totalVals, byzVals)
// extract out the subset of byzantine validators in the common validator set // extract out the subset of byzantine validators in the common validator set
byzValSet, byzPrivVals := commonValSet.Validators[:byzVals], commonPrivVals[:byzVals] byzValSet, byzPrivVals := commonValSet.Validators[:byzVals], commonPrivVals[:byzVals]
phantomValSet, phantomPrivVals := factory.ValidatorSet(t, ctx, phantomVals, defaultVotingPower) phantomValSet, phantomPrivVals := factory.ValidatorSet(ctx, t, phantomVals, defaultVotingPower)
conflictingVals := phantomValSet.Copy() conflictingVals := phantomValSet.Copy()
require.NoError(t, conflictingVals.UpdateWithChangeSet(byzValSet)) require.NoError(t, conflictingVals.UpdateWithChangeSet(byzValSet))
@@ -557,7 +557,7 @@ func makeLunaticEvidence(
ValidatorSet: commonValSet, ValidatorSet: commonValSet,
} }
trustedBlockID := factory.MakeBlockIDWithHash(trustedHeader.Hash()) trustedBlockID := factory.MakeBlockIDWithHash(trustedHeader.Hash())
trustedVals, privVals := factory.ValidatorSet(t, ctx, totalVals, defaultVotingPower) trustedVals, privVals := factory.ValidatorSet(ctx, t, totalVals, defaultVotingPower)
trustedVoteSet := types.NewVoteSet(evidenceChainID, height, 1, tmproto.SignedMsgType(2), trustedVals) trustedVoteSet := types.NewVoteSet(evidenceChainID, height, 1, tmproto.SignedMsgType(2), trustedVals)
trustedCommit, err := factory.MakeCommit(ctx, trustedBlockID, height, 1, trustedVoteSet, privVals, defaultEvidenceTime) trustedCommit, err := factory.MakeCommit(ctx, trustedBlockID, height, 1, trustedVoteSet, privVals, defaultEvidenceTime)
require.NoError(t, err) require.NoError(t, err)
+1 -1
View File
@@ -106,7 +106,7 @@ func setupStateStore(t *testing.T, height int64) state.Store {
stateStore := state.NewStore(dbm.NewMemDB()) stateStore := state.NewStore(dbm.NewMemDB())
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
valSet, _ := factory.ValidatorSet(t, ctx, 5, 10) valSet, _ := factory.ValidatorSet(ctx, t, 5, 10)
params := types.DefaultConsensusParams() params := types.DefaultConsensusParams()
params.Version.AppVersion = 10 params.Version.AppVersion = 10
+1 -1
View File
@@ -293,7 +293,7 @@ loop:
} }
func mockLBResp(ctx context.Context, t *testing.T, peer types.NodeID, height int64, time time.Time) lightBlockResponse { func mockLBResp(ctx context.Context, t *testing.T, peer types.NodeID, height int64, time time.Time) lightBlockResponse {
vals, pv := factory.ValidatorSet(t, ctx, 3, 10) vals, pv := factory.ValidatorSet(ctx, t, 3, 10)
_, _, lb := mockLB(ctx, t, height, time, factory.MakeBlockID(), vals, pv) _, _, lb := mockLB(ctx, t, height, time, factory.MakeBlockID(), vals, pv)
return lightBlockResponse{ return lightBlockResponse{
block: lb, block: lb,
+4 -4
View File
@@ -442,7 +442,7 @@ func TestReactor_LightBlockResponse(t *testing.T) {
h := factory.MakeHeader(t, &types.Header{}) h := factory.MakeHeader(t, &types.Header{})
h.Height = height h.Height = height
blockID := factory.MakeBlockIDWithHash(h.Hash()) blockID := factory.MakeBlockIDWithHash(h.Hash())
vals, pv := factory.ValidatorSet(t, ctx, 1, 10) vals, pv := factory.ValidatorSet(ctx, t, 1, 10)
vote, err := factory.MakeVote(ctx, pv[0], h.ChainID, 0, h.Height, 0, 2, vote, err := factory.MakeVote(ctx, pv[0], h.ChainID, 0, h.Height, 0, 2,
blockID, factory.DefaultTestTime) blockID, factory.DefaultTestTime)
require.NoError(t, err) require.NoError(t, err)
@@ -733,7 +733,7 @@ func handleLightBlockRequests(
} else { } else {
switch errorCount % 3 { switch errorCount % 3 {
case 0: // send a different block case 0: // send a different block
vals, pv := factory.ValidatorSet(t, ctx, 3, 10) vals, pv := factory.ValidatorSet(ctx, t, 3, 10)
_, _, lb := mockLB(ctx, t, int64(msg.Height), factory.DefaultTestTime, factory.MakeBlockID(), vals, pv) _, _, lb := mockLB(ctx, t, int64(msg.Height), factory.DefaultTestTime, factory.MakeBlockID(), vals, pv)
differntLB, err := lb.ToProto() differntLB, err := lb.ToProto()
require.NoError(t, err) require.NoError(t, err)
@@ -802,7 +802,7 @@ func buildLightBlockChain(ctx context.Context, t *testing.T, fromHeight, toHeigh
chain := make(map[int64]*types.LightBlock, toHeight-fromHeight) chain := make(map[int64]*types.LightBlock, toHeight-fromHeight)
lastBlockID := factory.MakeBlockID() lastBlockID := factory.MakeBlockID()
blockTime := startTime.Add(time.Duration(fromHeight-toHeight) * time.Minute) blockTime := startTime.Add(time.Duration(fromHeight-toHeight) * time.Minute)
vals, pv := factory.ValidatorSet(t, ctx, 3, 10) vals, pv := factory.ValidatorSet(ctx, t, 3, 10)
for height := fromHeight; height < toHeight; height++ { for height := fromHeight; height < toHeight; height++ {
vals, pv, chain[height] = mockLB(ctx, t, height, blockTime, lastBlockID, vals, pv) vals, pv, chain[height] = mockLB(ctx, t, height, blockTime, lastBlockID, vals, pv)
lastBlockID = factory.MakeBlockIDWithHash(chain[height].Header.Hash()) lastBlockID = factory.MakeBlockIDWithHash(chain[height].Header.Hash())
@@ -822,7 +822,7 @@ func mockLB(ctx context.Context, t *testing.T, height int64, time time.Time, las
}) })
header.Version.App = testAppVersion header.Version.App = testAppVersion
nextVals, nextPrivVals := factory.ValidatorSet(t, ctx, 3, 10) nextVals, nextPrivVals := factory.ValidatorSet(ctx, t, 3, 10)
header.ValidatorsHash = currentVals.Hash() header.ValidatorsHash = currentVals.Hash()
header.NextValidatorsHash = nextVals.Hash() header.NextValidatorsHash = nextVals.Hash()
header.ConsensusHash = types.DefaultConsensusParams().HashConsensusParams() header.ConsensusHash = types.DefaultConsensusParams().HashConsensusParams()
+1 -1
View File
@@ -20,7 +20,7 @@ func Validator(ctx context.Context, votingPower int64) (*types.Validator, types.
return val, privVal, nil return val, privVal, nil
} }
func ValidatorSet(t *testing.T, ctx context.Context, numValidators int, votingPower int64) (*types.ValidatorSet, []types.PrivValidator) { func ValidatorSet(ctx context.Context, t *testing.T, numValidators int, votingPower int64) (*types.ValidatorSet, []types.PrivValidator) {
var ( var (
valz = make([]*types.Validator, numValidators) valz = make([]*types.Validator, numValidators)
privValidators = make([]types.PrivValidator, numValidators) privValidators = make([]types.PrivValidator, numValidators)
+2 -2
View File
@@ -122,7 +122,7 @@ func TestClient(t *testing.T) {
t.Run("SequentialVerification", func(t *testing.T) { t.Run("SequentialVerification", func(t *testing.T) {
newKeys := genPrivKeys(4) newKeys := genPrivKeys(4)
newVals := newKeys.ToValidators(10, 1) newVals := newKeys.ToValidators(10, 1)
differentVals, _ := factory.ValidatorSet(t, ctx, 10, 100) differentVals, _ := factory.ValidatorSet(ctx, t, 10, 100)
testCases := []struct { testCases := []struct {
name string name string
@@ -940,7 +940,7 @@ func TestClient(t *testing.T) {
logger := log.NewTestingLogger(t) logger := log.NewTestingLogger(t)
differentVals, _ := factory.ValidatorSet(t, ctx, 10, 100) differentVals, _ := factory.ValidatorSet(ctx, t, 10, 100)
mockBadValSetNode := mockNodeFromHeadersAndVals( mockBadValSetNode := mockNodeFromHeadersAndVals(
map[int64]*types.SignedHeader{ map[int64]*types.SignedHeader{
1: h1, 1: h1,
+8 -8
View File
@@ -33,7 +33,7 @@ func TestLast_FirstLightBlockHeight(t *testing.T) {
assert.EqualValues(t, -1, height) assert.EqualValues(t, -1, height)
// 1 key // 1 key
err = dbStore.SaveLightBlock(randLightBlock(t, ctx, int64(1))) err = dbStore.SaveLightBlock(randLightBlock(ctx, t, int64(1)))
require.NoError(t, err) require.NoError(t, err)
height, err = dbStore.LastLightBlockHeight() height, err = dbStore.LastLightBlockHeight()
@@ -56,7 +56,7 @@ func Test_SaveLightBlock(t *testing.T) {
assert.Nil(t, h) assert.Nil(t, h)
// 1 key // 1 key
err = dbStore.SaveLightBlock(randLightBlock(t, ctx, 1)) err = dbStore.SaveLightBlock(randLightBlock(ctx, t, 1))
require.NoError(t, err) require.NoError(t, err)
size := dbStore.Size() size := dbStore.Size()
@@ -87,7 +87,7 @@ func Test_LightBlockBefore(t *testing.T) {
_, _ = dbStore.LightBlockBefore(100) _, _ = dbStore.LightBlockBefore(100)
}) })
err := dbStore.SaveLightBlock(randLightBlock(t, ctx, int64(2))) err := dbStore.SaveLightBlock(randLightBlock(ctx, t, int64(2)))
require.NoError(t, err) require.NoError(t, err)
h, err := dbStore.LightBlockBefore(3) h, err := dbStore.LightBlockBefore(3)
@@ -111,7 +111,7 @@ func Test_Prune(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// One header // One header
err = dbStore.SaveLightBlock(randLightBlock(t, ctx, 2)) err = dbStore.SaveLightBlock(randLightBlock(ctx, t, 2))
require.NoError(t, err) require.NoError(t, err)
assert.EqualValues(t, 1, dbStore.Size()) assert.EqualValues(t, 1, dbStore.Size())
@@ -126,7 +126,7 @@ func Test_Prune(t *testing.T) {
// Multiple headers // Multiple headers
for i := 1; i <= 10; i++ { for i := 1; i <= 10; i++ {
err = dbStore.SaveLightBlock(randLightBlock(t, ctx, int64(i))) err = dbStore.SaveLightBlock(randLightBlock(ctx, t, int64(i)))
require.NoError(t, err) require.NoError(t, err)
} }
@@ -151,7 +151,7 @@ func Test_Concurrency(t *testing.T) {
go func(i int64) { go func(i int64) {
defer wg.Done() defer wg.Done()
err := dbStore.SaveLightBlock(randLightBlock(t, ctx, i)) err := dbStore.SaveLightBlock(randLightBlock(ctx, t, i))
require.NoError(t, err) require.NoError(t, err)
_, err = dbStore.LightBlock(i) _, err = dbStore.LightBlock(i)
@@ -194,9 +194,9 @@ func Test_Concurrency(t *testing.T) {
wg.Wait() wg.Wait()
} }
func randLightBlock(t *testing.T, ctx context.Context, height int64) *types.LightBlock { func randLightBlock(ctx context.Context, t *testing.T, height int64) *types.LightBlock {
t.Helper() t.Helper()
vals, _ := factory.ValidatorSet(t, ctx, 2, 1) vals, _ := factory.ValidatorSet(ctx, t, 2, 1)
return &types.LightBlock{ return &types.LightBlock{
SignedHeader: &types.SignedHeader{ SignedHeader: &types.SignedHeader{
Header: &types.Header{ Header: &types.Header{
+1 -1
View File
@@ -728,7 +728,7 @@ func loadStatefromGenesis(ctx context.Context, t *testing.T) sm.State {
require.NoError(t, err) require.NoError(t, err)
require.True(t, loadedState.IsEmpty()) require.True(t, loadedState.IsEmpty())
valSet, _ := factory.ValidatorSet(t, ctx, 0, 10) valSet, _ := factory.ValidatorSet(ctx, t, 0, 10)
genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil) genDoc := factory.GenesisDoc(cfg, time.Now(), valSet.Validators, nil)
state, err := loadStateFromDBOrGenesisDocProvider( state, err := loadStateFromDBOrGenesisDocProvider(