From 3501ed200845c41633cf8ddab5269092865f1080 Mon Sep 17 00:00:00 2001 From: Peter Zhang Date: Mon, 18 Nov 2024 18:56:52 +0800 Subject: [PATCH] add snapshot test --- requirements.txt | 10 +++++----- tests/snapshot_test.py | 23 +++++++++++++++-------- tests/test_framework/blockchain_node.py | 6 +++--- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index ec81c35..2a6db6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ jsonrpcclient==4.0.3 pyyaml==6.0.1 -pysha3==1.0.2 -coincurve==18.0.0 -eth-utils==3.0.0 +safe-pysha3=1.0.4 +coincurve==20.0.0 +eth-utils==5.1.0 py-ecc==7.0.0 -web3==6.14.0 +web3==7.5.0 eth_tester cffi==1.16.0 -rtoml==0.10.0 \ No newline at end of file +rtoml==0.11.0 \ No newline at end of file diff --git a/tests/snapshot_test.py b/tests/snapshot_test.py index cdb260b..059eb02 100644 --- a/tests/snapshot_test.py +++ b/tests/snapshot_test.py @@ -9,28 +9,35 @@ class SnapshotTask(TestFramework): def setup_params(self): self.num_nodes = 2 + # Enable random auto sync only + for i in range(self.num_nodes): + self.zgs_node_configs[i] = { + "sync": { + "auto_sync_enabled": True, + "max_sequential_workers": 3, + "max_random_workers": 3, + } + } + def run_test(self): # Stop the last node to verify historical file sync # Submit and upload files on node 0 data_root_1 = self.__upload_file__(0, 256 * 1024) - data_root_2 = self.__upload_file__(0, 256 * 1024) wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_1) is not None) wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_1)["finalized"]) - wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_2) is not None) - wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_2)["finalized"]) # Start the last node to verify historical file sync self.nodes[1].shutdown() - shutil.rmtree(os.path.join(self.nodes[1].data_dir, 'data_db')) + shutil.rmtree(os.path.join(self.nodes[1].data_dir, 'db/data_db')) self.start_storage_node(1) self.nodes[1].wait_for_rpc_connection() - wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_1) is not None) - wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_1)["finalized"]) - wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_2) is not None) - wait_until(lambda: self.nodes[1].zgs_get_file_info(data_root_2)["finalized"]) + # Submit and upload files on node 0 + data_root_1 = self.__upload_file__(1, 256 * 1024) + wait_until(lambda: self.nodes[0].zgs_get_file_info(data_root_1) is not None) + wait_until(lambda: self.nodes[0].zgs_get_file_info(data_root_1)["finalized"]) if __name__ == "__main__": SnapshotTask().main() diff --git a/tests/test_framework/blockchain_node.py b/tests/test_framework/blockchain_node.py index e25a274..943f508 100644 --- a/tests/test_framework/blockchain_node.py +++ b/tests/test_framework/blockchain_node.py @@ -4,7 +4,7 @@ import tempfile import time from web3 import Web3, HTTPProvider -from web3.middleware import construct_sign_and_send_raw_middleware +from web3.middleware import SignAndSendRawMiddlewareBuilder from enum import Enum, unique from config.node_config import ( GENESIS_PRIV_KEY, @@ -262,7 +262,7 @@ class BlockchainNode(TestNode): account1 = w3.eth.account.from_key(GENESIS_PRIV_KEY) account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1) w3.middleware_onion.add( - construct_sign_and_send_raw_middleware([account1, account2]) + SignAndSendRawMiddlewareBuilder.build([account1, account2]) ) # account = w3.eth.account.from_key(GENESIS_PRIV_KEY1) # w3.middleware_onion.add(construct_sign_and_send_raw_middleware(account)) @@ -365,7 +365,7 @@ class BlockchainNode(TestNode): account1 = w3.eth.account.from_key(GENESIS_PRIV_KEY) account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1) w3.middleware_onion.add( - construct_sign_and_send_raw_middleware([account1, account2]) + SignAndSendRawMiddlewareBuilder.build([account1, account2]) ) contract_interface = load_contract_metadata(self.contract_path, "Flow")