Skip to content

Commit

Permalink
[Test] add mnwinner case for non-existent MN.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy authored and random-zebra committed Oct 30, 2021
1 parent e68773b commit 5aaa02a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ bool CMasternodePayments::ProcessMNWinner(CMasternodePaymentWinner& winner, CNod
// Only ask for missing items after the initial syncing process is complete
// otherwise will think a full sync succeeded when they return a result
if (pfrom && masternodeSync.IsSynced()) mnodeman.AskForMN(pfrom, winner.vinMasternode);
return state.Error("Invalid voter or voter mnwinner signature");
return state.Error("Non-existent mnwinner voter");
}
}
// either deterministic or legacy. not both
Expand Down
10 changes: 10 additions & 0 deletions src/test/mnpayments_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ BOOST_FIXTURE_TEST_CASE(mnwinner_test, TestChain100Setup)
std::vector<FakeMasternode> mnList = buildMNList(tipBlock.GetHash(), tipBlock.GetBlockTime(), 40);
std::vector<std::pair<int64_t, MasternodeRef>> mnRank = mnodeman.GetMasternodeRanks(nextBlockHeight - 100);

// Test mnwinner failure for non-existent MN voter.
CTxIn dummyVoter;
CScript dummyPayeeScript;
CKey dummyKey;
dummyKey.MakeNewKey(true);
CValidationState state0;
BOOST_CHECK(!CreateMNWinnerPayment(dummyVoter, nextBlockHeight, dummyPayeeScript,
dummyKey, dummyKey.GetPubKey(), state0));
BOOST_CHECK_MESSAGE(findStrError(state0, "Non-existent mnwinner voter"), state0.GetRejectReason());

// Take the first MN
auto firstMN = findMNData(mnList, mnRank[0].second);
CTxIn mnVinVoter(firstMN.mn.vin);
Expand Down

0 comments on commit 5aaa02a

Please sign in to comment.