Skip to content

Commit

Permalink
Merge branch 'master' into proposal-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar authored Jan 16, 2023
2 parents aea3c0b + c905f30 commit af5b1d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/masternodes/rpc_proposals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,17 @@ void iterateProposals(const T &list,
size_t limit,
const uint8_t type,
const uint8_t status) {
bool pastStart = false;
for (const auto &prop : list) {
if (status && status != prop.second.status) {
continue;
}
if (type && type != prop.second.type) {
continue;
}
if (start != CProposalId{} && prop.first != start)
if (prop.first == start)
pastStart = true;
if (start != CProposalId{} && prop.first != start && !pastStart)
continue;
if (!including_start) {
including_start = true;
Expand Down
18 changes: 17 additions & 1 deletion test/functional/feature_on_chain_government.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ def run_test(self):
len(self.nodes[1].listgovproposalvotes({"proposalId": tx, "masternode": "all", "cycle": -1, "pagination": {"start": 0, "including_start": True, "limit": 0}})),
3)

# should return all entries if limit is 0
assert_equal(
len(self.nodes[1].listgovproposalvotes({"proposalId": tx, "masternode": "all", "cycle": -1, "pagination": {"start": 0, "including_start": False, "limit": 0}})),
2)

# should respect filters
assert_equal(len(self.nodes[1].listgovproposalvotes({"proposalId": tx, "masternode": mn1, "cycle": -1, "pagination": {"start": 0}})), 0)

Expand Down Expand Up @@ -662,5 +667,16 @@ def run_test(self):
assert_equal(self.nodes[0].listgovproposals({"status": "voting", "pagination": {"start": tx1, "including_start": True, "limit": 1}})[0]["proposalId"], tx1)
assert_equal(self.nodes[0].listgovproposals({"status": "voting", "pagination": {"start": tx3, "including_start": True, "limit": 1}})[0]["proposalId"], tx3)

allProposals = self.nodes[0].listgovproposals({"status": "voting"})
nextProposal = []
for i in range(len(allProposals)):
if allProposals[i]["proposalId"] == tx1:
if i < len(allProposals) - 1:
nextProposal = [allProposals[i + 1]]
# otherwise tx1 is the last proposal
break

assert_equal(self.nodes[0].listgovproposals({"status": "voting", "pagination": {"start": tx1, "including_start": False, "limit": 1}}), nextProposal)

if __name__ == '__main__':
OnChainGovernanceTest().main ()
OnChainGovernanceTest().main()

0 comments on commit af5b1d4

Please sign in to comment.