mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
refactor(client): align naming with rddl claim client
- rddl claim client is `RCClient` Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
d27fa4883b
commit
45fcaf5e1a
@ -10,12 +10,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ShamirCoordinatorServiceClient client.IShamirCoordinatorClient
|
||||
SCClient client.ISCClient
|
||||
)
|
||||
|
||||
func lazyLoad() client.IShamirCoordinatorClient {
|
||||
if ShamirCoordinatorServiceClient != nil {
|
||||
return ShamirCoordinatorServiceClient
|
||||
func lazyLoad() client.ISCClient {
|
||||
if SCClient != nil {
|
||||
return SCClient
|
||||
}
|
||||
cfg := config.GetConfig()
|
||||
httpsClient, err := tls.Get2WayTLSClient(cfg.CertsPath)
|
||||
@ -23,8 +23,8 @@ func lazyLoad() client.IShamirCoordinatorClient {
|
||||
err := errors.New("fatal error setting up mutual tls client for shamir coordinator")
|
||||
panic(err)
|
||||
}
|
||||
ShamirCoordinatorServiceClient = client.NewShamirCoordinatorClient(cfg.IssuerHost, httpsClient)
|
||||
return ShamirCoordinatorServiceClient
|
||||
SCClient = client.NewSCClient(cfg.IssuerHost, httpsClient)
|
||||
return SCClient
|
||||
}
|
||||
|
||||
func SendTokens(ctx context.Context, recipient string, amount string, asset string) (txID string, err error) {
|
||||
|
2
go.mod
2
go.mod
@ -29,7 +29,7 @@ require (
|
||||
github.com/rddl-network/rddl-claim-service v0.3.2
|
||||
github.com/rddl-network/rddl-claim-service/client v0.0.6
|
||||
github.com/rddl-network/shamir-coordinator-service v0.7.7
|
||||
github.com/rddl-network/shamir-coordinator-service/client v0.0.10
|
||||
github.com/rddl-network/shamir-coordinator-service/client v0.1.0
|
||||
github.com/spf13/cast v1.6.0
|
||||
github.com/spf13/cobra v1.7.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
|
4
go.sum
4
go.sum
@ -943,8 +943,8 @@ github.com/rddl-network/rddl-claim-service/client v0.0.6 h1:GLqj8RMozFPVUvPQGRLB
|
||||
github.com/rddl-network/rddl-claim-service/client v0.0.6/go.mod h1:CFAfupB5XogWqVsb6ndsLU97feGs4oUqlGI4WRff3zU=
|
||||
github.com/rddl-network/shamir-coordinator-service v0.7.7 h1:hszDZZnqBdeiOEBWlnSK2lKIJEbWclX6cchYDazpvIU=
|
||||
github.com/rddl-network/shamir-coordinator-service v0.7.7/go.mod h1:g3JnQlzKQWtnp4ZA7VtD/4N0GKpFWrW0ANHqged7M/g=
|
||||
github.com/rddl-network/shamir-coordinator-service/client v0.0.10 h1:M1lxVprsfyCLK+1LLGhAW4mne129ey23n3VpA9Xz2Kg=
|
||||
github.com/rddl-network/shamir-coordinator-service/client v0.0.10/go.mod h1:dhxYyhmU71iv32WqS6S+6Pm/Lsb5/d0KVn2MVTq5Jfk=
|
||||
github.com/rddl-network/shamir-coordinator-service/client v0.1.0 h1:o8oZzvGSAyTto5hSkNRr2KvilhwWiqGbL70HRg4aKhA=
|
||||
github.com/rddl-network/shamir-coordinator-service/client v0.1.0/go.mod h1:dhxYyhmU71iv32WqS6S+6Pm/Lsb5/d0KVn2MVTq5Jfk=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
|
@ -12,31 +12,31 @@ import (
|
||||
"github.com/rddl-network/shamir-coordinator-service/types"
|
||||
)
|
||||
|
||||
// MockIShamirCoordinatorClient is a mock of IShamirCoordinatorClient interface.
|
||||
type MockIShamirCoordinatorClient struct {
|
||||
// MockISCClient is a mock of ISCClient interface.
|
||||
type MockISCClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockIShamirCoordinatorClientMockRecorder
|
||||
recorder *MockISCClientMockRecorder
|
||||
}
|
||||
|
||||
// MockIShamirCoordinatorClientMockRecorder is the mock recorder for MockIShamirCoordinatorClient.
|
||||
type MockIShamirCoordinatorClientMockRecorder struct {
|
||||
mock *MockIShamirCoordinatorClient
|
||||
// MockISCClientMockRecorder is the mock recorder for MockISCClient.
|
||||
type MockISCClientMockRecorder struct {
|
||||
mock *MockISCClient
|
||||
}
|
||||
|
||||
// NewMockIShamirCoordinatorClient creates a new mock instance.
|
||||
func NewMockIShamirCoordinatorClient(ctrl *gomock.Controller) *MockIShamirCoordinatorClient {
|
||||
mock := &MockIShamirCoordinatorClient{ctrl: ctrl}
|
||||
mock.recorder = &MockIShamirCoordinatorClientMockRecorder{mock}
|
||||
// NewMockISCClient creates a new mock instance.
|
||||
func NewMockISCClient(ctrl *gomock.Controller) *MockISCClient {
|
||||
mock := &MockISCClient{ctrl: ctrl}
|
||||
mock.recorder = &MockISCClientMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockIShamirCoordinatorClient) EXPECT() *MockIShamirCoordinatorClientMockRecorder {
|
||||
func (m *MockISCClient) EXPECT() *MockISCClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetMnemonics mocks base method.
|
||||
func (m *MockIShamirCoordinatorClient) GetMnemonics(ctx context.Context) (types.MnemonicsResponse, error) {
|
||||
func (m *MockISCClient) GetMnemonics(ctx context.Context) (types.MnemonicsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetMnemonics", ctx)
|
||||
ret0, _ := ret[0].(types.MnemonicsResponse)
|
||||
@ -45,13 +45,13 @@ func (m *MockIShamirCoordinatorClient) GetMnemonics(ctx context.Context) (types.
|
||||
}
|
||||
|
||||
// GetMnemonics indicates an expected call of GetMnemonics.
|
||||
func (mr *MockIShamirCoordinatorClientMockRecorder) GetMnemonics(ctx interface{}) *gomock.Call {
|
||||
func (mr *MockISCClientMockRecorder) GetMnemonics(ctx interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMnemonics", reflect.TypeOf((*MockIShamirCoordinatorClient)(nil).GetMnemonics), ctx)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMnemonics", reflect.TypeOf((*MockISCClient)(nil).GetMnemonics), ctx)
|
||||
}
|
||||
|
||||
// IssueMachineNFT mocks base method.
|
||||
func (m *MockIShamirCoordinatorClient) IssueMachineNFT(ctx context.Context, name, machineAddress, domain string) (types.IssueMachineNFTResponse, error) {
|
||||
func (m *MockISCClient) IssueMachineNFT(ctx context.Context, name, machineAddress, domain string) (types.IssueMachineNFTResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IssueMachineNFT", ctx, name, machineAddress, domain)
|
||||
ret0, _ := ret[0].(types.IssueMachineNFTResponse)
|
||||
@ -60,13 +60,13 @@ func (m *MockIShamirCoordinatorClient) IssueMachineNFT(ctx context.Context, name
|
||||
}
|
||||
|
||||
// IssueMachineNFT indicates an expected call of IssueMachineNFT.
|
||||
func (mr *MockIShamirCoordinatorClientMockRecorder) IssueMachineNFT(ctx, name, machineAddress, domain interface{}) *gomock.Call {
|
||||
func (mr *MockISCClientMockRecorder) IssueMachineNFT(ctx, name, machineAddress, domain interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IssueMachineNFT", reflect.TypeOf((*MockIShamirCoordinatorClient)(nil).IssueMachineNFT), ctx, name, machineAddress, domain)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IssueMachineNFT", reflect.TypeOf((*MockISCClient)(nil).IssueMachineNFT), ctx, name, machineAddress, domain)
|
||||
}
|
||||
|
||||
// PostMnemonics mocks base method.
|
||||
func (m *MockIShamirCoordinatorClient) PostMnemonics(ctx context.Context, secret string) error {
|
||||
func (m *MockISCClient) PostMnemonics(ctx context.Context, secret string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PostMnemonics", ctx, secret)
|
||||
ret0, _ := ret[0].(error)
|
||||
@ -74,13 +74,13 @@ func (m *MockIShamirCoordinatorClient) PostMnemonics(ctx context.Context, secret
|
||||
}
|
||||
|
||||
// PostMnemonics indicates an expected call of PostMnemonics.
|
||||
func (mr *MockIShamirCoordinatorClientMockRecorder) PostMnemonics(ctx, secret interface{}) *gomock.Call {
|
||||
func (mr *MockISCClientMockRecorder) PostMnemonics(ctx, secret interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostMnemonics", reflect.TypeOf((*MockIShamirCoordinatorClient)(nil).PostMnemonics), ctx, secret)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostMnemonics", reflect.TypeOf((*MockISCClient)(nil).PostMnemonics), ctx, secret)
|
||||
}
|
||||
|
||||
// ReIssueAsset mocks base method.
|
||||
func (m *MockIShamirCoordinatorClient) ReIssueAsset(ctx context.Context, asset, amount string) (types.ReIssueResponse, error) {
|
||||
func (m *MockISCClient) ReIssueAsset(ctx context.Context, asset, amount string) (types.ReIssueResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReIssueAsset", ctx, asset, amount)
|
||||
ret0, _ := ret[0].(types.ReIssueResponse)
|
||||
@ -89,13 +89,13 @@ func (m *MockIShamirCoordinatorClient) ReIssueAsset(ctx context.Context, asset,
|
||||
}
|
||||
|
||||
// ReIssueAsset indicates an expected call of ReIssueAsset.
|
||||
func (mr *MockIShamirCoordinatorClientMockRecorder) ReIssueAsset(ctx, asset, amount interface{}) *gomock.Call {
|
||||
func (mr *MockISCClientMockRecorder) ReIssueAsset(ctx, asset, amount interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReIssueAsset", reflect.TypeOf((*MockIShamirCoordinatorClient)(nil).ReIssueAsset), ctx, asset, amount)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReIssueAsset", reflect.TypeOf((*MockISCClient)(nil).ReIssueAsset), ctx, asset, amount)
|
||||
}
|
||||
|
||||
// SendTokens mocks base method.
|
||||
func (m *MockIShamirCoordinatorClient) SendTokens(ctx context.Context, recipient, amount, asset string) (types.SendTokensResponse, error) {
|
||||
func (m *MockISCClient) SendTokens(ctx context.Context, recipient, amount, asset string) (types.SendTokensResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendTokens", ctx, recipient, amount, asset)
|
||||
ret0, _ := ret[0].(types.SendTokensResponse)
|
||||
@ -104,7 +104,7 @@ func (m *MockIShamirCoordinatorClient) SendTokens(ctx context.Context, recipient
|
||||
}
|
||||
|
||||
// SendTokens indicates an expected call of SendTokens.
|
||||
func (mr *MockIShamirCoordinatorClientMockRecorder) SendTokens(ctx, recipient, amount, asset interface{}) *gomock.Call {
|
||||
func (mr *MockISCClientMockRecorder) SendTokens(ctx, recipient, amount, asset interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendTokens", reflect.TypeOf((*MockIShamirCoordinatorClient)(nil).SendTokens), ctx, recipient, amount, asset)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendTokens", reflect.TypeOf((*MockISCClient)(nil).SendTokens), ctx, recipient, amount, asset)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func Load(t *testing.T, configs ...Config) *Network {
|
||||
}, nil)
|
||||
claim.RCClient = claimMock
|
||||
|
||||
shamirMock := clientmocks.NewMockIShamirCoordinatorClient(ctrl)
|
||||
shamirMock := clientmocks.NewMockISCClient(ctrl)
|
||||
shamirMock.EXPECT().SendTokens(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return(scctypes.SendTokensResponse{
|
||||
TxID: "7add40beb27df701e02ee85089c5bc0021bc813823fedb5f1dcb5debda7f3da9",
|
||||
}, nil)
|
||||
@ -70,7 +70,7 @@ func Load(t *testing.T, configs ...Config) *Network {
|
||||
Contract: `{"entity":{"domain":"testnet-assets.rddl.io"}, "issuer_pubkey":"02", "machine_addr":"addr","name":"machine","precicion":8,"version":1}`,
|
||||
Asset: "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, nil)
|
||||
coordinator.ShamirCoordinatorServiceClient = shamirMock
|
||||
coordinator.SCClient = shamirMock
|
||||
|
||||
// enable application logger in tests
|
||||
appLogger := util.GetAppLogger()
|
||||
|
@ -55,13 +55,13 @@ func TestMachineNFTIssuance(t *testing.T) {
|
||||
t.Setenv(config.ValAddr, "plmnt10mq5nj8jhh27z7ejnz2ql3nh0qhzjnfvy50877")
|
||||
ctrl := gomock.NewController(t)
|
||||
elements.Client = &elementsmocks.MockClient{}
|
||||
shamirMock := clientmocks.NewMockIShamirCoordinatorClient(ctrl)
|
||||
shamirMock := clientmocks.NewMockISCClient(ctrl)
|
||||
shamirMock.EXPECT().IssueMachineNFT(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return(scctypes.IssueMachineNFTResponse{
|
||||
HexTX: "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
Contract: `{"entity":{"domain":"testnet-assets.rddl.io"}, "issuer_pubkey":"02", "machine_addr":"addr","name":"machine","precicion":8,"version":1}`,
|
||||
Asset: "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, nil)
|
||||
coordinator.ShamirCoordinatorServiceClient = shamirMock
|
||||
coordinator.SCClient = shamirMock
|
||||
util.RegisterAssetServiceHTTPClient = &mocks.MockClient{}
|
||||
_, ctx := keeper.MachineKeeper(t)
|
||||
params := types.DefaultParams()
|
||||
|
Loading…
x
Reference in New Issue
Block a user