functional_tests: add item ownership checks

This commit is contained in:
Crypto City 2021-04-09 16:26:10 +00:00
parent 4e6eac5552
commit 2392c7d372

View File

@ -56,6 +56,7 @@ ITEM_LABOUR = 256
ITEM_FIREWOOD = 257
ITEM_FIRST_PATENT = 4096
ITEM_FIRST_FOOD = 1024
ITEM_FIRST_GEMSTONE = 2048
ITEM_FOOD_VEGETABLES = ITEM_FIRST_FOOD
ITEM_FOOD_GRAIN = ITEM_FIRST_FOOD + 1
ITEM_FOOD_MEAT = ITEM_FIRST_FOOD + 2
@ -170,6 +171,7 @@ class CCTest():
self.check_no_items()
self.check_predefined_items()
self.check_gold_consistency()
self.check_item_count_consistency()
self.test_get_new_nonces()
self.test_cc_account_creation()
self.check_gold_consistency()
@ -188,6 +190,7 @@ class CCTest():
self.test_giving()
self.test_discoveries()
self.check_gold_consistency()
self.check_item_count_consistency()
self.test_game_update()
self.test_revert()
self.check_gold_consistency()
@ -196,6 +199,7 @@ class CCTest():
self.test_runestones()
self.test_custom_items()
self.check_gold_consistency()
self.check_item_count_consistency()
self.test_mortgages()
self.check_gold_consistency()
self.test_badges()
@ -208,6 +212,7 @@ class CCTest():
self.test_minting()
self.check_gold_consistency()
self.test_farming()
self.check_item_count_consistency()
self.test_cities()
self.check_gold_consistency()
self.check_item_count_consistency()
@ -5132,7 +5137,19 @@ script {
if not is_group:
item_count = self.add_item(item_count, idx + ITEM_FIRST_USER, res.counts[idx])
assert item_balances == item_count, "expected " + str(item_balances) + ", got " + str(item_count)
item_supply = []
for item in range(280) + range(ITEM_FIRST_FOOD, ITEM_FIRST_FOOD + 32) + range(ITEM_FIRST_PATENT, ITEM_FIRST_PATENT + 256) + range(ITEM_FIRST_GEMSTONE, ITEM_FIRST_GEMSTONE + 16) + [x + ITEM_FIRST_USER for x in range(256)]:
res = daemon.cc_get_item_ownership(item)
if 'ownership' in res:
total = 0
for e in res.ownership:
assert e.amount > 0
total += e.amount
assert total == res.supply
item_supply = self.add_item(item_supply, item, total)
assert item_balances == item_count, "item_balances: expected " + str(item_balances) + ", got " + str(item_count) + ", supply " + str(item_supply)
assert item_supply == item_count, "item_supply: expected " + str(item_supply) + ", got " + str(item_count) + ", balances " + str(item_balances)
def test_reorg(self):
daemon = self.daemon