Skip to content

Commit

Permalink
better test for Send
Browse files Browse the repository at this point in the history
  • Loading branch information
gouthamp-stellar committed Sep 23, 2024
1 parent db8714d commit 2c0d060
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/tss/channels/rpc_caller_service_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 21 additions & 1 deletion internal/tss/channels/rpc_caller_service_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,36 @@ 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()

var status string
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) {
Expand Down

0 comments on commit 2c0d060

Please sign in to comment.