Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion auditevents/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -94,7 +95,7 @@ func run(host string) error {
protocolID := event.BlockchainEvent.ProtocolID
fmt.Printf("%-10d %s\n", lastSequence, protocolID)
if protocolID <= lastProtocolID {
return fmt.Errorf("out of order events detected")
return errors.New("out of order events detected")
}
lastProtocolID = protocolID
validated++
Expand Down
3 changes: 2 additions & 1 deletion ffconfig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package main

import (
"errors"
"fmt"
"os"

Expand All @@ -29,7 +30,7 @@ var rootCmd = &cobra.Command{
Short: "FireFly configuration tool",
Long: "Tool for managing and migrating config files for Hyperledger FireFly",
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("a command is required")
return errors.New("a command is required")
},
}

Expand Down
3 changes: 2 additions & 1 deletion internal/blockchain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -1197,7 +1198,7 @@ func (e *Ethereum) GetTransactionStatus(ctx context.Context, operation *core.Ope
SetResult(&statusResponse).
Get(transactionRequestPath)
if err != nil || !res.IsSuccess() {
if res.StatusCode() == 404 {
if res.StatusCode() == http.StatusNotFound {
return nil, nil
}
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgEthConnectorRESTErr)
Expand Down
7 changes: 4 additions & 3 deletions internal/blockchain/ethereum/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"net/http"
"strconv"
"strings"

Expand Down Expand Up @@ -161,7 +162,7 @@ func (s *streamManager) deleteEventStream(ctx context.Context, esID string, okNo
SetContext(ctx).
Delete("/eventstreams/" + esID)
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil
}
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthConnectorRESTErr)
Expand All @@ -186,7 +187,7 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string, okNot
SetResult(&sub).
Get(fmt.Sprintf("/subscriptions/%s", subID))
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil, nil
}
return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthConnectorRESTErr)
Expand Down Expand Up @@ -282,7 +283,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string, ok
SetContext(ctx).
Delete("/subscriptions/" + subID)
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil
}
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthConnectorRESTErr)
Expand Down
7 changes: 4 additions & 3 deletions internal/blockchain/fabric/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package fabric
import (
"context"
"fmt"
"net/http"
"strconv"
"strings"

Expand Down Expand Up @@ -137,7 +138,7 @@ func (s *streamManager) deleteEventStream(ctx context.Context, esID string, okNo
SetContext(ctx).
Delete("/eventstreams/" + esID)
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil
}
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)
Expand All @@ -162,7 +163,7 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string, okNot
SetResult(&sub).
Get(fmt.Sprintf("/subscriptions/%s", subID))
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil, nil
}
return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)
Expand Down Expand Up @@ -261,7 +262,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string, ok
SetContext(ctx).
Delete("/subscriptions/" + subID)
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil
}
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)
Expand Down
3 changes: 2 additions & 1 deletion internal/blockchain/fabric/fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"regexp"
"strings"

