-
Notifications
You must be signed in to change notification settings - Fork 143
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
refactor: enhance migration testing tool #17246
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mustafa Uzun <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17246 +/- ##
============================================
+ Coverage 67.41% 67.43% +0.02%
- Complexity 22063 22076 +13
============================================
Files 2585 2585
Lines 96408 96433 +25
Branches 10071 10073 +2
============================================
+ Hits 64992 65031 +39
+ Misses 27698 27682 -16
- Partials 3718 3720 +2
|
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 |
…2-enhance-migration-testing-tool
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
…2-enhance-migration-testing-tool
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[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.
Review and approve file platform-sdk/platform-apps/tests/MigrationTestingTool/build.gradle.kts
…2-enhance-migration-testing-tool # Conflicts: # platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/SwirldMain.java
Signed-off-by: Mustafa Uzun <[email protected]>
@@ -207,4 +209,9 @@ public PlatformMerkleStateRoot newMerkleStateRoot() { | |||
public BasicSoftwareVersion getSoftwareVersion() { | |||
return softwareVersion; | |||
} | |||
|
|||
@Override | |||
public Bytes encodeSystemTransaction(@NonNull StateSignatureTransaction transaction) { |
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.
Add final for the argument and nonnull annotation for the return type
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.
Added
@Override | ||
public void preHandle( | ||
@NonNull Event event, | ||
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransaction) { |
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.
Make all arguments final
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.
Refactored
@NonNull Event event, | ||
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransaction) { | ||
event.forEachTransaction(transaction -> { | ||
if (!transaction.isSystem() && isSystemTransaction(transaction.getApplicationTransaction())) { |
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 extract the isSystem() check as a separate code before the if statement and add a comment on top of it - about why we check whether it's the deprecated system transaction format
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.
Refactored
@@ -335,4 +355,18 @@ public int getVersion() { | |||
public int getMinimumSupportedVersion() { | |||
return ClassVersion.VIRTUAL_MAP; | |||
} | |||
|
|||
private void consumeSystemTransaction( | |||
final Transaction transaction, |
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.
Add nonnull annotations for all arguments
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.
Added
public static boolean isSystemTransaction(@NonNull final Bytes bytes) { | ||
final SerializableDataInputStream in = new SerializableDataInputStream(bytes.toInputStream()); | ||
|
||
try { |
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.
It might be performance heavy to try to serialize every transaction that is incoming with having a try/catch block. You can add a marker byte as @lpetrovic05 suggested in another PR.
import org.mockito.MockedStatic; | ||
import org.mockito.Mockito; | ||
|
||
public class MigrationTestingToolStateTest { |
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.
public can be removed
import org.mockito.Mockito; | ||
|
||
public class MigrationTestingToolStateTest { | ||
private static MigrationTestingToolState state; |
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.
Why do we need the state to be static?
Signed-off-by: Mustafa Uzun <[email protected]>
Description:
Enhance the migration testing tool to work with new transactions of bytes.
Related issue(s):
Fixes #16842
Notes for reviewer:
Checklist