Skip to content

Commit

Permalink
Resolve circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Aug 21, 2020
1 parent 54b98c6 commit 30bfc48
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 34 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ mocks:
rm -rf mocks;
mockery --dir syncer --all --case underscore --outpkg syncer --output mocks/syncer;
mockery --dir reconciler --all --case underscore --outpkg reconciler --output mocks/reconciler;
mockery --dir constructor --all --case underscore --outpkg constructor --output mocks/constructor;
mockery --dir constructor/executor --all --case underscore --outpkg executor --output mocks/constructor/executor;
mockery --dir constructor/coordinator --all --case underscore --outpkg coordinator --output mocks/constructor/coordinator;
mockery --dir utils --all --case underscore --outpkg utils --output mocks/utils;

${ADDLICENCE_SCRIPT} .;
10 changes: 9 additions & 1 deletion constructor/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,15 @@ func (c *Coordinator) Process(
}

// Invoke Broadcast storage (in same TX as update job)
if err := c.helper.Broadcast(ctx, dbTransaction, jobIdentifier, broadcast.Network, broadcast.Intent, transactionIdentifier, networkTransaction); err != nil {
if err := c.helper.Broadcast(
ctx,
dbTransaction,
jobIdentifier,
broadcast.Network,
broadcast.Intent,
transactionIdentifier,
networkTransaction,
); err != nil {
return fmt.Errorf("%w: unable to enque broadcast", err)
}
}
Expand Down
14 changes: 14 additions & 0 deletions constructor/coordinator/errors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2020 Coinbase, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package coordinator

import (
Expand Down
3 changes: 2 additions & 1 deletion constructor/coordinator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const (
NoJobsWaitTime = 10 * time.Second
)

// Helper is used by the worker to process Jobs.
// Helper is used by the coordinator to process Jobs.
// It is a superset of functions required by the constructor/executor.Helper.
type Helper interface {
// StoreKey is called to persist an
// address + KeyPair.
Expand Down
2 changes: 1 addition & 1 deletion constructor/executor/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"regexp"
"testing"

mocks "github.com/coinbase/rosetta-sdk-go/mocks/constructor"
mocks "github.com/coinbase/rosetta-sdk-go/mocks/constructor/executor"
"github.com/coinbase/rosetta-sdk-go/types"

"github.com/stretchr/testify/assert"
Expand Down
32 changes: 16 additions & 16 deletions constructor/executor/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"errors"
"testing"

mocks "github.com/coinbase/rosetta-sdk-go/mocks/constructor"
mocks "github.com/coinbase/rosetta-sdk-go/mocks/constructor/executor"
"github.com/coinbase/rosetta-sdk-go/types"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestFindBalanceWorker(t *testing.T) {
tests := map[string]struct {
input *FindBalanceInput

mockHelper *mocks.WorkerHelper
mockHelper *mocks.Helper

output *FindBalanceOutput
err error
Expand All @@ -154,8 +154,8 @@ func TestFindBalanceWorker(t *testing.T) {
Wait: true,
NotAddress: []string{"addr4"},
},
mockHelper: func() *mocks.WorkerHelper {
helper := &mocks.WorkerHelper{}
mockHelper: func() *mocks.Helper {
helper := &mocks.Helper{}
helper.On(
"AllAddresses",
ctx,
Expand Down Expand Up @@ -231,8 +231,8 @@ func TestFindBalanceWorker(t *testing.T) {
Wait: true,
NotAddress: []string{"addr4"},
},
mockHelper: func() *mocks.WorkerHelper {
helper := &mocks.WorkerHelper{}
mockHelper: func() *mocks.Helper {
helper := &mocks.Helper{}
helper.On(
"AllAddresses",
ctx,
Expand Down Expand Up @@ -320,8 +320,8 @@ func TestFindBalanceWorker(t *testing.T) {
},
},
},
mockHelper: func() *mocks.WorkerHelper {
helper := &mocks.WorkerHelper{}
mockHelper: func() *mocks.Helper {
helper := &mocks.Helper{}
helper.On(
"AllAddresses",
ctx,
Expand Down Expand Up @@ -441,8 +441,8 @@ func TestFindBalanceWorker(t *testing.T) {
},
Create: -1,
},
mockHelper: func() *mocks.WorkerHelper {
helper := &mocks.WorkerHelper{}
mockHelper: func() *mocks.Helper {
helper := &mocks.Helper{}
helper.On(
"AllAddresses",
ctx,
Expand Down Expand Up @@ -520,8 +520,8 @@ func TestFindBalanceWorker(t *testing.T) {
},
Create: 10,
},
mockHelper: func() *mocks.WorkerHelper {
helper := &mocks.WorkerHelper{}
mockHelper: func() *mocks.Helper {
helper := &mocks.Helper{}
helper.On(
"AllAddresses",
ctx,
Expand Down Expand Up @@ -599,8 +599,8 @@ func TestFindBalanceWorker(t *testing.T) {
},
Create: 2,
},
mockHelper: func() *mocks.WorkerHelper {
helper := &mocks.WorkerHelper{}
mockHelper: func() *mocks.Helper {
helper := &mocks.Helper{}
helper.On(
"AllAddresses",
ctx,
Expand Down Expand Up @@ -678,7 +678,7 @@ func TestFindBalanceWorker(t *testing.T) {
},
Create: 2,
},
mockHelper: &mocks.WorkerHelper{},
mockHelper: &mocks.Helper{},
err: ErrInvalidInput,
},
"invalid currency": {
Expand All @@ -699,7 +699,7 @@ func TestFindBalanceWorker(t *testing.T) {
},
Create: 2,
},
mockHelper: &mocks.WorkerHelper{},
mockHelper: &mocks.Helper{},
err: ErrInvalidInput,
},
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 30bfc48

Please sign in to comment.