From 1cc42ce261c613a806cff03494f34b3b1c11ae68 Mon Sep 17 00:00:00 2001 From: mjalalzai <33738574+MForensic@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:20:42 -0700 Subject: [PATCH] Tests for voting --- carnot/test_happy_path.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/carnot/test_happy_path.py b/carnot/test_happy_path.py index 57bd28a..9c203cb 100644 --- a/carnot/test_happy_path.py +++ b/carnot/test_happy_path.py @@ -16,6 +16,14 @@ class TestCarnotHappyPath(TestCase): block = Block(view=1, qc=StandardQc(block=genesis_block.id(), view=0)) carnot.receive_block(block) + def test_prepare_vote_for_a_block(self,block:Block, carnot: Carnot) -> Vote: + vote: Vote = Vote( + block=block.id(), + voter=self.id, + view=self.current_view, + qc=self.build_qc(votes) + ) + return vote def test_receive_multiple_blocks_for_the_same_view(self): carnot = Carnot(int_to_id(0)) @@ -149,4 +157,22 @@ def test_receive_block_has_an_old_qc(self): + # Test cases for vote: + #1: If a nodes votes for same block twice + #2: If a node votes for two different blocks in the same view. + #3: If a node in parent committee votes before it receives threshold of children's votes + #4: If a node counts a single vote twice + #5: If a node votes only for block that are safe + def test_vote_for_received_block(self): + carnot = Carnot(int_to_id(0)) + genesis_block = self.add_genesis_block(carnot) + blocklist=[] + for i in range(1,5): + blocklist.append(Block(view=i, qc=StandardQc(block=i - 1, view=i - 1))) + + + + + +