Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy sysmessaging package 💥 #926

Merged
merged 3 commits into from
Aug 11, 2022
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: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ $(eval $(call makemock, pkg/tokens, Plugin, tokenmock
$(eval $(call makemock, pkg/tokens, Callbacks, tokenmocks))
$(eval $(call makemock, internal/txcommon, Helper, txcommonmocks))
$(eval $(call makemock, internal/identity, Manager, identitymanagermocks))
$(eval $(call makemock, internal/sysmessaging, SystemEvents, sysmessagingmocks))
$(eval $(call makemock, internal/sysmessaging, MessageSender, sysmessagingmocks))
$(eval $(call makemock, internal/sysmessaging, LocalNodeInfo, sysmessagingmocks))
$(eval $(call makemock, internal/syncasync, Sender, syncasyncmocks))
$(eval $(call makemock, internal/syncasync, Bridge, syncasyncmocks))
$(eval $(call makemock, internal/data, Manager, datamocks))
$(eval $(call makemock, internal/batch, Manager, batchmocks))
Expand All @@ -66,6 +64,7 @@ $(eval $(call makemock, internal/shareddownload, Callbacks, shareddow
$(eval $(call makemock, internal/definitions, Handler, definitionsmocks))
$(eval $(call makemock, internal/definitions, Sender, definitionsmocks))
$(eval $(call makemock, internal/events, EventManager, eventmocks))
$(eval $(call makemock, internal/events/system, EventInterface, systemeventmocks))
$(eval $(call makemock, internal/namespace, Manager, namespacemocks))
$(eval $(call makemock, internal/networkmap, Manager, networkmapmocks))
$(eval $(call makemock, internal/assets, Manager, assetmocks))
Expand Down
5 changes: 2 additions & 3 deletions internal/assets/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/hyperledger/firefly/internal/operations"
"github.com/hyperledger/firefly/internal/privatemessaging"
"github.com/hyperledger/firefly/internal/syncasync"
"github.com/hyperledger/firefly/internal/sysmessaging"
"github.com/hyperledger/firefly/internal/txcommon"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
Expand All @@ -53,14 +52,14 @@ type Manager interface {
GetTokenTransfers(ctx context.Context, filter database.AndFilter) ([]*core.TokenTransfer, *database.FilterResult, error)
GetTokenTransferByID(ctx context.Context, id string) (*core.TokenTransfer, error)

NewTransfer(transfer *core.TokenTransferInput) sysmessaging.MessageSender
NewTransfer(transfer *core.TokenTransferInput) syncasync.Sender
MintTokens(ctx context.Context, transfer *core.TokenTransferInput, waitConfirm bool) (*core.TokenTransfer, error)
BurnTokens(ctx context.Context, transfer *core.TokenTransferInput, waitConfirm bool) (*core.TokenTransfer, error)
TransferTokens(ctx context.Context, transfer *core.TokenTransferInput, waitConfirm bool) (*core.TokenTransfer, error)

GetTokenConnectors(ctx context.Context) []*core.TokenConnector

NewApproval(approve *core.TokenApprovalInput) sysmessaging.MessageSender
NewApproval(approve *core.TokenApprovalInput) syncasync.Sender
TokenApproval(ctx context.Context, approval *core.TokenApprovalInput, waitConfirm bool) (*core.TokenApproval, error)
GetTokenApprovals(ctx context.Context, filter database.AndFilter) ([]*core.TokenApproval, *database.FilterResult, error)

Expand Down
4 changes: 2 additions & 2 deletions internal/assets/token_approval.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/sysmessaging"
"github.com/hyperledger/firefly/internal/syncasync"
"github.com/hyperledger/firefly/internal/txcommon"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
Expand Down Expand Up @@ -53,7 +53,7 @@ func (s *approveSender) setDefaults() {
s.approval.LocalID = fftypes.NewUUID()
}

func (am *assetManager) NewApproval(approval *core.TokenApprovalInput) sysmessaging.MessageSender {
func (am *assetManager) NewApproval(approval *core.TokenApprovalInput) syncasync.Sender {
sender := &approveSender{
mgr: am,
approval: approval,
Expand Down
2 changes: 1 addition & 1 deletion internal/assets/token_approval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func TestTokenApprovalConfirm(t *testing.T) {

msa.On("WaitForTokenApproval", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(&core.TokenApproval{}, nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/assets/token_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func TestCreateTokenPoolConfirm(t *testing.T) {
mdi.On("InsertOperation", context.Background(), mock.Anything).Return(nil)
msa.On("WaitForTokenPool", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(nil, nil)
Expand Down
8 changes: 4 additions & 4 deletions internal/assets/token_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/sysmessaging"
"github.com/hyperledger/firefly/internal/syncasync"
"github.com/hyperledger/firefly/internal/txcommon"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
Expand All @@ -40,7 +40,7 @@ func (am *assetManager) GetTokenTransferByID(ctx context.Context, id string) (*c
return am.database.GetTokenTransferByID(ctx, am.namespace, transferID)
}

func (am *assetManager) NewTransfer(transfer *core.TokenTransferInput) sysmessaging.MessageSender {
func (am *assetManager) NewTransfer(transfer *core.TokenTransferInput) syncasync.Sender {
sender := &transferSender{
mgr: am,
transfer: transfer,
Expand All @@ -53,7 +53,7 @@ type transferSender struct {
mgr *assetManager
transfer *core.TokenTransferInput
resolved bool
msgSender sysmessaging.MessageSender
msgSender syncasync.Sender
}

// sendMethod is the specific operation requested of the transferSender.
Expand Down Expand Up @@ -260,7 +260,7 @@ func (s *transferSender) sendInternal(ctx context.Context, method sendMethod) (e
return err
}

func (s *transferSender) buildTransferMessage(ctx context.Context, in *core.MessageInOut) (sysmessaging.MessageSender, error) {
func (s *transferSender) buildTransferMessage(ctx context.Context, in *core.MessageInOut) (syncasync.Sender, error) {
allowedTypes := []fftypes.FFEnum{
core.MessageTypeTransferBroadcast,
core.MessageTypeTransferPrivate,
Expand Down
21 changes: 10 additions & 11 deletions internal/assets/token_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/hyperledger/firefly/mocks/operationmocks"
"github.com/hyperledger/firefly/mocks/privatemessagingmocks"
"github.com/hyperledger/firefly/mocks/syncasyncmocks"
"github.com/hyperledger/firefly/mocks/sysmessagingmocks"
"github.com/hyperledger/firefly/mocks/txcommonmocks"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
Expand Down Expand Up @@ -412,7 +411,7 @@ func TestMintTokensConfirm(t *testing.T) {
mdi.On("InsertOperation", context.Background(), mock.Anything).Return(nil)
msa.On("WaitForTokenTransfer", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(&core.TokenTransfer{}, nil)
Expand Down Expand Up @@ -519,7 +518,7 @@ func TestBurnTokensConfirm(t *testing.T) {
mdi.On("InsertOperation", context.Background(), mock.Anything).Return(nil)
msa.On("WaitForTokenTransfer", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(&core.TokenTransfer{}, nil)
Expand Down Expand Up @@ -724,7 +723,7 @@ func TestTransferTokensWithBroadcastMessage(t *testing.T) {
mdi := am.database.(*databasemocks.Plugin)
mim := am.identity.(*identitymanagermocks.Manager)
mbm := am.broadcast.(*broadcastmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mms := &syncasyncmocks.Sender{}
mth := am.txHelper.(*txcommonmocks.Helper)
mom := am.operations.(*operationmocks.Manager)
mim.On("NormalizeSigningKey", context.Background(), "", identity.KeyNormalizationBlockchainPlugin).Return("0x12345", nil)
Expand Down Expand Up @@ -820,7 +819,7 @@ func TestTransferTokensWithBroadcastMessageSendFail(t *testing.T) {
mdi := am.database.(*databasemocks.Plugin)
mim := am.identity.(*identitymanagermocks.Manager)
mbm := am.broadcast.(*broadcastmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mms := &syncasyncmocks.Sender{}
mth := am.txHelper.(*txcommonmocks.Helper)
mom := am.operations.(*operationmocks.Manager)
mim.On("NormalizeSigningKey", context.Background(), "", identity.KeyNormalizationBlockchainPlugin).Return("0x12345", nil)
Expand Down Expand Up @@ -865,7 +864,7 @@ func TestTransferTokensWithBroadcastPrepareFail(t *testing.T) {
}

mbm := am.broadcast.(*broadcastmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mms := &syncasyncmocks.Sender{}
mbm.On("NewBroadcast", transfer.Message).Return(mms)
mms.On("Prepare", context.Background()).Return(fmt.Errorf("pop"))

Expand Down Expand Up @@ -912,7 +911,7 @@ func TestTransferTokensWithPrivateMessage(t *testing.T) {
mdi := am.database.(*databasemocks.Plugin)
mim := am.identity.(*identitymanagermocks.Manager)
mpm := am.messaging.(*privatemessagingmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mms := &syncasyncmocks.Sender{}
mth := am.txHelper.(*txcommonmocks.Helper)
mom := am.operations.(*operationmocks.Manager)
mim.On("NormalizeSigningKey", context.Background(), "", identity.KeyNormalizationBlockchainPlugin).Return("0x12345", nil)
Expand Down Expand Up @@ -1031,7 +1030,7 @@ func TestTransferTokensConfirm(t *testing.T) {
mdi.On("InsertOperation", context.Background(), mock.Anything).Return(nil)
msa.On("WaitForTokenTransfer", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(&core.TokenTransfer{}, nil)
Expand Down Expand Up @@ -1085,7 +1084,7 @@ func TestTransferTokensWithBroadcastConfirm(t *testing.T) {
mdi := am.database.(*databasemocks.Plugin)
mim := am.identity.(*identitymanagermocks.Manager)
mbm := am.broadcast.(*broadcastmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mms := &syncasyncmocks.Sender{}
msa := am.syncasync.(*syncasyncmocks.Bridge)
mth := am.txHelper.(*txcommonmocks.Helper)
mom := am.operations.(*operationmocks.Manager)
Expand All @@ -1098,13 +1097,13 @@ func TestTransferTokensWithBroadcastConfirm(t *testing.T) {
mms.On("Send", context.Background()).Return(nil)
msa.On("WaitForMessage", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(&core.Message{}, nil)
msa.On("WaitForTokenTransfer", context.Background(), mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
send := args[2].(syncasync.RequestSender)
send := args[2].(syncasync.SendFunction)
send(context.Background())
}).
Return(&transfer.TokenTransfer, nil)
Expand Down
10 changes: 5 additions & 5 deletions internal/batch/batch_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import (
"github.com/hyperledger/firefly/internal/coreconfig"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/data"
"github.com/hyperledger/firefly/internal/sysmessaging"
"github.com/hyperledger/firefly/internal/identity"
"github.com/hyperledger/firefly/internal/txcommon"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
)

func NewBatchManager(ctx context.Context, ns string, ni sysmessaging.LocalNodeInfo, di database.Plugin, dm data.Manager, txHelper txcommon.Helper) (Manager, error) {
if di == nil || dm == nil {
func NewBatchManager(ctx context.Context, ns string, di database.Plugin, dm data.Manager, im identity.Manager, txHelper txcommon.Helper) (Manager, error) {
if di == nil || dm == nil || im == nil {
return nil, i18n.NewError(ctx, coremsgs.MsgInitializationNilDepError, "BatchManager")
}
pCtx, cancelCtx := context.WithCancel(log.WithLogField(ctx, "role", "batchmgr"))
Expand All @@ -46,7 +46,7 @@ func NewBatchManager(ctx context.Context, ns string, ni sysmessaging.LocalNodeIn
ctx: pCtx,
cancelCtx: cancelCtx,
namespace: ns,
ni: ni,
identity: im,
database: di,
data: dm,
txHelper: txHelper,
Expand Down Expand Up @@ -94,7 +94,7 @@ type batchManager struct {
ctx context.Context
cancelCtx func()
namespace string
ni sysmessaging.LocalNodeInfo
identity identity.Manager
database database.Plugin
data data.Manager
txHelper txcommon.Helper
Expand Down
Loading