mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
fix/tests: fix masternode payments
rpc, add tests (#5191)
## Issue being fixed or feature implemented it was picking the wrong DMN as a payee... ## What was done? see code and notes ## How Has This Been Tested? run tests ## Breaking Changes n/a ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation **For repository code-owners and collaborators only** - [x] I have assigned this pull request to a milestone
This commit is contained in:
parent
f12983cce7
commit
2b702f8e84
@ -461,7 +461,8 @@ static UniValue masternode_payments(const JSONRPCRequest& request)
|
||||
payeesArr.push_back(obj);
|
||||
}
|
||||
|
||||
const auto dmnPayee = deterministicMNManager->GetListForBlock(pindex).GetMNPayee();
|
||||
// NOTE: we use _previous_ block to find a payee for the current one
|
||||
const auto dmnPayee = deterministicMNManager->GetListForBlock(pindex->pprev).GetMNPayee();
|
||||
protxObj.pushKV("proTxHash", dmnPayee == nullptr ? "" : dmnPayee->proTxHash.ToString());
|
||||
protxObj.pushKV("amount", payedPerMasternode);
|
||||
protxObj.pushKV("payees", payeesArr);
|
||||
|
@ -66,6 +66,26 @@ class RPCMasternodeTest(DashTestFramework):
|
||||
assert_equal(gbt_masternode[i]["script"], payments_masternode["payees"][i]["script"])
|
||||
assert_equal(gbt_masternode[i]["amount"], payments_masternode["payees"][i]["amount"])
|
||||
|
||||
self.log.info("test that `masternode payments` results and `protx info` results match")
|
||||
# we expect some masternodes to have 0 operator reward and some to have non-0 operator reward
|
||||
checked_0_operator_reward = False
|
||||
checked_non_0_operator_reward = False
|
||||
while not checked_0_operator_reward or not checked_non_0_operator_reward:
|
||||
payments_masternode = self.nodes[0].masternode("payments")[0]["masternodes"][0]
|
||||
protx_info = self.nodes[0].protx("info", payments_masternode["proTxHash"])
|
||||
if len(payments_masternode["payees"]) == 1:
|
||||
assert_equal(protx_info["state"]["payoutAddress"], payments_masternode["payees"][0]["address"])
|
||||
checked_0_operator_reward = True
|
||||
else:
|
||||
assert_equal(len(payments_masternode["payees"]), 2)
|
||||
option1 = protx_info["state"]["payoutAddress"] == payments_masternode["payees"][0]["address"] and \
|
||||
protx_info["state"]["operatorPayoutAddress"] == payments_masternode["payees"][1]["address"]
|
||||
option2 = protx_info["state"]["payoutAddress"] == payments_masternode["payees"][1]["address"] and \
|
||||
protx_info["state"]["operatorPayoutAddress"] == payments_masternode["payees"][0]["address"]
|
||||
assert option1 or option2
|
||||
checked_non_0_operator_reward = True
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
self.log.info("test that `masternode outputs` show correct list")
|
||||
addr1 = self.nodes[0].getnewaddress()
|
||||
addr2 = self.nodes[0].getnewaddress()
|
||||
|
Loading…
Reference in New Issue
Block a user