Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceptance tests for token allowance amounts #6592

Merged
merged 15 commits into from
Aug 11, 2023

Conversation

jascks
Copy link
Contributor

@jascks jascks commented Aug 4, 2023

Description:
With the implementation of #3576 completed, implement acceptance tests around the new functionality provided, namely crypto and token allowance definition and that approved crypto/fungible token transfers are properly reflected in the allowance balances.

  • Create fungible token and allowance defining appropriate owner and spender IDs.
  • Verify existence and expected configuration via mirror node rest api
  • Perform fungible token transfer, both approved utilizing the owner and spender as expected, as well as other scenarios that should not affect the allowance balances.
  • Refer to code recently added to clean up and recover HBARs spent

Related issue(s):

Fixes #6553

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.12% 🎉

Comparison is base (e90ec06) 92.57% compared to head (364695f) 92.70%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6592      +/-   ##
============================================
+ Coverage     92.57%   92.70%   +0.12%     
+ Complexity     6503     6392     -111     
============================================
  Files           841      823      -18     
  Lines         27348    27079     -269     
  Branches       3126     3104      -22     
============================================
- Hits          25318    25104     -214     
+ Misses         1319     1270      -49     
+ Partials        711      705       -6     

see 20 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jascks jascks force-pushed the 6553-acceptance-tests-for-remaining-allowances-tokens branch from 886a05c to dc0ed60 Compare August 7, 2023 15:10
@jascks jascks marked this pull request as ready for review August 7, 2023 16:49
@jascks jascks requested a review from a team August 7, 2023 16:49
@jascks jascks self-assigned this Aug 7, 2023
@steven-sheehy steven-sheehy added this to the 0.87.0 milestone Aug 7, 2023
@steven-sheehy steven-sheehy added enhancement Type: New feature test Test infrastructure, automated tests required, etc labels Aug 7, 2023
Jeff Schmidt added 14 commits August 9, 2023 13:41
…_NOT_HAVE_ALLOWANCE problem.

Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
…scenario.

Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
…e tokens and accounts to get feedback.

Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
…wner transfer affecting allowance.

Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
…ng with mirror node API.

Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
If key is DER encoded, PrivateKey can figure out the algorithm.

Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
@jascks jascks force-pushed the 6553-acceptance-tests-for-remaining-allowances-tokens branch from cd22331 to 7e2d6bf Compare August 9, 2023 19:42
Signed-off-by: Jeff Schmidt <jeffrey.schmidt@swirldslabs.com>
@sonarcloud
Copy link

sonarcloud bot commented Aug 11, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Collaborator

@xin-hedera xin-hedera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@steven-sheehy steven-sheehy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Collections.emptyList());
@Given("I ensure token {string} has been created")
public void createNamedToken(String tokenName) {
// If just now created, then ensure transaction has been seen by mirror node and receipt was available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually ensure that the transaction has been seen by mirror node, just consensus nodes, right? Does it need to to avoid race conditions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh... Yes, this is only an interaction with the consensus nodes (HAPI). My comment is a lie! While that did appear to solve the issue, it could become problematic again.

When using the named token mechanism (TokenClient.getToken()) the token may or may not be created. So there may or may not be a transaction. Instead, in this step, after calling getToken() the mirror node API should be invoked to ensure the token exists (/api/v1/tokens?token.id=<tokenId>) with the standard retry template retrying 404.

Does that make sense? I can create a new ticket and PR to address this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just ensure the transaction is present on mirror node

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue #6648, opened PR #6649.

@jascks jascks merged commit 15239ab into main Aug 11, 2023
26 of 28 checks passed
@jascks jascks deleted the 6553-acceptance-tests-for-remaining-allowances-tokens branch August 11, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature test Test infrastructure, automated tests required, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Acceptance tests for remaining crypto and token allowance amounts
3 participants