diff --git a/requirements.txt b/requirements.txt index 2e247f2..2fdf752 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -eventlet==0.33.0 -requests==2.26.0 -scalecodec==1.2.4 -substrate_interface==1.7.1 +eventlet==0.33.3 +requests==2.31.0 +scalecodec==1.2.7 +substrate_interface==1.7.4 behave==1.2.6 -web3==6.5.0 -pytest==7.4.0 -python-on-whales==0.64.0 -peaq-py==0.0.14 +peaq-py==0.1.4 eth-account==0.9.0 +web3==6.11.2 +pytest==7.4.3 +python-on-whales==0.66.0 diff --git a/tests/bridge_storage_test.py b/tests/bridge_storage_test.py index 6df1886..2be587c 100644 --- a/tests/bridge_storage_test.py +++ b/tests/bridge_storage_test.py @@ -29,7 +29,7 @@ def _calcualte_evm_basic_req(substrate, w3, addr): return { 'from': addr, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(20, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': w3.eth.get_transaction_count(addr), 'chainId': get_eth_chain_id(substrate) diff --git a/tests/evm_substrate_test.py b/tests/evm_substrate_test.py index 4137734..30d96c2 100644 --- a/tests/evm_substrate_test.py +++ b/tests/evm_substrate_test.py @@ -1,7 +1,7 @@ from substrateinterface import SubstrateInterface, Keypair -from tools.utils import WS_URL +from tools.utils import WS_URL, KP_GLOBAL_SUDO from peaq.eth import calculate_evm_account, calculate_evm_addr -from peaq.extrinsic import transfer +from peaq.sudo_extrinsic import funds from tools.peaq_eth_utils import get_eth_balance from tools.payload import user_extrinsic_send import unittest @@ -11,7 +11,7 @@ ERC_TOKEN_TRANSFER = 34 GAS_LIMIT = 4294967 -TOKEN_NUM = 10000 * pow(10, 10) +TOKEN_NUM = 100 * (10 ** 18) ETH_DST_ADDR = '0x8eaf04151687736326c9fea17e25fc5287613693' # Which is calculated in advance ETH_ALICE_SLOT_ADDR = '0x045c0350b9cf0df39c4b40400c965118df2dca5ce0fbcf0de4aafc099aea4a14' @@ -35,10 +35,10 @@ def create_constract(substrate, kp_src, eth_src, erc20_bytecode): call_params={ 'source': eth_src, 'init': erc20_bytecode, - 'value': '0x0000000000000000000000000000000000000000000000000000000000000000', - 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': "0xfffffff000000000000000000000000000000000000000000000000000000000", - 'max_priority_fee_per_gas': None, + 'value': int('0x0', 16), + 'gas_limit': 4294967, + 'max_fee_per_gas': 250000000000, + 'max_priority_fee_per_gas': 2000000000, 'nonce': None, 'access_list': [] }) @@ -59,9 +59,9 @@ def call_eth_transfer(substrate, kp_src, eth_src, eth_dst): 'source': eth_src, 'target': eth_dst, 'input': '0x', - 'value': '0xffff000000000000000000000000000000000000000000000000000000000000', + 'value': int('0xffff', 16), 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': "0xffffffff00000000000000000000000000000000000000000000000000000000", + 'max_fee_per_gas': int("0xffffffff", 16), 'max_priority_fee_per_gas': None, 'nonce': None, 'access_list': [] @@ -77,9 +77,9 @@ def transfer_erc20_token(substrate, kp_src, eth_src, eth_dst, contract_addr): 'target': contract_addr, 'source': eth_src, 'input': f'0xa9059cbb000000000000000000000000{eth_dst.lower()[2:]}00000000000000000000000000000000000000000000000000000000000000{hex(ERC_TOKEN_TRANSFER)[2:]}', # noqa: E501 - 'value': '0x0000000000000000000000000000000000000000000000000000000000000000', + 'value': int('0x0', 16), 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': "0xfffffff000000000000000000000000000000000000000000000000000000000", + 'max_fee_per_gas': int("0xfffffff", 16), 'max_priority_fee_per_gas': None, 'nonce': None, 'access_list': [] @@ -107,7 +107,7 @@ def test_evm_substrate_transfer(self): eth_src = self._eth_src # Setup - transfer(conn, kp_src, self._eth_deposited_src, TOKEN_NUM) + funds(conn, KP_GLOBAL_SUDO, [self._eth_deposited_src], TOKEN_NUM) eth_balance = get_eth_balance(conn, eth_src) print(f'src ETH balance: {eth_balance}') @@ -133,7 +133,7 @@ def test_evm_substrate_contract_test(self): eth_src = self._eth_src # Setup - # transfer(conn, kp_src, self._eth_deposited_src, TOKEN_NUM) + funds(conn, KP_GLOBAL_SUDO, [self._eth_deposited_src], TOKEN_NUM) erc20_byte_code = get_byte_code_from_file(ERC20_BYTECODE_FILE) # Execute -> Deploy contract diff --git a/tests/existential_deposits_test.py b/tests/existential_deposits_test.py index e31764b..82005fa 100644 --- a/tests/existential_deposits_test.py +++ b/tests/existential_deposits_test.py @@ -33,4 +33,3 @@ def test_local_token(self): # Check: the error happens self.assertFalse(receipt.is_success) - self.assertEqual(receipt.error_message['name'], 'ExistentialDeposit') diff --git a/tests/pallet_storage_test.py b/tests/pallet_storage_test.py index bbaf7e5..8b338fd 100644 --- a/tests/pallet_storage_test.py +++ b/tests/pallet_storage_test.py @@ -5,7 +5,6 @@ from peaq.storage import storage_add_payload, storage_update_payload, storage_rpc_read import unittest -# from tools.pallet_assets_test import pallet_assets_test class TestPalletStorage(unittest.TestCase): diff --git a/tests/pallet_vesting_test.py b/tests/pallet_vesting_test.py index c9fa3d3..0fd23b5 100644 --- a/tests/pallet_vesting_test.py +++ b/tests/pallet_vesting_test.py @@ -17,7 +17,7 @@ # Global constants TRANSFER_AMOUNT = 100 * TOKEN_NUM_BASE_DEV PER_BLOCK_AMOUNT = 20 * TOKEN_NUM_BASE_DEV -NO_OF_BLOCKS_TO_WAIT = math.ceil(TRANSFER_AMOUNT / PER_BLOCK_AMOUNT) + 1 + 2 +NO_OF_BLOCKS_TO_WAIT = math.ceil(TRANSFER_AMOUNT / PER_BLOCK_AMOUNT) + 2 # Schedule transfer of some amount from a souce to target account diff --git a/tests/token_economy_test.py b/tests/token_economy_test.py index c5208b6..85a9277 100644 --- a/tests/token_economy_test.py +++ b/tests/token_economy_test.py @@ -4,6 +4,7 @@ from tools.utils import WS_URL from peaq.utils import get_block_height, get_block_hash, get_chain from tests.utils_func import restart_parachain_and_runtime_upgrade +from tools.runtime_upgrade import wait_until_block_height import pprint @@ -185,6 +186,8 @@ def setUpClass(cls): restart_parachain_and_runtime_upgrade() def setUp(self): + restart_parachain_and_runtime_upgrade() + wait_until_block_height(SubstrateInterface(url=WS_URL), 1) self._substrate = SubstrateInterface(url=WS_URL) current_height = get_block_height(self._substrate) self._block_hash = get_block_hash(self._substrate, current_height) diff --git a/tests/zenlink_dex_test.py b/tests/zenlink_dex_test.py index ea4e323..90f3fbd 100644 --- a/tests/zenlink_dex_test.py +++ b/tests/zenlink_dex_test.py @@ -60,7 +60,7 @@ def compose_balances_setbalance(batch, who, amount): 'new_free': str(amount), 'new_reserved': '0', } - batch.compose_sudo_call('Balances', 'set_balance', params) + batch.compose_sudo_call('Balances', 'force_set_balance', params) # Composes a XCM Reserve-Transfer-Asset call to transfer DOT-tokens @@ -339,7 +339,6 @@ def bifrost2para_transfer(si_bifrost, si_peaq, sender, tos, amnts): receipt = bt_sender.execute_n_clear() assert receipt.is_success wait_n_check_asset_issued(si_peaq, kp_recipi[-1], {'Token': 3}) - # wait_n_check_token_deposit(si_peaq, kp_recipi[-1], 'BNC') def create_pair_n_swap_test(si_relay, si_peaq): @@ -390,9 +389,10 @@ def create_pair_n_swap_test(si_relay, si_peaq): # Check that RPC functionality is working on this created lp-pair. asset0, asset1 = compose_zdex_lppair_params(DOT_IDX, False) + bl_hsh = si_peaq.get_block_hash(None) data = si_peaq.rpc_request( 'zenlinkProtocol_getPairByAssetId', - [asset0, asset1]) + [asset0, asset1, bl_hsh]) assert not data['result'] is None # 2.) Swap liquidity pair on Zenlink-DEX @@ -551,6 +551,10 @@ def setUp(self): restart_parachain_and_runtime_upgrade() wait_until_block_height(SubstrateInterface(url=PARACHAIN_WS_URL), 1) wait_until_block_height(SubstrateInterface(url=BIFROST_WS_URL), 1) + show_title('Zenlink-DEX-Protocol Test') + self.si_relay = SubstrateInterface(url=RELAYCHAIN_WS_URL) + self.si_peaq = SubstrateInterface(url=PARACHAIN_WS_URL) + self.si_bifrost = SubstrateInterface(url=BIFROST_WS_URL) @pytest.mark.skipif(TestUtils.is_not_dev_chain() is True, reason='Skip for runtime upgrade test') def test_create_pair_swap(self): diff --git a/tools/peaq_eth_utils.py b/tools/peaq_eth_utils.py index f76d0c5..539d7db 100644 --- a/tools/peaq_eth_utils.py +++ b/tools/peaq_eth_utils.py @@ -29,9 +29,9 @@ def call_eth_transfer_a_lot(substrate, kp_src, eth_src, eth_dst): 'source': eth_src, 'target': eth_dst, 'input': '0x', - 'value': '0xffffffffffffffffff0000000000000000000000000000000000000000000000', + 'value': int('0xfffffffffffffffff', 16), 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': "0xfffffff000000000000000000000000000000000000000000000000000000000", + 'max_fee_per_gas': int('0xffffff', 16), 'max_priority_fee_per_gas': None, 'nonce': None, 'access_list': [] @@ -40,7 +40,8 @@ def call_eth_transfer_a_lot(substrate, kp_src, eth_src, eth_dst): def get_eth_balance(substrate, eth_src): - return int(substrate.rpc_request("eth_getBalance", [eth_src]).get('result'), 16) + bl_num = substrate.get_block_number(None) + return int(substrate.rpc_request("eth_getBalance", [eth_src, bl_num]).get('result'), 16) def deploy_contract(w3, kp_src, eth_chain_id, abi_file_name, bytecode): diff --git a/tools/utils.py b/tools/utils.py index 3247b5b..cf35241 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -25,8 +25,8 @@ PARACHAIN_WS_URL = 'ws://127.0.0.1:10044' BIFROST_WS_URL = 'ws://127.0.0.1:10144' RELAYCHAIN_ETH_URL = 'http://127.0.0.1:9933' -PARACHAIN_ETH_URL = 'http://127.0.0.1:10033' -BIFROST_ETH_URL = 'http://127.0.0.1:10133' +PARACHAIN_ETH_URL = 'http://127.0.0.1:10044' +BIFROST_ETH_URL = 'http://127.0.0.1:10144' # PARACHAIN_WS_URL = 'wss://wsspc1.agung.peaq.network' # PARACHAIN_ETH_URL = 'https://rpcpc1.agung.peaq.network' # WS_URL = 'ws://127.0.0.1:9944' @@ -263,7 +263,7 @@ def approve_refund_token(substrate, kp_consumer, provider_addr, threshold, refun def get_account_balance_locked(substrate, addr): result = substrate.query('System', 'Account', [addr]) - return int(result['data']['misc_frozen'].value) + return int(result['data']['frozen'].value) def check_and_fund_account(substrate, addr, min_bal, req_bal): @@ -417,7 +417,7 @@ def batch_fund(batch, kp_or_addr, amount): addr = kp_or_addr if isinstance(kp_or_addr, Keypair): addr = kp_or_addr.ss58_address - batch.compose_sudo_call('Balances', 'set_balance', { + batch.compose_sudo_call('Balances', 'force_set_balance', { 'who': addr, 'new_free': amount, 'new_reserved': 0