-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fix more tests in ContractCallServiceTests #10382
base: main
Are you sure you want to change the base?
Fix more tests in ContractCallServiceTests #10382
Conversation
…iceTests Signed-off-by: Nikolay Nikolov <[email protected]>
Signed-off-by: Nikolay Nikolov <[email protected]>
Signed-off-by: Nikolay Nikolov <[email protected]>
ContractCallServiceTests
ContractCallServiceTests
Signed-off-by: Nikolay Nikolov <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10382 +/- ##
============================================
+ Coverage 92.19% 92.29% +0.09%
+ Complexity 8111 8009 -102
============================================
Files 989 971 -18
Lines 33758 33509 -249
Branches 4268 4247 -21
============================================
- Hits 31124 30926 -198
+ Misses 1617 1571 -46
+ Partials 1017 1012 -5 ☔ View full report in Codecov by Sentry. |
@@ -133,6 +134,20 @@ protected void setup() { | |||
treasuryEntity.getCreatedTimestamp(), treasuryEntity.toEntityId())) | |||
.balance(treasuryEntity.getBalance())) | |||
.persist(); | |||
domainBuilder |
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 and the next account is needed only only in a couple of tests in ContractCallServiceTest
. We don't need to initialize them in every test. We can add them only in the needed tests.
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
} | ||
if (exceptionToThrow != null) { |
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 don't need to do this separately. A finally block is guaranteed to execute no matter if an exception is thrown.
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
Signed-off-by: Nikolay Nikolov <[email protected]>
…ll-services-test # Conflicts: # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/TransactionExecutionService.java
@@ -82,7 +82,8 @@ public HederaEvmTransactionProcessingResult execute( | |||
TransactionBody transactionBody; | |||
HederaEvmTransactionProcessingResult result = null; | |||
if (isContractCreate) { | |||
transactionBody = buildContractCreateTransactionBody(params, estimatedGas, maxLifetime); | |||
transactionBody = buildContractCreateTransactionBody( | |||
params, estimatedGas, maxLifetime, mirrorNodeEvmProperties.getContractCreateTxFee()); |
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 4th parameter is always the same value, so it can be used in buildContractCreateTransactionBody()
directly.
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
@@ -142,15 +142,21 @@ void cleanup() { | |||
|
|||
protected long gasUsedAfterExecution(final ContractExecutionParameters serviceParameters) { | |||
try { | |||
return contractExecutionService.callContract(serviceParameters).getGasUsed(); | |||
if (mirrorNodeEvmProperties.isModularizedServices()) { |
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 if and the else are the same statement. Can be simplified.
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
@@ -140,6 +140,9 @@ public class MirrorNodeEvmProperties implements EvmProperties { | |||
@Min(21_000L) | |||
private long maxGasLimit = 15_000_000L; | |||
|
|||
@Getter | |||
private long contractCreateTxFee = 100_000_000L; |
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.
Does this really need to be a property? I am not sure if this needs to be configurable. I think a constant in the TransactionExecutionService
should be enough.
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.
we don't need it, removed
@@ -152,7 +156,9 @@ private void restoreGasToBucket(HederaEvmTransactionProcessingResult result, lon | |||
// of the gasLimit value back in the bucket. | |||
final var gasLimitToRestoreBaseline = | |||
(long) (Math.floorDiv(gasLimit, gasUnit) * throttleProperties.getGasLimitRefundPercent() / 100f); | |||
if (!result.isSuccessful() && gasLimit == result.getGasUsed()) { | |||
if (result == null) { |
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 if and the else-if can be combined since their body is the same.
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
@@ -145,7 +146,7 @@ private HederaEvmTransactionProcessingResult handleFailedResult( | |||
var detail = maybeDecodeSolidityErrorStringToReadableMessage(errorMessage); | |||
updateErrorGasUsedMetric(gasUsedCounter, result.gasUsed(), 1); | |||
if (ContractCallContext.get().getOpcodeTracerOptions() == null) { | |||
throw new MirrorEvmTransactionException(status.protoName(), detail, errorMessage.toHexString()); | |||
throw new MirrorEvmTransactionException(status.protoName(), detail, errorMessage.toHexString(), HederaEvmTransactionProcessingResult.failed(result.gasUsed(), 0L, 0L, Optional.empty(), Optional.empty())); |
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.
We already have the Optional.of(errorMessage)
- might as well pass it in the constructed result. Can become useful at some point.
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
@@ -116,7 +116,7 @@ protected void setup() { | |||
.entity() | |||
.customize(e -> e.id(2L) | |||
.num(2L) | |||
.balance(5000000000000000000L) | |||
.balance(1000000000000000000L) |
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.
We can add a comment here - to say that if a balance is set near the max value, some unexpected errors occur as the balance overflows the max value if we use the same account for the node operator. This might save us some headaches in the future to avoid the same issue.
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
Signed-off-by: Nikolay Nikolov <[email protected]>
|
Description:
This PR fixes some tests in
ContractCallServicesTests
Tests left to be fixed - 4
Related issue(s):
Related to #10087
Checklist