Skip to content

Commit

Permalink
chore: fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jtieri committed Sep 30, 2024
1 parent 59a75f8 commit e594946
Show file tree
Hide file tree
Showing 58 changed files with 233 additions and 167 deletions.
26 changes: 16 additions & 10 deletions blockdb/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func TestChain_SaveBlock(t *testing.T) {
)

t.Run("happy path", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down Expand Up @@ -98,27 +100,29 @@ ORDER BY tendermint_event_attr.id`)
for i = 0; rows.Next(); i++ {
var gotData, gotType, gotKey, gotValue string
require.NoError(t, rows.Scan(&gotData, &gotType, &gotKey, &gotValue))
require.Equal(t, gotData, `{"test":1}`)
require.Equal(t, `{"test":1}`, gotData)
switch i {
case 0:
require.Equal(t, gotType, "e1")
require.Equal(t, gotKey, "k1")
require.Equal(t, gotValue, "v1")
require.Equal(t, "e1", gotType)
require.Equal(t, "k1", gotKey)
require.Equal(t, "v1", gotValue)
case 1:
require.Equal(t, gotType, "e2")
require.Equal(t, gotKey, "k2")
require.Equal(t, gotValue, "v2")
require.Equal(t, "e2", gotType)
require.Equal(t, "k2", gotKey)
require.Equal(t, "v2", gotValue)
case 2:
require.Equal(t, gotType, "e2")
require.Equal(t, gotKey, "k3")
require.Equal(t, gotValue, "v3")
require.Equal(t, "e2", gotType)
require.Equal(t, "k3", gotKey)
require.Equal(t, "v3", gotValue)
default:
t.Fatalf("expected 3 results, got i=%d", i)
}
}
})

t.Run("idempotent", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down Expand Up @@ -152,6 +156,8 @@ ORDER BY tendermint_event_attr.id`)
})

