Skip to content

Commit

Permalink
Rename testing to testutils
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Aug 29, 2024
1 parent 3c2bcb8 commit 3dca8b7
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions pkg/api/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import (
"github.com/xmtp/xmtpd/pkg/proto/xmtpv4/message_api"
"github.com/xmtp/xmtpd/pkg/registrant"
"github.com/xmtp/xmtpd/pkg/registry"
test "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
"google.golang.org/protobuf/proto"
)

func newTestService(t *testing.T) (*Service, *sql.DB, func()) {
ctx := context.Background()
log := test.NewLog(t)
db, _, dbCleanup := test.NewDB(t, ctx)
log := testutils.NewLog(t)
db, _, dbCleanup := testutils.NewDB(t, ctx)
privKey, err := crypto.GenerateKey()
require.NoError(t, err)
privKeyStr := "0x" + test.HexEncode(crypto.FromECDSA(privKey))
privKeyStr := "0x" + testutils.HexEncode(crypto.FromECDSA(privKey))
mockRegistry := mocks.NewMockNodeRegistry(t)
mockRegistry.EXPECT().GetNodes().Return([]registry.Node{
{NodeID: 1, SigningKey: &privKey.PublicKey},
Expand Down
4 changes: 2 additions & 2 deletions pkg/db/subscription_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/xmtp/xmtpd/pkg/db/queries"
test "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -37,7 +37,7 @@ func insertGatewayEnvelopes(

func setup(t *testing.T) (*sql.DB, *zap.Logger, func()) {
ctx := context.Background()
db, _, dbCleanup := test.NewDB(t, ctx)
db, _, dbCleanup := testutils.NewDB(t, ctx)
log, err := zap.NewDevelopment()
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion pkg/indexer/blockchain/rpcLogStreamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/xmtp/xmtpd/pkg/mocks"
testutils "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"

ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
Expand Down
2 changes: 1 addition & 1 deletion pkg/indexer/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/xmtp/xmtpd/pkg/indexer/storer"
"github.com/xmtp/xmtpd/pkg/mocks"
testutils "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
)

func TestIndexLogsSuccess(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/indexer/storer/groupMessage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/xmtp/xmtpd/pkg/db"
"github.com/xmtp/xmtpd/pkg/db/queries"
"github.com/xmtp/xmtpd/pkg/indexer/blockchain"
testutils "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
"github.com/xmtp/xmtpd/pkg/utils"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/registrant/registrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/xmtp/xmtpd/pkg/proto/xmtpv4/message_api"
"github.com/xmtp/xmtpd/pkg/registrant"
"github.com/xmtp/xmtpd/pkg/registry"
test "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
"google.golang.org/protobuf/proto"
)

Expand All @@ -30,15 +30,15 @@ type deps struct {
func setup(t *testing.T) (deps, func()) {
ctx := context.Background()
mockRegistry := mocks.NewMockNodeRegistry(t)
db, _, dbCleanup := test.NewDB(t, ctx)
db, _, dbCleanup := testutils.NewDB(t, ctx)
queries := queries.New(db)
privKey1, err := crypto.GenerateKey()
require.NoError(t, err)
privKey2, err := crypto.GenerateKey()
require.NoError(t, err)
privKey3, err := crypto.GenerateKey()
require.NoError(t, err)
privKey1Str := "0x" + test.HexEncode(crypto.FromECDSA(privKey1))
privKey1Str := "0x" + testutils.HexEncode(crypto.FromECDSA(privKey1))

return deps{
ctx: ctx,
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestNewRegistrantPrivateKeyNo0x(t *testing.T) {
deps.ctx,
deps.db,
deps.registry,
test.HexEncode(crypto.FromECDSA(deps.privKey1)),
testutils.HexEncode(crypto.FromECDSA(deps.privKey1)),
)
require.NoError(t, err)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/contractRegistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"github.com/xmtp/xmtpd/pkg/config"
"github.com/xmtp/xmtpd/pkg/mocks"
r "github.com/xmtp/xmtpd/pkg/registry"
testUtils "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
)

func TestContractRegistryNewNodes(t *testing.T) {
registry, err := r.NewSmartContractRegistry(
nil,
testUtils.NewLog(t),
testutils.NewLog(t),
config.ContractsOptions{RefreshInterval: 100 * time.Millisecond},
)
require.NoError(t, err)
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestContractRegistryNewNodes(t *testing.T) {
func TestContractRegistryChangedNodes(t *testing.T) {
registry, err := r.NewSmartContractRegistry(
nil,
testUtils.NewLog(t),
testutils.NewLog(t),
config.ContractsOptions{RefreshInterval: 10 * time.Millisecond},
)
require.NoError(t, err)
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestContractRegistryChangedNodes(t *testing.T) {
func TestStopOnContextCancel(t *testing.T) {
registry, err := r.NewSmartContractRegistry(
nil,
testUtils.NewLog(t),
testutils.NewLog(t),
config.ContractsOptions{RefreshInterval: 10 * time.Millisecond},
)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/xmtp/xmtpd/pkg/mocks"
r "github.com/xmtp/xmtpd/pkg/registry"
s "github.com/xmtp/xmtpd/pkg/server"
test "github.com/xmtp/xmtpd/pkg/testing"
"github.com/xmtp/xmtpd/pkg/testutils"
)

func NewTestServer(
Expand All @@ -22,7 +22,7 @@ func NewTestServer(
registry r.NodeRegistry,
privateKey *ecdsa.PrivateKey,
) *s.ReplicationServer {
log := test.NewLog(t)
log := testutils.NewLog(t)

server, err := s.NewReplicationServer(context.Background(), log, config.ServerOptions{
PrivateKeyString: hex.EncodeToString(crypto.FromECDSA(privateKey)),
Expand All @@ -36,7 +36,7 @@ func NewTestServer(
}

func TestCreateServer(t *testing.T) {
dbs, dbCleanup := test.NewDBs(t, context.Background(), 2)
dbs, dbCleanup := testutils.NewDBs(t, context.Background(), 2)
defer dbCleanup()
privateKey1, err := crypto.GenerateKey()
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/config.go → pkg/testutils/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package testutils

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/contracts.go → pkg/testutils/contracts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package testutils

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/hex.go → pkg/testutils/hex.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package testutils

import "encoding/hex"

Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/log.go → pkg/testutils/log.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package testutils

import (
"flag"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/random.go → pkg/testutils/random.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package testutils

import (
cryptoRand "crypto/rand"
Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/store.go → pkg/testutils/store.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package testutils

import (
"context"
Expand Down

0 comments on commit 3dca8b7

Please sign in to comment.