Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal changes #1577

Merged
merged 15 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4247,7 +4247,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
if (obj.context.size() > MAX_PROP_CONTEXT_SIZE)
return Res::Err("proposal context cannot be more than %d bytes", MAX_PROP_CONTEXT_SIZE);

if (obj.contexthash.size() > MAX_PROP_CONTEXT_SIZE)
if (obj.contextHash.size() > MAX_PROP_CONTEXT_SIZE)
return Res::Err("proposal context hash cannot be more than %d bytes", MAX_PROP_CONTEXT_SIZE);

if (obj.nCycles < 1 || obj.nCycles > MAX_CYCLES)
Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/proposals.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct CCreatePropMessage {
uint8_t nCycles;
std::string title;
std::string context;
std::string contexthash;
std::string contextHash;
uint8_t options;

ADD_SERIALIZE_METHODS;
Expand All @@ -65,7 +65,7 @@ struct CCreatePropMessage {
READWRITE(nCycles);
READWRITE(title);
READWRITE(context);
READWRITE(contexthash);
READWRITE(contextHash);
READWRITE(options);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/rpc_customtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class CCustomTxRpcVisitor
finalHeight += votingPeriod;
}
}
rpcInfo.pushKV("finalizeAfter", int64_t(finalHeight));
rpcInfo.pushKV("endHeight", int64_t(finalHeight));
rpcInfo.pushKV("payoutAddress", ScriptToString(obj.address));
if (obj.options)
{
Expand Down
22 changes: 11 additions & 11 deletions src/masternodes/rpc_proposals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ UniValue propToJSON(CPropId const& propId, CPropObject const& prop)
ret.pushKV("proposalId", propId.GetHex());
ret.pushKV("title", prop.title);
ret.pushKV("context", prop.context);
ret.pushKV("contexthash", prop.contexthash);
ret.pushKV("contextHash", prop.contextHash);
auto type = static_cast<CPropType>(prop.type);
ret.pushKV("type", CPropTypeToString(type));
auto status = static_cast<CPropStatusType>(prop.status);
ret.pushKV("status", CPropStatusToString(status));
ret.pushKV("amount", ValueFromAmount(prop.nAmount));
ret.pushKV("nextCycle", static_cast<int32_t>(prop.cycle));
ret.pushKV("currentCycle", static_cast<int32_t>(prop.cycle));
ret.pushKV("totalCycles", static_cast<int32_t>(prop.nCycles));
ret.pushKV("finalizeAfter", static_cast<int32_t>(prop.finalHeight));
ret.pushKV("endHeight", static_cast<int32_t>(prop.finalHeight));
ret.pushKV("payoutAddress", ScriptToString(prop.address));
if (prop.options)
{
Expand Down Expand Up @@ -92,7 +92,7 @@ UniValue creategovcfp(const JSONRPCRequest& request)

CAmount amount;
int cycles = 1;
std::string title, context, contexthash, addressStr;
std::string title, context, contextHash, addressStr;

const UniValue& data = request.params[0].get_obj();

Expand All @@ -109,7 +109,7 @@ UniValue creategovcfp(const JSONRPCRequest& request)
}

if (!data["contextHash"].isNull())
contexthash = data["contextHash"].get_str();
contextHash = data["contextHash"].get_str();

if (!data["cycles"].isNull())
cycles = data["cycles"].get_int();
Expand Down Expand Up @@ -139,7 +139,7 @@ UniValue creategovcfp(const JSONRPCRequest& request)
pm.nCycles = cycles;
pm.title = title;
pm.context = context;
pm.contexthash = contexthash;
pm.contextHash = contextHash;
pm.options = 0;

// encode
Expand Down Expand Up @@ -223,7 +223,7 @@ UniValue creategovvoc(const JSONRPCRequest& request)

RPCTypeCheck(request.params, { UniValue::VOBJ, UniValue::VARR }, true);

std::string title, context, contexthash;
std::string title, context, contextHash;
bool emergency = false;

const UniValue& data = request.params[0].get_obj();
Expand All @@ -241,7 +241,7 @@ UniValue creategovvoc(const JSONRPCRequest& request)
}

if (!data["contextHash"].isNull())
contexthash = data["contextHash"].get_str();
contextHash = data["contextHash"].get_str();

