Skip to content

Commit 012a747

Browse files
committed
2 parents c39f872 + 1856c5c commit 012a747

File tree

13 files changed

+30
-21
lines changed

13 files changed

+30
-21
lines changed

.github/pull_request_template.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Fixes # <issue_number_here>
3030
- [ ] I have performed a self-review of my own code or work.
3131
- [ ] I have commented my code, particularly in hard-to-understand areas.
3232
- [ ] My changes generates no new warnings.
33-
- [ ] My Pull Request title is in format <code>< issue name ></code> eg <code>Added links in the documentation</code>.
3433
- [ ] I have added tests that prove my fix is effective or that my feature works.
3534
- [ ] My changes have sufficient code coverage (unit, integration, e2e tests).
3635

auditevents/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"encoding/json"
21+
"errors"
2122
"fmt"
2223
"io"
2324
"net/http"
@@ -94,7 +95,7 @@ func run(host string) error {
9495
protocolID := event.BlockchainEvent.ProtocolID
9596
fmt.Printf("%-10d %s\n", lastSequence, protocolID)
9697
if protocolID <= lastProtocolID {
97-
return fmt.Errorf("out of order events detected")
98+
return errors.New("out of order events detected")
9899
}
99100
lastProtocolID = protocolID
100101
validated++

ffconfig/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package main
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"os"
2223

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

internal/blockchain/ethereum/ethereum.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"encoding/hex"
2222
"encoding/json"
2323
"fmt"
24+
"net/http"
2425
"regexp"
2526
"strconv"
2627
"strings"
@@ -1197,7 +1198,7 @@ func (e *Ethereum) GetTransactionStatus(ctx context.Context, operation *core.Ope
11971198
SetResult(&statusResponse).
11981199
Get(transactionRequestPath)
11991200
if err != nil || !res.IsSuccess() {
1200-
if res.StatusCode() == 404 {
1201+
if res.StatusCode() == http.StatusNotFound {
12011202
return nil, nil
12021203
}
12031204
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgEthConnectorRESTErr)

internal/blockchain/ethereum/eventstream.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto/sha256"
2222
"encoding/hex"
2323
"fmt"
24+
"net/http"
2425
"strconv"
2526
"strings"
2627

@@ -161,7 +162,7 @@ func (s *streamManager) deleteEventStream(ctx context.Context, esID string, okNo
161162
SetContext(ctx).
162163
Delete("/eventstreams/" + esID)
163164
if err != nil || !res.IsSuccess() {
164-
if okNotFound && res.StatusCode() == 404 {
165+
if okNotFound && res.StatusCode() == http.StatusNotFound {
165166
return nil
166167
}
167168
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthConnectorRESTErr)
@@ -186,7 +187,7 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string, okNot
186187
SetResult(&sub).
187188
Get(fmt.Sprintf("/subscriptions/%s", subID))
188189
if err != nil || !res.IsSuccess() {
189-
if okNotFound && res.StatusCode() == 404 {
190+
if okNotFound && res.StatusCode() == http.StatusNotFound {
190191
return nil, nil
191192
}
192193
return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthConnectorRESTErr)
@@ -282,7 +283,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string, ok
282283
SetContext(ctx).
283284
Delete("/subscriptions/" + subID)
284285
if err != nil || !res.IsSuccess() {
285-
if okNotFound && res.StatusCode() == 404 {
286+
if okNotFound && res.StatusCode() == http.StatusNotFound {
286287
return nil
287288
}
288289
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthConnectorRESTErr)

internal/blockchain/fabric/eventstream.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package fabric
1919
import (
2020
"context"
2121
"fmt"
22+
"net/http"
2223
"strconv"
2324
"strings"
2425

@@ -137,7 +138,7 @@ func (s *streamManager) deleteEventStream(ctx context.Context, esID string, okNo
137138
SetContext(ctx).
138139
Delete("/eventstreams/" + esID)
139140
if err != nil || !res.IsSuccess() {
140-
if okNotFound && res.StatusCode() == 404 {
141+
if okNotFound && res.StatusCode() == http.StatusNotFound {
141142
return nil
142143
}
143144
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)
@@ -162,7 +163,7 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string, okNot
162163
SetResult(&sub).
163164
Get(fmt.Sprintf("/subscriptions/%s", subID))
164165
if err != nil || !res.IsSuccess() {
165-
if okNotFound && res.StatusCode() == 404 {
166+
if okNotFound && res.StatusCode() == http.StatusNotFound {
166167
return nil, nil
167168
}
168169
return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)
@@ -261,7 +262,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string, ok
261262
SetContext(ctx).
262263
Delete("/subscriptions/" + subID)
263264
if err != nil || !res.IsSuccess() {
264-
if okNotFound && res.StatusCode() == 404 {
265+
if okNotFound && res.StatusCode() == http.StatusNotFound {
265266
return nil
266267
}
267268
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)

internal/blockchain/fabric/fabric.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"encoding/hex"
2323
"encoding/json"
2424
"fmt"
25+
"net/http"
2526
"regexp"
2627
"strings"
2728

@@ -1118,7 +1119,7 @@ func (f *Fabric) GetTransactionStatus(ctx context.Context, operation *core.Opera
11181119
SetQueryParam("fly-signer", defaultSigner).
11191120
Get(transactionRequestPath)
11201121
if err != nil || !res.IsSuccess() {
1121-
if res.StatusCode() == 404 {
1122+
if res.StatusCode() == http.StatusNotFound {
11221123
return nil, nil
11231124
}
11241125
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgFabconnectRESTErr)

internal/blockchain/tezos/eventstream.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"encoding/hex"
2323
"encoding/json"
2424
"fmt"
25+
"net/http"
2526

2627
"github.com/go-resty/resty/v2"
2728
"github.com/hyperledger/firefly-common/pkg/ffresty"
@@ -155,7 +156,7 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string, okNot
155156
SetResult(&sub).
156157
Get(fmt.Sprintf("/subscriptions/%s", subID))
157158
if err != nil || !res.IsSuccess() {
158-
if okNotFound && res.StatusCode() == 404 {
159+
if okNotFound && res.StatusCode() == http.StatusNotFound {
159160
return nil, nil
160161
}
161162
return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgTezosconnectRESTErr)
@@ -206,7 +207,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string, ok
206207
SetContext(ctx).
207208
Delete("/subscriptions/" + subID)
208209
if err != nil || !res.IsSuccess() {
209-
if okNotFound && res.StatusCode() == 404 {
210+
if okNotFound && res.StatusCode() == http.StatusNotFound {
210211
return nil
211212
}
212213
return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgTezosconnectRESTErr)

internal/blockchain/tezos/tezos.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23+
"net/http"
2324
"regexp"
2425

2526
"blockwatch.cc/tzgo/micheline"
@@ -564,7 +565,7 @@ func (t *Tezos) GetTransactionStatus(ctx context.Context, operation *core.Operat
564565
SetResult(&statusResponse).
565566
Get(transactionRequestPath)
566567
if err != nil || !res.IsSuccess() {
567-
if res.StatusCode() == 404 {
568+
if res.StatusCode() == http.StatusNotFound {
568569
return nil, nil
569570
}
570571
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgTezosconnectRESTErr)

internal/events/persist_batch.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package events
1919
import (
2020
"context"
2121
"database/sql/driver"
22+
"errors"
2223

2324
"github.com/hyperledger/firefly-common/pkg/ffapi"
2425
"github.com/hyperledger/firefly-common/pkg/fftypes"
@@ -276,7 +277,7 @@ func (em *eventManager) persistBatchContent(ctx context.Context, batch *core.Bat
276277
// Fall back to individual upserts
277278
for i, data := range batch.Payload.Data {
278279
if err := em.database.UpsertData(ctx, data, database.UpsertOptimizationExisting); err != nil {
279-
if err == database.HashMismatch {
280+
if errors.Is(err, database.HashMismatch) {
280281
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)
281282
return false, nil
282283
}

internal/tokens/fftokens/fftokens.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ func (ft *FFTokens) CreateTokenPool(ctx context.Context, nsOpID string, pool *co
806806
if err != nil || !res.IsSuccess() {
807807
return core.OpPhaseInitializing, wrapError(ctx, &errRes, res, err)
808808
}
809-
if res.StatusCode() == 200 {
809+
if res.StatusCode() == http.StatusOK {
810810
// HTTP 200: Creation was successful, and pool details are in response body
811811
var obj fftypes.JSONObject
812812
if err := json.Unmarshal(res.Body(), &obj); err != nil {
@@ -841,7 +841,7 @@ func (ft *FFTokens) ActivateTokenPool(ctx context.Context, pool *core.TokenPool)
841841
if err != nil || !res.IsSuccess() {
842842
return core.OpPhaseInitializing, err
843843
}
844-
if res.StatusCode() == 200 {
844+
if res.StatusCode() == http.StatusOK {
845845
// HTTP 200: Activation was successful, and pool details are in response body
846846
var obj fftypes.JSONObject
847847
if err := json.Unmarshal(res.Body(), &obj); err != nil {
@@ -851,7 +851,7 @@ func (ft *FFTokens) ActivateTokenPool(ctx context.Context, pool *core.TokenPool)
851851
TX: pool.TX.ID,
852852
TXType: pool.TX.Type,
853853
})
854-
} else if res.StatusCode() == 204 {
854+
} else if res.StatusCode() == http.StatusNoContent {
855855
// HTTP 204: Activation was successful, but pool details are not available
856856
// This will resolve the operation, but connector is responsible for re-delivering pool details on the websocket.
857857
return core.OpPhaseComplete, nil
@@ -871,7 +871,7 @@ func (ft *FFTokens) DeactivateTokenPool(ctx context.Context, pool *core.TokenPoo
871871
}).
872872
SetError(&errRes).
873873
Post("/api/v1/deactivatepool")
874-
if err == nil && (res.IsSuccess() || res.StatusCode() == 404) {
874+
if err == nil && (res.IsSuccess() || res.StatusCode() == http.StatusNotFound) {
875875
return nil
876876
}
877877
return wrapError(ctx, &errRes, res, err)

test/e2e/client/restclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func (client *FireFlyClient) GetOrganization(t *testing.T, idOrName string) *cor
370370
SetResult(&identity).
371371
Get(client.namespaced(fmt.Sprintf("%s/%s", urlGetOrganizations, idOrName)))
372372
assert.NoError(t, err)
373-
if res.StatusCode() == 404 {
373+
if res.StatusCode() == http.StatusNotFound {
374374
return nil
375375
}
376376
assert.True(t, res.IsSuccess())

test/e2e/e2e.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package e2e
1919
import (
2020
"encoding/json"
2121
"fmt"
22+
"net/http"
2223
"os"
2324
"path/filepath"
2425
"strings"
@@ -63,7 +64,7 @@ func PollForUp(t *testing.T, client *client.FireFlyClient) {
6364
var err error
6465
for i := 0; i < 12; i++ {
6566
_, resp, err = client.GetStatus()
66-
if err == nil && resp.StatusCode() == 200 {
67+
if err == nil && resp.StatusCode() == http.StatusOK {
6768
break
6869
}
6970
time.Sleep(5 * time.Second)

0 commit comments

Comments
 (0)