From fef1017fb7b03a877b89a093e6e8958edb623aa5 Mon Sep 17 00:00:00 2001 From: Brandon Goodell Date: Wed, 13 Dec 2017 10:53:39 -0700 Subject: [PATCH] fixed small errors in unit testing --- source-code/Spectre/BlockHandler.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source-code/Spectre/BlockHandler.py b/source-code/Spectre/BlockHandler.py index 3cac181..407738c 100644 --- a/source-code/Spectre/BlockHandler.py +++ b/source-code/Spectre/BlockHandler.py @@ -417,7 +417,7 @@ class Test_RoBlock(unittest.TestCase): R.voteFor((gcid,xid,yid),{}) self.assertEqual(R.votes[(gcid,xid,yid)],1) self.assertEqual(R.votes[(gcid,yid,xid)],-1) - for pid in R.blocks[vid].parents: + for pid in R.blocks[gcid].parents: if pid in R.vids: q.append(gpid) while(len(q)>0): @@ -432,13 +432,13 @@ class Test_RoBlock(unittest.TestCase): R.voteFor((gcid,yid,xid),{}) self.assertEqual(R.votes[(gcid,xid,yid)],-1) self.assertEqual(R.votes[(gcid,yid,xid)],1) - for pid in R.blocks[vid].parents: + for pid in R.blocks[gcid].parents: if pid in R.vids: q.append(gpid) while(len(q)>0): wid = q.popleft() self.assertEqual(R.pendingVotes[(wid,xid,yid)],0) - self.assertEqual(R.pendingVotes[(wid,yid,yid)],0) + self.assertEqual(R.pendingVotes[(wid,yid,xid)],0) for pid in R.blocks[wid].parents: if pid in R.vids: q.append(pid) @@ -446,18 +446,23 @@ class Test_RoBlock(unittest.TestCase): R.voteFor((gcid,yid,xid),{}) self.assertEqual(R.votes[(gcid,xid,yid)],-1) self.assertEqual(R.votes[(gcid,yid,xid)],1) - for pid in R.blocks[vid].parents: + for pid in R.blocks[gcid].parents: if pid in R.vids: q.append(gpid) while(len(q)>0): wid = q.popleft() self.assertEqual(R.pendingVotes[(wid,xid,yid)],-1) - self.assertEqual(R.pendingVotes[(wid,yid,yid)],-1) + self.assertEqual(R.pendingVotes[(wid,yid,xid)],1) for pid in R.blocks[wid].parents: if pid in R.vids: q.append(pid) - + # Test sumPendingVotes + R.sumPendingVote(gcid, {}) + self.assertTrue((gcid,xid,yid) in R.votes) + self.assertTrue((gcid,yid,xid) in R.votes) + self.assertEqual(R.votes[(gcid,xid,yid)],-1) + self.assertEqual(R.votes[(gcid,yid,xid)],1)