mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Binance: Fix occassional race failure on TestWsOrderExecutionReport (#1652)
* Binance: Fix occassional race failure on TestWsOrderExecutionReport Fixes: ``` binance_test.go:2608: expected type order.Detail, found *orderbook.Depth ``` * fixup! Binance: Fix occassional race failure on TestWsOrderExecutionReport
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -44,8 +43,6 @@ const (
|
||||
|
||||
var (
|
||||
b = &Binance{}
|
||||
// this lock guards against orderbook tests race
|
||||
binanceOrderBookLock = &sync.Mutex{}
|
||||
// this pair is used to ensure that endpoints match it correctly
|
||||
testPairMapping = currency.NewPair(currency.DOGE, currency.USDT)
|
||||
)
|
||||
@@ -2082,8 +2079,9 @@ func TestWsTradeUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWsDepthUpdate(t *testing.T) {
|
||||
binanceOrderBookLock.Lock()
|
||||
defer binanceOrderBookLock.Unlock()
|
||||
t.Parallel()
|
||||
b := new(Binance) //nolint:govet // Intentional shadow to avoid future copy/paste mistakes
|
||||
require.NoError(t, testexch.Setup(b), "Test instance Setup must not error")
|
||||
b.setupOrderbookManager()
|
||||
seedLastUpdateID := int64(161)
|
||||
book := OrderBook{
|
||||
@@ -2470,8 +2468,9 @@ var websocketDepthUpdate = []byte(`{"E":1608001030784,"U":7145637266,"a":[["1945
|
||||
|
||||
func TestProcessUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
binanceOrderBookLock.Lock()
|
||||
defer binanceOrderBookLock.Unlock()
|
||||
b := new(Binance) //nolint:govet // Intentional shadow to avoid future copy/paste mistakes
|
||||
require.NoError(t, testexch.Setup(b), "Test instance Setup must not error")
|
||||
b.setupOrderbookManager()
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
var depth WebsocketDepthStream
|
||||
err := json.Unmarshal(websocketDepthUpdate, &depth)
|
||||
@@ -2562,7 +2561,9 @@ func TestSetExchangeOrderExecutionLimits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWsOrderExecutionReport(t *testing.T) {
|
||||
// cannot run in parallel due to inspecting the DataHandler result
|
||||
t.Parallel()
|
||||
b := new(Binance) //nolint:govet // Intentional shadow to avoid future copy/paste mistakes
|
||||
require.NoError(t, testexch.Setup(b), "Test instance Setup must not error")
|
||||
payload := []byte(`{"stream":"jTfvpakT2yT0hVIo5gYWVihZhdM2PrBgJUZ5PyfZ4EVpCkx4Uoxk5timcrQc","data":{"e":"executionReport","E":1616627567900,"s":"BTCUSDT","c":"c4wyKsIhoAaittTYlIVLqk","S":"BUY","o":"LIMIT","f":"GTC","q":"0.00028400","p":"52789.10000000","P":"0.00000000","F":"0.00000000","g":-1,"C":"","x":"NEW","X":"NEW","r":"NONE","i":5340845958,"l":"0.00000000","z":"0.00000000","L":"0.00000000","n":"0","N":"BTC","T":1616627567900,"t":-1,"I":11388173160,"w":true,"m":false,"M":false,"O":1616627567900,"Z":"0.00000000","Y":"0.00000000","Q":"0.00000000","W":1616627567900}}`)
|
||||
// this is a buy BTC order, normally commission is charged in BTC, vice versa.
|
||||
expectedResult := order.Detail{
|
||||
|
||||
Reference in New Issue
Block a user