if (!data["emergency"].isNull())
{
Expand All @@ -254,7 +254,7 @@ UniValue creategovvoc(const JSONRPCRequest& request)
pm.nCycles = (emergency ? 1 : VOC_CYCLES);
pm.title = title;
pm.context = context;
pm.contexthash = contexthash;
pm.contextHash = contextHash;
pm.options = (emergency ? CPropOption::Emergency : 0);

// encode
Expand Down Expand Up @@ -554,8 +554,8 @@ UniValue getgovproposal(const JSONRPCRequest& request)
ret.pushKV("proposalId", propId.GetHex());
ret.pushKV("title", prop->title);
ret.pushKV("context", prop->context);
if (!prop->contexthash.empty())
ret.pushKV("contexthash", prop->contexthash);
if (!prop->contextHash.empty())
ret.pushKV("contexthash", prop->contextHash);
dcorral marked this conversation as resolved.
Show resolved Hide resolved
auto type = static_cast<CPropType>(prop->type);
ret.pushKV("type", CPropTypeToString(type));

Expand Down
16 changes: 8 additions & 8 deletions test/functional/feature_on_chain_government.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ def run_test(self):
assert_equal(result[0]["type"], "CommunityFundProposal")
assert_equal(result[0]["status"], "Voting")
assert_equal(result[0]["amount"], Decimal("100"))
assert_equal(result[0]["nextCycle"], 1)
assert_equal(result[0]["currentCycle"], 1)
assert_equal(result[0]["totalCycles"], 2)
assert_equal(result[0]["payoutAddress"], address)
assert_equal(result[0]["finalizeAfter"], finalHeight)
assert_equal(result[0]["endHeight"], finalHeight)

# Check individual MN votes
results = self.nodes[1].listgovvotes(tx, mn0)
Expand Down Expand Up @@ -192,7 +192,7 @@ def run_test(self):

# Check first cycle length
result = self.nodes[0].listgovproposals()
assert_equal(result[0]['nextCycle'], 1)
assert_equal(result[0]['currentCycle'], 1)

# Move to cycle payout
self.nodes[0].generate(1)
Expand All @@ -202,7 +202,7 @@ def run_test(self):
blockcount = self.nodes[0].getblockcount()

# Actually moved to next cycle at cycle1
assert_equal(result[0]['nextCycle'], 2)
assert_equal(result[0]['currentCycle'], 2)
assert_equal(blockcount, cycle1)

# First cycle should last for at least a votingPeriod
Expand All @@ -215,7 +215,7 @@ def run_test(self):
assert_equal(self.nodes[1].getaccount(address), ['100.00000000@DFI'])
result = self.nodes[0].listgovproposals()[0]
assert_equal(result["status"], "Voting")
assert_equal(result["nextCycle"], 2)
assert_equal(result["currentCycle"], 2)

# Move to just before final height
self.nodes[0].generate(finalHeight - self.nodes[0].getblockcount() - 1)
Expand Down Expand Up @@ -337,10 +337,10 @@ def run_test(self):
assert_equal(result[0]["type"], "CommunityFundProposal")
assert_equal(result[0]["status"], "Voting")
assert_equal(result[0]["amount"], Decimal("50"))
assert_equal(result[0]["nextCycle"], 1)
assert_equal(result[0]["currentCycle"], 1)
assert_equal(result[0]["totalCycles"], 2)
assert_equal(result[0]["payoutAddress"], address)
assert_equal(result[0]["finalizeAfter"], finalHeight)
assert_equal(result[0]["endHeight"], finalHeight)

# Check individual MN votes
results = self.nodes[1].listgovvotes(propId, mn0)
Expand Down Expand Up @@ -379,7 +379,7 @@ def run_test(self):
assert_equal(self.nodes[1].getaccount(address), ['100.00000000@DFI'])
result = self.nodes[0].getgovproposal(propId)
assert_equal(result["status"], "Voting")
assert_equal(result["nextCycle"], 2)
assert_equal(result["currentCycle"], 2)
dcorral marked this conversation as resolved.
Show resolved Hide resolved

# Move to just before final height
self.nodes[0].generate(finalHeight - self.nodes[0].getblockcount() - 1)
Expand Down