Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Jan 2, 2024
1 parent c642887 commit e8d88da
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion protocols/stellarcore/tx_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func DiagnosticEventsToSlice(events string) ([]string, error) {
if err != nil {
return nil, err
}
result[0] = encoded
result[i] = encoded
}
return result, nil
}
10 changes: 6 additions & 4 deletions protocols/stellarcore/tx_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package stellarcore
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDiagnosticEventsToSlice(t *testing.T) {
events := "AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fA=="
events := "AAAAAgAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fA=="

Check failure on line 10 in protocols/stellarcore/tx_response_test.go

View workflow job for this annotation

GitHub Actions / golangci

line is 501 characters (lll)
slice, err := DiagnosticEventsToSlice(events)
assert.NoError(t, err)
assert.Len(t, slice, 1)
require.NoError(t, err)
require.Len(t, slice, 2)
require.Equal(t, slice[0], "AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAACAAAADwAAAAVlcnJvcgAAAAAAAAIAAAADAAAABQAAABAAAAABAAAAAwAAAA4AAABTdHJhbnNhY3Rpb24gYHNvcm9iYW5EYXRhLnJlc291cmNlRmVlYCBpcyBsb3dlciB0aGFuIHRoZSBhY3R1YWwgU29yb2JhbiByZXNvdXJjZSBmZWUAAAAABQAAAAAAAQlzAAAABQAAAAAAAbp8")

Check failure on line 14 in protocols/stellarcore/tx_response_test.go

View workflow job for this annotation

GitHub Actions / golangci

line is 271 characters (lll)
require.Equal(t, slice[1], "AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAACAAAADwAAAAVlcnJvcgAAAAAAAAIAAAADAAAABQAAABAAAAABAAAAAwAAAA4AAABTdHJhbnNhY3Rpb24gYHNvcm9iYW5EYXRhLnJlc291cmNlRmVlYCBpcyBsb3dlciB0aGFuIHRoZSBhY3R1YWwgU29yb2JhbiByZXNvdXJjZSBmZWUAAAAABQAAAAAAAQlzAAAABQAAAAAAAbp8")

Check failure on line 15 in protocols/stellarcore/tx_response_test.go

View workflow job for this annotation

GitHub Actions / golangci

line is 271 characters (lll)
}
4 changes: 2 additions & 2 deletions services/horizon/internal/actions/submit_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func (handler SubmitTransactionHandler) response(r *http.Request, info envelopeI
"result_xdr": failedErr.ResultXDR,
"result_codes": rcr,
}
if failedErr.DiagnosticEvents != "" {
events, err := stellarcore.DiagnosticEventsToSlice(failedErr.DiagnosticEvents)
if failedErr.DiagnosticEventsXDR != "" {
events, err := stellarcore.DiagnosticEventsToSlice(failedErr.DiagnosticEventsXDR)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/actions/submit_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ func TestSubmissionSorobanDiagnosticEvents(t *testing.T) {
mockSubmitter.On("Submit").Return(mockSubmitChannel)
mockSubmitChannel <- txsub.Result{
Err: &txsub.FailedTransactionError{
ResultXDR: "AAAAAAABCdf////vAAAAAA==",
DiagnosticEvents: "AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fA==",
ResultXDR: "AAAAAAABCdf////vAAAAAA==",
DiagnosticEventsXDR: "AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fA==",

Check failure on line 216 in services/horizon/internal/actions/submit_transaction_test.go

View workflow job for this annotation

GitHub Actions / golangci

line is 275 characters (lll)
},
}

Expand Down
5 changes: 3 additions & 2 deletions services/horizon/internal/txsub/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ var (
// stellar-core rejected the transaction. ResultXDR is a base64
// encoded TransactionResult struct
type FailedTransactionError struct {
ResultXDR string
DiagnosticEvents string
ResultXDR string
// DiagnosticEventsXDR is a base64-encoded []xdr.DiagnosticEvent
DiagnosticEventsXDR string
}

func (err *FailedTransactionError) Error() string {
Expand Down

0 comments on commit e8d88da

Please sign in to comment.