From 087b420c0d6533c1b89ca04327bda81754b6410c Mon Sep 17 00:00:00 2001 From: samuael <39623015+samuael@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:19:00 +0300 Subject: [PATCH] add test coverage for contract functions and minor fix on wrapper --- exchanges/futures/contract_test.go | 40 ++++++++++++++++++++++++++++++ exchanges/okx/okx_wrapper.go | 2 -- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/exchanges/futures/contract_test.go b/exchanges/futures/contract_test.go index e12ab93ff32..bad26f04731 100644 --- a/exchanges/futures/contract_test.go +++ b/exchanges/futures/contract_test.go @@ -31,3 +31,43 @@ func TestStringToContractSettlementType(t *testing.T) { assert.ErrorIs(t, err, contractSettlementTypesMap[x].Error) } } + +func TestContractSettlementTypeString(t *testing.T) { + t.Parallel() + contractSettlementTypeToStringMap := map[ContractSettlementType]string{ + UnsetSettlementType: "unset", + Linear: "linear", + Inverse: "inverse", + Quanto: "quanto", + LinearOrInverse: "linearOrInverse", + Hybrid: "hybrid", + ContractSettlementType(200): "unknown", + } + for k := range contractSettlementTypeToStringMap { + assert.Equal(t, k.String(), contractSettlementTypeToStringMap[k]) + } +} + +func TestContractTypeToString(t *testing.T) { + t.Parallel() + contractTypeToStringMap := map[ContractType]string{ + Daily: "day", + Perpetual: "perpetual", + LongDated: "long_dated", + Weekly: "weekly", + Fortnightly: "fortnightly", + ThreeWeekly: "three-weekly", + Monthly: "monthly", + Quarterly: "quarterly", + SemiAnnually: "semi-annually", + HalfYearly: "half-yearly", + NineMonthly: "nine-monthly", + Yearly: "yearly", + Unknown: "unknown", + UnsetContractType: "unset", + ContractType(200): "unset", + } + for k := range contractTypeToStringMap { + assert.Equal(t, k.String(), contractTypeToStringMap[k]) + } +} diff --git a/exchanges/okx/okx_wrapper.go b/exchanges/okx/okx_wrapper.go index 31320927ab4..bec9fc474d5 100644 --- a/exchanges/okx/okx_wrapper.go +++ b/exchanges/okx/okx_wrapper.go @@ -2864,8 +2864,6 @@ func (ok *Okx) GetFuturesContractDetails(ctx context.Context, item asset.Item) ( Type: futures.LongDated, SettlementType: contractSettlementType, MarginCurrency: currency.NewCode(results[s].QuoteCurrency), - Multiplier: results[s].TickSize.Float64(), - MaxLeverage: results[s].LotSize.Float64(), } } return resp, nil