Skip to content

Commit

Permalink
Fix several errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypan authored and Jay Pan committed Jan 16, 2025
1 parent 15f8255 commit 8a8f21e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
19 changes: 2 additions & 17 deletions tests/xcm_transfer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,11 @@ def get_metadata(symbol):
TEST_FEES_RANGE = {
'peaq-dev': {
'min': 0,
'max': 200000000000,
'max': 400000000000,
},
'krest-network': {
'min': 0,
'max': 200000000000,
},
'peaq-network': {
'min': 0,
'max': 40000000000000000,
},
}

TEST_FEES_RANGE = {
'peaq-dev': {
'min': 0,
'max': 200000000000,
},
'krest-network': {
'min': 0,
'max': 200000000000,
'max': 400000000000,
},
'peaq-network': {
'min': 0,
Expand Down
22 changes: 22 additions & 0 deletions tools/monkey/monkey_3rd_substrate_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from substrateinterface.exceptions import SubstrateRequestException, ExtrinsicNotFound
from scalecodec.types import GenericExtrinsic
from substrateinterface.base import ExtrinsicReceipt
from substrateinterface import SubstrateInterface
from json.decoder import JSONDecodeError
import time
import socket


from peaq.utils import wait_for_n_blocks


Expand All @@ -13,6 +19,22 @@ def _wait_finalization(substrate, included_block):
wait_for_n_blocks(substrate, 1)


def monkey_patch():
original_rpc_request = SubstrateInterface.rpc_request

def patched_rpc_request(self, method, params, result_handler=None):
try:
self.websocket.ping()
return original_rpc_request(self, method, params, result_handler)
except (BrokenPipeError, JSONDecodeError, socket.error) as e:
print(f"Connection error: {e}. Attempting to reconnect... {self.url}")
time.sleep(1)
self.connect_websocket()
return original_rpc_request(self, method, params, result_handler)

SubstrateInterface.rpc_request = patched_rpc_request


def monkey_submit_extrinsic(self, extrinsic: GenericExtrinsic, wait_for_inclusion: bool = False,
wait_for_finalization: bool = False) -> "ExtrinsicReceipt":
response = self.rpc_request("author_submitExtrinsic", [str(extrinsic.data)])
Expand Down
2 changes: 2 additions & 0 deletions tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

from tools.monkey.monkey_3rd_substrate_interface import monkey_submit_extrinsic
SubstrateInterface.submit_extrinsic = monkey_submit_extrinsic
from tools.monkey.monkey_3rd_substrate_interface import monkey_patch as monkey_3rd_substrate_patch
monkey_3rd_substrate_patch()

from peaq.utils import ExtrinsicBatch
from tools.monkey.monkey_reorg_batch import monkey_execute_extrinsic_batch
Expand Down

0 comments on commit 8a8f21e

Please sign in to comment.