Add some rewards tests
This commit is contained in:
@@ -161,8 +161,9 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
assert_equal(result['CCaddress'], 'RCRsm3VBXz8kKTsYaXKpy7pSEzrtNNQGJC')
|
assert_equal(result['CCaddress'], 'RCRsm3VBXz8kKTsYaXKpy7pSEzrtNNQGJC')
|
||||||
assert_equal(result['tokenid'], self.pubkey)
|
assert_equal(result['tokenid'], self.pubkey)
|
||||||
|
|
||||||
|
# this is not a valid assetid
|
||||||
result = rpc.tokeninfo(self.pubkey)
|
result = rpc.tokeninfo(self.pubkey)
|
||||||
assert_equal(result['result'], 'success')
|
assert_equal(result['result'], 'error')
|
||||||
|
|
||||||
def run_rewards_tests(self):
|
def run_rewards_tests(self):
|
||||||
rpc = self.nodes[0]
|
rpc = self.nodes[0]
|
||||||
@@ -174,6 +175,13 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress', 'CCaddress']:
|
for x in ['RewardsCCaddress', 'myCCaddress', 'Rewardsmarker', 'myaddress', 'CCaddress']:
|
||||||
assert_equal(result[x][0], 'R')
|
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):
|
def run_test (self):
|
||||||
print("Mining blocks...")
|
print("Mining blocks...")
|
||||||
|
|||||||
@@ -371,12 +371,14 @@ UniValue RewardsInfo(uint256 rewardsid)
|
|||||||
if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 )
|
if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"cant find fundingtxid\n");
|
fprintf(stderr,"cant find fundingtxid\n");
|
||||||
|
result.push_back(Pair("result","error"));
|
||||||
result.push_back(Pair("error","cant find fundingtxid"));
|
result.push_back(Pair("error","cant find fundingtxid"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) == 0 )
|
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");
|
fprintf(stderr,"fundingtxid isnt rewards creation txid\n");
|
||||||
|
result.push_back(Pair("result","error"));
|
||||||
result.push_back(Pair("error","fundingtxid isnt rewards creation txid"));
|
result.push_back(Pair("error","fundingtxid isnt rewards creation txid"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user