hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
280 stars 124 forks source link

Verify approval/allowance test case #2992

Open SimiHunjan opened 2 years ago

SimiHunjan commented 2 years ago

Problem

Please see the below scenario.

  1. Alice has given Bob an approval for 20 hbars. At that time, Bob had a balance of 100 hbars.
  2. Technically, Bob can spend 120 hbars now (100 of his own , and 20 from Alice’s account).
  3. Bob then transfers his 100 hbars to Carol.
  4. Now Bob has a balance of 0 and approval for 20.
  5. And Bob’s account comes up for auto-renewal.
  6. I am expecting that the auto-renewal for Bob will fail because he doesn’t have sufficient balance. Our auto-renewal logic will not automatically transfer the amount required for renewal (say 0.01 hbar) from Alice’s account to Bob’s account and then use that for auto-renewal.

Solution

Please verify or add test case for this scenario.

Alternatives

No response

SimiHunjan commented 2 years ago

cc: @atul-hedera

anighanta commented 2 years ago

Auto Renewal doesn't use any of the allowances. So atleast from top of my head I can say that this test will behave as you expected. Auto renewal fee is only debited from the Bobs account balance if any. Bobs MerkleAccount does't actually know that it has allowances granted by some other user as we dont have the backward lookup.

SimiHunjan commented 2 years ago

@anighanta can you please confirm this test is already part of the test suite?

netopyr commented 3 months ago

Auto-renewal is not implemented in modular code. Once it will be added again, we will also ensure there is a test for the scenario above.