Skip to content

Commit

Permalink
lint in pglive tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
jchappelow committed Dec 18, 2024
1 parent 2cb2cd2 commit c37fc0c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
run:
timeout: 10m
go: '1.22'
build-tags:
- pglive

issues:
exclude-dirs:
Expand Down
1 change: 1 addition & 0 deletions node/migrations/changesets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func TestChangesetMigration(t *testing.T) {
Engine: nil,
}
err = applyChangeset(ctx, app, tx, int64(height), int64(totalChunks))
require.NoError(t, err)

res, err := tx.Execute(ctx, "select * from ds_test.test", pg.QueryModeExec)
require.NoError(t, err)
Expand Down
12 changes: 8 additions & 4 deletions node/node_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func TestDualNodeMocknet(t *testing.T) {

bpl1 := log.New(log.WithName("BP1"), log.WithWriter(os.Stdout), log.WithLevel(log.LevelDebug), log.WithFormat(log.FormatUnstructured))
bp1, err := blockprocessor.NewBlockProcessor(ctx, db1, newDummyTxApp(valSetList), accounts1, vstore1, ss, es1, migrator, genCfg, signer1, bpl1)
require.NoError(t, err)

ceCfg1 := &consensus.Config{
PrivateKey: privKeys[0],
Expand Down Expand Up @@ -285,9 +286,12 @@ func TestDualNodeMocknet(t *testing.T) {
require.NoError(t, err)

migrator2, err := migrations.SetupMigrator(ctx, db2, newSnapshotStore(), accounts2, filepath.Join(root2, "migrations"), mparams, vstore2, log.New(log.WithName("MIGRATOR")))
require.NoError(t, err)

bpl2 := log.New(log.WithName("BP2"), log.WithWriter(os.Stdout), log.WithLevel(log.LevelDebug), log.WithFormat(log.FormatUnstructured))
bp2, err := blockprocessor.NewBlockProcessor(ctx, db2, newDummyTxApp(valSetList), accounts2, vstore2, ss, es2, migrator2, genCfg, signer2, bpl2)
require.NoError(t, err)

ceCfg2 := &consensus.Config{
PrivateKey: privKeys[1],
ValidatorSet: valSet,
Expand Down Expand Up @@ -423,7 +427,7 @@ func (d *dummyTxApp) ApplyMempool(ctx *common.TxContext, db sql.DB, tx *ktypes.T
return nil
}

type validatorStore struct {
/*type validatorStore struct {
valSet []*ktypes.Validator
}
Expand All @@ -439,7 +443,7 @@ func (v *validatorStore) GetValidators() []*ktypes.Validator {
func (v *validatorStore) ValidatorUpdates() map[string]*ktypes.Validator {
return nil
}
}*/

type mockAccounts struct{}

Expand Down Expand Up @@ -468,7 +472,7 @@ func (m *mockEventStore) GetUnbroadcastedEvents(ctx context.Context) ([]*ktypes.
}

// TODO: can test with real migrator
type mockMigrator struct{}
/*type mockMigrator struct{}
func (m *mockMigrator) NotifyHeight(ctx context.Context, block *common.BlockContext, db migrations.Database) error {
return nil
Expand All @@ -484,4 +488,4 @@ func (m *mockMigrator) PersistLastChangesetHeight(ctx context.Context, tx sql.Ex
func (m *mockMigrator) GetMigrationMetadata(ctx context.Context, status ktypes.MigrationStatus) (*ktypes.MigrationMetadata, error) {
return nil, nil
}
}*/
8 changes: 4 additions & 4 deletions node/pg/db_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ func Test_Listen(t *testing.T) {
}()

// notify 10 times to each
for i := 0; i < 10; i++ {
for i := range 10 {
_, err = tx.Execute(ctx, "SELECT NOTICE($1);", fmt.Sprint(i))
require.NoError(t, err)

Expand All @@ -1719,7 +1719,7 @@ func Test_Listen(t *testing.T) {
require.Len(t, received, 10)
require.Len(t, received2, 10)

for i := 0; i < 10; i++ {
for i := range 10 {
require.Equal(t, strconv.Itoa(i), received[i])
require.Equal(t, strconv.Itoa(-i), received2[i])
}
Expand Down Expand Up @@ -1748,7 +1748,7 @@ func Test_CancelListen(t *testing.T) {
}
}()

for i := 0; i < 10; i++ {
for i := range 10 {
_, err = tx.Execute(ctx, "SELECT NOTICE($1);", fmt.Sprint(i))
require.NoError(t, err)
}
Expand All @@ -1758,7 +1758,7 @@ func Test_CancelListen(t *testing.T) {
err = done(ctx)
require.NoError(t, err)

for i := 0; i < 10; i++ {
for i := range 10 {
_, err = tx.Execute(ctx, "SELECT NOTICE($1);", fmt.Sprint(-(i + 1)))
require.NoError(t, err)
}
Expand Down
4 changes: 1 addition & 3 deletions node/pg/repl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func Test_repl(t *testing.T) {
defer wg.Done()
defer quit()

for cid := range commitChan {
if cid, ok := <-commitChan; ok {
_, commitHash, err := decodeCommitPayload(cid)
if err != nil {
t.Errorf("invalid commit payload encoding: %v", err)
Expand All @@ -98,8 +98,6 @@ func Test_repl(t *testing.T) {

// commitChan was closed before receive (not expected in this test)
t.Error(<-errChan)

return
}()

tx, err := connQ.Begin(ctx)
Expand Down
2 changes: 1 addition & 1 deletion node/voting/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func Test_EventStore(t *testing.T) {
ctx := context.Background()

// create 3 events
for i := 0; i < 3; i++ {
for i := range 3 {
data := fmt.Sprintf("test%d", i)
err := e.Store(ctx, []byte(data), "test")
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion node/voting/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func Test_Voting(t *testing.T) {

events := make([]*types.VotableEvent, 3)
ids := make([]*types.UUID, 3)
for i := 0; i < 3; i++ {
for i := range 3 {
events[i] = &types.VotableEvent{
Body: []byte("test" + fmt.Sprint(i)),
Type: testType,
Expand Down

0 comments on commit c37fc0c

Please sign in to comment.