Skip to content

Commit

Permalink
fix: correctly register the blobstream module
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Jul 19, 2024
1 parent da27e8a commit 4b71f5b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 36 deletions.
39 changes: 21 additions & 18 deletions api/rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/celestiaorg/celestia-node/api/rpc/perms"
"github.com/celestiaorg/celestia-node/nodebuilder/blob"
"github.com/celestiaorg/celestia-node/nodebuilder/blobstream"
"github.com/celestiaorg/celestia-node/nodebuilder/da"
"github.com/celestiaorg/celestia-node/nodebuilder/das"
"github.com/celestiaorg/celestia-node/nodebuilder/fraud"
Expand All @@ -26,15 +27,16 @@ var (
)

type Client struct {
Fraud fraud.API
Header header.API
State state.API
Share share.API
DAS das.API
P2P p2p.API
Node node.API
Blob blob.API
DA da.API
Fraud fraud.API
Header header.API
State state.API
Share share.API
DAS das.API
P2P p2p.API
Node node.API
Blob blob.API
DA da.API
Blobstream blobstream.API

closer multiClientCloser
}
Expand Down Expand Up @@ -85,14 +87,15 @@ func newClient(ctx context.Context, addr string, authHeader http.Header) (*Clien
func moduleMap(client *Client) map[string]interface{} {
// TODO: this duplication of strings many times across the codebase can be avoided with issue #1176
return map[string]interface{}{
"share": &client.Share.Internal,
"state": &client.State.Internal,
"header": &client.Header.Internal,
"fraud": &client.Fraud.Internal,
"das": &client.DAS.Internal,
"p2p": &client.P2P.Internal,
"node": &client.Node.Internal,
"blob": &client.Blob.Internal,
"da": &client.DA.Internal,
"share": &client.Share.Internal,
"state": &client.State.Internal,
"header": &client.Header.Internal,
"fraud": &client.Fraud.Internal,
"das": &client.DAS.Internal,
"p2p": &client.P2P.Internal,
"node": &client.Node.Internal,
"blob": &client.Blob.Internal,
"da": &client.DA.Internal,
"blobstream": &client.Blobstream.Internal,
}
}
41 changes: 23 additions & 18 deletions api/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/celestiaorg/celestia-node/nodebuilder"
"github.com/celestiaorg/celestia-node/nodebuilder/blob"
blobMock "github.com/celestiaorg/celestia-node/nodebuilder/blob/mocks"
"github.com/celestiaorg/celestia-node/nodebuilder/blobstream"
blobstreamMock "github.com/celestiaorg/celestia-node/nodebuilder/blobstream/mocks"
"github.com/celestiaorg/celestia-node/nodebuilder/da"
daMock "github.com/celestiaorg/celestia-node/nodebuilder/da/mocks"
"github.com/celestiaorg/celestia-node/nodebuilder/das"
Expand Down Expand Up @@ -90,15 +92,16 @@ func TestRPCCallsUnderlyingNode(t *testing.T) {
// api contains all modules that are made available as the node's
// public API surface
type api struct {
Fraud fraud.Module
Header header.Module
State statemod.Module
Share share.Module
DAS das.Module
Node node.Module
P2P p2p.Module
Blob blob.Module
DA da.Module
Fraud fraud.Module
Header header.Module
State statemod.Module
Share share.Module
DAS das.Module
Node node.Module
P2P p2p.Module
Blob blob.Module
DA da.Module
Blobstream blobstream.Module
}

func TestModulesImplementFullAPI(t *testing.T) {
Expand Down Expand Up @@ -312,6 +315,7 @@ func setupNodeWithAuthedRPC(t *testing.T,
nodeMock.NewMockModule(ctrl),
blobMock.NewMockModule(ctrl),
daMock.NewMockModule(ctrl),
blobstreamMock.NewMockModule(ctrl),
}

// given the behavior of fx.Invoke, this invoke will be called last as it is added at the root
Expand Down Expand Up @@ -342,13 +346,14 @@ func setupNodeWithAuthedRPC(t *testing.T,
}

type mockAPI struct {
State *stateMock.MockModule
Share *shareMock.MockModule
Fraud *fraudMock.MockModule
Header *headerMock.MockModule
Das *dasMock.MockModule
P2P *p2pMock.MockModule
Node *nodeMock.MockModule
Blob *blobMock.MockModule
DA *daMock.MockModule
State *stateMock.MockModule
Share *shareMock.MockModule
Fraud *fraudMock.MockModule
Header *headerMock.MockModule
Das *dasMock.MockModule
P2P *p2pMock.MockModule
Node *nodeMock.MockModule
Blob *blobMock.MockModule
DA *daMock.MockModule
Blobstream *blobstreamMock.MockModule
}
3 changes: 3 additions & 0 deletions nodebuilder/rpc/constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/celestiaorg/celestia-node/api/rpc"
"github.com/celestiaorg/celestia-node/nodebuilder/blob"
"github.com/celestiaorg/celestia-node/nodebuilder/blobstream"
"github.com/celestiaorg/celestia-node/nodebuilder/da"
"github.com/celestiaorg/celestia-node/nodebuilder/das"
"github.com/celestiaorg/celestia-node/nodebuilder/fraud"
Expand All @@ -26,6 +27,7 @@ func registerEndpoints(
nodeMod node.Module,
blobMod blob.Module,
daMod da.Module,
blobstreamMod blobstream.Module,
serv *rpc.Server,
) {
serv.RegisterService("fraud", fraudMod, &fraud.API{})
Expand All @@ -37,6 +39,7 @@ func registerEndpoints(
serv.RegisterService("node", nodeMod, &node.API{})
serv.RegisterService("blob", blobMod, &blob.API{})
serv.RegisterService("da", daMod, &da.API{})
serv.RegisterService("blobstream", blobstreamMod, &blobstream.API{})
}

func server(cfg *Config, signer jwt.Signer, verifier jwt.Verifier) *rpc.Server {
Expand Down

0 comments on commit 4b71f5b

Please sign in to comment.