Skip to content

Commit

Permalink
[Testing, Docs] refactor: move /internal/... to /testutil/... for god…
Browse files Browse the repository at this point in the history
…ocs (#153)

* refactor: move /internal pkgs to /testutil

* chore: cleanup
  • Loading branch information
bryanchriswhite authored Nov 7, 2023
1 parent 5b3fd95 commit c66c251
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 54 deletions.
10 changes: 0 additions & 10 deletions internal/mocks/mocks.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/client/block/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testclient/testblock"
"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/testutil/testclient/testblock"
)

const blockIntegrationSubTimeout = 5 * time.Second
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/block/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
comettypes "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testclient"
"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/block"
"github.com/pokt-network/poktroll/testutil/testclient"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/events_query/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
)

// The query use to subscribe for new block events on the websocket endpoint exposed by CometBFT nodes
Expand Down
9 changes: 5 additions & 4 deletions pkg/client/events_query/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testchannel"
"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/internal/testerrors"
"github.com/pokt-network/poktroll/testutil/mockclient"

eventsquery "github.com/pokt-network/poktroll/pkg/client/events_query"
"github.com/pokt-network/poktroll/pkg/client/events_query/websocket"
"github.com/pokt-network/poktroll/pkg/either"
"github.com/pokt-network/poktroll/pkg/observable"
"github.com/pokt-network/poktroll/testutil/testchannel"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
"github.com/pokt-network/poktroll/testutil/testerrors"
)

func TestEventsQueryClient_Subscribe_Succeeds(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/client/interface.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//go:generate mockgen -destination=../../internal/mocks/mockclient/events_query_client_mock.go -package=mockclient . Dialer,Connection,EventsQueryClient
//go:generate mockgen -destination=../../internal/mocks/mockclient/block_client_mock.go -package=mockclient . Block,BlockClient
//go:generate mockgen -destination=../../internal/mocks/mockclient/tx_client_mock.go -package=mockclient . TxContext,TxClient
//go:generate mockgen -destination=../../internal/mocks/mockclient/cosmos_tx_builder_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client TxBuilder
//go:generate mockgen -destination=../../internal/mocks/mockclient/cosmos_keyring_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/crypto/keyring Keyring
//go:generate mockgen -destination=../../internal/mocks/mockclient/cosmos_client_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client AccountRetriever
//go:generate mockgen -destination=../../testutil/mockclient/events_query_client_mock.go -package=mockclient . Dialer,Connection,EventsQueryClient
//go:generate mockgen -destination=../../testutil/mockclient/block_client_mock.go -package=mockclient . Block,BlockClient
//go:generate mockgen -destination=../../testutil/mockclient/tx_client_mock.go -package=mockclient . TxContext,TxClient
//go:generate mockgen -destination=../../testutil/mockclient/cosmos_tx_builder_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client TxBuilder
//go:generate mockgen -destination=../../testutil/mockclient/cosmos_keyring_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/crypto/keyring Keyring
//go:generate mockgen -destination=../../testutil/mockclient/cosmos_client_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client AccountRetriever

package client

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/supplier/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testclient/testsupplier"
"github.com/pokt-network/poktroll/testutil/testclient/testsupplier"
sessiontypes "github.com/pokt-network/poktroll/x/session/types"
)

Expand Down
7 changes: 4 additions & 3 deletions pkg/client/supplier/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"github.com/pokt-network/smt"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testclient/testkeyring"
"github.com/pokt-network/poktroll/internal/testclient/testtx"
"github.com/pokt-network/poktroll/testutil/mockclient"

"github.com/pokt-network/poktroll/pkg/client/keyring"
"github.com/pokt-network/poktroll/pkg/client/supplier"
"github.com/pokt-network/poktroll/testutil/testclient/testkeyring"
"github.com/pokt-network/poktroll/testutil/testclient/testtx"
sessiontypes "github.com/pokt-network/poktroll/x/session/types"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/client/tx/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testclient/testkeyring"
"github.com/pokt-network/poktroll/pkg/client/tx"
"github.com/pokt-network/poktroll/testutil/testclient/testblock"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
"github.com/pokt-network/poktroll/testutil/testclient/testkeyring"
"github.com/pokt-network/poktroll/testutil/testclient/testtx"

