Skip to content

Commit

Permalink
Put in a no-op policy engine for API transaction tests
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <[email protected]>
  • Loading branch information
peterbroadhurst committed Aug 10, 2022
1 parent 251633a commit b9bae85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/fftm/route_get_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package fftm
import (
"fmt"
"testing"
"time"

"github.com/go-resty/resty/v2"
"github.com/hyperledger/firefly-transaction-manager/pkg/apitypes"
Expand All @@ -30,7 +29,7 @@ func TestGetTransaction(t *testing.T) {

url, m, done := newTestManager(t)
defer done()
m.policyLoopInterval = 1 * time.Hour
noopPolicyEngine(m)

err := m.Start()
assert.NoError(t, err)
Expand Down
11 changes: 9 additions & 2 deletions pkg/fftm/route_get_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/go-resty/resty/v2"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-transaction-manager/mocks/policyenginemocks"
"github.com/hyperledger/firefly-transaction-manager/pkg/apitypes"
"github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func newTestTxn(t *testing.T, m *manager, signer string, nonce int64, status apitypes.TxStatus) *apitypes.ManagedTX {
Expand All @@ -45,11 +46,17 @@ func newTestTxn(t *testing.T, m *manager, signer string, nonce int64, status api
return tx
}

func noopPolicyEngine(m *manager) {
mpe := &policyenginemocks.PolicyEngine{}
m.policyEngine = mpe
mpe.On("Execute", mock.Anything, mock.Anything, mock.Anything).Return(false, ffcapi.ErrorReason(""), nil).Maybe()
}

func TestGetTransactions(t *testing.T) {

url, m, done := newTestManager(t)
defer done()
m.policyLoopInterval = 1 * time.Hour
noopPolicyEngine(m)

err := m.Start()
assert.NoError(t, err)
Expand Down

0 comments on commit b9bae85

Please sign in to comment.