Skip to content

Commit

Permalink
Removed goleak pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 25, 2023
1 parent 708696f commit f762961
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 71 deletions.
18 changes: 0 additions & 18 deletions best_quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tonicpow/go-minercraft/v2/apis/mapi"
"go.uber.org/goleak"
)

// mockHTTPValidBestQuote for mocking requests
Expand Down Expand Up @@ -149,8 +148,6 @@ func TestClient_BestQuote(t *testing.T) {

t.Run("get a valid best quote", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidBestQuote{})

Expand All @@ -168,35 +165,27 @@ func TestClient_BestQuote(t *testing.T) {
})

t.Run("http error", func(t *testing.T) {
defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPError{})
response, err := client.BestQuote(context.Background(), mapi.FeeCategoryMining, mapi.FeeTypeData)
require.Error(t, err)
require.Nil(t, response)
})

t.Run("bad request", func(t *testing.T) {
defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPBadRequest{})
response, err := client.BestQuote(context.Background(), mapi.FeeCategoryMining, mapi.FeeTypeData)
require.Error(t, err)
require.Nil(t, response)
})

t.Run("invalid JSON", func(t *testing.T) {
defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPInvalidJSON{})
response, err := client.BestQuote(context.Background(), mapi.FeeCategoryMining, mapi.FeeTypeData)
require.Error(t, err)
require.Nil(t, response)
})

t.Run("invalid category", func(t *testing.T) {
defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPValidBestQuote{})
response, err := client.BestQuote(context.Background(), "invalid", mapi.FeeTypeData)
require.Error(t, err)
Expand All @@ -209,8 +198,6 @@ func TestClient_BestQuote(t *testing.T) {
})

t.Run("better rate", func(t *testing.T) {
defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPBetterRate{})
response, err := client.BestQuote(context.Background(), mapi.FeeCategoryRelay, mapi.FeeTypeData)
require.NoError(t, err)
Expand All @@ -230,8 +217,6 @@ func TestClient_BestQuote(t *testing.T) {
})