t.Run("zero state", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down
2 changes: 1 addition & 1 deletion blockdb/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func timeToLocal(timeStr string) (time.Time, error) {
if err != nil {
return time.Time{}, fmt.Errorf("time.Parse RFC3339: %w", err)
}
return t.In(time.Local), nil
return t.In(time.Local), nil //nolint: gosmopolitan
}

type SchemaVersionResult struct {
Expand Down
12 changes: 11 additions & 1 deletion blockdb/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func TestQuery_RecentTestCases(t *testing.T) {
ctx := context.Background()

t.Run("happy path", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down Expand Up @@ -83,6 +85,8 @@ func TestQuery_RecentTestCases(t *testing.T) {
})

t.Run("limit", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand All @@ -99,6 +103,8 @@ func TestQuery_RecentTestCases(t *testing.T) {
})

t.Run("no test cases", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down Expand Up @@ -174,6 +180,8 @@ func TestQuery_Transactions(t *testing.T) {
ctx := context.Background()

t.Run("happy path", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down Expand Up @@ -201,6 +209,8 @@ func TestQuery_Transactions(t *testing.T) {
})

t.Run("no txs", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand All @@ -212,6 +222,6 @@ func TestQuery_Transactions(t *testing.T) {
results, err := NewQuery(db).Transactions(ctx, chain.id)
require.NoError(t, err)

require.Len(t, results, 0)
require.Empty(t, results)
})
}
2 changes: 1 addition & 1 deletion blockdb/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestDB_Concurrency(t *testing.T) {
for {
if ctx.Err() != nil {
// Context was canceled; querying is finished.
return nil
return nil //nolint: nilerr
}

// Deliberately using context.Background() here so that
Expand Down
8 changes: 8 additions & 0 deletions blockdb/test_case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func TestCreateTestCase(t *testing.T) {
ctx := context.Background()

t.Run("happy path", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand All @@ -39,6 +41,8 @@ func TestCreateTestCase(t *testing.T) {
})

t.Run("errors", func(t *testing.T) {
t.Parallel()

db := emptyDB()
_, err := CreateTestCase(ctx, db, "fail", "")
require.Error(t, err)
Expand All @@ -51,6 +55,8 @@ func TestTestCase_AddChain(t *testing.T) {
ctx := context.Background()

t.Run("happy path", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down Expand Up @@ -80,6 +86,8 @@ func TestTestCase_AddChain(t *testing.T) {
})

t.Run("errors", func(t *testing.T) {
t.Parallel()

db := migratedDB()
defer db.Close()

Expand Down
2 changes: 1 addition & 1 deletion blockdb/tui/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ func TestModel_RootView(t *testing.T) {
m := NewModel(&mockQueryService{}, "test.db", "abc123", time.Now(), make([]blockdb.TestCaseResult, 1))
view := m.RootView()
require.NotNil(t, view)
require.Greater(t, view.GetItemCount(), 0)
require.Positive(t, view.GetItemCount())
}
4 changes: 4 additions & 0 deletions blockdb/tui/presenter/cosmos_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func TestCosmosMessage(t *testing.T) {
t.Parallel()

t.Run("non-variable fields", func(t *testing.T) {
t.Parallel()

res := blockdb.CosmosMessageResult{
Height: 55,
Index: 13,
Expand All @@ -30,6 +32,8 @@ func TestCosmosMessage(t *testing.T) {
})

t.Run("ibc details", func(t *testing.T) {
t.Parallel()

for _, tt := range []struct {
Result blockdb.CosmosMessageResult
WantClients string
Expand Down
4 changes: 4 additions & 0 deletions blockdb/tui/presenter/test_case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ func TestTestCase(t *testing.T) {
t.Parallel()

t.Run("happy path", func(t *testing.T) {
t.Parallel()

result := blockdb.TestCaseResult{
ID: 321,
Name: "My Test",
Expand All @@ -36,6 +38,8 @@ func TestTestCase(t *testing.T) {
})

t.Run("zero state", func(t *testing.T) {
t.Parallel()

var pres TestCase

require.Empty(t, pres.Height())
Expand Down
2 changes: 1 addition & 1 deletion chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (tn *ChainNode) NewSidecarProcess(
VolumeName: v.Name,
ImageRef: image.Ref(),
TestName: tn.TestName,
UidGid: image.UidGid,
UidGid: image.UIDGID,
}); err != nil {
return fmt.Errorf("set volume owner: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewCosmosHeighlinerChainConfig(name string,
Images: []ibc.DockerImage{
{
Repository: fmt.Sprintf("ghcr.io/strangelove-ventures/heighliner/%s", name),
UidGid: dockerutil.GetHeighlinerUserString(),
UIDGID: dockerutil.GetHeighlinerUserString(),
},
},
Bin: binary,
Expand Down Expand Up @@ -674,7 +674,7 @@ func (c *CosmosChain) NewChainNode(
VolumeName: v.Name,
ImageRef: image.Ref(),
TestName: testName,
UidGid: image.UidGid,
UidGid: image.UIDGID,
}); err != nil {
return nil, fmt.Errorf("set volume owner: %w", err)
}
Expand Down Expand Up @@ -731,7 +731,7 @@ func (c *CosmosChain) NewSidecarProcess(
VolumeName: v.Name,
ImageRef: image.Ref(),
TestName: testName,
UidGid: image.UidGid,
UidGid: image.UIDGID,
}); err != nil {
return fmt.Errorf("set volume owner: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/ethererum_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *EthereumChain) Initialize(ctx context.Context, testName string, cli *do
VolumeName: v.Name,
ImageRef: image.Ref(),
TestName: testName,
UidGid: image.UidGid,
UidGid: image.UIDGID,
}); err != nil {
return fmt.Errorf("set volume owner: %w", err)
}
Expand Down
12 changes: 6 additions & 6 deletions chain/ethereum/foundry/anvil_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ func (c *AnvilChain) Start(testName string, ctx context.Context, additionalGenes
if err != nil {
return err
}
localJsonFile := filepath.Join(pwd, loadState)
dockerJsonFile := path.Join(c.HomeDir(), path.Base(loadState))
localJSONFile := filepath.Join(pwd, loadState)
dockerJSONFile := path.Join(c.HomeDir(), path.Base(loadState))
mounts = []mount.Mount{
{
Type: mount.TypeBind,
Source: localJsonFile,
Target: dockerJsonFile,
Source: localJSONFile,
Target: dockerJSONFile,
},
}
cmd = append(cmd, "--load-state", dockerJsonFile)
cmd = append(cmd, "--load-state", dockerJSONFile)
}

return c.EthereumChain.Start(ctx, cmd, mounts)
Expand Down Expand Up @@ -201,7 +201,7 @@ func (c *AnvilChain) BuildWallet(ctx context.Context, keyName string, mnemonic s
} else {
// Use the genesis account
if keyName == "faucet" {
mnemonic = "test test test test test test test test test test test junk"
mnemonic = "test test test test test test test test test test test junk" //nolint: dupword
err := c.RecoverKey(ctx, keyName, mnemonic)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion chain/ethereum/foundry/default_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func DefaultEthereumAnvilChainConfig(
{
Repository: "ghcr.io/foundry-rs/foundry",
Version: "latest",
UidGid: "1000:1000",
UIDGID: "1000:1000",
},
},
Bin: "anvil",
Expand Down
4 changes: 2 additions & 2 deletions chain/ethereum/geth/default_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func DefaultEthereumGethChainConfig(
{
Repository: "ethereum/client-go",
Version: "v1.14.7",
UidGid: "1025:1025",
UIDGID: "1025:1025",
},
},
Bin: "geth",
Expand Down Expand Up @@ -59,7 +59,7 @@ func DefaultBscChainConfig(
Repository: "ghcr.io/bnb-chain/bsc",
Version: "1.2.13", // same version as other sim tests
// Version: "1.4.13", // this version does not work in dev mode (1.3.x+)
UidGid: "1000:1000",
UIDGID: "1000:1000",
},
},
Bin: "geth",
Expand Down
2 changes: 1 addition & 1 deletion chain/internal/tendermint/tendermint_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func NewTendermintNode(
VolumeName: tn.VolumeName,
ImageRef: tn.Image.Ref(),
TestName: tn.TestName,
UidGid: tn.Image.UidGid,
UidGid: tn.Image.UIDGID,
}); err != nil {
return nil, fmt.Errorf("set tendermint volume owner: %w", err)
}
Expand Down
12 changes: 6 additions & 6 deletions chain/penumbra/penumbra_app_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewPenumbraAppNode(
VolumeName: pn.VolumeName,
ImageRef: pn.Image.Ref(),
TestName: pn.TestName,
UidGid: image.UidGid,
UidGid: image.UIDGID,
}); err != nil {
return nil, fmt.Errorf("set penumbra volume owner: %w", err)
}
Expand Down Expand Up @@ -124,8 +124,8 @@ func (p *PenumbraAppNode) HomeDir() string {
// CreateKey attempts to initialize a new pcli config file with a newly generated FullViewingKey and CustodyKey.
func (p *PenumbraAppNode) CreateKey(ctx context.Context, keyName string) error {
keyPath := filepath.Join(p.HomeDir(), "keys", keyName)
pdUrl := fmt.Sprintf("http://%s:8080", p.HostName())
cmd := []string{"pcli", "--home", keyPath, "init", "--grpc-url", pdUrl, "soft-kms", "generate"}
pdURL := fmt.Sprintf("http://%s:8080", p.HostName())
cmd := []string{"pcli", "--home", keyPath, "init", "--grpc-url", pdURL, "soft-kms", "generate"}

_, stderr, err := p.Exec(ctx, cmd, nil)

Expand Down Expand Up @@ -248,13 +248,13 @@ func (p *PenumbraAppNode) GenerateGenesisFile(
validators []PenumbraValidatorDefinition,
allocations []PenumbraGenesisAppStateAllocation,
) error {
validatorsJson, err := json.Marshal(validators)
validatorsJSON, err := json.Marshal(validators)
if err != nil {
return fmt.Errorf("error marshalling validators to json: %w", err)
}

fw := dockerutil.NewFileWriter(p.log, p.DockerClient, p.TestName)
if err := fw.WriteFile(ctx, p.VolumeName, "validators.json", validatorsJson); err != nil {
if err := fw.WriteFile(ctx, p.VolumeName, "validators.json", validatorsJSON); err != nil {
return fmt.Errorf("error writing validators to file: %w", err)
}

Expand Down Expand Up @@ -387,7 +387,7 @@ func (p *PenumbraAppNode) Exec(ctx context.Context, cmd []string, env []string)
opts := dockerutil.ContainerOptions{
Binds: p.Bind(),
Env: env,
User: p.Image.UidGid,
User: p.Image.UIDGID,
}

res := job.Run(ctx, cmd, opts)
Expand Down
Loading

0 comments on commit e594946

Please sign in to comment.