tests adjusted for heirCC json enhancement
This commit is contained in:
@@ -34,21 +34,18 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
|
|
||||||
# getting empty heir list
|
# getting empty heir list
|
||||||
result = rpc.heirlist()
|
result = rpc.heirlist()
|
||||||
assert_equal(len(result), 1)
|
assert_equal(result, [])
|
||||||
assert_success(result)
|
|
||||||
|
|
||||||
# valid heirfund case with coins
|
# valid heirfund case with coins
|
||||||
result = rpc.heirfund("0", "1000", "UNITHEIR", self.pubkey1, "10")
|
result = rpc.heirfund("0", "1000", "UNITHEIR", self.pubkey1, "10", "TESTMEMO")
|
||||||
assert_success(result)
|
assert_success(result)
|
||||||
|
|
||||||
heir_fund_txid = self.send_and_mine(result["hextx"], rpc)
|
heir_fund_txid = self.send_and_mine(result["hex"], rpc)
|
||||||
assert heir_fund_txid, "got heir funding txid"
|
assert heir_fund_txid, "got heir funding txid"
|
||||||
|
|
||||||
# heir fund txid should be in heirlist now
|
# heir fund txid should be in heirlist now
|
||||||
result = rpc.heirlist()
|
result = rpc.heirlist()
|
||||||
assert_equal(len(result), 2)
|
assert_equal(result, [heir_fund_txid])
|
||||||
assert_success(result)
|
|
||||||
assert_equal(result["fundingtxid"], heir_fund_txid)
|
|
||||||
|
|
||||||
# checking heirinfo
|
# checking heirinfo
|
||||||
result = rpc.heirinfo(heir_fund_txid)
|
result = rpc.heirinfo(heir_fund_txid)
|
||||||
@@ -57,20 +54,20 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
assert_equal(result["name"], "UNITHEIR")
|
assert_equal(result["name"], "UNITHEIR")
|
||||||
assert_equal(result["owner"], self.pubkey)
|
assert_equal(result["owner"], self.pubkey)
|
||||||
assert_equal(result["heir"], self.pubkey1)
|
assert_equal(result["heir"], self.pubkey1)
|
||||||
assert_equal(result["funding total in coins"], "1000.00000000")
|
assert_equal(result["memo"], "TESTMEMO")
|
||||||
assert_equal(result["funding available in coins"], "1000.00000000")
|
assert_equal(result["lifetime"], "1000.00000000")
|
||||||
assert_equal(result["inactivity time setting, sec"], "10")
|
assert_equal(result["type"], "coins")
|
||||||
assert_equal(result["spending allowed for the heir"], "false")
|
assert_equal(result["InactivityTimeSetting"], "10")
|
||||||
|
assert_equal(result["InactivityTime"], "0")
|
||||||
# TODO: heirlist keys are duplicating now
|
assert_equal(result["IsHeirSpendingAllowed"], "false")
|
||||||
|
|
||||||
# waiting for 11 seconds to be sure that needed time passed for heir claiming
|
# waiting for 11 seconds to be sure that needed time passed for heir claiming
|
||||||
time.sleep(11)
|
time.sleep(11)
|
||||||
rpc.generate(1)
|
rpc.generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
result = rpc.heirinfo(heir_fund_txid)
|
result = rpc.heirinfo(heir_fund_txid)
|
||||||
assert_equal(result["funding available in coins"], "1000.00000000")
|
assert_equal(result["lifetime"], "1000.00000000")
|
||||||
assert_equal(result["spending allowed for the heir"], "true")
|
assert_equal(result["IsHeirSpendingAllowed"], "true")
|
||||||
|
|
||||||
# have to check that second node have coins to cover txfee at least
|
# have to check that second node have coins to cover txfee at least
|
||||||
rpc.sendtoaddress(rpc1.getnewaddress(), 1)
|
rpc.sendtoaddress(rpc1.getnewaddress(), 1)
|
||||||
@@ -84,7 +81,7 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
result = rpc1.heirclaim("0", "1000", heir_fund_txid)
|
result = rpc1.heirclaim("0", "1000", heir_fund_txid)
|
||||||
assert_success(result)
|
assert_success(result)
|
||||||
|
|
||||||
heir_claim_txid = self.send_and_mine(result["hextx"], rpc1)
|
heir_claim_txid = self.send_and_mine(result["hex"], rpc1)
|
||||||
assert heir_claim_txid, "got claim txid"
|
assert heir_claim_txid, "got claim txid"
|
||||||
|
|
||||||
# balance of second node after heirclaim should increase for 1000 coins - txfees
|
# balance of second node after heirclaim should increase for 1000 coins - txfees
|
||||||
@@ -96,7 +93,8 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
|
|
||||||
# no more funds should be available for claiming
|
# no more funds should be available for claiming
|
||||||
result = rpc.heirinfo(heir_fund_txid)
|
result = rpc.heirinfo(heir_fund_txid)
|
||||||
assert_equal(result["funding available in coins"], "0.00000000")
|
assert_equal(result["lifetime"], "1000.00000000")
|
||||||
|
assert_equal(result["available"], "0.00000000")
|
||||||
|
|
||||||
# creating tokens which we put to heir contract
|
# creating tokens which we put to heir contract
|
||||||
token_hex = rpc.tokencreate("TEST", "1", "TESTING")
|
token_hex = rpc.tokencreate("TEST", "1", "TESTING")
|
||||||
@@ -108,8 +106,8 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
assert_equal(result, 100000000)
|
assert_equal(result, 100000000)
|
||||||
|
|
||||||
# valid heir case with tokens
|
# valid heir case with tokens
|
||||||
token_heir_hex = rpc.heirfund("0", "100000000", "UNITHEIR", self.pubkey1, "10", token_txid)
|
token_heir_hex = rpc.heirfund("0", "100000000", "UNITHEIR", self.pubkey1, "10", "TESTMEMO", token_txid)
|
||||||
token_heir_txid = self.send_and_mine(token_heir_hex["hextx"], rpc)
|
token_heir_txid = self.send_and_mine(token_heir_hex["hex"], rpc)
|
||||||
assert token_heir_txid, "got txid of heirfund with tokens"
|
assert token_heir_txid, "got txid of heirfund with tokens"
|
||||||
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
@@ -121,24 +119,25 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
assert_equal(result["name"], "UNITHEIR")
|
assert_equal(result["name"], "UNITHEIR")
|
||||||
assert_equal(result["owner"], self.pubkey)
|
assert_equal(result["owner"], self.pubkey)
|
||||||
assert_equal(result["heir"], self.pubkey1)
|
assert_equal(result["heir"], self.pubkey1)
|
||||||
assert_equal(result["funding total in tokens"], "100000000")
|
assert_equal(result["lifetime"], "100000000")
|
||||||
assert_equal(result["funding available in tokens"], "100000000")
|
assert_equal(result["type"], "tokens")
|
||||||
assert_equal(result["inactivity time setting, sec"], "10")
|
assert_equal(result["InactivityTimeSetting"], "10")
|
||||||
assert_equal(result["spending allowed for the heir"], "false")
|
assert_equal(result["InactivityTime"], "0")
|
||||||
|
assert_equal(result["IsHeirSpendingAllowed"], "false")
|
||||||
|
|
||||||
# waiting for 11 seconds to be sure that needed time passed for heir claiming
|
# waiting for 11 seconds to be sure that needed time passed for heir claiming
|
||||||
time.sleep(11)
|
time.sleep(11)
|
||||||
rpc.generate(1)
|
rpc.generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
result = rpc.heirinfo(token_heir_txid)
|
result = rpc.heirinfo(token_heir_txid)
|
||||||
assert_equal(result["funding available in tokens"], "100000000")
|
assert_equal(result["lifetime"], "100000000")
|
||||||
assert_equal(result["spending allowed for the heir"], "true")
|
assert_equal(result["IsHeirSpendingAllowed"], "true")
|
||||||
|
|
||||||
# let's claim whole heir sum from second node
|
# let's claim whole heir sum from second node
|
||||||
result = rpc1.heirclaim("0", "100000000", token_heir_txid)
|
result = rpc1.heirclaim("0", "100000000", token_heir_txid)
|
||||||
assert_success(result)
|
assert_success(result)
|
||||||
|
|
||||||
heir_tokens_claim_txid = self.send_and_mine(result["hextx"], rpc1)
|
heir_tokens_claim_txid = self.send_and_mine(result["hex"], rpc1)
|
||||||
assert heir_tokens_claim_txid, "got claim txid"
|
assert heir_tokens_claim_txid, "got claim txid"
|
||||||
|
|
||||||
# claiming node should have correct token balance now
|
# claiming node should have correct token balance now
|
||||||
@@ -149,7 +148,8 @@ class CryptoconditionsHeirTest(CryptoconditionsTestFramework):
|
|||||||
|
|
||||||
# no more funds should be available for claiming
|
# no more funds should be available for claiming
|
||||||
result = rpc.heirinfo(token_heir_txid)
|
result = rpc.heirinfo(token_heir_txid)
|
||||||
assert_equal(result["funding available in tokens"], "0")
|
assert_equal(result["lifetime"], "100000000")
|
||||||
|
assert_equal(result["available"], "0")
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
print("Mining blocks...")
|
print("Mining blocks...")
|
||||||
|
|||||||
Reference in New Issue
Block a user