Created
March 7, 2024 00:00
-
-
Save gloriousCode/283ecc528898779b73b5701c880e31ec to your computer and use it in GitHub Desktop.
diff.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ -0,0 +1,210 @@ | |
diff --git a/exchanges/deribit/deribit_test.go b/exchanges/deribit/deribit_test.go | |
index d89af8ded..23a84e6f4 100644 | |
--- a/exchanges/deribit/deribit_test.go | |
+++ b/exchanges/deribit/deribit_test.go | |
@@ -7,6 +7,7 @@ import ( | |
"log" | |
"os" | |
"strconv" | |
+ "strings" | |
"sync" | |
"testing" | |
"time" | |
@@ -31,8 +32,10 @@ const ( | |
apiKey = "" | |
apiSecret = "" | |
- canManipulateRealOrders = false | |
- btcPerpInstrument = "BTC-PERPETUAL" | |
+ canManipulateRealOrders = false | |
+ canManipulateAPIEndpoints = false | |
+ btcPerpInstrument = "BTC-PERPETUAL" | |
+ useTestNet = false | |
) | |
var ( | |
@@ -68,6 +71,15 @@ func TestMain(m *testing.M) { | |
if err != nil { | |
log.Fatal("Deribit setup error", err) | |
} | |
+ if useTestNet { | |
+ for k, v := range d.API.Endpoints.GetURLMap() { | |
+ v = strings.Replace(v, "www.deribit.com", "test.deribit.com", 1) | |
+ err = d.API.Endpoints.SetRunning(k, v) | |
+ if err != nil { | |
+ log.Fatal(err) | |
+ } | |
+ } | |
+ } | |
d.Websocket.DataHandler = sharedtestvalues.GetWebsocketInterfaceChannelOverride() | |
d.Websocket.TrafficAlert = sharedtestvalues.GetWebsocketStructChannelOverride() | |
fetchTradablePairChan = make(chan struct{}) | |
@@ -960,6 +972,9 @@ func TestWSRetrieveAccessLog(t *testing.T) { | |
func TestChangeAPIKeyName(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.ChangeAPIKeyName(context.Background(), 1, "TestKey123") | |
assert.NoError(t, err) | |
} | |
@@ -967,6 +982,9 @@ func TestChangeAPIKeyName(t *testing.T) { | |
func TestWSChangeAPIKeyName(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WSChangeAPIKeyName(1, "TestKey123") | |
assert.NoError(t, err) | |
} | |
@@ -988,6 +1006,9 @@ func TestWsChangeMarginModel(t *testing.T) { | |
func TestChangeScopeInAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.ChangeScopeInAPIKey(context.Background(), 1, "account:read_write") | |
assert.NoError(t, err) | |
} | |
@@ -995,6 +1016,9 @@ func TestChangeScopeInAPIKey(t *testing.T) { | |
func TestWSChangeScopeInAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WSChangeScopeInAPIKey(1, "account:read_write") | |
assert.NoError(t, err) | |
} | |
@@ -1002,6 +1026,9 @@ func TestWSChangeScopeInAPIKey(t *testing.T) { | |
func TestChangeSubAccountName(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
err := d.ChangeSubAccountName(context.Background(), 1, "new_sub") | |
assert.NoError(t, err) | |
} | |
@@ -1009,6 +1036,9 @@ func TestChangeSubAccountName(t *testing.T) { | |
func TestWSChangeSubAccountName(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
err := d.WSChangeSubAccountName(1, "new_sub") | |
assert.NoError(t, err) | |
} | |
@@ -1016,6 +1046,9 @@ func TestWSChangeSubAccountName(t *testing.T) { | |
func TestCreateAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.CreateAPIKey(context.Background(), "account:read_write", "new_sub", false) | |
assert.NoError(t, err) | |
} | |
@@ -1023,6 +1056,9 @@ func TestCreateAPIKey(t *testing.T) { | |
func TestWSCreateAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WSCreateAPIKey("account:read_write", "new_sub", false) | |
assert.NoError(t, err) | |
} | |
@@ -1030,6 +1066,9 @@ func TestWSCreateAPIKey(t *testing.T) { | |
func TestCreateSubAccount(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.CreateSubAccount(context.Background()) | |
assert.NoError(t, err) | |
} | |
@@ -1037,6 +1076,9 @@ func TestCreateSubAccount(t *testing.T) { | |
func TestWSCreateSubAccount(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WSCreateSubAccount() | |
assert.NoError(t, err) | |
} | |
@@ -1044,6 +1086,9 @@ func TestWSCreateSubAccount(t *testing.T) { | |
func TestDisableAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.DisableAPIKey(context.Background(), 1) | |
assert.NoError(t, err) | |
} | |
@@ -1051,6 +1096,9 @@ func TestDisableAPIKey(t *testing.T) { | |
func TestWSDisableAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WSDisableAPIKey(1) | |
assert.NoError(t, err) | |
} | |
@@ -1058,6 +1106,9 @@ func TestWSDisableAPIKey(t *testing.T) { | |
func TestEditAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.EditAPIKey(context.Background(), 1234, "trade", "", false, []string{"read", "read_write"}, []string{}) | |
require.NoError(t, err) | |
} | |
@@ -1065,6 +1116,9 @@ func TestEditAPIKey(t *testing.T) { | |
func TestWsEditAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WsEditAPIKey(1234, "trade", "", false, []string{"read", "read_write"}, []string{}) | |
require.NoError(t, err) | |
} | |
@@ -1086,6 +1140,9 @@ func TestWSEnableAffiliateProgram(t *testing.T) { | |
func TestEnableAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.EnableAPIKey(context.Background(), 1) | |
assert.NoError(t, err) | |
} | |
@@ -1093,6 +1150,9 @@ func TestEnableAPIKey(t *testing.T) { | |
func TestWSEnableAPIKey(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders) | |
+ if !canManipulateAPIEndpoints { | |
+ t.Skip("cannot manipulate API endpoints") | |
+ } | |
_, err := d.WSEnableAPIKey(1) | |
assert.NoError(t, err) | |
} | |
@@ -1146,7 +1206,7 @@ func TestGetPrivatePortfolioMargins(t *testing.T) { | |
assert.NoError(t, err) | |
} | |
-func TestWsRetrivePricatePortfolioMargins(t *testing.T) { | |
+func TestWsRetrievePrivatePortfolioMargins(t *testing.T) { | |
t.Parallel() | |
sharedtestvalues.SkipTestIfCredentialsUnset(t, d) | |
_, err := d.WSRetrievePrivatePortfolioMargins(currencyBTC, false, nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment