Esempio n. 1
0
    def test_node_receives_higher_proposals(self):
        self.assertEqual(self.state.read(Node.PROPOSED), Proposal(None, 0))

        self.role.receive(Prepare.create(proposal=Proposal('A', 1)), self.channel)
        self.assertEqual(self.state.read(Node.PROPOSED), Proposal('A', 2))

        self.role.receive(Promise.create(proposal=Proposal('A', 3)), self.channel)
        self.assertEqual(self.state.read(Node.PROPOSED), Proposal('A', 4))

        self.role.receive(Accept.create(proposal=Proposal('A', 5)), self.channel)
        self.assertEqual(self.state.read(Node.PROPOSED), Proposal('A', 6))

        self.role.receive(Accepted.create(proposal=Proposal('A', 7)), self.channel)
        self.assertEqual(self.state.read(Node.PROPOSED), Proposal('A', 8))
Esempio n. 2
0
    def test_acceptor_receives_prepare_and_then_receives_lower_accept(self):
        self.role.receive(Prepare.create(proposal=Proposal('A', 1)), self.channel)
        self.role.receive(Accept.create(proposal=Proposal('A', 0)), self.channel)

        self.assertTrue(type(self.channel.unicast_messages[-1]) is Nack)