Skip to content

Commit

Permalink
changed function name
Browse files Browse the repository at this point in the history
  • Loading branch information
gouthamp-stellar committed Sep 20, 2024
1 parent 9492d71 commit e28ff02
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (p *rpcErrorHandlerServiceJitterPool) Receive(payload tss.Payload) {
for i = 0; i < p.MaxRetries; i++ {
currentBackoff := p.MinWaitBtwnRetriesMS * (1 << i)
sleep(jitter(time.Duration(currentBackoff)) * time.Microsecond)
rpcSendResp, err := SignAndSubmitTransaction(ctx, "ErrorHandlerServiceJitterChannel", payload, p.Store, p.TxService)
rpcSendResp, err := BuildAndSubmitTransaction(ctx, "ErrorHandlerServiceJitterChannel", payload, p.Store, p.TxService)
if err != nil {
log.Errorf(err.Error())
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (p *rpcErrorHandlerServiceNonJitterPool) Receive(payload tss.Payload) {
var i int
for i = 0; i < p.MaxRetries; i++ {
sleep(time.Duration(p.WaitBtwnRetriesMS) * time.Microsecond)
rpcSendResp, err := SignAndSubmitTransaction(ctx, "ErrorHandlerServiceNonJitterChannel", payload, p.Store, p.TxService)
rpcSendResp, err := BuildAndSubmitTransaction(ctx, "ErrorHandlerServiceNonJitterChannel", payload, p.Store, p.TxService)
if err != nil {
log.Errorf(err.Error())
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestNonJitterSend(t *testing.T) {
payload.TransactionHash = "hash"
payload.TransactionXDR = "xdr"
txServiceMock.
On("SignAndBuildNewFeeBumpTransaction", payload.TransactionXDR).
On("SignAndBuildNewFeeBumpTransaction", context.Background(), payload.TransactionXDR).
Return(nil, errors.New("signing failed"))

_ = store.UpsertTransaction(context.Background(), payload.WebhookURL, payload.TransactionHash, payload.TransactionXDR, tss.NewStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestJitterSend(t *testing.T) {
payload.TransactionHash = "hash"
payload.TransactionXDR = "xdr"
txServiceMock.
On("SignAndBuildNewFeeBumpTransaction", payload.TransactionXDR).
On("SignAndBuildNewFeeBumpTransaction", context.Background(), payload.TransactionXDR).
Return(nil, errors.New("signing failed"))

_ = store.UpsertTransaction(context.Background(), payload.WebhookURL, payload.TransactionHash, payload.TransactionXDR, tss.NewStatus)
Expand Down
2 changes: 1 addition & 1 deletion internal/tss/channels/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"golang.org/x/net/context"
)

func SignAndSubmitTransaction(ctx context.Context, channelName string, payload tss.Payload, store store.Store, txService utils.TransactionService) (tss.RPCSendTxResponse, error) {
func BuildAndSubmitTransaction(ctx context.Context, channelName string, payload tss.Payload, store store.Store, txService utils.TransactionService) (tss.RPCSendTxResponse, error) {
feeBumpTx, err := txService.SignAndBuildNewFeeBumpTransaction(ctx, payload.TransactionXDR)
if err != nil {
return tss.RPCSendTxResponse{}, fmt.Errorf("%s: Unable to sign/build transaction: %s", channelName, err.Error())
Expand Down
10 changes: 5 additions & 5 deletions internal/tss/channels/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestSignAndSubmitTransaction(t *testing.T) {
func TestBuildAndSubmitTransaction(t *testing.T) {
dbt := dbtest.Open(t)
defer dbt.Close()

Expand All @@ -40,7 +40,7 @@ func TestSignAndSubmitTransaction(t *testing.T) {
Return(nil, errors.New("signing failed")).
Once()

_, err := SignAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)
_, err := BuildAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)

assert.Equal(t, "channel: Unable to sign/build transaction: signing failed", err.Error())

Expand All @@ -64,7 +64,7 @@ func TestSignAndSubmitTransaction(t *testing.T) {
Return(sendResp, errors.New("RPC Fail")).
Once()

_, err := SignAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)
_, err := BuildAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)

assert.Equal(t, "channel: RPC fail: RPC Fail", err.Error())

Expand Down Expand Up @@ -93,7 +93,7 @@ func TestSignAndSubmitTransaction(t *testing.T) {
Return(sendResp, errors.New("unable to unmarshal")).
Once()

_, err := SignAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)
_, err := BuildAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)

assert.Equal(t, "channel: RPC fail: unable to unmarshal", err.Error())

Expand Down Expand Up @@ -124,7 +124,7 @@ func TestSignAndSubmitTransaction(t *testing.T) {
Return(sendResp, nil).
Once()

resp, err := SignAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)
resp, err := BuildAndSubmitTransaction(context.Background(), "channel", payload, store, &txServiceMock)

assert.Equal(t, tss.TryAgainLaterStatus, resp.Status)
assert.Equal(t, xdr.TransactionResultCodeTxInsufficientFee, resp.Code.TxResultCode)
Expand Down

0 comments on commit e28ff02

Please sign in to comment.