Browse Source

Add some rewards tests

pull/4/head
Jonathan "Duke" Leto 6 years ago
parent
commit
efa644f28e
  1. 10
      qa/rpc-tests/cryptoconditions.py
  2. 2
      src/cc/rewards.cpp

10
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...")

2
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);
}

Loading…
Cancel
Save