Skip to content

Commit 4cdb587

Browse files
committed
test: add coverage for single proposal sync based on an orphan proposal vote reception and single finalization sync based on an orphan finalization vote.
Github-Pull: #2659 Rebased-From: 32196b1
1 parent 979bb2c commit 4cdb587

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

test/functional/tiertwo_governance_sync_basic.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
assert_true,
2121
connect_nodes,
2222
get_datadir_path,
23-
satoshi_round,
23+
satoshi_round
2424
)
2525
import shutil
2626
import os
@@ -235,11 +235,25 @@ def run_test(self):
235235
self.check_vote_existence(firstProposal.name, self.mnOneCollateral.hash, "YES", True)
236236
self.log.info("all good, MN1 vote accepted everywhere!")
237237

238+
# before broadcast the second vote, let's drop the budget data of ownerOne.
239+
# so the node is forced to send a single proposal sync when the, now orphan, proposal vote is received.
240+
self.log.info("Testing single proposal re-sync based on an orphan vote, dropping budget data...")
241+
self.ownerOne.cleanbudget(try_sync=False)
242+
assert_equal(self.ownerOne.getbudgetprojection(), []) # empty
243+
assert_equal(self.ownerOne.getbudgetinfo(), [])
244+
238245
# now let's vote for the proposal with the second MN
239246
self.log.info("Voting with MN2...")
240247
voteResult = self.ownerTwo.mnbudgetvote("alias", firstProposal.proposalHash, "yes", self.masternodeTwoAlias, True)
241248
assert_equal(voteResult["detail"][0]["result"], "success")
242249

250+
# check orphan vote proposal re-sync
251+
self.log.info("checking orphan vote based proposal re-sync...")
252+
time.sleep(5) # wait a bit before check it
253+
self.check_proposal_existence(firstProposal.name, firstProposal.proposalHash)
254+
self.check_vote_existence(firstProposal.name, self.mnOneCollateral.hash, "YES", True)
255+
self.log.info("all good, orphan vote based proposal re-sync succeeded")
256+
243257
# check that the vote was accepted everywhere
244258
self.stake(1, [self.remoteOne, self.remoteTwo])
245259
self.check_vote_existence(firstProposal.name, self.mnTwoCollateral.hash, "YES", True)
@@ -288,22 +302,38 @@ def run_test(self):
288302
self.check_budget_finalization_sync(0, "OK")
289303

290304
self.log.info("budget finalization synced!, now voting for the budget finalization..")
305+
# Connecting owner to all the other nodes.
306+
self.connect_to_all(self.ownerOnePos)
291307

292308
voteResult = self.ownerOne.mnfinalbudget("vote-many", budgetFinHash, True)
293309
assert_equal(voteResult["detail"][0]["result"], "success")
310+
time.sleep(2) # wait a bit
311+
self.stake(2, [self.remoteOne, self.remoteTwo])
312+
self.check_budget_finalization_sync(1, "OK")
294313
self.log.info("Remote One voted successfully.")
314+
315+
# before broadcast the second finalization vote, let's drop the budget data of remoteOne.
316+
# so the node is forced to send a single fin sync when the, now orphan, vote is received.
317+
self.log.info("Testing single fin re-sync based on an orphan vote, dropping budget data...")
318+
self.remoteOne.cleanbudget(try_sync=False)
319+
assert_equal(self.remoteOne.getbudgetprojection(), []) # empty
320+
assert_equal(self.remoteOne.getbudgetinfo(), [])
321+
322+
# vote for finalization with MN2 and the DMN
295323
voteResult = self.ownerTwo.mnfinalbudget("vote-many", budgetFinHash, True)
296324
assert_equal(voteResult["detail"][0]["result"], "success")
297325
self.log.info("Remote Two voted successfully.")
298326
voteResult = self.remoteDMN1.mnfinalbudget("vote", budgetFinHash)
299327
assert_equal(voteResult["detail"][0]["result"], "success")
300328
self.log.info("DMN voted successfully.")
329+
time.sleep(2) # wait a bit
301330
self.stake(2, [self.remoteOne, self.remoteTwo])
302331

303332
self.log.info("checking finalization votes..")
304333
self.check_budget_finalization_sync(3, "OK")
334+
self.log.info("orphan vote based finalization re-sync succeeded")
305335

306-
self.stake(8, [self.remoteOne, self.remoteTwo])
336+
self.stake(6, [self.remoteOne, self.remoteTwo])
307337
addrInfo = self.miner.listreceivedbyaddress(0, False, False, firstProposal.paymentAddr)
308338
assert_equal(addrInfo[0]["amount"], firstProposal.amountPerCycle)
309339

@@ -341,9 +371,7 @@ def run_test(self):
341371
self.log.info("restarting node..")
342372
self.start_node(self.ownerTwoPos)
343373
self.ownerTwo.setmocktime(self.mocktime)
344-
for i in range(self.num_nodes):
345-
if i is not self.ownerTwoPos:
346-
self.connect_nodes_bi(self.nodes, self.ownerTwoPos, i)
374+
self.connect_to_all(self.ownerTwoPos)
347375
self.stake(2, [self.remoteOne, self.remoteTwo])
348376

349377
self.log.info("syncing node..")

0 commit comments

Comments
 (0)