def test_another_election_message(visitor_repository): node = GateNode(nodes[0], [nodes[1], nodes[2], nodes[3]], visitor_repository) node.state = GateNode.STATE_ELECTING node.parent = nodes[1] assert list(node.process_message(NetworkMessage('election_started', nodes[2], nodes[0]))) == \ [NetworkMessage('election_voted', nodes[0], nodes[2], leader=None)] assert node.state == GateNode.STATE_ELECTING assert node.parent == nodes[1]
def test_last_ack_intermediate_node(visitor_repository): node = GateNode(nodes[0], [nodes[1], nodes[2], nodes[3]], visitor_repository) node.state = GateNode.STATE_ELECTING node.parent = nodes[1] node.answers = {nodes[2]: nodes[5]} assert list(node.process_message(NetworkMessage('election_voted', nodes[3], nodes[0], leader=nodes[4]))) == \ [NetworkMessage('election_voted', nodes[0], nodes[1], leader=nodes[5])] assert node.state == GateNode.STATE_WAITING assert node.answers == {nodes[2]: nodes[5], nodes[3]: nodes[4]}