functional_tests: add tests for cc_is_invitation_used

This commit is contained in:
Crypto City 2021-07-07 14:13:19 +00:00
parent 7a6beb4b3c
commit 21676e11be

View File

@ -4290,11 +4290,22 @@ class CCTest():
invitation = res.invitation
assert len(invitation) > 0
# it's not used yet
res = daemon.cc_is_invitation_used(invitation)
assert not res.used
assert res.expiration == 0
assert not res.expired
assert res.balance_ok
# only the intended recipient can redeem
self.assert_exception(lambda: self.wallet[3].cc_redeem_account(invitation, "invited account with recipient"))
res = self.wallet[4].cc_redeem_account(invitation, "invited account with recipient")
self.generate_blocks('TF1MMBg4zx18SnZC6oswCRB7DzdVeUKce5NdCMSWUHNY4wNvNhzmFj4WqZY2bFj8R1REAWR3qAH5zD7sjXyHz3tVayzHSswqymx', 1)
# it's used now
res = daemon.cc_is_invitation_used(invitation)
assert res.used
self.wallet[4].refresh()
res = self.wallet[4].cc_get_info()
account_id = res.account_id
@ -4302,6 +4313,26 @@ class CCTest():
res = daemon.cc_get_account(account_id)
assert res.balance == 250000000
res = daemon.get_info()
height = res.height
res = self.wallet[2].cc_create_invitation(amount = 250000000, expiration = height + 2)
expiring_invitation = res.invitation
# it's not used yet
res = daemon.cc_is_invitation_used(expiring_invitation)
assert not res.used
assert res.expiration == height + 2
assert not res.expired
assert res.balance_ok
# mine two blocks and it's expired
self.generate_blocks('TF1MMBg4zx18SnZC6oswCRB7DzdVeUKce5NdCMSWUHNY4wNvNhzmFj4WqZY2bFj8R1REAWR3qAH5zD7sjXyHz3tVayzHSswqymx', 2)
res = daemon.cc_is_invitation_used(expiring_invitation)
assert not res.used
assert res.expiration == height + 2
assert res.expired
assert res.balance_ok
res = self.wallet[4].get_balance()
assert res.cc_balance == 250000000