From 70ea7ec74ef06cf73fd11f68e595236d428ad072 Mon Sep 17 00:00:00 2001 From: 5lliot Date: Fri, 6 Oct 2023 21:03:06 +0700 Subject: [PATCH] fix: entry and account fields test --- calc/account_fields.go | 1 + calc/account_fields_test.go | 1 + core/balance.go | 2 +- core/version.go | 2 +- jsonnet/calc_account_fields.jsonnet | 4 ++-- jsonnet/calc_account_fields_v2.jsonnet | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/calc/account_fields.go b/calc/account_fields.go index 40cda1d49..b511fe432 100644 --- a/calc/account_fields.go +++ b/calc/account_fields.go @@ -55,6 +55,7 @@ func (c Calculator) CalcAccountFields(ts uint64, blockNum int64, calTotalValueInUSD = new(big.Int).Add(calTotalValueInUSD, tokenValueInUSD) } } + calBorrowWithInterest = new(big.Int).Quo( new(big.Int).Mul(poolCumIndexNow, account.GetBorrowedAmount()), account.GetCumulativeIndex()) diff --git a/calc/account_fields_test.go b/calc/account_fields_test.go index a02af9ba8..83875d892 100644 --- a/calc/account_fields_test.go +++ b/calc/account_fields_test.go @@ -80,6 +80,7 @@ type CalcFieldsParams struct { // for v1 func TestCalcFields(t *testing.T) { + log.SetTestLogging(t) // input := CalcFieldsParams{} utils.ReadJsonAndSetInterface("../inputs/calc_account_fields.json", &input) diff --git a/core/balance.go b/core/balance.go index c014c4731..a9ef8242a 100644 --- a/core/balance.go +++ b/core/balance.go @@ -33,7 +33,7 @@ type TokenBalanceCallData struct { func ConvertToDBBalanceFormat(dcv2Balances []TokenBalanceCallData) DBBalanceFormat { m := DBBalanceFormat{} for _, entry := range dcv2Balances { - if !entry.IsEnabled { + if entry.IsEnabled { m[entry.Token] = entry.DBTokenBalance } } diff --git a/core/version.go b/core/version.go index f36a66607..78e5cb000 100644 --- a/core/version.go +++ b/core/version.go @@ -41,7 +41,7 @@ func NewVersion(v int16) VersionType { } else if v == 210 || v == 220 { return VersionType{v: 2} } - log.Fatal("version not supported") + log.Fatal("version not supported", v) panic("") } diff --git a/jsonnet/calc_account_fields.jsonnet b/jsonnet/calc_account_fields.jsonnet index c8e2bbb77..7ff4a4914 100644 --- a/jsonnet/calc_account_fields.jsonnet +++ b/jsonnet/calc_account_fields.jsonnet @@ -137,10 +137,10 @@ IsEnabled: true, }, ], + UnderlyingToken: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', + Version: 1, }, - UnderlyingToken: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', BlockNum: 15380052, - Version: 1, CumIndexOfPool: '1008974004624121395847841465', Prices: { '1': { diff --git a/jsonnet/calc_account_fields_v2.jsonnet b/jsonnet/calc_account_fields_v2.jsonnet index 219599d23..18e5ceffe 100644 --- a/jsonnet/calc_account_fields_v2.jsonnet +++ b/jsonnet/calc_account_fields_v2.jsonnet @@ -263,10 +263,10 @@ Balance: 0, }, ], + UnderlyingToken: '0x595DFFf822767c2E14CFB7D5e0b5a5e23eCfACdd', + Version: 2, }, - UnderlyingToken: '0x595DFFf822767c2E14CFB7D5e0b5a5e23eCfACdd', BlockNum: 7712345, - Version: 2, CumIndexOfPool: '1000748182006430558180400186', Prices: { '2': {