add snapshot test

This commit is contained in:
Peter Zhang 2024-11-18 18:56:52 +08:00
parent b6309284f4
commit 3501ed2008
3 changed files with 23 additions and 16 deletions

View File

@ -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
rtoml==0.11.0

View File

@ -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()

View File

@ -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")