From fee15bd7adafb06f21b630215f2d4357d3c8b291 Mon Sep 17 00:00:00 2001 From: jar-o Date: Wed, 16 Nov 2022 15:46:03 -0700 Subject: [PATCH 1/3] Fix bittrex mock for v3 --- origin/bittrex.go | 25 +++++++++---------------- smocker/api_test.go | 9 ++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/origin/bittrex.go b/origin/bittrex.go index 9893e9e..a99d6e1 100644 --- a/origin/bittrex.go +++ b/origin/bittrex.go @@ -13,26 +13,19 @@ func (b BitTrex) BuildMocks(e []ExchangeMock) ([]*smocker.Mock, error) { } func (b BitTrex) build(e ExchangeMock) (*smocker.Mock, error) { - symbol := fmt.Sprintf("%s-%s", e.Symbol.Quote, e.Symbol.Base) + symbol := fmt.Sprintf("%s-%s", e.Symbol.Base, e.Symbol.Quote) + fmt.Printf("james symbol: %s\n\n\n", symbol) body := `{ - "success": true, - "message": "", - "result": { - "Bid": %f, - "Ask": %f, - "Last": %f - } - }` + "symbol": "%s", + "lastTradeRate": "%f", + "bidRate": "%f", + "askRate": "%f" +}` return &smocker.Mock{ Request: smocker.MockRequest{ Method: smocker.ShouldEqual("GET"), - Path: smocker.ShouldEqual("/api/v1.1/public/getticker"), - QueryParams: map[string]smocker.StringMatcherSlice{ - "market": []smocker.StringMatcher{ - smocker.ShouldEqual(symbol), - }, - }, + Path: smocker.ShouldEqual(fmt.Sprintf("/v3/markets/%s/ticker", symbol)), }, Response: &smocker.MockResponse{ Status: e.StatusCode, @@ -41,7 +34,7 @@ func (b BitTrex) build(e ExchangeMock) (*smocker.Mock, error) { "application/json", }, }, - Body: fmt.Sprintf(body, e.Bid, e.Ask, e.Price), + Body: fmt.Sprintf(body, symbol, e.Price, e.Bid, e.Ask), }, }, nil } diff --git a/smocker/api_test.go b/smocker/api_test.go index c275f5a..c54a459 100644 --- a/smocker/api_test.go +++ b/smocker/api_test.go @@ -2,11 +2,18 @@ package smocker import ( "context" + "os" "testing" ) +const defaultURI = "http://localhost:8081" + func TestResetAPICall(t *testing.T) { - api := NewAPI("http://localhost:8081") + uri = defaultURI + if os.Getenv("SMOCKER_HOST") != "" { + uri = os.Getenv("SMOCKER_HOST") + } + api := NewAPI(uri) err := api.Reset(context.Background()) if err != nil { t.Errorf("Error resetting API call: %s", err) From b62c591117f5d22da536023c3448ae50813a0462 Mon Sep 17 00:00:00 2001 From: jar-o Date: Wed, 16 Nov 2022 17:29:25 -0700 Subject: [PATCH 2/3] ... --- origin/bittrex.go | 1 - 1 file changed, 1 deletion(-) diff --git a/origin/bittrex.go b/origin/bittrex.go index a99d6e1..8aa3e9b 100644 --- a/origin/bittrex.go +++ b/origin/bittrex.go @@ -14,7 +14,6 @@ func (b BitTrex) BuildMocks(e []ExchangeMock) ([]*smocker.Mock, error) { func (b BitTrex) build(e ExchangeMock) (*smocker.Mock, error) { symbol := fmt.Sprintf("%s-%s", e.Symbol.Base, e.Symbol.Quote) - fmt.Printf("james symbol: %s\n\n\n", symbol) body := `{ "symbol": "%s", "lastTradeRate": "%f", From d6a705958ffb7875f3fe37e31b72e767a6706e86 Mon Sep 17 00:00:00 2001 From: jar-o Date: Wed, 16 Nov 2022 17:30:50 -0700 Subject: [PATCH 3/3] ... --- smocker/api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smocker/api_test.go b/smocker/api_test.go index c54a459..0d9bfdb 100644 --- a/smocker/api_test.go +++ b/smocker/api_test.go @@ -9,7 +9,7 @@ import ( const defaultURI = "http://localhost:8081" func TestResetAPICall(t *testing.T) { - uri = defaultURI + uri := defaultURI if os.Getenv("SMOCKER_HOST") != "" { uri = os.Getenv("SMOCKER_HOST") }