diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dda7bdd81..a782b05a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,15 +18,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v4 with: - go-version: "1.19" - - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version: '1.19' - name: Run tests run: | make ci @@ -43,7 +37,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: "1.19" - name: generate diff --git a/flowkit/gateway/mocks/Gateway.go b/flowkit/gateway/mocks/Gateway.go index 3d04bfa04..5fd4ba569 100644 --- a/flowkit/gateway/mocks/Gateway.go +++ b/flowkit/gateway/mocks/Gateway.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.2. DO NOT EDIT. +// Code generated by mockery v2.36.0. DO NOT EDIT. package mocks @@ -432,13 +432,12 @@ func (_m *Gateway) SendSignedTransaction(_a0 *flow.Transaction) (*flow.Transacti return r0, r1 } -type mockConstructorTestingTNewGateway interface { +// NewGateway creates a new instance of Gateway. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewGateway(t interface { mock.TestingT Cleanup(func()) -} - -// NewGateway creates a new instance of Gateway. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewGateway(t mockConstructorTestingTNewGateway) *Gateway { +}) *Gateway { mock := &Gateway{} mock.Mock.Test(t) diff --git a/flowkit/mocks/Services.go b/flowkit/mocks/Services.go index 1605a8f41..d78805928 100644 --- a/flowkit/mocks/Services.go +++ b/flowkit/mocks/Services.go @@ -1,10 +1,9 @@ -// Code generated by mockery v2.28.2. DO NOT EDIT. +// Code generated by mockery v2.36.0. DO NOT EDIT. package mocks import ( cadence "github.com/onflow/cadence" - accounts "github.com/onflow/flow-cli/flowkit/accounts" config "github.com/onflow/flow-cli/flowkit/config" @@ -609,13 +608,12 @@ func (_m *Services) SignTransactionPayload(_a0 context.Context, _a1 *accounts.Ac return r0, r1 } -type mockConstructorTestingTNewServices interface { +// NewServices creates a new instance of Services. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewServices(t interface { mock.TestingT Cleanup(func()) -} - -// NewServices creates a new instance of Services. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewServices(t mockConstructorTestingTNewServices) *Services { +}) *Services { mock := &Services{} mock.Mock.Test(t) diff --git a/internal/transactions/send.go b/internal/transactions/send.go index 5a82f7dec..ac18309c7 100644 --- a/internal/transactions/send.go +++ b/internal/transactions/send.go @@ -104,8 +104,14 @@ func SendTransaction(code []byte, args []string, location string, flow flowkit.S signerName := sendFlags.Signer - if signerName == "" && proposer == nil && payer == nil && len(authorizers) == 0 { - signerName = state.Config().Emulators.Default().ServiceAccount + if signerName == "" { + if proposer == nil && payer == nil && len(authorizers) == 0 { + signerName = state.Config().Emulators.Default().ServiceAccount + } else { + if proposer == nil || payer == nil { + return nil, fmt.Errorf("proposer/payer flags are required when signer flag is not used") + } + } } if signerName != "" { diff --git a/internal/transactions/transactions_test.go b/internal/transactions/transactions_test.go index ff5a6f5b1..e4dcd3c84 100644 --- a/internal/transactions/transactions_test.go +++ b/internal/transactions/transactions_test.go @@ -191,7 +191,25 @@ func Test_Send(t *testing.T) { flags.Signer = "" // reset }) + t.Run("Fail signer not used and payer flag not set", func(t *testing.T) { + flags.Payer = "" + flags.Proposer = config.DefaultEmulator.ServiceAccount + _, err := send([]string{""}, command.GlobalFlags{}, util.NoLogger, srv.Mock, state) + assert.EqualError(t, err, "proposer/payer flags are required when signer flag is not used") + flags.Signer = "" // reset + }) + + t.Run("Fail signer not used and proposer flag not set", func(t *testing.T) { + flags.Proposer = "" + flags.Payer = config.DefaultEmulator.ServiceAccount + _, err := send([]string{""}, command.GlobalFlags{}, util.NoLogger, srv.Mock, state) + assert.EqualError(t, err, "proposer/payer flags are required when signer flag is not used") + flags.Signer = "" // reset + }) + t.Run("Fail loading transaction file", func(t *testing.T) { + flags.Proposer = config.DefaultEmulator.ServiceAccount + flags.Payer = config.DefaultEmulator.ServiceAccount _, err := send([]string{"invalid"}, command.GlobalFlags{}, util.NoLogger, srv.Mock, state) assert.EqualError(t, err, "error loading transaction file: open invalid: file does not exist") })