Skip to content

Commit

Permalink
- wrap error only if missing
Browse files Browse the repository at this point in the history
- changed github workflows scope
  • Loading branch information
iulianpascalau committed Apr 20, 2022
1 parent 606f5f7 commit 97935e5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
pull_request:
branches: [ master, development ]
types: [opened, ready_for_review]
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- master
pull_request:
branches: [ master, development ]
types: [opened, ready_for_review]
jobs:
golangci:
name: golangci linter
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/vm/arwen/arwenvm/arwenVM_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestSCMoveBalanceBeforeSCDeploy(t *testing.T) {
_, err = testContext.TxProcessor.ProcessTransaction(tx)

require.Equal(t, process.ErrFailedTransaction, err)
require.Equal(t, fmt.Errorf("%s: %s", process.ErrAccountNotPayable.Error(), "sending value to non payable contract"), testContext.GetCompositeTestError())
require.Equal(t, process.ErrAccountNotPayable, testContext.GetCompositeTestError())
vm.TestAccount(
t,
testContext.Accounts,
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/vm/txsFee/multiShard/moveBalance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestMoveBalanceContractAddressDataFieldNilShouldConsumeGas(t *testing.T) {
retCode, err := testContext.TxProcessor.ProcessTransaction(tx)
require.Equal(t, vmcommon.UserError, retCode)
require.Nil(t, err)
require.Equal(t, errors.New("sending value to non payable contract: sending value to non payable contract"), testContext.GetCompositeTestError())
require.Equal(t, errors.New("sending value to non payable contract"), testContext.GetCompositeTestError())

_, err = testContext.Accounts.Commit()
require.Nil(t, err)
Expand Down
13 changes: 9 additions & 4 deletions process/smartContract/testScProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (tsp *TestScProcessor) GetCompositeTestError() error {
for _, logs := range allLogs {
for _, event := range logs.GetLogEvents() {
if string(event.GetIdentifier()) == signalError {
returnError = wrapError(returnError, string(event.GetTopics()[1]))
returnError = wrapErrorIfNotContains(returnError, string(event.GetTopics()[1]))
}
}
}
Expand Down Expand Up @@ -67,10 +67,10 @@ func (tsp *TestScProcessor) GetCompositeTestError() error {
if returnCodeAsString == "ok" || returnCodeAsString == "" {
return returnError
}
return wrapError(returnError, returnCodeAsString)
return wrapErrorIfNotContains(returnError, returnCodeAsString)
}

return wrapError(returnError, returnCodeHex)
return wrapErrorIfNotContains(returnError, returnCodeHex)
}

tsp.txLogsProcessor.Clean()
Expand All @@ -79,11 +79,16 @@ func (tsp *TestScProcessor) GetCompositeTestError() error {
return returnError
}

func wrapError(originalError error, msg string) error {
func wrapErrorIfNotContains(originalError error, msg string) error {
if originalError == nil {
return fmt.Errorf(msg)
}

alreadyContainsMessage := strings.Contains(originalError.Error(), msg)
if alreadyContainsMessage {
return originalError
}

return fmt.Errorf("%s: %s", originalError.Error(), msg)
}

Expand Down

0 comments on commit 97935e5

Please sign in to comment.