Skip to content

Commit

Permalink
Merge pull request #70 from peaqnetwork/feat/1207949918221283_async_u…
Browse files Browse the repository at this point in the history
…pdate

Feat/1207949918221283 async update
  • Loading branch information
sfffaaa authored Aug 30, 2024
2 parents e311e2e + 1a0b08f commit 4fddbe4
Show file tree
Hide file tree
Showing 60 changed files with 489 additions and 144 deletions.
2 changes: 1 addition & 1 deletion features/steps/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from behave import given, when, then
from substrateinterface import Keypair
from tools.utils import TOKEN_NUM_BASE
from tools.constants import TOKEN_NUM_BASE
from peaq.extrinsic import transfer
from peaq.utils import calculate_multi_sig
import random
Expand Down
2 changes: 1 addition & 1 deletion tests/block_creation_time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from substrateinterface import SubstrateInterface
from tools.utils import WS_URL
from tools.constants import WS_URL
from peaq.utils import wait_for_n_blocks, get_block_height
from tools.block_creation_utils import get_block_creation_times

Expand Down
4 changes: 2 additions & 2 deletions tests/bridge_asset_factory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

from substrateinterface import SubstrateInterface
from tools.asset import get_valid_asset_id
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from peaq.utils import ExtrinsicBatch
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import calculate_asset_to_evm_address
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from web3 import Web3

Expand Down
4 changes: 2 additions & 2 deletions tests/bridge_balance_erc20_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from peaq.utils import get_account_balance
from tools.utils import get_modified_chain_spec
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.utils import WS_URL, ETH_URL
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import WS_URL, ETH_URL
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
Expand Down
4 changes: 2 additions & 2 deletions tests/bridge_batch_test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import unittest
import pytest

from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
# from tools.runtime_upgrade import wait_until_block_height
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.peaq_eth_utils import get_eth_chain_id
from substrateinterface import SubstrateInterface
from peaq.utils import ExtrinsicBatch
from web3 import Web3
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.peaq_eth_utils import generate_random_hex

Expand Down
2 changes: 1 addition & 1 deletion tests/bridge_did_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from peaq.eth import calculate_evm_account, calculate_evm_addr
from peaq.extrinsic import transfer
from tools.peaq_eth_utils import call_eth_transfer_a_lot, get_contract, generate_random_hex
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.peaq_eth_utils import get_eth_chain_id
from web3 import Web3
Expand Down
2 changes: 1 addition & 1 deletion tests/bridge_erc20_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
from substrateinterface import SubstrateInterface, Keypair
from tools.asset import batch_create_asset, get_valid_asset_id, batch_set_metadata, batch_mint
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from peaq.utils import ExtrinsicBatch
from tools.peaq_eth_utils import get_contract
Expand Down
4 changes: 2 additions & 2 deletions tests/bridge_parachain_staking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from tests.utils_func import restart_parachain_and_runtime_upgrade
from tools.runtime_upgrade import wait_until_block_height
from substrateinterface import SubstrateInterface
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from peaq.utils import ExtrinsicBatch
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
# , calculate_evm_default_addr
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.evm_claim_sign import calculate_claim_signature, claim_account
from tools.utils import KP_GLOBAL_SUDO, KP_COLLATOR
from tools.constants import KP_GLOBAL_SUDO, KP_COLLATOR
from peaq.utils import get_block_hash
from web3 import Web3

