Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion da/grpc/mockserv/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import (
"flag"
"log"
"net"
"os"
"strconv"

grpcda "github.com/celestiaorg/rollmint/da/grpc"
"github.com/celestiaorg/rollmint/da/grpc/mockserv"
"github.com/celestiaorg/rollmint/store"
tmlog "github.com/tendermint/tendermint/libs/log"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mixing "local" and 3rd party imports. tmlog should be imported in separate "section" before all the rollmint imports.

This should be detected by linter.

)

func main() {
conf := grpcda.DefaultConfig
logger := tmlog.NewTMLogger(os.Stdout)

flag.IntVar(&conf.Port, "port", conf.Port, "listening port")
flag.StringVar(&conf.Host, "host", "0.0.0.0", "listening address")
Expand All @@ -24,7 +27,7 @@ func main() {
log.Panic(err)
}
log.Println("Listening on:", lis.Addr())
srv := mockserv.GetServer(kv, conf, nil)
srv := mockserv.GetServer(kv, conf, nil, logger)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if err := srv.Serve(lis); err != nil {
log.Println("error while serving:", err)
}
Expand Down
5 changes: 1 addition & 4 deletions da/grpc/mockserv/mockserv.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package mockserv

import (
"context"
"os"

tmlog "github.com/tendermint/tendermint/libs/log"
"google.golang.org/grpc"
Expand All @@ -16,9 +15,7 @@ import (
)

// GetServer creates and returns gRPC server instance.
func GetServer(kv store.KVStore, conf grpcda.Config, mockConfig []byte) *grpc.Server {
logger := tmlog.NewTMLogger(os.Stdout)

func GetServer(kv store.KVStore, conf grpcda.Config, mockConfig []byte, logger tmlog.Logger) *grpc.Server {
srv := grpc.NewServer()
mockImpl := &mockImpl{}
err := mockImpl.mock.Init([8]byte{}, mockConfig, kv, logger)
Expand Down
6 changes: 5 additions & 1 deletion da/test/da_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"math/rand"
"net"
"os"
"strconv"
"testing"
"time"
Expand All @@ -22,6 +23,7 @@ import (
"github.com/celestiaorg/rollmint/log/test"
"github.com/celestiaorg/rollmint/store"
"github.com/celestiaorg/rollmint/types"
tmlog "github.com/tendermint/tendermint/libs/log"
)

const mockDaBlockTime = 100 * time.Millisecond
Expand Down Expand Up @@ -142,7 +144,9 @@ func TestRetrieve(t *testing.T) {
func startMockGRPCServ(t *testing.T) *grpc.Server {
t.Helper()
conf := grpcda.DefaultConfig
srv := mockserv.GetServer(store.NewDefaultInMemoryKVStore(), conf, []byte(mockDaBlockTime.String()))
logger := tmlog.NewTMLogger(os.Stdout)

srv := mockserv.GetServer(store.NewDefaultInMemoryKVStore(), conf, []byte(mockDaBlockTime.String()), logger)
lis, err := net.Listen("tcp", conf.Host+":"+strconv.Itoa(conf.Port))
if err != nil {
t.Fatal(err)
Expand Down