Skip to content

Commit

Permalink
renamed mock da to local
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Apr 4, 2024
1 parent e40db8c commit db7e31b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions block/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/dymensionxyz/dymint/config"
"github.com/dymensionxyz/dymint/da"
mockda "github.com/dymensionxyz/dymint/da/mock"
localda "github.com/dymensionxyz/dymint/da/local"
mempoolv1 "github.com/dymensionxyz/dymint/mempool/v1"
nodemempool "github.com/dymensionxyz/dymint/node/mempool"
slregistry "github.com/dymensionxyz/dymint/settlement/registry"
Expand Down Expand Up @@ -72,7 +72,7 @@ func getManagerWithProposerKey(conf config.BlockManagerConfig, proposerKey crypt
}

if dalc == nil {
dalc = &mockda.DataAvailabilityLayerClient{}
dalc = &localda.DataAvailabilityLayerClient{}
}
initDALCMock(dalc, pubsubServer, logger)

Expand Down Expand Up @@ -123,7 +123,7 @@ func getManager(conf config.BlockManagerConfig, settlementlc settlement.LayerI,

// TODO(omritoptix): Possible move out to a generic testutil
func getMockDALC(logger log.Logger) da.DataAvailabilityLayerClient {
dalc := &mockda.DataAvailabilityLayerClient{}
dalc := &localda.DataAvailabilityLayerClient{}
initDALCMock(dalc, pubsub.NewServer(), logger)
return dalc
}
Expand Down
6 changes: 3 additions & 3 deletions da/celestia/mock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import (

"github.com/celestiaorg/go-cnc"
"github.com/dymensionxyz/dymint/da"
mockda "github.com/dymensionxyz/dymint/da/mock"
"github.com/dymensionxyz/dymint/da/local"
"github.com/dymensionxyz/dymint/log"
"github.com/dymensionxyz/dymint/store"
"github.com/dymensionxyz/dymint/types"
)

// Server mocks celestia-node HTTP API.
type Server struct {
mock *mockda.DataAvailabilityLayerClient
mock *local.DataAvailabilityLayerClient
blockTime time.Duration
server *http.Server
logger log.Logger
Expand All @@ -32,7 +32,7 @@ type Server struct {
// NewServer creates new instance of Server.
func NewServer(blockTime time.Duration, logger log.Logger) *Server {
return &Server{
mock: new(mockda.DataAvailabilityLayerClient),
mock: new(local.DataAvailabilityLayerClient),
blockTime: blockTime,
logger: logger,
}
Expand Down
10 changes: 5 additions & 5 deletions da/da_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/dymensionxyz/dymint/da"
"github.com/dymensionxyz/dymint/da/celestia"
"github.com/dymensionxyz/dymint/da/mock"
"github.com/dymensionxyz/dymint/da/local"
"github.com/dymensionxyz/dymint/da/registry"
"github.com/dymensionxyz/dymint/store"
"github.com/dymensionxyz/dymint/types"
Expand Down Expand Up @@ -59,11 +59,11 @@ func doTestDALC(t *testing.T, mockDalc da.DataAvailabilityLayerClient) {
var err error

// mock DALC will advance block height every 100ms
if _, ok := mockDalc.(*mock.DataAvailabilityLayerClient); !ok {
t.Fatal("mock DALC is not of type *mock.DataAvailabilityLayerClient")
if _, ok := mockDalc.(*local.DataAvailabilityLayerClient); !ok {
t.Fatal("mock DALC is not of type *local.DataAvailabilityLayerClient")
}
conf := []byte(mockDaBlockTime.String())
dalc := mockDalc.(*mock.DataAvailabilityLayerClient)
dalc := mockDalc.(*local.DataAvailabilityLayerClient)

pubsubServer := pubsub.NewServer()
err = pubsubServer.Start()
Expand Down Expand Up @@ -132,7 +132,7 @@ func doTestRetrieve(t *testing.T, dalc da.DataAvailabilityLayerClient) {

// mock DALC will advance block height every 100ms
conf := []byte{}
if _, ok := dalc.(*mock.DataAvailabilityLayerClient); ok {
if _, ok := dalc.(*local.DataAvailabilityLayerClient); ok {
conf = []byte(mockDaBlockTime.String())
}
if _, ok := dalc.(*celestia.DataAvailabilityLayerClient); ok {
Expand Down
4 changes: 2 additions & 2 deletions da/grpc/mockserv/mockserv.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/dymensionxyz/dymint/da"
grpcda "github.com/dymensionxyz/dymint/da/grpc"
"github.com/dymensionxyz/dymint/da/mock"
"github.com/dymensionxyz/dymint/da/local"
"github.com/dymensionxyz/dymint/store"
"github.com/dymensionxyz/dymint/types"
"github.com/dymensionxyz/dymint/types/pb/dalc"
Expand Down Expand Up @@ -38,7 +38,7 @@ func GetServer(kv store.KVStore, conf grpcda.Config, mockConfig []byte) *grpc.Se
}

type mockImpl struct {
mock mock.DataAvailabilityLayerClient
mock local.DataAvailabilityLayerClient
}

func (m *mockImpl) SubmitBatch(_ context.Context, request *dalc.SubmitBatchRequest) (*dalc.SubmitBatchResponse, error) {
Expand Down
2 changes: 1 addition & 1 deletion da/mock/mock.go → da/local/local.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mock
package local

import (
"crypto/sha1" //#nosec
Expand Down
4 changes: 2 additions & 2 deletions da/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"github.com/dymensionxyz/dymint/da/avail"
"github.com/dymensionxyz/dymint/da/celestia"
"github.com/dymensionxyz/dymint/da/grpc"
"github.com/dymensionxyz/dymint/da/mock"
"github.com/dymensionxyz/dymint/da/local"
)

// this is a central registry for all Data Availability Layer Clients
var clients = map[string]func() da.DataAvailabilityLayerClient{
"mock": func() da.DataAvailabilityLayerClient { return &mock.DataAvailabilityLayerClient{} },
"mock": func() da.DataAvailabilityLayerClient { return &local.DataAvailabilityLayerClient{} },
"grpc": func() da.DataAvailabilityLayerClient { return &grpc.DataAvailabilityLayerClient{} },
"celestia": func() da.DataAvailabilityLayerClient { return &celestia.DataAvailabilityLayerClient{} },
"avail": func() da.DataAvailabilityLayerClient { return &avail.DataAvailabilityLayerClient{} },
Expand Down
6 changes: 3 additions & 3 deletions testutil/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/tendermint/tendermint/proxy"

"github.com/dymensionxyz/dymint/da"
mockda "github.com/dymensionxyz/dymint/da/mock"
localda "github.com/dymensionxyz/dymint/da/local"
"github.com/dymensionxyz/dymint/store"
)

Expand Down Expand Up @@ -137,7 +137,7 @@ const connectionRefusedErrorMessage = "connection refused"

// DALayerClientSubmitBatchError is a mock data availability layer client that can be used to test error handling
type DALayerClientSubmitBatchError struct {
mockda.DataAvailabilityLayerClient
localda.DataAvailabilityLayerClient
}

// SubmitBatch submits a batch to the data availability layer
Expand All @@ -147,7 +147,7 @@ func (s *DALayerClientSubmitBatchError) SubmitBatch(_ *types.Batch) da.ResultSub

// DALayerClientRetrieveBatchesError is a mock data availability layer client that can be used to test error handling
type DALayerClientRetrieveBatchesError struct {
mockda.DataAvailabilityLayerClient
localda.DataAvailabilityLayerClient
}

// RetrieveBatches retrieves batches from the data availability layer
Expand Down

0 comments on commit db7e31b

Please sign in to comment.