diff --git a/exchanges/margin/margin_test.go b/exchanges/margin/margin_test.go index 4d37ca10b83..09c57dc27fc 100644 --- a/exchanges/margin/margin_test.go +++ b/exchanges/margin/margin_test.go @@ -13,6 +13,8 @@ func TestValid(t *testing.T) { t.Parallel() require.True(t, Isolated.Valid()) require.True(t, Multi.Valid()) + require.True(t, Cash.Valid()) + require.True(t, SpotIsolated.Valid()) require.False(t, Unset.Valid()) require.False(t, Unknown.Valid()) require.False(t, Type(137).Valid()) @@ -35,6 +37,16 @@ func TestUnmarshalJSON(t *testing.T) { assert.NoError(t, err) assert.Equalf(t, Multi, alien.M, "received '%v' expected '%v'", alien.M, Multi) + jason = []byte(`{"margin":"cash"}`) + err = json.Unmarshal(jason, &alien) + assert.NoError(t, err) + assert.Equalf(t, Cash, alien.M, "received '%v' expected '%v'", alien.M, Cash) + + jason = []byte(`{"margin":"spot_isolated"}`) + err = json.Unmarshal(jason, &alien) + assert.NoError(t, err) + assert.Equalf(t, SpotIsolated, alien.M, "received '%v' expected '%v'", alien.M, SpotIsolated) + jason = []byte(`{"margin":"hello moto"}`) err = json.Unmarshal(jason, &alien) require.ErrorIs(t, err, ErrInvalidMarginType) @@ -57,17 +69,20 @@ func TestUpper(t *testing.T) { assert.Equal(t, Unknown.Upper(), strings.ToUpper(unknownStr)) assert.Equal(t, Isolated.Upper(), strings.ToUpper(isolatedStr)) assert.Equal(t, Multi.Upper(), strings.ToUpper(multiStr)) + assert.Equal(t, SpotIsolated.Upper(), strings.ToUpper(spotIsolatedStr)) + assert.Equal(t, Cash.Upper(), strings.ToUpper(cashStr)) assert.Equal(t, Unset.Upper(), strings.ToUpper(unsetStr)) } func TestIsValidString(t *testing.T) { t.Parallel() require.False(t, IsValidString("lol")) + require.True(t, IsValidString("spot_isolated")) + require.True(t, IsValidString("cash")) require.True(t, IsValidString("isolated")) require.True(t, IsValidString("cross")) require.True(t, IsValidString("multi")) - require.True(t, IsValidString("unset")) - require.False(t, IsValidString("")) + require.True(t, IsValidString("")) require.False(t, IsValidString("unknown")) } diff --git a/exchanges/margin/margin_types.go b/exchanges/margin/margin_types.go index c2ccda2eca9..102049358ff 100644 --- a/exchanges/margin/margin_types.go +++ b/exchanges/margin/margin_types.go @@ -87,7 +87,7 @@ const ( Unknown ) -var supported = Isolated | Multi +var supported = Isolated | Multi | Cash | SpotIsolated const ( unsetStr = ""