Skip to content

Commit 107529b

Browse files
random-zebraFuzzbawls
authored andcommitted
Tests: check getbudgetinfo / getbudgetprojection updated output
Github-Pull: #2101 Rebased-From: a005fa7
1 parent 495c546 commit 107529b

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

test/functional/tiertwo_governance_sync_basic.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from test_framework.util import (
88
assert_equal,
99
assert_true,
10+
Decimal,
1011
)
1112

1213
import time
@@ -60,6 +61,39 @@ def check_vote_existence(self, proposalName, mnCollateralHash, voteType):
6061
found = True
6162
assert_true(found, "Error checking vote existence in node " + str(i))
6263

64+
def get_proposal_obj(self, Name, URL, Hash, FeeHash, BlockStart, BlockEnd,
65+
TotalPaymentCount, RemainingPaymentCount, PaymentAddress,
66+
Ratio, Yeas, Nays, Abstains, TotalPayment, MonthlyPayment,
67+
IsEstablished, IsValid, Allotted, TotalBudgetAllotted, IsInvalidReason = ""):
68+
obj = {}
69+
obj["Name"] = Name
70+
obj["URL"] = URL
71+
obj["Hash"] = Hash
72+
obj["FeeHash"] = FeeHash
73+
obj["BlockStart"] = BlockStart
74+
obj["BlockEnd"] = BlockEnd
75+
obj["TotalPaymentCount"] = TotalPaymentCount
76+
obj["RemainingPaymentCount"] = RemainingPaymentCount
77+
obj["PaymentAddress"] = PaymentAddress
78+
obj["Ratio"] = Ratio
79+
obj["Yeas"] = Yeas
80+
obj["Nays"] = Nays
81+
obj["Abstains"] = Abstains
82+
obj["TotalPayment"] = TotalPayment
83+
obj["MonthlyPayment"] = MonthlyPayment
84+
obj["IsEstablished"] = IsEstablished
85+
obj["IsValid"] = IsValid
86+
if IsInvalidReason != "":
87+
obj["IsInvalidReason"] = IsInvalidReason
88+
obj["Alloted"] = Allotted
89+
obj["TotalBudgetAlloted"] = TotalBudgetAllotted
90+
return obj
91+
92+
def check_budgetprojection(self, expected):
93+
for i in range(self.num_nodes):
94+
assert_equal(self.nodes[i].getbudgetprojection(), expected)
95+
self.log.info("Budget projection valid for node %d" % i)
96+
6397
def run_test(self):
6498
self.enable_mocktime()
6599
self.setup_2_masternodes_network()
@@ -106,7 +140,7 @@ def run_test(self):
106140
# let's wait a little bit and see if all nodes are sync
107141
time.sleep(1)
108142
self.check_proposal_existence(firstProposalName, proposalHash)
109-
self.log.info("proposal broadcast succeed!")
143+
self.log.info("proposal broadcast successful!")
110144

111145
# Proposal is established after 5 minutes. Mine 7 blocks
112146
# Proposal needs to be on the chain > 5 min.
@@ -131,6 +165,20 @@ def run_test(self):
131165
self.check_vote_existence(firstProposalName, self.mnTwoTxHash, "YES")
132166
self.log.info("all good, MN2 vote accepted everywhere!")
133167

168+
# Now check the budget
169+
blockStart = nextSuperBlockHeight
170+
blockEnd = blockStart + firstProposalCycles * 145
171+
TotalPayment = firstProposalAmountPerCycle * firstProposalCycles
172+
Allotted = firstProposalAmountPerCycle
173+
RemainingPaymentCount = firstProposalCycles
174+
expected_budget = [
175+
self.get_proposal_obj(firstProposalName, firstProposalLink, proposalHash, proposalFeeTxId, blockStart,
176+
blockEnd, firstProposalCycles, RemainingPaymentCount, firstProposalAddress, 1,
177+
2, 0, 0, Decimal(str(TotalPayment)), Decimal(str(firstProposalAmountPerCycle)),
178+
True, True, Decimal(str(Allotted)), Decimal(str(Allotted)))
179+
]
180+
self.check_budgetprojection(expected_budget)
181+
134182
# Quick block count check.
135183
assert_equal(self.ownerOne.getblockcount(), 276)
136184

@@ -164,6 +212,10 @@ def run_test(self):
164212

165213
self.log.info("budget proposal paid!, all good")
166214

215+
# Check that the proposal info returns updated payment count
216+
expected_budget[0]["RemainingPaymentCount"] -= 1
217+
self.check_budgetprojection(expected_budget)
218+
167219

168220

169221

0 commit comments

Comments
 (0)