"github.com/pokt-network/poktroll/internal/testclient/testblock"
"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/internal/testclient/testtx"
"github.com/pokt-network/poktroll/pkg/client"
apptypes "github.com/pokt-network/poktroll/x/application/types"
)
Expand Down
13 changes: 7 additions & 6 deletions pkg/client/tx/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testclient"
"github.com/pokt-network/poktroll/internal/testclient/testblock"
"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/internal/testclient/testkeyring"
"github.com/pokt-network/poktroll/internal/testclient/testtx"
"github.com/pokt-network/poktroll/testutil/mockclient"

"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/keyring"
"github.com/pokt-network/poktroll/pkg/client/tx"
"github.com/pokt-network/poktroll/pkg/either"
"github.com/pokt-network/poktroll/testutil/testclient"
"github.com/pokt-network/poktroll/testutil/testclient/testblock"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
"github.com/pokt-network/poktroll/testutil/testclient/testkeyring"
"github.com/pokt-network/poktroll/testutil/testclient/testtx"
apptypes "github.com/pokt-network/poktroll/x/application/types"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/observable/channel/observable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"

"github.com/pokt-network/poktroll/internal/testchannel"
"github.com/pokt-network/poktroll/internal/testerrors"
"github.com/pokt-network/poktroll/pkg/observable"
"github.com/pokt-network/poktroll/pkg/observable/channel"
"github.com/pokt-network/poktroll/testutil/testchannel"
"github.com/pokt-network/poktroll/testutil/testerrors"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/observable/channel/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testerrors"
"github.com/pokt-network/poktroll/pkg/observable/channel"
"github.com/pokt-network/poktroll/testutil/testerrors"
)

func TestReplayObservable(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testclient"
"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/testutil/mockclient"

"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/block"
"github.com/pokt-network/poktroll/pkg/observable/channel"
"github.com/pokt-network/poktroll/testutil/testclient"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
)

// NewLocalnetClient creates and returns a new BlockClient that's configured for
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testclient"
"github.com/pokt-network/poktroll/testutil/mockclient"

"github.com/pokt-network/poktroll/pkg/client"
eventsquery "github.com/pokt-network/poktroll/pkg/client/events_query"
"github.com/pokt-network/poktroll/pkg/either"
"github.com/pokt-network/poktroll/pkg/observable/channel"
"github.com/pokt-network/poktroll/testutil/testclient"
)

// NewLocalnetClient creates and returns a new events query client that's configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/golang/mock/gomock"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/pkg/either"
"github.com/pokt-network/poktroll/testutil/mockclient"
)

// NewOneTimeMockConnAndDialer returns a new mock connection and mock dialer that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/keyring"

"github.com/pokt-network/poktroll/internal/testclient"
"github.com/pokt-network/poktroll/testutil/testclient"
)

// NewTestKeyringWithKey creates a new in-memory keyring with a test key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"cosmossdk.io/depinject"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/testclient/testtx"
"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/supplier"
"github.com/pokt-network/poktroll/pkg/client/tx"
"github.com/pokt-network/poktroll/testutil/testclient/testtx"
)

// NewLocalnetClient creates and returns a new supplier client that connects to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testclient/testblock"
"github.com/pokt-network/poktroll/internal/testclient/testeventsquery"
"github.com/pokt-network/poktroll/testutil/mockclient"

"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/tx"
"github.com/pokt-network/poktroll/pkg/either"
"github.com/pokt-network/poktroll/testutil/testclient/testblock"
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
)

type signAndBroadcastFn func(context.Context, cosmostypes.Msg) either.AsyncError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/internal/mocks/mockclient"
"github.com/pokt-network/poktroll/internal/testclient"
"github.com/pokt-network/poktroll/testutil/mockclient"

"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/client/tx"
"github.com/pokt-network/poktroll/testutil/testclient"
)

// NewLocalnetContext creates and returns a new transaction context configured
Expand Down
File renamed without changes.

0 comments on commit c66c251

Please sign in to comment.