From efa644f28ebff71c000b5742fd1c89537c9b4a68 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 11 Aug 2018 08:21:32 +0200 Subject: [PATCH] Add some rewards tests --- qa/rpc-tests/cryptoconditions.py | 10 +++++++++- src/cc/rewards.cpp | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py index 420cddf31..57befe997 100755 --- a/qa/rpc-tests/cryptoconditions.py +++ b/qa/rpc-tests/cryptoconditions.py @@ -161,8 +161,9 @@ class CryptoConditionsTest (BitcoinTestFramework): assert_equal(result['CCaddress'], 'RCRsm3VBXz8kKTsYaXKpy7pSEzrtNNQGJC') assert_equal(result['tokenid'], self.pubkey) + # this is not a valid assetid result = rpc.tokeninfo(self.pubkey) - assert_equal(result['result'], 'success') + assert_equal(result['result'], 'error') def run_rewards_tests(self): rpc = self.nodes[0] @@ -174,6 +175,13 @@ class CryptoConditionsTest (BitcoinTestFramework): for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress', 'CCaddress']: assert_equal(result[x][0], 'R') + # no rewards yet + result = rpc.rewardslist() + assert_equal(result, []) + + # looking up non-existent reward should return error + result = rpc.rewardsinfo("none") + assert_equal(result['result'], 'error') def run_test (self): print("Mining blocks...") diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 896284245..083133eca 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -371,12 +371,14 @@ UniValue RewardsInfo(uint256 rewardsid) if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 ) { fprintf(stderr,"cant find fundingtxid\n"); + result.push_back(Pair("result","error")); result.push_back(Pair("error","cant find fundingtxid")); return(result); } if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) == 0 ) { fprintf(stderr,"fundingtxid isnt rewards creation txid\n"); + result.push_back(Pair("result","error")); result.push_back(Pair("error","fundingtxid isnt rewards creation txid")); return(result); }