-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 32c9295 Author: Shoham Chakraborty <[email protected]> Date: Fri Feb 3 13:11:51 2023 +0800 Update test commit 15fb0e5 Author: Shoham Chakraborty <[email protected]> Date: Fri Feb 3 12:38:41 2023 +0800 Use VotingInfo, remove unknown votes from output commit 0609603 Merge: e51834a faaad56 Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 22:42:22 2023 +0800 Merge branch 'master' into proposalvotes-stats commit faaad56 Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 20:09:41 2023 +0800 Fix setgov crashes (#1719) Co-authored-by: Prasanna Loganathar <[email protected]> commit 7807454 Author: Mihailo Milenkovic <[email protected]> Date: Thu Feb 2 11:13:43 2023 +0100 Fix voting scenarios test (#1727) commit e51834a Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 15:38:06 2023 +0800 Fix test commit 808ed6e Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 14:49:20 2023 +0800 Redo neutral changes commit 4a9c8f0 Merge: bc55ada b7b14c2 Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 14:30:31 2023 +0800 Merge branch 'master' into proposalvotes-stats # Conflicts: # src/masternodes/rpc_proposals.cpp # test/functional/feature_on_chain_government.py commit bc55ada Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 14:27:51 2023 +0800 Refactor tests commit e47befd Author: Shoham Chakraborty <[email protected]> Date: Thu Feb 2 14:25:13 2023 +0800 Default cycles fix commit 44d0a02 Author: Shoham Chakraborty <[email protected]> Date: Wed Feb 1 15:08:29 2023 +0800 Fix isMine default commit 7246e04 Author: Shoham Chakraborty <[email protected]> Date: Wed Feb 1 14:51:04 2023 +0800 Fix multiple proposal output when aggregating commit 8b072df Author: Shoham Chakraborty <[email protected]> Date: Wed Feb 1 14:45:48 2023 +0800 Fix output schema commit 9fa408b Author: Shoham Chakraborty <[email protected]> Date: Mon Jan 30 12:09:57 2023 +0800 Add aggregate stats support to listgovproposalvotes
- Loading branch information
Showing
5 changed files
with
192 additions
and
43 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
from test_framework.test_framework import DefiTestFramework | ||
import calendar | ||
import time | ||
from decimal import Decimal | ||
|
||
class Verify (DefiTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
self.setup_clean_chain = True | ||
self.extra_args = [ | ||
['-txnotokens=0', '-amkheight=5', '-bayfrontheight=5', '-eunosheight=10', '-fortcanningheight=11', '-fortcanninghillheight=12', '-fortcanningroadheight=13', '-fortcanningcrunchheight=14', '-fortcanningspringheight=15', '-grandcentralheight=16']] | ||
|
||
def run_test(self): | ||
node = self.nodes[0] | ||
|
||
node.generate(200) | ||
|
||
account0 = node.get_genesis_keys().ownerAuthAddress | ||
symbolBTC = "BTC" | ||
symbolTSLA = "TSLA" | ||
symbolDFI = "DFI" | ||
symboldUSD = "DUSD" | ||
|
||
|
||
self.nodes[0].createtoken({ | ||
"symbol": symbolBTC, | ||
"name": "BTC token", | ||
"isDAT": True, | ||
"collateralAddress": account0 | ||
}) | ||
self.nodes[0].createtoken({ | ||
"symbol": symboldUSD, | ||
"name": "DUSD token", | ||
"isDAT": True, | ||
"collateralAddress": account0 | ||
}) | ||
self.nodes[0].generate(1) | ||
|
||
oracle_address1 = self.nodes[0].getnewaddress("", "legacy") | ||
price_feeds1 = [{"currency": "USD", "token": "DFI"}, | ||
{"currency": "USD", "token": "BTC"}, | ||
{"currency": "USD", "token": "TSLA"}, | ||
{"currency": "USD", "token": "GOOGL"}] | ||
oracle_id1 = self.nodes[0].appointoracle(oracle_address1, price_feeds1, 10) | ||
self.nodes[0].generate(1) | ||
oracle1_prices = [{"currency": "USD", "tokenAmount": "10@TSLA"}, | ||
{"currency": "USD", "tokenAmount": "10@GOOGL"}, | ||
{"currency": "USD", "tokenAmount": "10@DFI"}, | ||
{"currency": "USD", "tokenAmount": "10@BTC"}] | ||
timestamp = calendar.timegm(time.gmtime()) | ||
self.nodes[0].setoracledata(oracle_id1, timestamp, oracle1_prices) | ||
self.nodes[0].generate(1) | ||
|
||
idBTC = list(self.nodes[0].gettoken(symbolBTC).keys())[0] | ||
idDFI = list(self.nodes[0].gettoken(symbolDFI).keys())[0] | ||
iddUSD = list(self.nodes[0].gettoken(symboldUSD).keys())[0] | ||
self.nodes[0].setcollateraltoken({ | ||
'token': idBTC, | ||
'factor': 1, | ||
'fixedIntervalPriceId': "BTC/USD"}) | ||
self.nodes[0].setcollateraltoken({ | ||
'token': idDFI, | ||
'factor': 1, | ||
'fixedIntervalPriceId': "DFI/USD"}) | ||
self.nodes[0].generate(1) | ||
|
||
setLoanTokenTSLA = self.nodes[0].setloantoken({ | ||
'symbol': symbolTSLA, | ||
'name': "Tesla stock token", | ||
'fixedIntervalPriceId': "TSLA/USD", | ||
'mintable': True, | ||
'interest': 1}) | ||
self.nodes[0].createloanscheme(150, 5, 'LOAN150') | ||
self.nodes[0].generate(10) | ||
idTSLA = list(self.nodes[0].getloantoken(symbolTSLA)["token"])[0] | ||
|
||
vaultId = self.nodes[0].createvault(account0, 'LOAN150') | ||
self.nodes[0].minttokens(["2@" + symbolBTC]) | ||
node.utxostoaccount({account0: "2000@DFI"}) | ||
self.nodes[0].generate(1) | ||
|
||
self.nodes[0].deposittovault(vaultId, account0, "2000@DFI") | ||
self.nodes[0].generate(1) | ||
|
||
poolOwner = self.nodes[0].getnewaddress("", "legacy") | ||
|
||
self.nodes[0].createpoolpair({ | ||
"tokenA": iddUSD, | ||
"tokenB": idTSLA, | ||
"commission": Decimal('0.002'), | ||
"status": True, | ||
"ownerAddress": poolOwner, | ||
"pairSymbol": "DUSD-TSLA", | ||
}, []) | ||
self.nodes[0].createpoolpair({ | ||
"tokenA": iddUSD, | ||
"tokenB": idDFI, | ||
"commission": Decimal('0.002'), | ||
"status": True, | ||
"ownerAddress": poolOwner, | ||
"pairSymbol": "DUSD-DFI", | ||
}, []) | ||
node.generate(1) | ||
|
||
self.nodes[0].minttokens(["4000@" + symboldUSD, "2000@" + symbolTSLA]) | ||
node.utxostoaccount({account0: "100@DFI"}) | ||
node.generate(1) | ||
|
||
node.addpoolliquidity({ | ||
account0: ["2000@" + symboldUSD, "100@" + symbolDFI] | ||
}, account0, []) | ||
node.addpoolliquidity({ | ||
account0: ["2000@" + symboldUSD, "2000@" + symbolTSLA] | ||
}, account0, []) | ||
node.generate(1) | ||
|
||
self.nodes[0].takeloan({ | ||
'vaultId': vaultId, | ||
'amounts': "1@" + symbolTSLA}) | ||
self.nodes[0].generate(1) | ||
|
||
self.nodes[0].paybackloan({ | ||
'vaultId': vaultId, | ||
'from': account0, | ||
'amounts': "0.5@" + symbolTSLA}) | ||
self.nodes[0].generate(1) | ||
|
||
self.nodes[0].paybackloan({ | ||
'vaultId': vaultId, | ||
'from': account0, | ||
'amounts': "0.5@" + symbolTSLA}) | ||
self.nodes[0].generate(1) | ||
|
||
# self.nodes[0].generate(6) | ||
|
||
preinvalid = node.getburninfo() | ||
blockhash = node.getblockhash(node.getblockcount() - 5) | ||
node.invalidateblock(blockhash) | ||
burninfo = node.getburninfo() | ||
print(node.verifychain()) | ||
|
||
self.restart_node(0) | ||
|
||
print(node.verifychain()) | ||
assert(node.getburninfo() == burninfo) | ||
|
||
node.reconsiderblock(blockhash) | ||
assert(node.getburninfo() == preinvalid) | ||
|
||
raise Exception() | ||
|
||
if __name__ == '__main__': | ||
Verify().main() |