Skip to content

Commit

Permalink
more var renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Apr 4, 2024
1 parent db7e31b commit c042bc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions da/celestia/mock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

// Server mocks celestia-node HTTP API.
type Server struct {
mock *local.DataAvailabilityLayerClient
da *local.DataAvailabilityLayerClient
blockTime time.Duration
server *http.Server
logger log.Logger
Expand All @@ -32,19 +32,19 @@ type Server struct {
// NewServer creates new instance of Server.
func NewServer(blockTime time.Duration, logger log.Logger) *Server {
return &Server{
mock: new(local.DataAvailabilityLayerClient),
da: new(local.DataAvailabilityLayerClient),

Check warning on line 35 in da/celestia/mock/server.go

View check run for this annotation

Codecov / codecov/patch

da/celestia/mock/server.go#L35

Added line #L35 was not covered by tests
blockTime: blockTime,
logger: logger,
}
}

// Start starts HTTP server with given listener.
func (s *Server) Start(listener net.Listener) error {
err := s.mock.Init([]byte(s.blockTime.String()), pubsub.NewServer(), store.NewDefaultInMemoryKVStore(), s.logger)
err := s.da.Init([]byte(s.blockTime.String()), pubsub.NewServer(), store.NewDefaultInMemoryKVStore(), s.logger)

Check warning on line 43 in da/celestia/mock/server.go

View check run for this annotation

Codecov / codecov/patch

da/celestia/mock/server.go#L43

Added line #L43 was not covered by tests
if err != nil {
return err
}
err = s.mock.Start()
err = s.da.Start()

Check warning on line 47 in da/celestia/mock/server.go

View check run for this annotation

Codecov / codecov/patch

da/celestia/mock/server.go#L47

Added line #L47 was not covered by tests
if err != nil {
return err
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func (s *Server) submit(w http.ResponseWriter, r *http.Request) {
return
}

res := s.mock.SubmitBatch(&batch)
res := s.da.SubmitBatch(&batch)

Check warning on line 96 in da/celestia/mock/server.go

View check run for this annotation

Codecov / codecov/patch

da/celestia/mock/server.go#L96

Added line #L96 was not covered by tests
code := 0
if res.Code != da.StatusSuccess {
code = 3
Expand Down Expand Up @@ -122,7 +122,7 @@ func (s *Server) shares(w http.ResponseWriter, r *http.Request) {
daMetaData := &da.DASubmitMetaData{
Height: height,
}
res := s.mock.RetrieveBatches(daMetaData)
res := s.da.RetrieveBatches(daMetaData)

Check warning on line 125 in da/celestia/mock/server.go

View check run for this annotation

Codecov / codecov/patch

da/celestia/mock/server.go#L125

Added line #L125 was not covered by tests
if res.Code != da.StatusSuccess {
s.writeError(w, errors.New(res.Message))
return
Expand Down Expand Up @@ -167,7 +167,7 @@ func (s *Server) data(w http.ResponseWriter, r *http.Request) {
daMetaData := &da.DASubmitMetaData{
Height: height,
}
res := s.mock.RetrieveBatches(daMetaData)
res := s.da.RetrieveBatches(daMetaData)

Check warning on line 170 in da/celestia/mock/server.go

View check run for this annotation

Codecov / codecov/patch

da/celestia/mock/server.go#L170

Added line #L170 was not covered by tests
if res.Code != da.StatusSuccess {
s.writeError(w, errors.New(res.Message))
return
Expand Down
12 changes: 6 additions & 6 deletions da/grpc/mockserv/mockserv.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ func GetServer(kv store.KVStore, conf grpcda.Config, mockConfig []byte) *grpc.Se

srv := grpc.NewServer()
mockImpl := &mockImpl{}
err := mockImpl.mock.Init(mockConfig, pubsub.NewServer(), kv, logger)
err := mockImpl.da.Init(mockConfig, pubsub.NewServer(), kv, logger)

Check warning on line 26 in da/grpc/mockserv/mockserv.go

View check run for this annotation

Codecov / codecov/patch

da/grpc/mockserv/mockserv.go#L26

Added line #L26 was not covered by tests
if err != nil {
logger.Error("failed to initialize mock DALC", "error", err)
panic(err)
}
err = mockImpl.mock.Start()
err = mockImpl.da.Start()

Check warning on line 31 in da/grpc/mockserv/mockserv.go

View check run for this annotation

Codecov / codecov/patch

da/grpc/mockserv/mockserv.go#L31

Added line #L31 was not covered by tests
if err != nil {
logger.Error("failed to start mock DALC", "error", err)
panic(err)
Expand All @@ -38,7 +38,7 @@ func GetServer(kv store.KVStore, conf grpcda.Config, mockConfig []byte) *grpc.Se
}

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

func (m *mockImpl) SubmitBatch(_ context.Context, request *dalc.SubmitBatchRequest) (*dalc.SubmitBatchResponse, error) {
Expand All @@ -47,7 +47,7 @@ func (m *mockImpl) SubmitBatch(_ context.Context, request *dalc.SubmitBatchReque
if err != nil {
return nil, err
}
resp := m.mock.SubmitBatch(&b)
resp := m.da.SubmitBatch(&b)

Check warning on line 50 in da/grpc/mockserv/mockserv.go

View check run for this annotation

Codecov / codecov/patch

da/grpc/mockserv/mockserv.go#L50

Added line #L50 was not covered by tests
return &dalc.SubmitBatchResponse{
Result: &dalc.DAResponse{
Code: dalc.StatusCode(resp.Code),
Expand All @@ -62,7 +62,7 @@ func (m *mockImpl) CheckBatchAvailability(_ context.Context, request *dalc.Check
daMetaData := &da.DASubmitMetaData{
Height: request.DataLayerHeight,
}
resp := m.mock.CheckBatchAvailability(daMetaData)
resp := m.da.CheckBatchAvailability(daMetaData)

Check warning on line 65 in da/grpc/mockserv/mockserv.go

View check run for this annotation

Codecov / codecov/patch

da/grpc/mockserv/mockserv.go#L65

Added line #L65 was not covered by tests
return &dalc.CheckBatchAvailabilityResponse{
Result: &dalc.DAResponse{
Code: dalc.StatusCode(resp.Code),
Expand All @@ -75,7 +75,7 @@ func (m *mockImpl) RetrieveBatches(context context.Context, request *dalc.Retrie
dataMetaData := &da.DASubmitMetaData{
Height: request.DataLayerHeight,
}
resp := m.mock.RetrieveBatches(dataMetaData)
resp := m.da.RetrieveBatches(dataMetaData)

Check warning on line 78 in da/grpc/mockserv/mockserv.go

View check run for this annotation

Codecov / codecov/patch

da/grpc/mockserv/mockserv.go#L78

Added line #L78 was not covered by tests
batches := make([]*dymint.Batch, len(resp.Batches))
for i := range resp.Batches {
batches[i] = resp.Batches[i].ToProto()
Expand Down

0 comments on commit c042bc0

Please sign in to comment.