t.Run("bad rate", func(t *testing.T) {
defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPBadRate{})
response, err := client.BestQuote(context.Background(), mapi.FeeCategoryRelay, mapi.FeeTypeData)
require.Error(t, err)
Expand All @@ -240,7 +225,6 @@ func TestClient_BestQuote(t *testing.T) {

// TODO: Verify this test case for Arc API
// t.Run("best quote - two failed", func(t *testing.T) {
// defer goleak.VerifyNone(t)

// // Create a client
// client := newTestClient(&mockHTTPBestQuoteTwoFailed{})
Expand All @@ -261,8 +245,6 @@ func TestClient_BestQuote(t *testing.T) {

t.Run("best quote - all failed", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPBestQuoteAllFailed{})

Expand Down
18 changes: 0 additions & 18 deletions fastest_quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/stretchr/testify/assert"
"go.uber.org/goleak"
)

// mockHTTPValidFastestQuote for mocking requests
Expand Down Expand Up @@ -118,8 +117,6 @@ func TestClient_FastestQuote(t *testing.T) {

t.Run("get a valid fastest quote", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidFastestQuote{})

Expand All @@ -139,8 +136,6 @@ func TestClient_FastestQuote(t *testing.T) {
// todo: this timeout is not working as expected
t.Run("valid quote - quick timeout", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidFastestQuoteSlow{})

Expand All @@ -160,8 +155,6 @@ func TestClient_FastestQuote(t *testing.T) {

t.Run("valid quote - no timeout", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidFastestQuoteSlow{})

Expand All @@ -179,29 +172,20 @@ func TestClient_FastestQuote(t *testing.T) {
})

t.Run("http error", func(t *testing.T) {

defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPError{})
response, err := client.FastestQuote(context.Background(), defaultFastQuoteTimeout)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("bad request", func(t *testing.T) {

defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPBadRequest{})
response, err := client.FastestQuote(context.Background(), defaultFastQuoteTimeout)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("invalid JSON", func(t *testing.T) {

defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPInvalidJSON{})
response, err := client.FastestQuote(context.Background(), defaultFastQuoteTimeout)
assert.Error(t, err)
Expand All @@ -211,8 +195,6 @@ func TestClient_FastestQuote(t *testing.T) {
// TODO: Vetify this test case for Arc and mAPI
// t.Run("two bad quote responses, one good", func(t *testing.T) {

// defer goleak.VerifyNone(t)

// // Create a client
// client := newTestClient(&mockHTTPFastestQuoteTwoFailed{})

Expand Down
12 changes: 0 additions & 12 deletions fee_quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/libsv/go-bt/v2"
"github.com/stretchr/testify/assert"
"github.com/tonicpow/go-minercraft/v2/apis/mapi"
"go.uber.org/goleak"
)

const feeTestSignature = "3045022100eed49f6bf75d8f975f581271e3df658fbe8ec67e6301ea8fc25a72d18c92e30e022056af253f0d24db6a8fde4e2c1ee95e7a5ecf2c7cdc93246f8328c9e0ca582fc4"
Expand Down Expand Up @@ -284,8 +283,6 @@ func TestClient_FeeQuote(t *testing.T) {

t.Run("get a valid fee quote", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidFeeQuote{})

Expand All @@ -306,8 +303,6 @@ func TestClient_FeeQuote(t *testing.T) {

t.Run("valid parse values", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidFeeQuote{})

Expand All @@ -329,8 +324,6 @@ func TestClient_FeeQuote(t *testing.T) {

t.Run("get actual rates", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidFeeQuote{})

Expand All @@ -352,39 +345,34 @@ func TestClient_FeeQuote(t *testing.T) {
})

t.Run("invalid miner", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPValidFeeQuote{})
response, err := client.FeeQuote(context.Background(), nil)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("http error", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPError{})
response, err := client.FeeQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("bad request", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPBadRequest{})
response, err := client.FeeQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("invalid JSON", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPInvalidJSON{})
response, err := client.FeeQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("missing fees", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPMissingFees{})
response, err := client.FeeQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/libsv/go-bk v0.1.6
github.com/libsv/go-bt/v2 v2.2.5
github.com/stretchr/testify v1.8.4
go.uber.org/goleak v1.3.0
)

require (
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
Expand Down
9 changes: 0 additions & 9 deletions policy_quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/tonicpow/go-minercraft/v2/apis/mapi"
"go.uber.org/goleak"
)

// mockHTTPValidPolicyQuote for mocking requests
Expand Down Expand Up @@ -46,8 +45,6 @@ func TestClient_PolicyQuote(t *testing.T) {

t.Run("get a valid policy quote", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidPolicyQuote{})

Expand Down Expand Up @@ -81,47 +78,41 @@ func TestClient_PolicyQuote(t *testing.T) {
})

t.Run("invalid miner", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPValidPolicyQuote{})
response, err := client.PolicyQuote(context.Background(), nil)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("http error", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPError{})
response, err := client.PolicyQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("bad request", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPBadRequest{})
response, err := client.PolicyQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("invalid JSON", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPInvalidJSON{})
response, err := client.PolicyQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("invalid signature", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPInvalidSignature{})
response, err := client.PolicyQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("missing fees", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPMissingFees{})
response, err := client.PolicyQuote(context.Background(), client.MinerByName(MinerTaal))
assert.Error(t, err)
Expand Down
11 changes: 0 additions & 11 deletions submit_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/goleak"
)

const submitTestSignature = "3045022100f65ae83b20bc60e7a5f0e9c1bd9aceb2b26962ad0ee35472264e83e059f4b9be022010ca2334ff088d6e085eb3c2118306e61ec97781e8e1544e75224533dcc32379"
Expand Down Expand Up @@ -76,8 +75,6 @@ func TestClient_SubmitTransaction(t *testing.T) {

t.Run("submit a valid transaction", func(t *testing.T) {

defer goleak.VerifyNone(t)

// Create a client
client := newTestClient(&mockHTTPValidSubmission{})

Expand All @@ -96,8 +93,6 @@ func TestClient_SubmitTransaction(t *testing.T) {

t.Run("validate parsed values", func(t *testing.T) {

defer goleak.VerifyNone(t)

client := newTestClient(&mockHTTPValidSubmission{})
response, err := client.SubmitTransaction(context.Background(), client.MinerByName(MinerGorillaPool), tx)
assert.NoError(t, err)
Expand All @@ -113,47 +108,41 @@ func TestClient_SubmitTransaction(t *testing.T) {
})

t.Run("invalid miner", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPValidSubmission{})
response, err := client.SubmitTransaction(context.Background(), nil, tx)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("http error", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPError{})
response, err := client.SubmitTransaction(context.Background(), client.MinerByName(MinerGorillaPool), tx)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("bad request", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPBadRequest{})
response, err := client.SubmitTransaction(context.Background(), client.MinerByName(MinerGorillaPool), tx)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("invalid JSON", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPInvalidJSON{})
response, err := client.SubmitTransaction(context.Background(), client.MinerByName(MinerGorillaPool), tx)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("invalid signature", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPInvalidSignature{})
response, err := client.SubmitTransaction(context.Background(), client.MinerByName(MinerGorillaPool), tx)
assert.Error(t, err)
assert.Nil(t, response)
})

t.Run("bad submission", func(t *testing.T) {
defer goleak.VerifyNone(t)
client := newTestClient(&mockHTTPBadSubmission{})
response, err := client.SubmitTransaction(context.Background(), client.MinerByName(MinerGorillaPool), tx)
assert.Error(t, err)
Expand Down

0 comments on commit f762961

Please sign in to comment.