-
Notifications
You must be signed in to change notification settings - Fork 146
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
test: add additional tests for HIP-904 #17773
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17773 +/- ##
=========================================
Coverage 69.01% 69.01%
Complexity 23036 23036
=========================================
Files 2654 2654
Lines 99652 99652
Branches 10284 10284
=========================================
Hits 68777 68777
Misses 26976 26976
Partials 3899 3899 |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
Signed-off-by: Lyuben Ivanov <[email protected]>
bb18d69
to
425403c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job so far.
Left a few comments for more verifications and one of the tests needs a bit more work to deploy contract with create2
final var hollowAccountKey = "hollowAccountKey"; | ||
final AtomicReference<ByteString> hollowAccountAlias = new AtomicReference<>(); | ||
|
||
return hapiTest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only airdrops to a hollow account. You can check Create2OperationSuite
to get a reference on how to do the create2 part with a hapi test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the description and the method name here were wrong, this test does not need create2 contract.
.call("tokenAirdrop", token, sender, receiver, 5L) | ||
.sending(85_000_000L) | ||
.gas(1_500_000L), | ||
receiver.getBalance().andAssert(balance -> balance.hasTokenBalance(token.name(), 0L)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also verify the PendingAirdrop from the record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add the including*PendingAirdrop
.via("AirdropTxn"), | ||
receiver.getBalance().andAssert(balance -> balance.hasTokenBalance(token1.name(), 0L)), | ||
receiver.getBalance().andAssert(balance -> balance.hasTokenBalance(token2.name(), 0L)), | ||
getTxnRecord("AirdropTxn").hasChildRecords(recordWith().pendingAirdropsCount(2))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also verify the PendingAirdrops apart from the counter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Lyuben Ivanov <[email protected]>
Signed-off-by: Lyuben Ivanov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a few more adjustments.
Try to be more explicit in the assertions and add comments if needed, this helps a lot with the reviews and understanding of what is being tested.
getTxnRecord("AirdropTxn").hasChildRecords(recordWith().pendingAirdropsCount(2)), | ||
getTxnRecord("AirdropTxn") | ||
.hasChildRecords(recordWith() | ||
.pendingAirdrops(includingFungiblePendingAirdrop( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to get the record again, you can just chain the pending checks
.call("tokenAirdrop", token, sender, receiver, 5L) | ||
.sending(85_000_000L) | ||
.gas(1_500_000L), | ||
receiver.getBalance().andAssert(balance -> balance.hasTokenBalance(token.name(), 0L)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add the including*PendingAirdrop
.sending(85_000_000L) | ||
.gas(1_500_000L) | ||
.via("AirdropTxn"), | ||
getTxnRecord("AirdropTxn").hasChildRecords(recordWith().pendingAirdropsCount(1)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
.sending(85_000_000L) | ||
.gas(1_500_000L) | ||
.via("AirdropTxn"), | ||
getTxnRecord("AirdropTxn").hasChildRecords(recordWith().pendingAirdropsCount(1)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
.sending(85_000_000L) | ||
.gas(1_500_000L) | ||
.via("AirdropTxn"), | ||
getTxnRecord("AirdropTxn").hasChildRecords(recordWith().pendingAirdropsCount(0)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use different transaction ids as this might result in race conditions and leaky tests
token.treasury().transferUnitsTo(sender2, 10L, token)); | ||
allRunFor( | ||
spec, | ||
airdropContract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it should be only one airdrop with multiple senders and receivers.
You can check the multiAirdrops()
tests in AirdropToContractSystemContractTest
.call("tokenAirdrop", token, sender, receiver, 1L) | ||
.sending(85_000_000L) | ||
.gas(1_500_000L) | ||
.via("AirdropTxn"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the transaction ids should be different
Description:
Tests from the Airdrop to Contract test plan - 8, 9, 11, 12
Related issue(s):
Fixes #
#16269
#16270
#16272
#16273
Notes for reviewer:
Checklist