Expand Down Expand Up @@ -1118,7 +1119,7 @@ func (f *Fabric) GetTransactionStatus(ctx context.Context, operation *core.Opera
SetQueryParam("fly-signer", defaultSigner).
Get(transactionRequestPath)
if err != nil || !res.IsSuccess() {
if res.StatusCode() == 404 {
if res.StatusCode() == http.StatusNotFound {
return nil, nil
}
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgFabconnectRESTErr)
Expand Down
5 changes: 3 additions & 2 deletions internal/blockchain/tezos/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"net/http"

"github.com/go-resty/resty/v2"
"github.com/hyperledger/firefly-common/pkg/ffresty"
Expand Down Expand Up @@ -155,7 +156,7 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string, okNot
SetResult(&sub).
Get(fmt.Sprintf("/subscriptions/%s", subID))
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil, nil
}
return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgTezosconnectRESTErr)
Expand Down Expand Up @@ -206,7 +207,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string, ok
SetContext(ctx).
Delete("/subscriptions/" + subID)
if err != nil || !res.IsSuccess() {
if okNotFound && res.StatusCode() == 404 {
if okNotFound && res.StatusCode() == http.StatusNotFound {
return nil
}
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgTezosconnectRESTErr)
Expand Down
3 changes: 2 additions & 1 deletion internal/blockchain/tezos/tezos.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"regexp"

"blockwatch.cc/tzgo/micheline"
Expand Down Expand Up @@ -564,7 +565,7 @@ func (t *Tezos) GetTransactionStatus(ctx context.Context, operation *core.Operat
SetResult(&statusResponse).
Get(transactionRequestPath)
if err != nil || !res.IsSuccess() {
if res.StatusCode() == 404 {
if res.StatusCode() == http.StatusNotFound {
return nil, nil
}
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgTezosconnectRESTErr)
Expand Down
3 changes: 2 additions & 1 deletion internal/events/persist_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package events
import (
"context"
"database/sql/driver"
"errors"

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
Expand Down Expand Up @@ -276,7 +277,7 @@ func (em *eventManager) persistBatchContent(ctx context.Context, batch *core.Bat
// Fall back to individual upserts
for i, data := range batch.Payload.Data {
if err := em.database.UpsertData(ctx, data, database.UpsertOptimizationExisting); err != nil {
if err == database.HashMismatch {
if errors.Is(err, database.HashMismatch) {
log.L(ctx).Errorf("Invalid data entry %d in batch '%s'. Hash mismatch with existing record with same UUID '%s' Hash=%s", i, batch.ID, data.ID, data.Hash)
return false, nil
}
Expand Down
8 changes: 4 additions & 4 deletions internal/tokens/fftokens/fftokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ func (ft *FFTokens) CreateTokenPool(ctx context.Context, nsOpID string, pool *co
if err != nil || !res.IsSuccess() {
return core.OpPhaseInitializing, wrapError(ctx, &errRes, res, err)
}
if res.StatusCode() == 200 {
if res.StatusCode() == http.StatusOK {
// HTTP 200: Creation was successful, and pool details are in response body
var obj fftypes.JSONObject
if err := json.Unmarshal(res.Body(), &obj); err != nil {
Expand Down Expand Up @@ -841,7 +841,7 @@ func (ft *FFTokens) ActivateTokenPool(ctx context.Context, pool *core.TokenPool)
if err != nil || !res.IsSuccess() {
return core.OpPhaseInitializing, err
}
if res.StatusCode() == 200 {
if res.StatusCode() == http.StatusOK {
// HTTP 200: Activation was successful, and pool details are in response body
var obj fftypes.JSONObject
if err := json.Unmarshal(res.Body(), &obj); err != nil {
Expand All @@ -851,7 +851,7 @@ func (ft *FFTokens) ActivateTokenPool(ctx context.Context, pool *core.TokenPool)
TX: pool.TX.ID,
TXType: pool.TX.Type,
})
} else if res.StatusCode() == 204 {
} else if res.StatusCode() == http.StatusNoContent {
// HTTP 204: Activation was successful, but pool details are not available
// This will resolve the operation, but connector is responsible for re-delivering pool details on the websocket.
return core.OpPhaseComplete, nil
Expand All @@ -871,7 +871,7 @@ func (ft *FFTokens) DeactivateTokenPool(ctx context.Context, pool *core.TokenPoo
}).
SetError(&errRes).
Post("/api/v1/deactivatepool")
if err == nil && (res.IsSuccess() || res.StatusCode() == 404) {
if err == nil && (res.IsSuccess() || res.StatusCode() == http.StatusNotFound) {
return nil
}
return wrapError(ctx, &errRes, res, err)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/client/restclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func (client *FireFlyClient) GetOrganization(t *testing.T, idOrName string) *cor
SetResult(&identity).
Get(client.namespaced(fmt.Sprintf("%s/%s", urlGetOrganizations, idOrName)))
assert.NoError(t, err)
if res.StatusCode() == 404 {
if res.StatusCode() == http.StatusNotFound {
return nil
}
assert.True(t, res.IsSuccess())
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package e2e
import (
"encoding/json"
"fmt"
"net/http"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -63,7 +64,7 @@ func PollForUp(t *testing.T, client *client.FireFlyClient) {
var err error
for i := 0; i < 12; i++ {
_, resp, err = client.GetStatus()
if err == nil && resp.StatusCode() == 200 {
if err == nil && resp.StatusCode() == http.StatusOK {
break
}
time.Sleep(5 * time.Second)
Expand Down