From 812d3dfedf38f00dcba223f9dd095913d2217aea Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Tue, 25 Oct 2022 16:06:54 +0800 Subject: [PATCH 1/2] Skip collateral factor check (#1515) * undo rename and add new flag to skip loan collateral check * add skip collateral factor test * fix formatting --- src/init.cpp | 1 + src/masternodes/govvariables/attributes.cpp | 6 +++ .../feature_skip_collateral_factor_check.py | 49 +++++++++++++++++++ test/functional/test_runner.py | 1 + 4 files changed, 57 insertions(+) create mode 100644 test/functional/feature_skip_collateral_factor_check.py diff --git a/src/init.cpp b/src/init.cpp index 93c28e20b0..c8be1d444a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -505,6 +505,7 @@ void SetupServerArgs() gArgs.AddArg("-greatworldheight", "Alias for Fort Canning Great World fork activation height (regtest only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); gArgs.AddArg("-fortcanningepilogueheight", "Alias for Fort Canning Epilogue fork activation height (regtest only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); gArgs.AddArg("-jellyfish_regtest", "Configure the regtest network for jellyfish testing", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); + gArgs.AddArg("-regtest-skip-loan-collateral-validation", "Skip loan collateral check for jellyfish testing", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); gArgs.AddArg("-simulatemainnet", "Configure the regtest network to mainnet target timespan and spacing ", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); gArgs.AddArg("-dexstats", strprintf("Enable storing live dex data in DB (default: %u)", DEFAULT_DEXSTATS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); #ifdef USE_UPNP diff --git a/src/masternodes/govvariables/attributes.cpp b/src/masternodes/govvariables/attributes.cpp index c2503d0367..9b1557358a 100644 --- a/src/masternodes/govvariables/attributes.cpp +++ b/src/masternodes/govvariables/attributes.cpp @@ -1210,6 +1210,12 @@ Res ATTRIBUTES::Apply(CCustomCSView & mnview, const uint32_t height) } } else if (attrV0->key == TokenKeys::LoanCollateralFactor) { if (height >= static_cast(Params().GetConsensus().FortCanningEpilogueHeight)) { + // Skip on if skip collateral check is passed + if (Params().NetworkIDString() == CBaseChainParams::REGTEST && + gArgs.GetBoolArg("-regtest-skip-loan-collateral-validation", false)) { + continue; + } + std::set ratio; mnview.ForEachLoanScheme([&ratio](const std::string &identifier, const CLoanSchemeData &data) { ratio.insert(data.ratio); diff --git a/test/functional/feature_skip_collateral_factor_check.py b/test/functional/feature_skip_collateral_factor_check.py new file mode 100644 index 0000000000..1c58501a66 --- /dev/null +++ b/test/functional/feature_skip_collateral_factor_check.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# Copyright (c) 2014-2019 The Bitcoin Core developers +# Copyright (c) DeFi Blockchain Developers +# Distributed under the MIT software license, see the accompanying +# file LICENSE or http://www.opensource.org/licenses/mit-license.php. +"""Test - Skip Collateral Factor """ + +from test_framework.test_framework import DefiTestFramework + + +class SkipCollateralFactorTest (DefiTestFramework): + def set_test_params(self): + self.num_nodes = 1 + self.setup_clean_chain = True + self.extra_args = [['-txnotokens=0', '-amkheight=1', '-bayfrontheight=1', '-bayfrontgardensheight=1', '-eunosheight=1', '-txindex=1', '-fortcanningheight=1', '-fortcanningroadheight=1', + '-fortcanninghillheight=1', '-fortcanningcrunchheight=1', '-fortcanninggreatworldheight=1', '-fortcanningepilogueheight=200', '-regtest-skip-loan-collateral-validation', '-jellyfish_regtest=1']] + + def run_test(self): + # Generate chain + self.nodes[0].generate(120) + + # Create loan tokens + self.symbolDUSD = "DUSD" + self.nodes[0].setloantoken({ + 'symbol': self.symbolDUSD, + 'name': self.symbolDUSD, + 'fixedIntervalPriceId': f"{self.symbolDUSD}/USD", + 'mintable': True, + 'interest': -1 + }) + self.nodes[0].generate(1) + + # Store DUSD ID + self.idDUSD = list(self.nodes[0].gettoken(self.symbolDUSD).keys())[0] + + # Move to fork + self.nodes[0].generate(200 - self.nodes[0].getblockcount()) + + # Create loan scheme + self.nodes[0].createloanscheme(150, 1, 'LOAN001') + self.nodes[0].generate(1) + + # Should not throw error + self.nodes[0].setgov( + {"ATTRIBUTES": {f'v0/token/{self.idDUSD}/loan_collateral_factor': '1.50'}}) + + +if __name__ == '__main__': + SkipCollateralFactorTest().main() diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index e397fee8b9..79453d6027 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -244,6 +244,7 @@ 'wallet_listsinceblock.py', 'p2p_leak.py', 'feature_higher_collateral_factor.py', + 'feature_skip_collateral_factor_check.py', 'wallet_encryption.py', 'feature_dersig.py', 'feature_cltv.py', From 5983bd5282314a7f7f17653a02e3bc58c2b4c411 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Wed, 26 Oct 2022 12:18:43 +0800 Subject: [PATCH 2/2] run dev build and jellyfish tests on epic branches (#1527) Co-authored-by: Prasanna Loganathar --- .github/workflows/dev-builds.yaml | 2 ++ .github/workflows/jellyfish-tests.yml | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-builds.yaml b/.github/workflows/dev-builds.yaml index 3f7e801ffb..1e07966d75 100644 --- a/.github/workflows/dev-builds.yaml +++ b/.github/workflows/dev-builds.yaml @@ -8,6 +8,7 @@ on: branches: - master - testnet + - epic/* - t/* - e/* - v* @@ -16,6 +17,7 @@ on: branches: - master - testnet + - epic/* - t/* - e/* - v* diff --git a/.github/workflows/jellyfish-tests.yml b/.github/workflows/jellyfish-tests.yml index 3737f77dff..7b4091429b 100644 --- a/.github/workflows/jellyfish-tests.yml +++ b/.github/workflows/jellyfish-tests.yml @@ -2,9 +2,13 @@ name: Jellyfish Tests on: push: - branches: [ master ] + branches: + - master + - epic/* pull_request: - branches: [ master ] + branches: + - master + - epic/* jobs: test: