Skip to content

Commit

Permalink
Merge branch 'feature/1204080823207081_upgrade_polkadot_v0.9.43' into…
Browse files Browse the repository at this point in the history
… feat/1205658662562816_filter
  • Loading branch information
jaypan committed Nov 20, 2023
2 parents 9c0196a + 8367a49 commit 7fddfa5
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 35 deletions.
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/bridge_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions tests/evm_substrate_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
Expand All @@ -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': []
})
Expand All @@ -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': []
Expand All @@ -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': []
Expand Down Expand Up @@ -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}')
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/existential_deposits_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
1 change: 0 additions & 1 deletion tests/pallet_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/pallet_vesting_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/token_economy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions tests/zenlink_dex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions tools/peaq_eth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': []
Expand All @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7fddfa5

Please sign in to comment.