1212pytestmark = pytest .mark .slow
1313
1414
15- def update_node2_cmd (path , cmd , i ):
15+ def update_node_cmd (path , cmd , i ):
1616 ini_path = path / SUPERVISOR_CONFIG_FILE
1717 ini = configparser .RawConfigParser ()
1818 ini .read (ini_path )
@@ -31,7 +31,8 @@ def update_node2_cmd(path, cmd, i):
3131def post_init (broken_binary ):
3232 def inner (path , base_port , config ):
3333 chain_id = "cronos_777-1"
34- update_node2_cmd (path / chain_id , broken_binary , 2 )
34+ update_node_cmd (path / chain_id , broken_binary , 2 )
35+ update_node_cmd (path / chain_id , broken_binary , 3 )
3536
3637 return inner
3738
@@ -65,32 +66,42 @@ def test_rollback(custom_cronos):
6566 - the broken node will sync up to block 10 then crash.
6667 - use rollback command to rollback the db.
6768 - switch to correct binary should make the node syncing again.
68- """
69- wait_for_port (ports .rpc_port (custom_cronos .base_port (2 )))
7069
71- print ("wait for node2 to sync the first 10 blocks" )
72- cli2 = custom_cronos .cosmos_cli (2 )
73- wait_for_block (cli2 , 10 )
70+ node2: test memiavl node
71+ node3: test iavl node
72+ """
73+ nodes = [2 , 3 ]
74+ clis = {i : custom_cronos .cosmos_cli (i ) for i in nodes }
75+ for i , cli in clis .items ():
76+ wait_for_port (ports .rpc_port (custom_cronos .base_port (i )))
77+ print (f"wait for node { i } to sync the first 10 blocks" )
78+ wait_for_block (cli , 10 )
7479
7580 print ("wait for a few more blocks on the healthy nodes" )
7681 cli = custom_cronos .cosmos_cli (0 )
7782 wait_for_block (cli , 13 )
7883
7984 # (app hash mismatch happens after the 10th block, detected in the 11th block)
80- print ("check node2 get stuck at block 10" )
81- assert cli2 .block_height () == 10
85+ for i , cli in clis .items ():
86+ print (f"check node { i } get stuck at block 10" )
87+ assert cli .block_height () == 10
8288
83- print ("stop node2" )
84- supervisorctl (custom_cronos .base_dir / "../tasks.ini" , "stop" , "cronos_777-1-node2" )
89+ print (f"stop node { i } " )
90+ supervisorctl (
91+ custom_cronos .base_dir / "../tasks.ini" , "stop" , f"cronos_777-1-node{ i } "
92+ )
8593
86- print ("do rollback on node2" )
87- cli2 .rollback ()
94+ print (f"do rollback on node{ i } " )
95+ cli .rollback ()
96+
97+ print ("switch to normal binary" )
98+ update_node_cmd (custom_cronos .base_dir , "cronosd" , i )
8899
89- print ("switch to normal binary" )
90- update_node2_cmd (custom_cronos .base_dir , "cronosd" , 2 )
91100 supervisorctl (custom_cronos .base_dir / "../tasks.ini" , "update" )
92- wait_for_port (ports .rpc_port (custom_cronos .base_port (2 )))
93101
94- print ("check node2 sync again" )
95- cli2 = custom_cronos .cosmos_cli (2 )
96- wait_for_block (cli2 , 15 )
102+ for i in clis :
103+ wait_for_port (ports .rpc_port (custom_cronos .base_port (i )))
104+
105+ print (f"check node{ i } sync again" )
106+ cli = custom_cronos .cosmos_cli (i )
107+ wait_for_block (cli , 15 )
0 commit comments