Skip to content

Commit f1ee213

Browse files
yihuangcoderabbitai[bot]
andauthored
Problem: iavl rollback not tested (#1693)
* Problem: iavl rollback not tested * iteration * Update integration_tests/test_rollback.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: yihuang <[email protected]> --------- Signed-off-by: yihuang <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6dc645a commit f1ee213

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

integration_tests/configs/rollback.jsonnet

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ local config = import 'default.jsonnet';
33
config {
44
'cronos_777-1'+: {
55
validators: super.validators + [{
6-
name: 'fullnode',
6+
name: 'rollback-test-memiavl',
77
'app-config': {
88
memiavl: {
99
enable: true,
1010
},
1111
},
12+
}, {
13+
name: 'rollback-test-iavl',
14+
'app-config': {
15+
memiavl: {
16+
enable: false,
17+
},
18+
},
1219
}],
1320
},
1421
}

integration_tests/test_rollback.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
pytestmark = 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):
3131
def 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

Comments
 (0)