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

test: stabilize acceptance tests and update local-node #2255

Merged
merged 18 commits into from
Apr 23, 2024

Conversation

georgi-l95
Copy link
Collaborator

@georgi-l95 georgi-l95 commented Mar 28, 2024

Description:
This PR aims to update local node version to latest and utilize the modulirezed codebase version of the network node, as well as refactor most of the acceptance tests, because now network node is more heavy and this makes the tests flaky. SDKs are timing out, probably due to not enough resources.

  1. Remove unused and re-arange all used imports according to JS conventions.
  2. Changes to before logic of the index.spec.ts:
  • Creates on Inital Account using the SDK, which will be responsible for creating other accounts.
  1. Changes to before logic of the index.spec.ts:
  • Adds logic to refund all HBars back from all created accounts back to operator, to minimize expenses and provide more correct spent amount.
  1. Rework before of most of the tests to add optimizations, rely less on SDKs and more on the relay itself.
  2. Modifies eth_sendRawTransaction to retry on certain errors, like Timeout or connection dropped. Retyring triggers the flow of creating new instance of the SDK Client, which should mitigate the issues we face with the new local-node versions and more specifically when Client is configured to point against only one node.
  3. Updates SDK and Local-node version to latests.

Positives:

  • Faster tests, because we don't used so ofter the SDKs and that means that we don't need to explicitly wait for changes to be propagated to mirror node. Some tests are more than a minute faster.
  • We rely more on the relay itself, which is the object of our tests here.

Related issue(s):

Fixes #2309
Fixes #2341

Notes for reviewer:
This will not fix the issues with the SDK itself and how we handle timeout. This will be done in the next PR to avoid many changes at once. Main aim here is to update to the latest modularization code base and make use of the tests.

Checklist

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

Copy link

github-actions bot commented Mar 28, 2024

Tests

    2 files  147 suites   13s ⏱️
815 tests 814 ✔️ 1 💤 0
827 runs  826 ✔️ 1 💤 0

Results for commit 82f9370.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.15%. Comparing base (f5d8a48) to head (619406e).
Report is 18 commits behind head on main.

❗ Current head 619406e differs from pull request most recent head 3c26881. Consider uploading reports for the commit 3c26881 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2255   +/-   ##
=======================================
  Coverage   75.15%   75.15%           
=======================================
  Files          13       13           
  Lines         644      644           
  Branches      118      118           
=======================================
  Hits          484      484           
  Misses        115      115           
  Partials       45       45           

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

@georgi-l95 georgi-l95 self-assigned this Mar 28, 2024
Copy link

github-actions bot commented Mar 28, 2024

Acceptance Tests

     24 files     581 suites   33m 30s ⏱️
   583 tests    571 ✔️   3 💤   9
2 339 runs  2 305 ✔️ 15 💤 19

Results for commit 82f9370.

♻️ This comment has been updated with latest results.

Nana-EC
Nana-EC previously approved these changes Mar 28, 2024
AlfredoG87
AlfredoG87 previously approved these changes Apr 2, 2024
Copy link
Collaborator

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM

AlfredoG87
AlfredoG87 previously approved these changes Apr 3, 2024
@georgi-l95 georgi-l95 marked this pull request as draft April 4, 2024 16:57
@georgi-l95 georgi-l95 linked an issue Apr 10, 2024 that may be closed by this pull request
@georgi-l95 georgi-l95 force-pushed the bump-local-node-version branch 3 times, most recently from f57c043 to 7831882 Compare April 12, 2024 07:37
@georgi-l95 georgi-l95 changed the title chore: update local node version test: stabilize acceptance tests and update local-node Apr 12, 2024
@georgi-l95 georgi-l95 force-pushed the bump-local-node-version branch 2 times, most recently from aa65ea2 to e2783fa Compare April 16, 2024 14:35
@georgi-l95 georgi-l95 marked this pull request as ready for review April 17, 2024 07:47
Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

