From 91f68ad61cf8cc7c1c017df825a2e130dc13e991 Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Wed, 13 Sep 2023 18:44:16 +0200 Subject: [PATCH] Functional test --- src/consensus/upgrades.cpp | 124 +++++++++--------- test/functional/mining_pos_coldStaking.py | 12 +- .../test_framework/test_framework.py | 6 +- test/functional/test_runner.py | 1 + 4 files changed, 74 insertions(+), 69 deletions(-) diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index e313d831c94785..917511c7e9016d 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -13,66 +13,70 @@ * We are using it in the -nuparams startup arg and input it with spaces is just ugly. */ const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES] = { - { - /*.strName =*/ "Base", - /*.strInfo =*/ "PIVX network", - }, - { - /*.strName =*/ "PoS", - /*.strInfo =*/ "Proof of Stake Consensus activation", - }, - { - /*.strName =*/ "PoS_v2", - /*.strInfo =*/ "New selection for stake modifier", - }, - { - /*.strName =*/ "Zerocoin", - /*.strInfo =*/ "ZeroCoin protocol activation - start block v4", - }, - { - /*.strName =*/ "Zerocoin_v2", - /*.strInfo =*/ "New zerocoin serials and zPOS start", - }, - { - /*.strName =*/ "BIP65", - /*.strInfo =*/ "CLTV (BIP65) activation - start block v5", - }, - { - /*.strName =*/ "Zerocoin_Public", - /*.strInfo =*/ "Activation of zerocoin public spends (spend v3)", - }, - { - /*.strName =*/ "PIVX_v3.4", - /*.strInfo =*/ "New 256-bit stake modifier - start block v6", - }, - { - /*.strName =*/ "PIVX_v4.0", - /*.strInfo =*/ "New message sigs - start block v7 - time protocol - zc spend v4", - }, - { - /*.strName =*/ "v5_shield", - /*.strInfo =*/ "Sapling Shield - start block v8 - start transaction v3", - }, - { - /*.strName =*/ "PIVX_v5.2", - /*.strInfo =*/ "New cold-staking rules", - }, - { - /*.strName =*/ "PIVX_v5.3", - /*.strInfo =*/ "New staking rules", - }, - { - /*.strName =*/ "PIVX_v5.5", - /*.strInfo =*/ "New rewards structure", - }, - { - /*.strName =*/ "v6_evo", - /*.strInfo =*/ "Deterministic Masternodes", - }, - { - /*.strName =*/ "Test_dummy", - /*.strInfo =*/ "Test dummy info", - }, + { + /*.strName =*/"Base", + /*.strInfo =*/"PIVX network", + }, + { + /*.strName =*/"PoS", + /*.strInfo =*/"Proof of Stake Consensus activation", + }, + { + /*.strName =*/"PoS_v2", + /*.strInfo =*/"New selection for stake modifier", + }, + { + /*.strName =*/"Zerocoin", + /*.strInfo =*/"ZeroCoin protocol activation - start block v4", + }, + { + /*.strName =*/"Zerocoin_v2", + /*.strInfo =*/"New zerocoin serials and zPOS start", + }, + { + /*.strName =*/"BIP65", + /*.strInfo =*/"CLTV (BIP65) activation - start block v5", + }, + { + /*.strName =*/"Zerocoin_Public", + /*.strInfo =*/"Activation of zerocoin public spends (spend v3)", + }, + { + /*.strName =*/"PIVX_v3.4", + /*.strInfo =*/"New 256-bit stake modifier - start block v6", + }, + { + /*.strName =*/"PIVX_v4.0", + /*.strInfo =*/"New message sigs - start block v7 - time protocol - zc spend v4", + }, + { + /*.strName =*/"v5_shield", + /*.strInfo =*/"Sapling Shield - start block v8 - start transaction v3", + }, + { + /*.strName =*/"PIVX_v5.2", + /*.strInfo =*/"New cold-staking rules", + }, + { + /*.strName =*/"PIVX_v5.3", + /*.strInfo =*/"New staking rules", + }, + { + /*.strName =*/"PIVX_v5.5", + /*.strInfo =*/"New rewards structure", + }, + { + /*.strName =*/"v6_evo", + /*.strInfo =*/"Deterministic Masternodes", + }, + { + /*.strName =*/"shield_staking", + /*.strInfo =*/"Shield Staking", + }, + { + /*.strName =*/"Test_dummy", + /*.strInfo =*/"Test dummy info", + }, }; UpgradeState NetworkUpgradeState( diff --git a/test/functional/mining_pos_coldStaking.py b/test/functional/mining_pos_coldStaking.py index c073da2563cd47..9306d6d90d9860 100755 --- a/test/functional/mining_pos_coldStaking.py +++ b/test/functional/mining_pos_coldStaking.py @@ -92,7 +92,7 @@ def run_test(self): assert self.nodes[1].lockunspent(False, True, [{"txid": x['txid'], "vout": x['vout']}]) # check that it cannot stake sleep(1) - assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], 0) + assert_equal(self.nodes[1].getstakingstatus()["transparent_stakeable_coins"], 0) # create shielded balance for node 0 self.log.info("Shielding some coins for node0...") self.nodes[0].shieldsendmany("from_transparent", [{"address": self.nodes[0].getnewshieldaddress(), @@ -205,7 +205,7 @@ def run_test(self): # ----------------------------------------------------------- print("*** 7 ***") self.log.info("Trying to generate a cold-stake block before whitelisting the owner...") - assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], 0) + assert_equal(self.nodes[1].getstakingstatus()["transparent_stakeable_coins"], 0) assert_equal(self.nodes[1].listdelegators(), []) self.log.info("Nice. Cold staker was NOT able to create the block yet.") @@ -232,7 +232,7 @@ def run_test(self): # 9) check that the staker can use the coins to stake a block with internal miner. # -------------------------------------------------------------------------------- print("*** 9 ***") - assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], NUM_OF_INPUTS-1) + assert_equal(self.nodes[1].getstakingstatus()["transparent_stakeable_coins"], NUM_OF_INPUTS-1) self.log.info("Generating one valid cold-stake block...") self.mocktime = self.generate_pos(1, self.mocktime) self.log.info("New block created by cold-staking. Trying to submit...") @@ -338,12 +338,12 @@ def run_test(self): assert ret assert_equal(self.nodes[1].listdelegators(), []) assert_equal(self.nodes[1].listdelegators(True)[0]["address"], owner_address) - assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], 0) + assert_equal(self.nodes[1].getstakingstatus()["transparent_stakeable_coins"], 0) self.log.info("Re-enable delegation") ret = self.nodes[1].delegatoradd(owner_address) assert ret assert_equal(self.nodes[1].listdelegators()[0]["address"], owner_address) - assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], len(stakeable_coins)) + assert_equal(self.nodes[1].getstakingstatus()["transparent_stakeable_coins"], len(stakeable_coins)) self.log.info("Cancel the stake delegation spending the delegated utxos...") delegated_utxos = getDelegatedUtxos(self.nodes[0].listunspent()) # remove one utxo to spend later @@ -379,7 +379,7 @@ def run_test(self): # ----------------------------------------------------------- print("*** 14 ***") self.log.info("Trying to generate one cold-stake block again...") - assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], 0) + assert_equal(self.nodes[1].getstakingstatus()["transparent_stakeable_coins"], 0) self.log.info("Good. Cold staker was NOT able to create any more blocks.") # 15) check balances when mature. diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 99067f6988c820..20ef615a8df682 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -886,8 +886,8 @@ def generate_pos(self, node_id, btime=None): rpc_conn = self.nodes[node_id] ss = rpc_conn.getstakingstatus() assert ss["walletunlocked"] - assert ss["stakeablecoins"] > 0 - assert ss["stakingbalance"] > 0.0 + assert ss["transparent_stakeable_coins"] > 0 + assert ss["transparent_staking_balance"] > 0.0 if btime is not None: next_btime = btime + 60 fStaked = False @@ -902,7 +902,7 @@ def generate_pos(self, node_id, btime=None): # couldn't generate block. check that this node can still stake (after 60 failures) if failures > 60: ss = rpc_conn.getstakingstatus() - if not (ss["walletunlocked"] and ss["stakeablecoins"] > 0 and ss["stakingbalance"] > 0.0): + if not (ss["walletunlocked"] and ss["transparent_stakeable_coins"] > 0 and ss["transparent_staking_balance"] > 0.0): raise AssertionError("Node %d unable to stake!" % node_id) # try to stake one sec in the future if btime is not None: diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index bcec57836aecba..83270d9d29a0d7 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -94,6 +94,7 @@ 'rpc_bind.py --nonloopback', # ~ 126 sec 'feature_uacomment.py', # ~ 125 sec 'interface_rest.py', # ~ 120 sec + 'mining_shield_pos.py', # ~ 120 sec # vv Tests less than 2m vv 'wallet_upgrade.py', # ~ 119 sec