mirror of
				https://github.com/0glabs/0g-storage-node.git
				synced 2025-11-03 16:17:27 +00:00 
			
		
		
		
	
							parent
							
								
									2a24bbde18
								
							
						
					
					
						commit
						0da3c374db
					
				@ -1,10 +1,10 @@
 | 
				
			|||||||
jsonrpcclient==4.0.3
 | 
					jsonrpcclient==4.0.3
 | 
				
			||||||
pyyaml==6.0.1
 | 
					pyyaml==6.0.1
 | 
				
			||||||
pysha3==1.0.2
 | 
					safe-pysha3==1.0.4
 | 
				
			||||||
coincurve==18.0.0
 | 
					coincurve==20.0.0
 | 
				
			||||||
eth-utils==3.0.0
 | 
					eth-utils==5.1.0
 | 
				
			||||||
py-ecc==7.0.0
 | 
					py-ecc==7.0.0
 | 
				
			||||||
web3==6.14.0
 | 
					web3==7.5.0
 | 
				
			||||||
eth_tester
 | 
					eth_tester
 | 
				
			||||||
cffi==1.16.0
 | 
					cffi==1.16.0
 | 
				
			||||||
rtoml==0.10.0
 | 
					rtoml==0.11.0
 | 
				
			||||||
							
								
								
									
										41
									
								
								tests/snapshot_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								tests/snapshot_test.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					import shutil
 | 
				
			||||||
 | 
					from test_framework.test_framework import TestFramework
 | 
				
			||||||
 | 
					from utility.utils import wait_until
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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,
 | 
				
			||||||
 | 
					                    "neighbors_only": True,
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def run_test(self):
 | 
				
			||||||
 | 
					        # Submit and upload files on node 0
 | 
				
			||||||
 | 
					        data_root_1 = 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"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Start the last node to verify historical file sync
 | 
				
			||||||
 | 
					        self.nodes[1].shutdown()
 | 
				
			||||||
 | 
					        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"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					    SnapshotTask().main()
 | 
				
			||||||
@ -4,7 +4,7 @@ import tempfile
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from web3 import Web3, HTTPProvider
 | 
					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 enum import Enum, unique
 | 
				
			||||||
from config.node_config import (
 | 
					from config.node_config import (
 | 
				
			||||||
    GENESIS_PRIV_KEY,
 | 
					    GENESIS_PRIV_KEY,
 | 
				
			||||||
@ -262,7 +262,7 @@ class BlockchainNode(TestNode):
 | 
				
			|||||||
        account1 = w3.eth.account.from_key(GENESIS_PRIV_KEY)
 | 
					        account1 = w3.eth.account.from_key(GENESIS_PRIV_KEY)
 | 
				
			||||||
        account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1)
 | 
					        account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1)
 | 
				
			||||||
        w3.middleware_onion.add(
 | 
					        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)
 | 
					        # account = w3.eth.account.from_key(GENESIS_PRIV_KEY1)
 | 
				
			||||||
        # w3.middleware_onion.add(construct_sign_and_send_raw_middleware(account))
 | 
					        # 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)
 | 
					        account1 = w3.eth.account.from_key(GENESIS_PRIV_KEY)
 | 
				
			||||||
        account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1)
 | 
					        account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1)
 | 
				
			||||||
        w3.middleware_onion.add(
 | 
					        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")
 | 
					        contract_interface = load_contract_metadata(self.contract_path, "Flow")
 | 
				
			||||||
 | 
				
			|||||||
@ -44,7 +44,7 @@ class TestFramework:
 | 
				
			|||||||
        self.num_blockchain_nodes = 1
 | 
					        self.num_blockchain_nodes = 1
 | 
				
			||||||
        self.num_nodes = 1
 | 
					        self.num_nodes = 1
 | 
				
			||||||
        self.blockchain_nodes = []
 | 
					        self.blockchain_nodes = []
 | 
				
			||||||
        self.nodes = []
 | 
					        self.nodes: list[ZgsNode] = []
 | 
				
			||||||
        self.contract = None
 | 
					        self.contract = None
 | 
				
			||||||
        self.blockchain_node_configs = {}
 | 
					        self.blockchain_node_configs = {}
 | 
				
			||||||
        self.zgs_node_configs = {}
 | 
					        self.zgs_node_configs = {}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user