Good effort on stabilization.
Left some comments on 1st pass

const contractExecuteResponse = await this.hapiService
.getSDKClient()
.submitEthereumTransaction(transactionBuffer, EthImpl.ethSendRawTransaction, requestIdPrefix);
const contractExecuteResponse = await this.sendRawTransactionWithRetry(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: Why are we retrying for sendRawTransaction vs leaving it on user client logic?
The challenge is here is there's balance implication to both the sender and the host.

@@ -101,7 +101,7 @@ export default class HAPIService {
const currentDateNow = Date.now();
this.initialTransactionCount = parseInt(process.env.HAPI_CLIENT_TRANSACTION_RESET!) || 0;
this.initialResetDuration = parseInt(process.env.HAPI_CLIENT_DURATION_RESET!) || 0;
this.initialErrorCodes = JSON.parse(process.env.HAPI_CLIENT_ERROR_RESET || '[50]');
this.initialErrorCodes = JSON.parse(process.env.HAPI_CLIENT_ERROR_RESET || '[21, 50]');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q:50 is INVALID_TRANSACTION_BODY and 21 is UNKNOWN
We should document these somewhere. Likely in configs README

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added to configuration.md


this.beforeAll(async () => {
requestId = Utils.generateRequestId();
const initialAccount: AliasAccount = global.accounts[0];
const initialAmount: string = '5000000000'; //50 Hbar
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should make this configureable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

const contractDeployer = await servicesNode.createAliasAccount(50, relay.provider, requestId);
BaseHTSContractAddress = await deployBaseHTSContract(contractDeployer.wallet);
const initialAccount: AliasAccount = global.accounts[0];
const initialAmount: string = '5000000000'; //50 Hbar
Copy link
Collaborator

Choose a reason for hiding this comment

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

make configureable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


global.accounts = new Array<AliasAccount>(initialAccount);
// wait 3 seconds to propagate to mirror node all needed changes.
await new Promise((r) => setTimeout(r, 3000));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: Why wait instead of poll.
Waiting can be problematic and hides failure reasons

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, you're right. Changed.

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Absolute wonderful work! Thanks a lot! I left comments and questions around!

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: update local node

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: set verbose to trace

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: bump service tag

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: add extra debug steps

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

chore: fix debug test

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

chore: fix debugging

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

chore: fix debugging

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

chore:test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: testing

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

chore: revert reset counts

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

fix: vlaue fiddle

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

add env logging

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

bump timeout

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

switch to full node

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

revert unnecessery changes

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

test

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 1

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 1

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix tests

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

remove only

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimize rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimization

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimize

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimizaitons

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

more optimizations and code smells

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimization

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

adds JSDocs

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

last optimizations to rpc_batch1

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rateLimiter.spec.ts

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimize htsPrecompile_v1.spec.ts

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimize precompileCalls

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

revert

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix precompileCall

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimize rpc_batch2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimize rpc_batch2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc_batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix precompileCalls

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

disable batch

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc_batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc_batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc_batch 2

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rpc batch 2 and 3

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix rate limiter

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

revert changes to retry script

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix tokenCreate

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: update local node

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: update sdk

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

rework ws acceptance tests

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

add logger

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

adjust websocket values

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

address comments

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

optimization

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix websocket tests

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix websocket tests

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

fix precompilecalls

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>

chore: add missing type

Signed-off-by: georgi-l95 <glazarov95@gmail.com>

apply more clear logic to condition

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
konstantinabl
konstantinabl previously approved these changes Apr 23, 2024
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Copy link

sonarcloud bot commented Apr 23, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

LGTM. Great work!

@quiet-node quiet-node merged commit c2867d5 into main Apr 23, 2024
29 of 30 checks passed
@quiet-node quiet-node deleted the bump-local-node-version branch April 23, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand HAPI Client to handle Timeout error Stabilize acceptance tests and update local node
9 participants