Skip to content

Commit

Permalink
chore: address the remaining linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jtieri committed Oct 1, 2024
1 parent a9dbecb commit 2b9e013
Show file tree
Hide file tree
Showing 121 changed files with 665 additions and 628 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ protoVer=0.13.2
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
golangci_lint_cmd=golangci-lint
golangci_version=v1.57.2
golangci_version=v1.61.0
gofumpt_cmd=gofumpt
gofumpt_version=v0.6.0
gofumpt_version=v0.7.0

default: help

Expand Down
39 changes: 20 additions & 19 deletions blockdb/messages_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import (
"path/filepath"
"testing"

"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/relayer"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"

"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/types"

"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/relayer"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
)

func TestMessagesView(t *testing.T) {
Expand Down Expand Up @@ -87,7 +88,7 @@ func TestMessagesView(t *testing.T) {
var count int
row := db.QueryRow(`SELECT COUNT(*) FROM v_cosmos_messages`)
require.NoError(t, row.Scan(&count))
require.Equal(t, count, 0)
require.Equal(t, 0, count)

// Generate the path.
// No transactions happen here.
Expand All @@ -105,10 +106,10 @@ FROM v_cosmos_messages
WHERE type = "/ibc.core.client.v1.MsgCreateClient" AND chain_id = ?;`
var clientChainID string
require.NoError(t, db.QueryRow(qCreateClient, gaia0ChainID).Scan(&clientChainID))
require.Equal(t, clientChainID, gaia1ChainID)
require.Equal(t, gaia1ChainID, clientChainID)

require.NoError(t, db.QueryRow(qCreateClient, gaia1ChainID).Scan(&clientChainID))
require.Equal(t, clientChainID, gaia0ChainID)
require.Equal(t, gaia0ChainID, clientChainID)
})
if t.Failed() {
return
Expand Down Expand Up @@ -208,8 +209,8 @@ WHERE type = "/ibc.core.channel.v1.MsgChannelOpenInit" AND chain_id = ?
`
var portID, counterpartyPortID string
require.NoError(t, db.QueryRow(qChannelOpenInit, gaia0ChainID).Scan(&portID, &counterpartyPortID))
require.Equal(t, portID, gaia0Port)
require.Equal(t, counterpartyPortID, gaia1Port)
require.Equal(t, gaia0Port, portID)
require.Equal(t, gaia1Port, counterpartyPortID)

// OpenTry happens on second chain.
const qChannelOpenTry = `SELECT
Expand All @@ -219,8 +220,8 @@ WHERE type = "/ibc.core.channel.v1.MsgChannelOpenTry" AND chain_id = ?
`
var counterpartyChannelID string
require.NoError(t, db.QueryRow(qChannelOpenTry, gaia1ChainID).Scan(&portID, &counterpartyPortID, &counterpartyChannelID))
require.Equal(t, portID, gaia1Port)
require.Equal(t, counterpartyPortID, gaia0Port)
require.Equal(t, gaia1Port, portID)
require.Equal(t, gaia0Port, counterpartyPortID)
require.Equal(t, counterpartyChannelID, gaia0ChannelID)

// OpenAck happens on first chain again.
Expand All @@ -231,7 +232,7 @@ WHERE type = "/ibc.core.channel.v1.MsgChannelOpenAck" AND chain_id = ?
`
var channelID string
require.NoError(t, db.QueryRow(qChannelOpenAck, gaia0ChainID).Scan(&portID, &channelID, &counterpartyChannelID))
require.Equal(t, portID, gaia0Port)
require.Equal(t, gaia0Port, portID)
require.Equal(t, channelID, gaia0ChannelID)
require.Equal(t, counterpartyChannelID, gaia1ChannelID)

Expand All @@ -242,7 +243,7 @@ FROM v_cosmos_messages
WHERE type = "/ibc.core.channel.v1.MsgChannelOpenConfirm" AND chain_id = ?
`
require.NoError(t, db.QueryRow(qChannelOpenConfirm, gaia1ChainID).Scan(&portID, &channelID))
require.Equal(t, portID, gaia1Port)
require.Equal(t, gaia1Port, portID)
require.Equal(t, channelID, gaia1ChannelID)
})
if t.Failed() {
Expand Down Expand Up @@ -274,7 +275,7 @@ WHERE type = "/ibc.applications.transfer.v1.MsgTransfer" AND chain_id = ?
`
var portID, channelID string
require.NoError(t, db.QueryRow(qMsgTransfer, gaia0ChainID).Scan(&portID, &channelID))
require.Equal(t, portID, gaia0Port)
require.Equal(t, gaia0Port, portID)
require.Equal(t, channelID, gaia0ChannelID)
})
if t.Failed() {
Expand All @@ -299,9 +300,9 @@ WHERE type = "/ibc.core.channel.v1.MsgRecvPacket" AND chain_id = ?

require.NoError(t, db.QueryRow(qMsgRecvPacket, gaia1ChainID).Scan(&portID, &channelID, &counterpartyPortID, &counterpartyChannelID))

require.Equal(t, portID, gaia0Port)
require.Equal(t, gaia0Port, portID)
require.Equal(t, channelID, gaia0ChannelID)
require.Equal(t, counterpartyPortID, gaia1Port)
require.Equal(t, gaia1Port, counterpartyPortID)
require.Equal(t, counterpartyChannelID, gaia1ChannelID)

const qMsgAck = `SELECT
Expand All @@ -311,9 +312,9 @@ WHERE type = "/ibc.core.channel.v1.MsgAcknowledgement" AND chain_id = ?
`
require.NoError(t, db.QueryRow(qMsgAck, gaia0ChainID).Scan(&portID, &channelID, &counterpartyPortID, &counterpartyChannelID))

require.Equal(t, portID, gaia0Port)
require.Equal(t, gaia0Port, portID)
require.Equal(t, channelID, gaia0ChannelID)
require.Equal(t, counterpartyPortID, gaia1Port)
require.Equal(t, gaia1Port, counterpartyPortID)
require.Equal(t, counterpartyChannelID, gaia1ChannelID)
})
}
4 changes: 0 additions & 4 deletions blockdb/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ func TestDB_Concurrency(t *testing.T) {
// and a shared context so all fail if one fails.
egWrites, egCtx := errgroup.WithContext(ctx)
for i := 0; i < nWriters; i++ {
i := i

// Connecting to the database in the main goroutine
// because concurrently connecting to the same database
// causes a data race inside sqlite.
Expand Down Expand Up @@ -98,8 +96,6 @@ func TestDB_Concurrency(t *testing.T) {
// Separate errgroup for the queriers.
var egQueries errgroup.Group
for i := 0; i < nQueriers; i++ {
i := i

db, err := ConnectDB(ctx, dbPath)
require.NoErrorf(t, err, "failed to connect to db for querier %d: %v", i, err)
defer db.Close()
Expand Down
1 change: 1 addition & 0 deletions blockdb/tui/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/atotto/clipboard"
"github.com/rivo/tview"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
)

Expand Down
3 changes: 2 additions & 1 deletion blockdb/tui/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"testing"
"time"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
"github.com/stretchr/testify/require"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
)

func TestModel_RootView(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion blockdb/tui/presenter/cosmos_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"database/sql"
"testing"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
"github.com/stretchr/testify/require"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
)

func TestCosmosMessage(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion blockdb/tui/presenter/test_case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"testing"
"time"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
"github.com/stretchr/testify/require"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
)

func TestTestCase(t *testing.T) {
Expand Down
7 changes: 6 additions & 1 deletion blockdb/tui/presenter/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import (
"encoding/json"
"testing"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
"github.com/stretchr/testify/require"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
)

func TestTx(t *testing.T) {
t.Parallel()

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

tx := blockdb.TxResult{
Height: 13,
Tx: []byte(`{"json":{"foo":true}}`),
Expand All @@ -30,6 +33,8 @@ func TestTx(t *testing.T) {
})

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

tx := blockdb.TxResult{
Tx: []byte(`some data`),
}
Expand Down
1 change: 1 addition & 0 deletions blockdb/tui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"

"github.com/strangelove-ventures/interchaintest/v8/blockdb/tui/presenter"
)

Expand Down
3 changes: 2 additions & 1 deletion blockdb/tui/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (

"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
"github.com/strangelove-ventures/interchaintest/v8/blockdb"
"github.com/stretchr/testify/require"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
)

var (
Expand Down
1 change: 1 addition & 0 deletions blockdb/tui/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"

"github.com/strangelove-ventures/interchaintest/v8/blockdb"
"github.com/strangelove-ventures/interchaintest/v8/blockdb/tui/presenter"
)
Expand Down
18 changes: 9 additions & 9 deletions blockdb/views_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ ORDER BY test_case_id, chain_kid, block_id, tx_id
require.Equal(t, tcID, tc.id)
require.GreaterOrEqual(t, tcCreatedAt, beforeTestCaseCreate)
require.LessOrEqual(t, tcCreatedAt, beforeBlocksCreated)
require.Equal(t, tcName, "mytest")
require.Equal(t, "mytest", tcName)

require.Equal(t, chainKeyID, chain.id)
require.Equal(t, chainID, "chain1")
require.Equal(t, chainType, "cosmos")
require.Equal(t, "chain1", chainID)
require.Equal(t, "cosmos", chainType)

require.GreaterOrEqual(t, blockCreatedAt, beforeBlocksCreated)
require.LessOrEqual(t, blockCreatedAt, afterBlocksCreated)
require.Equal(t, blockHeight, 1)
require.Equal(t, 1, blockHeight)

require.Equal(t, tx, "tx1.0")
require.Equal(t, "tx1.0", tx)

// Save some state gathered from the first row.
firstBlockCreatedAt := blockCreatedAt
Expand All @@ -104,11 +104,11 @@ ORDER BY test_case_id, chain_kid, block_id, tx_id
// New block height.
require.GreaterOrEqual(t, blockCreatedAt, firstBlockCreatedAt)
require.LessOrEqual(t, blockCreatedAt, afterBlocksCreated)
require.Equal(t, blockHeight, 2)
require.Equal(t, 2, blockHeight)

// Next transaction.
require.Greater(t, txID, firstTxID)
require.Equal(t, tx, "tx2.0")
require.Equal(t, "tx2.0", tx)

secondTxID := txID

Expand All @@ -126,11 +126,11 @@ ORDER BY test_case_id, chain_kid, block_id, tx_id
require.Equal(t, chainKeyID, chain.id)

// Same block height.
require.Equal(t, blockHeight, 2)
require.Equal(t, 2, blockHeight)

// Next transaction.
require.Greater(t, txID, secondTxID)
require.Equal(t, tx, "tx2.1")
require.Equal(t, "tx2.1", tx)

// No more rows.
require.False(t, rows.Next())
Expand Down
8 changes: 5 additions & 3 deletions chain/cosmos/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
"testing"
"time"

"github.com/strangelove-ventures/interchaintest/v8/dockerutil"
"github.com/strangelove-ventures/interchaintest/v8/testutil"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"

"github.com/strangelove-ventures/interchaintest/v8/dockerutil"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
)

type ClientContextOpt func(clientContext client.Context) client.Context
Expand Down Expand Up @@ -50,6 +50,8 @@ type Broadcaster struct {
// NewBroadcaster returns a instance of Broadcaster which can be used with broadcast.Tx to
// broadcast messages sdk messages.
func NewBroadcaster(t *testing.T, chain *CosmosChain) *Broadcaster {
t.Helper()

return &Broadcaster{
t: t,
chain: chain,
Expand Down
Loading

0 comments on commit 2b9e013

Please sign in to comment.