From cad715b38bb4bfac7cf5138011b2b93c0b86ce69 Mon Sep 17 00:00:00 2001 From: Alex Gap Date: Wed, 19 Jul 2023 13:46:35 -0700 Subject: [PATCH 1/6] update to rpc client interface --- cmd/booster-http/gateway_handler.go | 5 ++--- cmd/booster-http/server.go | 7 +++---- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/booster-http/gateway_handler.go b/cmd/booster-http/gateway_handler.go index 78023da70..02cd01d4a 100644 --- a/cmd/booster-http/gateway_handler.go +++ b/cmd/booster-http/gateway_handler.go @@ -22,10 +22,10 @@ import ( type gatewayHandler struct { gwh http.Handler supportedFormats map[string]struct{} - nitroRpcClient *rpc.RpcClient + nitroRpcClient rpc.RpcClientApi } -func newGatewayHandler(gw *gateway.BlocksBackend, supportedFormats []string, nitroRpcClient *rpc.RpcClient) http.Handler { +func newGatewayHandler(gw *gateway.BlocksBackend, supportedFormats []string, nitroRpcClient rpc.RpcClientApi) http.Handler { headers := map[string][]string{} gateway.AddAccessControlHeaders(headers) @@ -70,7 +70,6 @@ func (h *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } s, err := h.nitroRpcClient.ReceiveVoucher(v) - if err != nil { webError(w, fmt.Errorf("error processing voucher %w", err), http.StatusBadRequest) return diff --git a/cmd/booster-http/server.go b/cmd/booster-http/server.go index 5a95ef9ff..c3c99b568 100644 --- a/cmd/booster-http/server.go +++ b/cmd/booster-http/server.go @@ -55,7 +55,7 @@ type HttpServer struct { cancel context.CancelFunc server *http.Server - nitroRpcClient *nrpc.RpcClient + nitroRpcClient nrpc.RpcClientApi } type HttpServerApi interface { @@ -79,7 +79,7 @@ func NewHttpServer(path string, listenAddr string, port int, api HttpServerApi, if opts == nil { opts = &HttpServerOptions{ServePieces: true} } - var rpcClient *nrpc.RpcClient + var rpcClient nrpc.RpcClientApi var err error if nitroOpts != nil && nitroOpts.Enabled { @@ -89,7 +89,6 @@ func NewHttpServer(path string, listenAddr string, port int, api HttpServerApi, } } return &HttpServer{path: path, port: port, api: api, opts: *opts, idxPage: parseTemplate(*opts), nitroRpcClient: rpcClient} - } func (s *HttpServer) pieceBasePath() string { @@ -222,7 +221,7 @@ func serveContent(w http.ResponseWriter, r *http.Request, content io.ReadSeeker) err = e }} - writer = writeErrWatcher //Need writeErrWatcher to be of type writeErrorWatcher for addCommas() + writer = writeErrWatcher // Need writeErrWatcher to be of type writeErrorWatcher for addCommas() // Note that the last modified time is a constant value because the data // in a piece identified by a cid will never change. diff --git a/go.mod b/go.mod index 2221b8e74..fa225247c 100644 --- a/go.mod +++ b/go.mod @@ -346,7 +346,7 @@ require ( github.com/ipfs/boxo v0.10.1 github.com/ipfs/kubo v0.21.0-rc1 github.com/ipni/go-libipni v0.0.8 - github.com/statechannels/go-nitro v0.0.0-20230710223658-280d0225a9d8 + github.com/statechannels/go-nitro v0.0.0-20230719201014-41ddb3b8b67f ) require ( diff --git a/go.sum b/go.sum index 788f3ea99..af32d0e72 100644 --- a/go.sum +++ b/go.sum @@ -1846,8 +1846,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc= -github.com/statechannels/go-nitro v0.0.0-20230710223658-280d0225a9d8 h1:XvtnSc99gOVH5Cd5b4OKU0Zx+YdA7am1QmZPCNkXZNw= -github.com/statechannels/go-nitro v0.0.0-20230710223658-280d0225a9d8/go.mod h1:h2DTAAg1B2CgyL4y3YWIHwcLQk0ZqMHzOCfUXLBURTI= +github.com/statechannels/go-nitro v0.0.0-20230719201014-41ddb3b8b67f h1:PZbG5JK0L6yXFqh3BRZhHoT0AmywWERjVzOQYvQwv7w= +github.com/statechannels/go-nitro v0.0.0-20230719201014-41ddb3b8b67f/go.mod h1:h2DTAAg1B2CgyL4y3YWIHwcLQk0ZqMHzOCfUXLBURTI= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= From 3c51b90289c9234b2559bc2dfa3f02bf537fd055 Mon Sep 17 00:00:00 2001 From: Alex Gap Date: Wed, 19 Jul 2023 13:48:27 -0700 Subject: [PATCH 2/6] generate mock nitro rpc client --- cmd/booster-http/mocks/mock_nitro_rpc.go | 279 +++++++++++++++++++++++ cmd/booster-http/server.go | 1 + 2 files changed, 280 insertions(+) create mode 100644 cmd/booster-http/mocks/mock_nitro_rpc.go diff --git a/cmd/booster-http/mocks/mock_nitro_rpc.go b/cmd/booster-http/mocks/mock_nitro_rpc.go new file mode 100644 index 000000000..6d186193f --- /dev/null +++ b/cmd/booster-http/mocks/mock_nitro_rpc.go @@ -0,0 +1,279 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/statechannels/go-nitro/rpc (interfaces: RpcClientApi) + +// Package mock_rpc is a generated GoMock package. +package mock_rpc + +import ( + reflect "reflect" + + common "github.com/ethereum/go-ethereum/common" + gomock "github.com/golang/mock/gomock" + outcome "github.com/statechannels/go-nitro/channel/state/outcome" + query "github.com/statechannels/go-nitro/node/query" + payments "github.com/statechannels/go-nitro/payments" + protocols "github.com/statechannels/go-nitro/protocols" + directfund "github.com/statechannels/go-nitro/protocols/directfund" + virtualfund "github.com/statechannels/go-nitro/protocols/virtualfund" + serde "github.com/statechannels/go-nitro/rpc/serde" + types "github.com/statechannels/go-nitro/types" +) + +// MockRpcClientApi is a mock of RpcClientApi interface. +type MockRpcClientApi struct { + ctrl *gomock.Controller + recorder *MockRpcClientApiMockRecorder +} + +// MockRpcClientApiMockRecorder is the mock recorder for MockRpcClientApi. +type MockRpcClientApiMockRecorder struct { + mock *MockRpcClientApi +} + +// NewMockRpcClientApi creates a new mock instance. +func NewMockRpcClientApi(ctrl *gomock.Controller) *MockRpcClientApi { + mock := &MockRpcClientApi{ctrl: ctrl} + mock.recorder = &MockRpcClientApiMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRpcClientApi) EXPECT() *MockRpcClientApiMockRecorder { + return m.recorder +} + +// Address mocks base method. +func (m *MockRpcClientApi) Address() (common.Address, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Address") + ret0, _ := ret[0].(common.Address) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Address indicates an expected call of Address. +func (mr *MockRpcClientApiMockRecorder) Address() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Address", reflect.TypeOf((*MockRpcClientApi)(nil).Address)) +} + +// Close mocks base method. +func (m *MockRpcClientApi) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockRpcClientApiMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockRpcClientApi)(nil).Close)) +} + +// CloseLedgerChannel mocks base method. +func (m *MockRpcClientApi) CloseLedgerChannel(arg0 types.Destination) (protocols.ObjectiveId, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseLedgerChannel", arg0) + ret0, _ := ret[0].(protocols.ObjectiveId) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CloseLedgerChannel indicates an expected call of CloseLedgerChannel. +func (mr *MockRpcClientApiMockRecorder) CloseLedgerChannel(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseLedgerChannel", reflect.TypeOf((*MockRpcClientApi)(nil).CloseLedgerChannel), arg0) +} + +// ClosePaymentChannel mocks base method. +func (m *MockRpcClientApi) ClosePaymentChannel(arg0 types.Destination) (protocols.ObjectiveId, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ClosePaymentChannel", arg0) + ret0, _ := ret[0].(protocols.ObjectiveId) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ClosePaymentChannel indicates an expected call of ClosePaymentChannel. +func (mr *MockRpcClientApiMockRecorder) ClosePaymentChannel(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClosePaymentChannel", reflect.TypeOf((*MockRpcClientApi)(nil).ClosePaymentChannel), arg0) +} + +// CreateLedgerChannel mocks base method. +func (m *MockRpcClientApi) CreateLedgerChannel(arg0 common.Address, arg1 uint32, arg2 outcome.Exit) (directfund.ObjectiveResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateLedgerChannel", arg0, arg1, arg2) + ret0, _ := ret[0].(directfund.ObjectiveResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateLedgerChannel indicates an expected call of CreateLedgerChannel. +func (mr *MockRpcClientApiMockRecorder) CreateLedgerChannel(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedgerChannel", reflect.TypeOf((*MockRpcClientApi)(nil).CreateLedgerChannel), arg0, arg1, arg2) +} + +// CreatePaymentChannel mocks base method. +func (m *MockRpcClientApi) CreatePaymentChannel(arg0 []common.Address, arg1 common.Address, arg2 uint32, arg3 outcome.Exit) (virtualfund.ObjectiveResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreatePaymentChannel", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(virtualfund.ObjectiveResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreatePaymentChannel indicates an expected call of CreatePaymentChannel. +func (mr *MockRpcClientApiMockRecorder) CreatePaymentChannel(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePaymentChannel", reflect.TypeOf((*MockRpcClientApi)(nil).CreatePaymentChannel), arg0, arg1, arg2, arg3) +} + +// CreateVoucher mocks base method. +func (m *MockRpcClientApi) CreateVoucher(arg0 types.Destination, arg1 uint64) (payments.Voucher, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateVoucher", arg0, arg1) + ret0, _ := ret[0].(payments.Voucher) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateVoucher indicates an expected call of CreateVoucher. +func (mr *MockRpcClientApiMockRecorder) CreateVoucher(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVoucher", reflect.TypeOf((*MockRpcClientApi)(nil).CreateVoucher), arg0, arg1) +} + +// GetAllLedgerChannels mocks base method. +func (m *MockRpcClientApi) GetAllLedgerChannels() ([]query.LedgerChannelInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllLedgerChannels") + ret0, _ := ret[0].([]query.LedgerChannelInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAllLedgerChannels indicates an expected call of GetAllLedgerChannels. +func (mr *MockRpcClientApiMockRecorder) GetAllLedgerChannels() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllLedgerChannels", reflect.TypeOf((*MockRpcClientApi)(nil).GetAllLedgerChannels)) +} + +// GetLedgerChannel mocks base method. +func (m *MockRpcClientApi) GetLedgerChannel(arg0 types.Destination) (query.LedgerChannelInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLedgerChannel", arg0) + ret0, _ := ret[0].(query.LedgerChannelInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetLedgerChannel indicates an expected call of GetLedgerChannel. +func (mr *MockRpcClientApiMockRecorder) GetLedgerChannel(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerChannel", reflect.TypeOf((*MockRpcClientApi)(nil).GetLedgerChannel), arg0) +} + +// GetPaymentChannel mocks base method. +func (m *MockRpcClientApi) GetPaymentChannel(arg0 types.Destination) (query.PaymentChannelInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPaymentChannel", arg0) + ret0, _ := ret[0].(query.PaymentChannelInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPaymentChannel indicates an expected call of GetPaymentChannel. +func (mr *MockRpcClientApiMockRecorder) GetPaymentChannel(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaymentChannel", reflect.TypeOf((*MockRpcClientApi)(nil).GetPaymentChannel), arg0) +} + +// GetPaymentChannelsByLedger mocks base method. +func (m *MockRpcClientApi) GetPaymentChannelsByLedger(arg0 types.Destination) ([]query.PaymentChannelInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPaymentChannelsByLedger", arg0) + ret0, _ := ret[0].([]query.PaymentChannelInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPaymentChannelsByLedger indicates an expected call of GetPaymentChannelsByLedger. +func (mr *MockRpcClientApiMockRecorder) GetPaymentChannelsByLedger(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaymentChannelsByLedger", reflect.TypeOf((*MockRpcClientApi)(nil).GetPaymentChannelsByLedger), arg0) +} + +// LedgerChannelUpdatesChan mocks base method. +func (m *MockRpcClientApi) LedgerChannelUpdatesChan(arg0 types.Destination) <-chan query.LedgerChannelInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LedgerChannelUpdatesChan", arg0) + ret0, _ := ret[0].(<-chan query.LedgerChannelInfo) + return ret0 +} + +// LedgerChannelUpdatesChan indicates an expected call of LedgerChannelUpdatesChan. +func (mr *MockRpcClientApiMockRecorder) LedgerChannelUpdatesChan(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LedgerChannelUpdatesChan", reflect.TypeOf((*MockRpcClientApi)(nil).LedgerChannelUpdatesChan), arg0) +} + +// ObjectiveCompleteChan mocks base method. +func (m *MockRpcClientApi) ObjectiveCompleteChan(arg0 protocols.ObjectiveId) <-chan struct{} { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ObjectiveCompleteChan", arg0) + ret0, _ := ret[0].(<-chan struct{}) + return ret0 +} + +// ObjectiveCompleteChan indicates an expected call of ObjectiveCompleteChan. +func (mr *MockRpcClientApiMockRecorder) ObjectiveCompleteChan(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectiveCompleteChan", reflect.TypeOf((*MockRpcClientApi)(nil).ObjectiveCompleteChan), arg0) +} + +// Pay mocks base method. +func (m *MockRpcClientApi) Pay(arg0 types.Destination, arg1 uint64) (serde.PaymentRequest, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Pay", arg0, arg1) + ret0, _ := ret[0].(serde.PaymentRequest) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Pay indicates an expected call of Pay. +func (mr *MockRpcClientApiMockRecorder) Pay(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Pay", reflect.TypeOf((*MockRpcClientApi)(nil).Pay), arg0, arg1) +} + +// PaymentChannelUpdatesChan mocks base method. +func (m *MockRpcClientApi) PaymentChannelUpdatesChan(arg0 types.Destination) <-chan query.PaymentChannelInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PaymentChannelUpdatesChan", arg0) + ret0, _ := ret[0].(<-chan query.PaymentChannelInfo) + return ret0 +} + +// PaymentChannelUpdatesChan indicates an expected call of PaymentChannelUpdatesChan. +func (mr *MockRpcClientApiMockRecorder) PaymentChannelUpdatesChan(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PaymentChannelUpdatesChan", reflect.TypeOf((*MockRpcClientApi)(nil).PaymentChannelUpdatesChan), arg0) +} + +// ReceiveVoucher mocks base method. +func (m *MockRpcClientApi) ReceiveVoucher(arg0 payments.Voucher) (payments.ReceiveVoucherSummary, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReceiveVoucher", arg0) + ret0, _ := ret[0].(payments.ReceiveVoucherSummary) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReceiveVoucher indicates an expected call of ReceiveVoucher. +func (mr *MockRpcClientApiMockRecorder) ReceiveVoucher(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveVoucher", reflect.TypeOf((*MockRpcClientApi)(nil).ReceiveVoucher), arg0) +} diff --git a/cmd/booster-http/server.go b/cmd/booster-http/server.go index c3c99b568..effbce1d4 100644 --- a/cmd/booster-http/server.go +++ b/cmd/booster-http/server.go @@ -31,6 +31,7 @@ import ( ) //go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_booster_http.go -package=mocks_booster_http -source=server.go HttpServerApi,serverApi +//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_nitro_rpc.go github.com/statechannels/go-nitro/rpc RpcClientApi var ErrNotFound = errors.New("not found") From 55f0c4306b916aa5ba531b59bd0a242496202977 Mon Sep 17 00:00:00 2001 From: Alex Gap Date: Wed, 19 Jul 2023 15:45:16 -0700 Subject: [PATCH 3/6] nitro API dependency injection --- cmd/booster-http/run.go | 18 ++++++++++++------ cmd/booster-http/server.go | 12 ++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cmd/booster-http/run.go b/cmd/booster-http/run.go index 4193fb3af..8f7ffd1cd 100644 --- a/cmd/booster-http/run.go +++ b/cmd/booster-http/run.go @@ -25,6 +25,7 @@ import ( "github.com/filecoin-project/lotus/markets/dagstore" "github.com/ipfs/go-cid" "github.com/mitchellh/go-homedir" + nrpc "github.com/statechannels/go-nitro/rpc" "github.com/urfave/cli/v2" ) @@ -216,19 +217,24 @@ var runCmd = &cli.Command{ opts.Blockstore = filtered } - nitroOpts := &NitroOptions{ - Enabled: cctx.Bool("nitro-enabled"), - Endpoint: cctx.String("nitro-endpoint"), + sapi := serverApi{ctx: ctx, bapi: bapi, sa: sa} + var nitroAPI nrpc.RpcClientApi + + if cctx.Bool("nitro-enabled") { + var err error + nitroAPI, err = nrpc.NewHttpRpcClient(cctx.String("nitro-endpoint")) + if err != nil { + return fmt.Errorf("error creating nitro API client: %w", err) + } } - sapi := serverApi{ctx: ctx, bapi: bapi, sa: sa} server := NewHttpServer( cctx.String("base-path"), cctx.String("address"), cctx.Int("port"), sapi, + nitroAPI, opts, - nitroOpts, ) // Start the server @@ -315,7 +321,7 @@ func createRepoDir(repoDir string) (string, error) { if repoDir == "" { return "", fmt.Errorf("%s is a required flag", FlagRepo.Name) } - return repoDir, os.MkdirAll(repoDir, 0744) + return repoDir, os.MkdirAll(repoDir, 0o744) } type serverApi struct { diff --git a/cmd/booster-http/server.go b/cmd/booster-http/server.go index effbce1d4..9972cbcbb 100644 --- a/cmd/booster-http/server.go +++ b/cmd/booster-http/server.go @@ -76,20 +76,12 @@ type NitroOptions struct { Endpoint string } -func NewHttpServer(path string, listenAddr string, port int, api HttpServerApi, opts *HttpServerOptions, nitroOpts *NitroOptions) *HttpServer { +func NewHttpServer(path string, listenAddr string, port int, api HttpServerApi, nitroApi nrpc.RpcClientApi, opts *HttpServerOptions) *HttpServer { if opts == nil { opts = &HttpServerOptions{ServePieces: true} } - var rpcClient nrpc.RpcClientApi - var err error - if nitroOpts != nil && nitroOpts.Enabled { - rpcClient, err = nrpc.NewHttpRpcClient(nitroOpts.Endpoint) - if err != nil { - panic(err) - } - } - return &HttpServer{path: path, port: port, api: api, opts: *opts, idxPage: parseTemplate(*opts), nitroRpcClient: rpcClient} + return &HttpServer{path: path, port: port, api: api, opts: *opts, idxPage: parseTemplate(*opts), nitroRpcClient: nitroApi} } func (s *HttpServer) pieceBasePath() string { From 99531d05ebb7df37ad7d6a1af117e473e5da19d5 Mon Sep 17 00:00:00 2001 From: Alex Gap Date: Wed, 19 Jul 2023 15:47:15 -0700 Subject: [PATCH 4/6] use the same mock package --- cmd/booster-http/mocks/mock_nitro_rpc.go | 4 ++-- cmd/booster-http/server.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/booster-http/mocks/mock_nitro_rpc.go b/cmd/booster-http/mocks/mock_nitro_rpc.go index 6d186193f..fe179fd00 100644 --- a/cmd/booster-http/mocks/mock_nitro_rpc.go +++ b/cmd/booster-http/mocks/mock_nitro_rpc.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/statechannels/go-nitro/rpc (interfaces: RpcClientApi) -// Package mock_rpc is a generated GoMock package. -package mock_rpc +// Package mocks_booster_http is a generated GoMock package. +package mocks_booster_http import ( reflect "reflect" diff --git a/cmd/booster-http/server.go b/cmd/booster-http/server.go index 9972cbcbb..af7e977d9 100644 --- a/cmd/booster-http/server.go +++ b/cmd/booster-http/server.go @@ -31,7 +31,7 @@ import ( ) //go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_booster_http.go -package=mocks_booster_http -source=server.go HttpServerApi,serverApi -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_nitro_rpc.go github.com/statechannels/go-nitro/rpc RpcClientApi +//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_nitro_rpc.go -package=mocks_booster_http github.com/statechannels/go-nitro/rpc RpcClientApi var ErrNotFound = errors.New("not found") From 3d5fb6e9ec64b49b2b0004f1973e9203d208b169 Mon Sep 17 00:00:00 2001 From: Alex Gap Date: Wed, 19 Jul 2023 15:51:11 -0700 Subject: [PATCH 5/6] rename mock name --- cmd/booster-http/mocks/mock_nitro_rpc.go | 118 +++++++++++------------ cmd/booster-http/server.go | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/cmd/booster-http/mocks/mock_nitro_rpc.go b/cmd/booster-http/mocks/mock_nitro_rpc.go index fe179fd00..8db20a068 100644 --- a/cmd/booster-http/mocks/mock_nitro_rpc.go +++ b/cmd/booster-http/mocks/mock_nitro_rpc.go @@ -19,31 +19,31 @@ import ( types "github.com/statechannels/go-nitro/types" ) -// MockRpcClientApi is a mock of RpcClientApi interface. -type MockRpcClientApi struct { +// MockNitroRpcApi is a mock of RpcClientApi interface. +type MockNitroRpcApi struct { ctrl *gomock.Controller - recorder *MockRpcClientApiMockRecorder + recorder *MockNitroRpcApiMockRecorder } -// MockRpcClientApiMockRecorder is the mock recorder for MockRpcClientApi. -type MockRpcClientApiMockRecorder struct { - mock *MockRpcClientApi +// MockNitroRpcApiMockRecorder is the mock recorder for MockNitroRpcApi. +type MockNitroRpcApiMockRecorder struct { + mock *MockNitroRpcApi } -// NewMockRpcClientApi creates a new mock instance. -func NewMockRpcClientApi(ctrl *gomock.Controller) *MockRpcClientApi { - mock := &MockRpcClientApi{ctrl: ctrl} - mock.recorder = &MockRpcClientApiMockRecorder{mock} +// NewMockNitroRpcApi creates a new mock instance. +func NewMockNitroRpcApi(ctrl *gomock.Controller) *MockNitroRpcApi { + mock := &MockNitroRpcApi{ctrl: ctrl} + mock.recorder = &MockNitroRpcApiMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockRpcClientApi) EXPECT() *MockRpcClientApiMockRecorder { +func (m *MockNitroRpcApi) EXPECT() *MockNitroRpcApiMockRecorder { return m.recorder } // Address mocks base method. -func (m *MockRpcClientApi) Address() (common.Address, error) { +func (m *MockNitroRpcApi) Address() (common.Address, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Address") ret0, _ := ret[0].(common.Address) @@ -52,13 +52,13 @@ func (m *MockRpcClientApi) Address() (common.Address, error) { } // Address indicates an expected call of Address. -func (mr *MockRpcClientApiMockRecorder) Address() *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) Address() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Address", reflect.TypeOf((*MockRpcClientApi)(nil).Address)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Address", reflect.TypeOf((*MockNitroRpcApi)(nil).Address)) } // Close mocks base method. -func (m *MockRpcClientApi) Close() error { +func (m *MockNitroRpcApi) Close() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Close") ret0, _ := ret[0].(error) @@ -66,13 +66,13 @@ func (m *MockRpcClientApi) Close() error { } // Close indicates an expected call of Close. -func (mr *MockRpcClientApiMockRecorder) Close() *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) Close() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockRpcClientApi)(nil).Close)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockNitroRpcApi)(nil).Close)) } // CloseLedgerChannel mocks base method. -func (m *MockRpcClientApi) CloseLedgerChannel(arg0 types.Destination) (protocols.ObjectiveId, error) { +func (m *MockNitroRpcApi) CloseLedgerChannel(arg0 types.Destination) (protocols.ObjectiveId, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CloseLedgerChannel", arg0) ret0, _ := ret[0].(protocols.ObjectiveId) @@ -81,13 +81,13 @@ func (m *MockRpcClientApi) CloseLedgerChannel(arg0 types.Destination) (protocols } // CloseLedgerChannel indicates an expected call of CloseLedgerChannel. -func (mr *MockRpcClientApiMockRecorder) CloseLedgerChannel(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) CloseLedgerChannel(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseLedgerChannel", reflect.TypeOf((*MockRpcClientApi)(nil).CloseLedgerChannel), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseLedgerChannel", reflect.TypeOf((*MockNitroRpcApi)(nil).CloseLedgerChannel), arg0) } // ClosePaymentChannel mocks base method. -func (m *MockRpcClientApi) ClosePaymentChannel(arg0 types.Destination) (protocols.ObjectiveId, error) { +func (m *MockNitroRpcApi) ClosePaymentChannel(arg0 types.Destination) (protocols.ObjectiveId, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ClosePaymentChannel", arg0) ret0, _ := ret[0].(protocols.ObjectiveId) @@ -96,13 +96,13 @@ func (m *MockRpcClientApi) ClosePaymentChannel(arg0 types.Destination) (protocol } // ClosePaymentChannel indicates an expected call of ClosePaymentChannel. -func (mr *MockRpcClientApiMockRecorder) ClosePaymentChannel(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) ClosePaymentChannel(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClosePaymentChannel", reflect.TypeOf((*MockRpcClientApi)(nil).ClosePaymentChannel), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClosePaymentChannel", reflect.TypeOf((*MockNitroRpcApi)(nil).ClosePaymentChannel), arg0) } // CreateLedgerChannel mocks base method. -func (m *MockRpcClientApi) CreateLedgerChannel(arg0 common.Address, arg1 uint32, arg2 outcome.Exit) (directfund.ObjectiveResponse, error) { +func (m *MockNitroRpcApi) CreateLedgerChannel(arg0 common.Address, arg1 uint32, arg2 outcome.Exit) (directfund.ObjectiveResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLedgerChannel", arg0, arg1, arg2) ret0, _ := ret[0].(directfund.ObjectiveResponse) @@ -111,13 +111,13 @@ func (m *MockRpcClientApi) CreateLedgerChannel(arg0 common.Address, arg1 uint32, } // CreateLedgerChannel indicates an expected call of CreateLedgerChannel. -func (mr *MockRpcClientApiMockRecorder) CreateLedgerChannel(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) CreateLedgerChannel(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedgerChannel", reflect.TypeOf((*MockRpcClientApi)(nil).CreateLedgerChannel), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedgerChannel", reflect.TypeOf((*MockNitroRpcApi)(nil).CreateLedgerChannel), arg0, arg1, arg2) } // CreatePaymentChannel mocks base method. -func (m *MockRpcClientApi) CreatePaymentChannel(arg0 []common.Address, arg1 common.Address, arg2 uint32, arg3 outcome.Exit) (virtualfund.ObjectiveResponse, error) { +func (m *MockNitroRpcApi) CreatePaymentChannel(arg0 []common.Address, arg1 common.Address, arg2 uint32, arg3 outcome.Exit) (virtualfund.ObjectiveResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreatePaymentChannel", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(virtualfund.ObjectiveResponse) @@ -126,13 +126,13 @@ func (m *MockRpcClientApi) CreatePaymentChannel(arg0 []common.Address, arg1 comm } // CreatePaymentChannel indicates an expected call of CreatePaymentChannel. -func (mr *MockRpcClientApiMockRecorder) CreatePaymentChannel(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) CreatePaymentChannel(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePaymentChannel", reflect.TypeOf((*MockRpcClientApi)(nil).CreatePaymentChannel), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePaymentChannel", reflect.TypeOf((*MockNitroRpcApi)(nil).CreatePaymentChannel), arg0, arg1, arg2, arg3) } // CreateVoucher mocks base method. -func (m *MockRpcClientApi) CreateVoucher(arg0 types.Destination, arg1 uint64) (payments.Voucher, error) { +func (m *MockNitroRpcApi) CreateVoucher(arg0 types.Destination, arg1 uint64) (payments.Voucher, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateVoucher", arg0, arg1) ret0, _ := ret[0].(payments.Voucher) @@ -141,13 +141,13 @@ func (m *MockRpcClientApi) CreateVoucher(arg0 types.Destination, arg1 uint64) (p } // CreateVoucher indicates an expected call of CreateVoucher. -func (mr *MockRpcClientApiMockRecorder) CreateVoucher(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) CreateVoucher(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVoucher", reflect.TypeOf((*MockRpcClientApi)(nil).CreateVoucher), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVoucher", reflect.TypeOf((*MockNitroRpcApi)(nil).CreateVoucher), arg0, arg1) } // GetAllLedgerChannels mocks base method. -func (m *MockRpcClientApi) GetAllLedgerChannels() ([]query.LedgerChannelInfo, error) { +func (m *MockNitroRpcApi) GetAllLedgerChannels() ([]query.LedgerChannelInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllLedgerChannels") ret0, _ := ret[0].([]query.LedgerChannelInfo) @@ -156,13 +156,13 @@ func (m *MockRpcClientApi) GetAllLedgerChannels() ([]query.LedgerChannelInfo, er } // GetAllLedgerChannels indicates an expected call of GetAllLedgerChannels. -func (mr *MockRpcClientApiMockRecorder) GetAllLedgerChannels() *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) GetAllLedgerChannels() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllLedgerChannels", reflect.TypeOf((*MockRpcClientApi)(nil).GetAllLedgerChannels)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllLedgerChannels", reflect.TypeOf((*MockNitroRpcApi)(nil).GetAllLedgerChannels)) } // GetLedgerChannel mocks base method. -func (m *MockRpcClientApi) GetLedgerChannel(arg0 types.Destination) (query.LedgerChannelInfo, error) { +func (m *MockNitroRpcApi) GetLedgerChannel(arg0 types.Destination) (query.LedgerChannelInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLedgerChannel", arg0) ret0, _ := ret[0].(query.LedgerChannelInfo) @@ -171,13 +171,13 @@ func (m *MockRpcClientApi) GetLedgerChannel(arg0 types.Destination) (query.Ledge } // GetLedgerChannel indicates an expected call of GetLedgerChannel. -func (mr *MockRpcClientApiMockRecorder) GetLedgerChannel(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) GetLedgerChannel(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerChannel", reflect.TypeOf((*MockRpcClientApi)(nil).GetLedgerChannel), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerChannel", reflect.TypeOf((*MockNitroRpcApi)(nil).GetLedgerChannel), arg0) } // GetPaymentChannel mocks base method. -func (m *MockRpcClientApi) GetPaymentChannel(arg0 types.Destination) (query.PaymentChannelInfo, error) { +func (m *MockNitroRpcApi) GetPaymentChannel(arg0 types.Destination) (query.PaymentChannelInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPaymentChannel", arg0) ret0, _ := ret[0].(query.PaymentChannelInfo) @@ -186,13 +186,13 @@ func (m *MockRpcClientApi) GetPaymentChannel(arg0 types.Destination) (query.Paym } // GetPaymentChannel indicates an expected call of GetPaymentChannel. -func (mr *MockRpcClientApiMockRecorder) GetPaymentChannel(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) GetPaymentChannel(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaymentChannel", reflect.TypeOf((*MockRpcClientApi)(nil).GetPaymentChannel), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaymentChannel", reflect.TypeOf((*MockNitroRpcApi)(nil).GetPaymentChannel), arg0) } // GetPaymentChannelsByLedger mocks base method. -func (m *MockRpcClientApi) GetPaymentChannelsByLedger(arg0 types.Destination) ([]query.PaymentChannelInfo, error) { +func (m *MockNitroRpcApi) GetPaymentChannelsByLedger(arg0 types.Destination) ([]query.PaymentChannelInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPaymentChannelsByLedger", arg0) ret0, _ := ret[0].([]query.PaymentChannelInfo) @@ -201,13 +201,13 @@ func (m *MockRpcClientApi) GetPaymentChannelsByLedger(arg0 types.Destination) ([ } // GetPaymentChannelsByLedger indicates an expected call of GetPaymentChannelsByLedger. -func (mr *MockRpcClientApiMockRecorder) GetPaymentChannelsByLedger(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) GetPaymentChannelsByLedger(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaymentChannelsByLedger", reflect.TypeOf((*MockRpcClientApi)(nil).GetPaymentChannelsByLedger), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPaymentChannelsByLedger", reflect.TypeOf((*MockNitroRpcApi)(nil).GetPaymentChannelsByLedger), arg0) } // LedgerChannelUpdatesChan mocks base method. -func (m *MockRpcClientApi) LedgerChannelUpdatesChan(arg0 types.Destination) <-chan query.LedgerChannelInfo { +func (m *MockNitroRpcApi) LedgerChannelUpdatesChan(arg0 types.Destination) <-chan query.LedgerChannelInfo { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LedgerChannelUpdatesChan", arg0) ret0, _ := ret[0].(<-chan query.LedgerChannelInfo) @@ -215,13 +215,13 @@ func (m *MockRpcClientApi) LedgerChannelUpdatesChan(arg0 types.Destination) <-ch } // LedgerChannelUpdatesChan indicates an expected call of LedgerChannelUpdatesChan. -func (mr *MockRpcClientApiMockRecorder) LedgerChannelUpdatesChan(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) LedgerChannelUpdatesChan(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LedgerChannelUpdatesChan", reflect.TypeOf((*MockRpcClientApi)(nil).LedgerChannelUpdatesChan), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LedgerChannelUpdatesChan", reflect.TypeOf((*MockNitroRpcApi)(nil).LedgerChannelUpdatesChan), arg0) } // ObjectiveCompleteChan mocks base method. -func (m *MockRpcClientApi) ObjectiveCompleteChan(arg0 protocols.ObjectiveId) <-chan struct{} { +func (m *MockNitroRpcApi) ObjectiveCompleteChan(arg0 protocols.ObjectiveId) <-chan struct{} { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ObjectiveCompleteChan", arg0) ret0, _ := ret[0].(<-chan struct{}) @@ -229,13 +229,13 @@ func (m *MockRpcClientApi) ObjectiveCompleteChan(arg0 protocols.ObjectiveId) <-c } // ObjectiveCompleteChan indicates an expected call of ObjectiveCompleteChan. -func (mr *MockRpcClientApiMockRecorder) ObjectiveCompleteChan(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) ObjectiveCompleteChan(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectiveCompleteChan", reflect.TypeOf((*MockRpcClientApi)(nil).ObjectiveCompleteChan), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectiveCompleteChan", reflect.TypeOf((*MockNitroRpcApi)(nil).ObjectiveCompleteChan), arg0) } // Pay mocks base method. -func (m *MockRpcClientApi) Pay(arg0 types.Destination, arg1 uint64) (serde.PaymentRequest, error) { +func (m *MockNitroRpcApi) Pay(arg0 types.Destination, arg1 uint64) (serde.PaymentRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Pay", arg0, arg1) ret0, _ := ret[0].(serde.PaymentRequest) @@ -244,13 +244,13 @@ func (m *MockRpcClientApi) Pay(arg0 types.Destination, arg1 uint64) (serde.Payme } // Pay indicates an expected call of Pay. -func (mr *MockRpcClientApiMockRecorder) Pay(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) Pay(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Pay", reflect.TypeOf((*MockRpcClientApi)(nil).Pay), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Pay", reflect.TypeOf((*MockNitroRpcApi)(nil).Pay), arg0, arg1) } // PaymentChannelUpdatesChan mocks base method. -func (m *MockRpcClientApi) PaymentChannelUpdatesChan(arg0 types.Destination) <-chan query.PaymentChannelInfo { +func (m *MockNitroRpcApi) PaymentChannelUpdatesChan(arg0 types.Destination) <-chan query.PaymentChannelInfo { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PaymentChannelUpdatesChan", arg0) ret0, _ := ret[0].(<-chan query.PaymentChannelInfo) @@ -258,13 +258,13 @@ func (m *MockRpcClientApi) PaymentChannelUpdatesChan(arg0 types.Destination) <-c } // PaymentChannelUpdatesChan indicates an expected call of PaymentChannelUpdatesChan. -func (mr *MockRpcClientApiMockRecorder) PaymentChannelUpdatesChan(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) PaymentChannelUpdatesChan(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PaymentChannelUpdatesChan", reflect.TypeOf((*MockRpcClientApi)(nil).PaymentChannelUpdatesChan), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PaymentChannelUpdatesChan", reflect.TypeOf((*MockNitroRpcApi)(nil).PaymentChannelUpdatesChan), arg0) } // ReceiveVoucher mocks base method. -func (m *MockRpcClientApi) ReceiveVoucher(arg0 payments.Voucher) (payments.ReceiveVoucherSummary, error) { +func (m *MockNitroRpcApi) ReceiveVoucher(arg0 payments.Voucher) (payments.ReceiveVoucherSummary, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ReceiveVoucher", arg0) ret0, _ := ret[0].(payments.ReceiveVoucherSummary) @@ -273,7 +273,7 @@ func (m *MockRpcClientApi) ReceiveVoucher(arg0 payments.Voucher) (payments.Recei } // ReceiveVoucher indicates an expected call of ReceiveVoucher. -func (mr *MockRpcClientApiMockRecorder) ReceiveVoucher(arg0 interface{}) *gomock.Call { +func (mr *MockNitroRpcApiMockRecorder) ReceiveVoucher(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveVoucher", reflect.TypeOf((*MockRpcClientApi)(nil).ReceiveVoucher), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceiveVoucher", reflect.TypeOf((*MockNitroRpcApi)(nil).ReceiveVoucher), arg0) } diff --git a/cmd/booster-http/server.go b/cmd/booster-http/server.go index af7e977d9..c16b4dbde 100644 --- a/cmd/booster-http/server.go +++ b/cmd/booster-http/server.go @@ -31,7 +31,7 @@ import ( ) //go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_booster_http.go -package=mocks_booster_http -source=server.go HttpServerApi,serverApi -//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_nitro_rpc.go -package=mocks_booster_http github.com/statechannels/go-nitro/rpc RpcClientApi +//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_nitro_rpc.go -package=mocks_booster_http -mock_names=RpcClientApi=MockNitroRpcApi github.com/statechannels/go-nitro/rpc RpcClientApi var ErrNotFound = errors.New("not found") From 12bdd428f654544d252c307bd6392b2334a853c3 Mon Sep 17 00:00:00 2001 From: Alex Gap Date: Tue, 11 Jul 2023 12:28:32 -0700 Subject: [PATCH 6/6] disable tc and bitswap --- docker/devnet/docker-compose.yaml | 76 +++++++++++++++---------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/docker/devnet/docker-compose.yaml b/docker/devnet/docker-compose.yaml index 88ca91440..db4cbe379 100644 --- a/docker/devnet/docker-compose.yaml +++ b/docker/devnet/docker-compose.yaml @@ -89,29 +89,29 @@ services: - ./data/lotus:/var/lib/lotus:ro - ./data/lotus-miner:/var/lib/lotus-miner:ro labels: - - "com.docker-tc.enabled=1" - - "com.docker-tc.delay=10ms" + - "com.docker-tc.enabled=0" + - booster-bitswap: - container_name: booster-bitswap - image: ${BOOSTER_BITSWAP_IMAGE} - ports: - - "8888:8888" - environment: - - BOOSTER_BITSWAP_REPO=/var/lib/booster-bitswap - - BOOST_PATH=/var/lib/boost - - LOTUS_PATH=/var/lib/lotus - - LOTUS_MINER_PATH=/var/lib/lotus-miner - restart: unless-stopped - logging: *default-logging - volumes: - - ./data/booster-bitswap:/var/lib/booster-bitswap:rw - - ./data/boost:/var/lib/boost:ro - - ./data/lotus:/var/lib/lotus:ro - - ./data/lotus-miner:/var/lib/lotus-miner:ro - labels: - - "com.docker-tc.enabled=1" - - "com.docker-tc.delay=10ms" + # booster-bitswap: + # container_name: booster-bitswap + # image: ${BOOSTER_BITSWAP_IMAGE} + # ports: + # - "8888:8888" + # environment: + # - BOOSTER_BITSWAP_REPO=/var/lib/booster-bitswap + # - BOOST_PATH=/var/lib/boost + # - LOTUS_PATH=/var/lib/lotus + # - LOTUS_MINER_PATH=/var/lib/lotus-miner + # restart: unless-stopped + # logging: *default-logging + # volumes: + # - ./data/booster-bitswap:/var/lib/booster-bitswap:rw + # - ./data/boost:/var/lib/boost:ro + # - ./data/lotus:/var/lib/lotus:ro + # - ./data/lotus-miner:/var/lib/lotus-miner:ro + # labels: + # - "com.docker-tc.enabled=1" + # - "com.docker-tc.delay=10ms" demo-http-server: container_name: demo-http-server @@ -125,19 +125,19 @@ services: - "com.docker-tc.limit=1mbps" - "com.docker-tc.delay=100ms" - tc: - image: "${DOCKER_IMAGE_TERMINAL:-lukaszlach/docker-tc}" - container_name: docker-tc - cap_add: - - NET_ADMIN - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - /var/docker-tc:/var/docker-tc - deploy: - mode: global - restart_policy: - condition: any - environment: - HTTP_BIND: "${HTTP_BIND:-127.0.0.1}" - HTTP_PORT: "${HTTP_PORT:-4080}" - network_mode: host + # tc: + # image: "${DOCKER_IMAGE_TERMINAL:-lukaszlach/docker-tc}" + # container_name: docker-tc + # cap_add: + # - NET_ADMIN + # volumes: + # - /var/run/docker.sock:/var/run/docker.sock + # - /var/docker-tc:/var/docker-tc + # deploy: + # mode: global + # restart_policy: + # condition: any + # environment: + # HTTP_BIND: "${HTTP_BIND:-127.0.0.1}" + # HTTP_PORT: "${HTTP_PORT:-4080}" + # network_mode: host