diff --git a/internal/tss/channels/rpc_caller_service_channel.go b/internal/tss/channels/rpc_caller_service_channel.go index 9cb4f47..33300c3 100644 --- a/internal/tss/channels/rpc_caller_service_channel.go +++ b/internal/tss/channels/rpc_caller_service_channel.go @@ -29,7 +29,7 @@ type rpcCallerServicePool struct { Router router.Router } -func NewRPCCallerServiceChannel(cfg RPCCallerServiceChannelConfigs) tss.Channel { +func NewRPCCallerServiceChannel(cfg RPCCallerServiceChannelConfigs) *rpcCallerServicePool { pool := pond.New(cfg.MaxBufferSize, cfg.MaxWorkers, pond.Strategy(pond.Balanced())) return &rpcCallerServicePool{ Pool: pool, diff --git a/internal/tss/channels/rpc_caller_service_channel_test.go b/internal/tss/channels/rpc_caller_service_channel_test.go index 276080a..797b56d 100644 --- a/internal/tss/channels/rpc_caller_service_channel_test.go +++ b/internal/tss/channels/rpc_caller_service_channel_test.go @@ -36,9 +36,23 @@ func TestSend(t *testing.T) { payload.WebhookURL = "www.stellar.com" payload.TransactionHash = "hash" payload.TransactionXDR = "xdr" + networkPass := "passphrase" + + feeBumpTx := utils.BuildTestFeeBumpTransaction() + feeBumpTxXDR, _ := feeBumpTx.Base64() + sendResp := tss.RPCSendTxResponse{} + sendResp.Code.OtherCodes = tss.RPCFailCode txServiceMock. On("SignAndBuildNewFeeBumpTransaction", context.Background(), payload.TransactionXDR). - Return(nil, errors.New("signing failed")) + Return(feeBumpTx, nil). + Once(). + On("NetworkPassphrase"). + Return(networkPass). + Once(). + On("SendTransaction", feeBumpTxXDR). + Return(sendResp, errors.New("RPC Fail")). + Once() + channel.Send(payload) channel.Stop() @@ -46,6 +60,12 @@ func TestSend(t *testing.T) { err = dbConnectionPool.GetContext(context.Background(), &status, `SELECT current_status FROM tss_transactions WHERE transaction_hash = $1`, payload.TransactionHash) require.NoError(t, err) assert.Equal(t, status, string(tss.NewStatus)) + + var tryStatus int + feeBumpTxHash, _ := feeBumpTx.HashHex(networkPass) + err = dbConnectionPool.GetContext(context.Background(), &tryStatus, `SELECT status FROM tss_transaction_submission_tries WHERE try_transaction_hash = $1`, feeBumpTxHash) + require.NoError(t, err) + assert.Equal(t, int(tss.RPCFailCode), tryStatus) } func TestReceive(t *testing.T) {