Added more rewards CC tests
This commit is contained in:
@@ -280,7 +280,6 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
fundinfoactual = rpc.diceinfo(diceid)
|
fundinfoactual = rpc.diceinfo(diceid)
|
||||||
assert_equal(round(fundbalanceguess),round(float(fundinfoactual['funding'])))
|
assert_equal(round(fundbalanceguess),round(float(fundinfoactual['funding'])))
|
||||||
|
|
||||||
|
|
||||||
def run_token_tests(self):
|
def run_token_tests(self):
|
||||||
rpc = self.nodes[0]
|
rpc = self.nodes[0]
|
||||||
result = rpc.tokenaddress()
|
result = rpc.tokenaddress()
|
||||||
@@ -491,14 +490,31 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
result = rpc.rewardsinfo("none")
|
result = rpc.rewardsinfo("none")
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating rewards plan with name > 8 chars, should return error
|
||||||
|
result = rpc.rewardscreatefunding("STUFFSTUFF", "7777", "25", "0", "10", "10")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating rewards plan with 0 funding
|
||||||
|
result = rpc.rewardscreatefunding("STUFF", "0", "25", "0", "10", "10")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating rewards plan with 0 maxdays
|
||||||
|
result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "0")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating rewards plan with > 25% APR
|
||||||
|
result = rpc.rewardscreatefunding("STUFF", "7777", "30", "0", "10", "10")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating valid rewards plan
|
||||||
result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10")
|
result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10")
|
||||||
assert result['hex'], 'got raw xtn'
|
assert result['hex'], 'got raw xtn'
|
||||||
txid = rpc.sendrawtransaction(result['hex'])
|
fundingtxid = rpc.sendrawtransaction(result['hex'])
|
||||||
assert txid, 'got txid'
|
assert fundingtxid, 'got txid'
|
||||||
|
|
||||||
# confirm the above xtn
|
# confirm the above xtn
|
||||||
rpc.generate(1)
|
rpc.generate(1)
|
||||||
result = rpc.rewardsinfo(txid)
|
result = rpc.rewardsinfo(fundingtxid)
|
||||||
assert_success(result)
|
assert_success(result)
|
||||||
assert_equal(result['name'], 'STUFF')
|
assert_equal(result['name'], 'STUFF')
|
||||||
assert_equal(result['APR'], "25.00000000")
|
assert_equal(result['APR'], "25.00000000")
|
||||||
@@ -506,39 +522,38 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
assert_equal(result['maxseconds'], 864000)
|
assert_equal(result['maxseconds'], 864000)
|
||||||
assert_equal(result['funding'], "7777.00000000")
|
assert_equal(result['funding'], "7777.00000000")
|
||||||
assert_equal(result['mindeposit'], "10.00000000")
|
assert_equal(result['mindeposit'], "10.00000000")
|
||||||
assert_equal(result['fundingtxid'], txid)
|
assert_equal(result['fundingtxid'], fundingtxid)
|
||||||
|
|
||||||
# funding amount must be positive
|
# checking if new plan in rewardslist
|
||||||
result = rpc.rewardsaddfunding("STUFF", txid, "0")
|
result = rpc.rewardslist()
|
||||||
|
assert_equal(result[0], fundingtxid)
|
||||||
|
|
||||||
|
# creating reward plan with already existing name, should return error
|
||||||
|
result = rpc.rewardscreatefunding("STUFF", "7777", "25", "0", "10", "10")
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
result = rpc.rewardsaddfunding("STUFF", txid, "555")
|
# add funding amount must be positive
|
||||||
assert_success(result)
|
result = rpc.rewardsaddfunding("STUFF", fundingtxid, "-1")
|
||||||
fundingtxid = result['hex']
|
|
||||||
assert fundingtxid, "got funding txid"
|
|
||||||
|
|
||||||
result = rpc.rewardslock("STUFF", fundingtxid, "7")
|
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
# the previous xtn has not been broadcasted yet
|
# add funding amount must be positive
|
||||||
result = rpc.rewardsunlock("STUFF", fundingtxid)
|
result = rpc.rewardsaddfunding("STUFF", fundingtxid, "0")
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
# wrong plan name
|
# adding valid funding
|
||||||
result = rpc.rewardsunlock("SHTUFF", fundingtxid)
|
result = rpc.rewardsaddfunding("STUFF", fundingtxid, "555")
|
||||||
assert_error(result)
|
addfundingtxid = self.send_and_mine(result['hex'])
|
||||||
|
assert addfundingtxid, 'got funding txid'
|
||||||
|
|
||||||
txid = rpc.sendrawtransaction(fundingtxid)
|
# checking if funding added to rewardsplan
|
||||||
assert txid, 'got txid from sendrawtransaction'
|
result = rpc.rewardsinfo(fundingtxid)
|
||||||
|
assert_equal(result['funding'], "8332.00000000")
|
||||||
|
|
||||||
# confirm the xtn above
|
# trying to lock funds, locking funds amount must be positive
|
||||||
rpc.generate(1)
|
|
||||||
|
|
||||||
# amount must be positive
|
|
||||||
result = rpc.rewardslock("STUFF", fundingtxid, "-5")
|
result = rpc.rewardslock("STUFF", fundingtxid, "-5")
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
# amount must be positive
|
# trying to lock funds, locking funds amount must be positive
|
||||||
result = rpc.rewardslock("STUFF", fundingtxid, "0")
|
result = rpc.rewardslock("STUFF", fundingtxid, "0")
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
@@ -546,25 +561,26 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
result = rpc.rewardslock("STUFF", fundingtxid, "7")
|
result = rpc.rewardslock("STUFF", fundingtxid, "7")
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
# not working
|
# locking funds in rewards plan
|
||||||
#result = rpc.rewardslock("STUFF", fundingtxid, "10")
|
result = rpc.rewardslock("STUFF", fundingtxid, "10")
|
||||||
#assert_success(result)
|
assert_success(result)
|
||||||
#locktxid = result['hex']
|
locktxid = result['hex']
|
||||||
#assert locktxid, "got lock txid"
|
assert locktxid, "got lock txid"
|
||||||
|
|
||||||
# locktxid has not been broadcast yet
|
# locktxid has not been broadcast yet
|
||||||
#result = rpc.rewardsunlock("STUFF", locktxid)
|
result = rpc.rewardsunlock("STUFF", fundingtxid, locktxid)
|
||||||
#assert_error(result)
|
assert_error(result)
|
||||||
|
|
||||||
# broadcast xtn
|
# broadcast xtn
|
||||||
#txid = rpc.sendrawtransaction(locktxid)
|
txid = rpc.sendrawtransaction(locktxid)
|
||||||
#assert txid, 'got txid from sendrawtransaction'
|
assert txid, 'got txid from sendrawtransaction'
|
||||||
|
|
||||||
# confirm the xtn above
|
# confirm the xtn above
|
||||||
#rpc.generate(1)
|
rpc.generate(1)
|
||||||
|
|
||||||
#result = rpc.rewardsunlock("STUFF", locktxid)
|
# will not unlock since reward amount is less than tx fee
|
||||||
#assert_error(result)
|
result = rpc.rewardsunlock("STUFF", fundingtxid, locktxid)
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
|
||||||
def run_test (self):
|
def run_test (self):
|
||||||
|
|||||||
Reference in New Issue
Block a user