-
Notifications
You must be signed in to change notification settings - Fork 108
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
Remove data generator #2387
Remove data generator #2387
Conversation
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
.../hedera/mirror/monitor/publish/transaction/account/AccountUpdateTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...hedera/mirror/monitor/publish/transaction/account/CryptoTransferTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
class AccountCreateTransactionSupplierTest extends AbstractTransactionSupplierTest { | ||
|
||
@Test | ||
void createWithMinimumData() { |
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.
Should probably be Minimal
, no Minimum
Codecov Report
@@ Coverage Diff @@
## main #2387 +/- ##
============================================
+ Coverage 84.42% 90.69% +6.27%
- Complexity 2335 2424 +89
============================================
Files 440 419 -21
Lines 12018 11578 -440
Branches 1024 1009 -15
============================================
+ Hits 10146 10501 +355
+ Misses 1554 745 -809
- Partials 318 332 +14
Continue to review full report at Codecov.
|
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Will address code smells |
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
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.
Seems there were merge issue with copyrights details.
* | ||
* Hedera Mirror Node | ||
* | ||
* Copyright (C) 2019 - 2021 Hedera Hashgraph, LLC | ||
* Copyright (C) 2019 - 2020 Hedera Hashgraph, LLC |
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.
Fix year
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.
Fixed. I've removed the setup I had to add this automatically as it had all sorts of issues so this doesn't crop up again.
* | ||
* Hedera Mirror Node | ||
* | ||
* Copyright (C) 2019 - 2020 Hedera Hashgraph, LLC |
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.
Copy right repeated. Should also be 2021
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.
Fixed.
...test/java/com/hedera/mirror/monitor/publish/transaction/AbstractTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
hedera-mirror-monitor/src/test/java/com/hedera/mirror/monitor/util/UtilityTest.java
Outdated
Show resolved
Hide resolved
AccountCreateTransaction expected = new AccountCreateTransaction() | ||
.setAccountMemo(actual.getAccountMemo()) | ||
.setInitialBalance(ONE_TINYBAR) | ||
.setKey(key) | ||
.setMaxTransactionFee(ONE_TINYBAR) | ||
.setReceiverSignatureRequired(true) | ||
.setTransactionMemo(actual.getTransactionMemo()); | ||
|
||
assertAll( | ||
() -> assertThat(actual.getTransactionMemo()).contains("Mirror node created test account"), | ||
() -> assertThat(actual.getAccountMemo()).contains("Mirror node created test account"), | ||
() -> assertThat(actual).usingRecursiveComparison().isEqualTo(expected) | ||
); |
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.
I don't like creating a temporary object just do do equality on it. I'm also not a fan of assertAll
. It would be simpler to do a single chaining assert to verify results:
assertThat(actual)
.returns(key, AccountCreateTransaction::getKey)
.returns(ONE_TINYBAR, AccountCreateTransaction::getMaxTransactionFee)
...
You can chain non-equality assertions like contains using satisfies(a -> assertThat(a.get...())
or using extracting()
at the end.
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 thing I like about creating the temporary object and doing equality on it is it forces someone to set every field, it protects against future fields or some of the fields that aren't as explicit (like setting adminKey
in a supplier also gets used for submitKey
, freezeKey
, etc.). The other thing I'm running into as I've tried to convert over, TokenNftTransfer
is not a public class so I don't know of a great way to go field-by-field for that.
I do see the value in the chaining you mentioned, that can be done.
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.
That logic makes sense in general, but these SDK objects are quite complex and I'm not sure we want to rely on their internals being stable. They don't implement equals()
/hashCode()
to provide proper equality and they contain a lot of internal, non-settable fields like proto builders, node account IDs, signed transactions, signatures, etc. that should not be compared.
I don't think we're trying to validate quite to the level of every field. My intent with the ticket was just to test that the few fields we set are getting passed through. Validating everything might become brittle as the SDK changes things internally.
I've opened hashgraph/hedera-sdk-java#603 to address the TokenNftTransfer issue. If you see such minor issues with the SDK you can always just submit a PR to fix it.
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.
That's fair, I did have a to do something different with ScheduleCreate
for that reason, too many internal fields that I could not get a hold of to even set the expected
and all of the extra fields you mentioned. I'll work on swapping things over to just checking fields and will keep an eye out for other bugs.
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.
2.0.11 of sdk was released with my fix for public class.
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.
Reworked the tests to use the chaining suggested.
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
...irror-monitor/src/main/java/com/hedera/mirror/monitor/publish/PublishScenarioProperties.java
Outdated
Show resolved
Hide resolved
.../hedera/mirror/monitor/publish/transaction/account/AccountCreateTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
.satisfies(a -> assertThat(a.getAccountMemo()).contains("Mirror node created test account")) | ||
.satisfies(a -> assertThat(a.getKey()).isNotNull()) | ||
.satisfies(a -> assertThat(a.getTransactionMemo()).contains("Mirror node created test account")) | ||
.satisfies(a -> assertThat(a).usingRecursiveComparison().isEqualTo(expected)); |
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.
.satisfies(a -> assertThat(a).usingRecursiveComparison().isEqualTo(expected)); | |
.usingRecursiveComparison() | |
.isEqualTo(expected)); |
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.
Removed this line.
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
.../hedera/mirror/monitor/publish/transaction/account/AccountDeleteTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
.../hedera/mirror/monitor/publish/transaction/account/AccountDeleteTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
.../hedera/mirror/monitor/publish/transaction/account/AccountUpdateTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...hedera/mirror/monitor/publish/transaction/account/CryptoTransferTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...hedera/mirror/monitor/publish/transaction/account/CryptoTransferTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...hedera/mirror/monitor/publish/transaction/account/CryptoTransferTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...hedera/mirror/monitor/publish/transaction/account/CryptoTransferTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...ror/monitor/publish/transaction/consensus/ConsensusSubmitMessageTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
...ror/monitor/publish/transaction/consensus/ConsensusSubmitMessageTransactionSupplierTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
.extracting(TokenMintTransaction::getMetadata) | ||
.returns(2, List::size) | ||
.returns(14, metadataList -> metadataList.get(0).length) | ||
.returns(14, metadataList -> metadataList.get(1).length); |
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.
Haven't found a good chain to check this yet, if I cast it to a list in the extracting
it won't let me use returns
, which then I didn't see a great way to extract the length of each the byte array cleanly. Suggestions are welcome, this is the only test that hasn't been refactored.
.setAutoRenewPeriod(autoRenewPeriod) | ||
.setExpirationTime(expirationTime) |
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.
expirationTime
is coerced by the autoRenewPeriod
, if setExpirationTime
is called it also sets autoRenewPeriod
to null, so setting both does nothing. I'll have a separate PR to address this in a couple other spots I saw in other modules.
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.
LGTM
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.
LGTM
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.
LGTM
* Remove data generator (#2387) * Remove the data generator module and all references to it. * Move TransactionSuppliers and anything else needed by the monitor into the monitor module * Add unit tests for the TransactionSuppliers Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com> * Fix startDate logic on empty DB (#2421) * Fix startDate logic on empty DB The current MirrorDateRangePropertiesProcessor.newDateRangeFilter() currently doesn't honor the startDate set on an empty db - Update newDateRangeFilter() logic to handle case when there's no lastFileInstant - Add a test case to verify scenario Signed-off-by: Nana-EC <nana.essilfie-conduah@hedera.com> * Remove transactionMemo from TransactionSupplier and expirationTime from TokenClient (#2423) * Remove setting transactionMemo in TransactionSuppliers * Remove setting expirationTime in TokenClient Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com> * Fix rest service startup crash (#2425) - replace the one-time verifyDbConnection with on-demand transaction result & type loading Signed-off-by: Xin Li <xin.li@hedera.com> * Add missing token account association migration (#2424) - add a db migration script to add the missing token account associations Signed-off-by: Xin Li <xin.li@hedera.com> Co-authored-by: Ian Jungmann <ian.jungmann@hedera.com> Co-authored-by: Nana-EC <56320167+Nana-EC@users.noreply.github.com> Co-authored-by: Xin Li <59580070+xin-hedera@users.noreply.github.com>
Description:
Remove data generator module and add test cases for TransactionSuppliers
Related issue(s):
Fixes #2312
Checklist