diff --git a/tests/delegator_issue_test.py b/tests/delegator_issue_test.py index 44a6cfa..fd7191c 100644 --- a/tests/delegator_issue_test.py +++ b/tests/delegator_issue_test.py @@ -10,6 +10,7 @@ from peaq.utils import get_block_height, get_block_hash, get_chain from peaq.utils import ExtrinsicBatch, get_account_balance from tests.utils_func import restart_parachain_and_runtime_upgrade +from tools.utils import set_block_reward_configuration import warnings @@ -79,6 +80,8 @@ def set_reward_rate(substrate, collator, delegator): @pytest.mark.substrate class TestDelegator(unittest.TestCase): def setUp(self): + restart_parachain_and_runtime_upgrade() + self.substrate = SubstrateInterface( url=WS_URL, ) @@ -88,9 +91,28 @@ def setUp(self): Keypair.create_from_mnemonic(Keypair.generate_mnemonic()), Keypair.create_from_mnemonic(Keypair.generate_mnemonic()) ] + self.ori_reward_config = self.substrate.query( + module='BlockReward', + storage_function='RewardDistributionConfigStorage', + ) + self.set_collator_delegator_precentage() def tearDown(self): - restart_parachain_and_runtime_upgrade() + receipt = set_block_reward_configuration(self.substrate, self.ori_reward_config.value) + self.assertTrue(receipt.is_success, 'cannot reset the block reward configuration') + + def set_collator_delegator_precentage(self): + set_value = { + 'treasury_percent': 20000000, + 'depin_incentivization_percent': 10000000, + 'collators_delegators_percent': 20000000, + 'depin_staking_percent': 50000000, + 'coretime_percent': 40000000, + 'subsidization_pool_percent': 860000000, + } + receipt = set_block_reward_configuration(self.substrate, set_value) + self.assertTrue(receipt.is_success, + 'cannot setup the block reward configuration') def get_balance_difference(self, addr): current_height = get_block_height(self.substrate) diff --git a/tests/pallet_inflation_manager_test.py b/tests/pallet_inflation_manager_test.py index fd83ebe..cc94b39 100644 --- a/tests/pallet_inflation_manager_test.py +++ b/tests/pallet_inflation_manager_test.py @@ -62,7 +62,7 @@ INFLATION_RECALCULATION = { 'peaq-network': 5256000, - 'peaq-network-fork': 3617954, + 'peaq-network-fork': 5684095, 'peaq-dev': 5256000, 'peaq-dev-fork': 5084632, # Because of the delay TGE diff --git a/tests/pallet_vesting_test.py b/tests/pallet_vesting_test.py index ac20efc..63d0bbc 100644 --- a/tests/pallet_vesting_test.py +++ b/tests/pallet_vesting_test.py @@ -223,8 +223,8 @@ def merge_schedule_test(self, substrate, kp_source, kp_target_second): block_header = substrate.get_block_header() current_block_number = int(block_header['header']['number']) - first_starting_block_number = current_block_number + 10 - second_starting_block_number = current_block_number + 20 + first_starting_block_number = current_block_number + 100 + second_starting_block_number = current_block_number + 200 print("Current Block: ", current_block_number) print("Starting Block Number of first schedule: ", first_starting_block_number) @@ -233,10 +233,10 @@ def merge_schedule_test(self, substrate, kp_source, kp_target_second): max(first_starting_block_number, second_starting_block_number)) first_schedule = {'locked': 100 * TOKEN_NUM_BASE_DEV, - 'per_block': 10 * TOKEN_NUM_BASE_DEV, + 'per_block': 1 * TOKEN_NUM_BASE_DEV, 'starting_block': first_starting_block_number} second_schedule = {'locked': 200 * TOKEN_NUM_BASE_DEV, - 'per_block': 20 * TOKEN_NUM_BASE_DEV, + 'per_block': 2 * TOKEN_NUM_BASE_DEV, 'starting_block': second_starting_block_number} print("First vested trasnfer") diff --git a/tests/token_economy_test.py b/tests/token_economy_test.py index 55525df..4d78542 100644 --- a/tests/token_economy_test.py +++ b/tests/token_economy_test.py @@ -63,6 +63,14 @@ 'subsidization_pool_percent': 50000000, 'depin_staking_percent': 50000000, 'depin_incentivization_percent': 150000000, + }, + 'peaq-network-fork': { + 'treasury_percent': 650000000, + 'collators_delegators_percent': 0, + 'coretime_percent': 100000000, + 'subsidization_pool_percent': 50000000, + 'depin_staking_percent': 50000000, + 'depin_incentivization_percent': 150000000, } } }] @@ -194,7 +202,7 @@ def test_block_reward(self): block_reward = { 'peaq-dev-fork': int(3.805175038 * 10 ** 18), 'krest-network-fork': int(3.805175038 * 10 ** 18), - 'peaq-network-fork': int(55.93607306 * 10 ** 18), + 'peaq-network-fork': int(27.96803653 * 10 ** 18), } if 'peaq-dev-fork' != self._chain_spec and \ 'krest-network-fork' != self._chain_spec and \ diff --git a/tests/xcm_transfer_test.py b/tests/xcm_transfer_test.py index 7560d19..c02877a 100644 --- a/tests/xcm_transfer_test.py +++ b/tests/xcm_transfer_test.py @@ -260,6 +260,7 @@ def get_parachain_id(self, peaq_substrate): @classmethod def setUpClass(cls): restart_parachain_and_runtime_upgrade() + wait_until_block_height(SubstrateInterface(url=RELAYCHAIN_WS_URL), 3) wait_until_block_height(SubstrateInterface(url=PARACHAIN_WS_URL), 3) wait_until_block_height(SubstrateInterface(url=ACA_WS_URL), 3) diff --git a/tools/runtime_upgrade.py b/tools/runtime_upgrade.py index 3a1b7ad..49f9d82 100644 --- a/tools/runtime_upgrade.py +++ b/tools/runtime_upgrade.py @@ -2,6 +2,7 @@ sys.path.append('./') import os import time +import importlib from substrateinterface import SubstrateInterface from tools.constants import WS_URL, KP_GLOBAL_SUDO, RELAYCHAIN_WS_URL, KP_COLLATOR @@ -154,7 +155,7 @@ def do_runtime_upgrade(wasm_path): batch.execute() upgrade(wasm_path) - wait_for_n_blocks(substrate, 10) + wait_for_n_blocks(substrate, 15) # Cannot move in front of the upgrade because V4 only exists in 1.7.2 update_xcm_default_version(substrate) @@ -186,4 +187,11 @@ def main(): if __name__ == '__main__': + # For the monkey patching to work, the module must be reloaded + # Avoid the dependency on the module name + if 'substrateinterface' in sys.modules: + importlib.reload(sys.modules['substrateinterface']) + if 'peaq.utils' in sys.modules: + importlib.reload(sys.modules['peaq.utils']) + main()