Expand Down
4 changes: 2 additions & 2 deletions tests/bridge_rbac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from substrateinterface import SubstrateInterface, Keypair, KeypairType
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from peaq.eth import calculate_evm_account, calculate_evm_addr
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import call_eth_transfer_a_lot, get_contract, generate_random_hex, GAS_LIMIT, TX_SUCCESS_STATUS
from tools.peaq_eth_utils import call_eth_transfer_a_lot, get_contract, generate_random_hex, TX_SUCCESS_STATUS
from web3 import Web3
import enum
import unittest
Expand Down
2 changes: 1 addition & 1 deletion tests/bridge_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from substrateinterface import SubstrateInterface, Keypair, KeypairType
from peaq.eth import calculate_evm_account_hex, calculate_evm_addr, calculate_evm_account
from peaq.extrinsic import transfer
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import call_eth_transfer_a_lot, get_contract, generate_random_hex
Expand Down
9 changes: 5 additions & 4 deletions tests/bridge_vest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from substrateinterface import SubstrateInterface
from peaq.utils import ExtrinsicBatch
from tools.peaq_eth_utils import get_contract
from tools.utils import KP_GLOBAL_SUDO
from tools.utils import WS_URL, ETH_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.constants import BLOCK_GENERATE_TIME
from tools.constants import KP_GLOBAL_SUDO
from tools.constants import WS_URL, ETH_URL
from tools.utils import get_account_balance_locked
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import get_eth_info
from tools.utils import batch_fund
Expand Down Expand Up @@ -102,7 +103,7 @@ def test_bridge_vest(self):
contract, self._kp_moon['kp'], self._kp_mars['eth'], 10 ** 18, now_block)
self.assertTrue(tx_receipt.status)
block_idx = tx_receipt['blockNumber']
time.sleep(12)
time.sleep(BLOCK_GENERATE_TIME)
event = contract.events.VestedTransfer.create_filter(fromBlock=block_idx, toBlock=block_idx)
self.check_vested_transfer_from_event(
event,
Expand Down
8 changes: 4 additions & 4 deletions tests/bridge_xcmutils_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest
from tests.utils_func import restart_parachain_and_runtime_upgrade
from tools.utils import WS_URL, ETH_URL, ACA_WS_URL
from tools.utils import ACA_PD_CHAIN_ID
from tools.utils import PARACHAIN_WS_URL
from tools.constants import WS_URL, ETH_URL, ACA_WS_URL
from tools.constants import ACA_PD_CHAIN_ID
from tools.constants import PARACHAIN_WS_URL
from tools.runtime_upgrade import wait_until_block_height
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
Expand All @@ -11,7 +11,7 @@
from substrateinterface import SubstrateInterface, Keypair
from peaq.utils import ExtrinsicBatch
from web3 import Web3
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from peaq.utils import get_account_balance
from tests import utils_func as TestUtils
Expand Down
6 changes: 3 additions & 3 deletions tests/bridge_xtokens_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from tests.utils_func import restart_parachain_and_runtime_upgrade
from tools.runtime_upgrade import wait_until_block_height
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import ETH_URL, RELAYCHAIN_WS_URL
from tools.utils import WS_URL, ACA_WS_URL, PARACHAIN_WS_URL
from tools.constants import ETH_URL, RELAYCHAIN_WS_URL
from tools.constants import WS_URL, ACA_WS_URL, PARACHAIN_WS_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from peaq.utils import get_account_balance
from peaq.utils import ExtrinsicBatch
from tools.asset import convert_enum_to_asset_id
from tools.utils import KP_GLOBAL_SUDO, ACA_PD_CHAIN_ID
from tools.constants import KP_GLOBAL_SUDO, ACA_PD_CHAIN_ID
from tools.asset import batch_register_location, batch_set_units_per_second, setup_xc_register_if_not_exist
from tools.asset import setup_aca_asset_if_not_exist
from tools.asset import UNITS_PER_SECOND
Expand Down
11 changes: 7 additions & 4 deletions tests/delegator_issue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import pytest

from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, get_collators, batch_fund
from tools.utils import KP_GLOBAL_SUDO, exist_pallet, KP_COLLATOR
from tools.utils import get_collators, batch_fund
from tools.utils import exist_pallet
from tools.constants import WS_URL, KP_GLOBAL_SUDO, KP_COLLATOR
from tools.constants import BLOCK_GENERATE_TIME
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
Expand Down Expand Up @@ -108,7 +110,7 @@ def get_one_collator_without_delegator(self, keys):
return None

def wait_get_reward(self, addr):
time.sleep(12 * 2)
time.sleep(BLOCK_GENERATE_TIME * 2)
count_down = 0
wait_time = 120
prev_balance = get_account_balance(self.substrate, addr)
Expand All @@ -117,9 +119,10 @@ def wait_get_reward(self, addr):
return True
print(f'already wait about {count_down} seconds')
count_down += 12
time.sleep(12)
time.sleep(BLOCK_GENERATE_TIME)
return False

# Deprecated: We don't use it now
def test_issue_fixed_precentage(self):
if not exist_pallet(self.substrate, 'StakingFixedRewardCalculator'):
warnings.warn('StakingFixedRewardCalculator pallet not exist, skip the test')
Expand Down
2 changes: 1 addition & 1 deletion tests/evm_eth_rpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from substrateinterface import SubstrateInterface, Keypair, KeypairType
from peaq.eth import calculate_evm_account, calculate_evm_addr
from peaq.extrinsic import transfer
from tools.utils import WS_URL, ETH_URL
from tools.constants import WS_URL, ETH_URL
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import deploy_contract
Expand Down
2 changes: 1 addition & 1 deletion tests/evm_substrate_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, KP_GLOBAL_SUDO
from tools.constants import WS_URL, KP_GLOBAL_SUDO
from peaq.eth import calculate_evm_account, calculate_evm_addr
from peaq.utils import ExtrinsicBatch
from peaq.sudo_extrinsic import funds
Expand Down
2 changes: 1 addition & 1 deletion tests/existential_deposits_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import unittest
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL
from tools.constants import WS_URL
from peaq.extrinsic import transfer


Expand Down
4 changes: 2 additions & 2 deletions tests/fund_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import unittest
import pytest
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, TOKEN_NUM_BASE
from tools.constants import WS_URL, TOKEN_NUM_BASE
from peaq.sudo_extrinsic import fund
from peaq.utils import get_account_balance
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import KP_GLOBAL_SUDO


@pytest.mark.substrate
Expand Down
4 changes: 2 additions & 2 deletions tests/pallet_address_unification.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest
import pytest
from substrateinterface import SubstrateInterface, Keypair, KeypairType
from tools.utils import WS_URL, ETH_URL
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import WS_URL, ETH_URL
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from tools.asset import batch_create_asset, batch_mint, get_valid_asset_id
from tools.asset import get_asset_balance
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_assets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, KP_GLOBAL_SUDO
from tools.constants import WS_URL, KP_GLOBAL_SUDO
from tools.asset import batch_create_asset, batch_set_metadata, batch_mint, get_valid_asset_id
from tools.asset import get_asset_balance, convert_enum_to_asset_id
from peaq.utils import ExtrinsicBatch
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_block_reward_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL
from tools.constants import WS_URL
from tools.utils import set_block_reward_configuration
import unittest
import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_did_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from substrateinterface import SubstrateInterface, Keypair
from tools.utils import get_balance_reserve_value
from tools.utils import WS_URL
from tools.constants import WS_URL
from peaq.utils import ExtrinsicBatch
from peaq.did import did_add_payload, did_update_payload, did_remove_payload, did_rpc_read

Expand Down
3 changes: 2 additions & 1 deletion tests/pallet_inflation_manager_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pytest
import unittest
from substrateinterface import SubstrateInterface
from tools.utils import WS_URL, get_modified_chain_spec
from tools.utils import get_modified_chain_spec
from tools.constants import WS_URL
from peaq.utils import get_block_height
# from tools.utils import wait_for_event
from enum import Enum
Expand Down
4 changes: 2 additions & 2 deletions tests/pallet_multisig_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest
import pytest
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import WS_URL
from tools.constants import KP_GLOBAL_SUDO
from tools.utils import show_account, send_approval, send_proposal, get_as_multi_extrinsic_id
from peaq.extrinsic import transfer
from peaq.utils import calculate_multi_sig
Expand Down
4 changes: 2 additions & 2 deletions tests/pallet_rbac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL
from tools.constants import WS_URL
from peaq.sudo_extrinsic import fund
from peaq.utils import ExtrinsicBatch
from peaq.rbac import rbac_add_role_payload, rbac_add_group_payload, rbac_add_permission_payload
Expand All @@ -18,7 +18,7 @@
from peaq.rbac import rbac_rpc_fetch_permissions
from peaq.rbac import rbac_rpc_fetch_groups
from tools.utils import get_balance_reserve_value
from tools.utils import KP_GLOBAL_SUDO
from tools.constants import KP_GLOBAL_SUDO
import unittest


Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_storage_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
import pytest
from tools.utils import WS_URL
from tools.constants import WS_URL
from tools.utils import get_balance_reserve_value
from substrateinterface import SubstrateInterface, Keypair
from peaq.utils import ExtrinsicBatch
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_transaction_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import unittest
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL
from tools.constants import WS_URL
from peaq.utils import ExtrinsicBatch


Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_treasury_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, TOKEN_NUM_BASE_DEV, KP_GLOBAL_SUDO
from tools.constants import WS_URL, TOKEN_NUM_BASE_DEV, KP_GLOBAL_SUDO
from peaq.utils import show_extrinsic
from peaq.utils import ExtrinsicBatch
from tools.utils import batch_fund, get_event
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_utility_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, TOKEN_NUM_BASE
from tools.constants import WS_URL, TOKEN_NUM_BASE
from peaq.utils import show_extrinsic
from tools.utils import show_account
import unittest
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_vesting_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
import pytest
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import WS_URL, TOKEN_NUM_BASE_DEV, KP_GLOBAL_SUDO
from tools.constants import WS_URL, TOKEN_NUM_BASE_DEV, KP_GLOBAL_SUDO
from tools.utils import get_account_balance_locked
from peaq.utils import get_account_balance
from peaq.sudo_extrinsic import funds
Expand Down
Loading

0 comments on commit 4fddbe4

Please sign in to comment.