Skip to content

Commit

Permalink
Make intermediate variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Jun 27, 2023
1 parent 551f5c2 commit 860a142
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions harness/tests/test_raft.py
Original file line number Diff line number Diff line change
Expand Up @@ -3550,13 +3550,13 @@ def new_test_learner_raft(
storage: MemStorage_Ref,
logger: Logger_Ref,
) -> Interface:
initial_state = storage.initial_state()

assert not (
storage.initial_state().initialized() and not peers
initial_state.initialized() and not peers
), f"new_test_raft with empty peers on initialized store"

# 이렇게 하면 유일하게 깨지는 케이스가 이거.
# 얘는 참조가 비어 있어서 깨진다.
if peers and not storage.initial_state().initialized():
if peers and not initial_state.initialized():
storage.initialize_with_conf_state(ConfState(peers, learners))

cfg = new_test_config(id, election, heartbeat)
Expand Down Expand Up @@ -4252,7 +4252,8 @@ def test_advance_commit_index_by_vote_request(use_prevote: bool):
e.set_data(v1.encode())
else:
e.set_entry_type(EntryType.EntryConfChangeV2)
e.set_data(cc.as_v2().encode())
v2 = cc.as_v2()
e.set_data(v2.encode())

# propose a confchange entry but don't let it commit
nt.ignore(MessageType.MsgAppendResponse)
Expand Down Expand Up @@ -4383,7 +4384,8 @@ def test_advance_commit_index_by_vote_response(use_prevote: bool):
e.set_data(v1.encode())
else:
e.set_entry_type(EntryType.EntryConfChangeV2)
e.set_data(cc.as_v2().encode())
v2 = cc.as_v2()
e.set_data(v2.encode())

# propose a confchange entry but don't let it commit
nt.ignore(MessageType.MsgAppendResponse)
Expand Down
8 changes: 5 additions & 3 deletions harness/tests/test_raw_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ def new_raw_node_with_config(
storage: MemStorage,
logger: Logger_Ref,
) -> InMemoryRawNode:
initial_state = storage.initial_state()
assert not (
storage.initial_state().initialized() and not peers
initial_state.initialized() and not peers
), f"new_raw_node with empty peers on initialized store"

if peers and not storage.initial_state().initialized():
if peers and not initial_state.initialized():
storage.wl().apply_snapshot(new_snapshot(1, 1, peers))

return InMemoryRawNode(config, storage, logger)
Expand Down Expand Up @@ -399,7 +400,8 @@ def handle_committed_entries(
assert cs == exp

conf_index = last_index
if cc.as_v2().enter_joint():
v2 = cc.as_v2()
if v2.enter_joint():
# If this is an auto-leaving joint conf change, it will have
# appended the entry that auto-leaves, so add one to the last
# index that forms the basis of our expectations on
Expand Down

0 comments on commit 860a142

Please sign in to comment.