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

Refactor and reorganize integration tests in hedera-mirror-web3 module #8057

Closed
29 tasks done
IvanKavaldzhiev opened this issue Apr 9, 2024 · 2 comments
Closed
29 tasks done
Assignees
Labels
enhancement Type: New feature epic Type: Large user story that encompasses multiple tasks technical debt test Test infrastructure, automated tests required, etc web3 Area: Web3 API
Milestone

Comments

@IvanKavaldzhiev
Copy link
Contributor

IvanKavaldzhiev commented Apr 9, 2024

Problem

Currently all integrations tests in hedera-mirorr-web3 rely on a DB test setup, which is processed in ContractCallTestSetup, which creates a strong dependency between all test data. As a result if we change the ID of a single entity, for example, we might break an existing set of tests or see unexpected results. In addition maintenance and adding new tests with new test data would become harder and harder in the future.

Solution

Remove ContractCallTestSetup as a central database setup and refactor all integration tests to include their own test data and be self-sufficient without relying on an external setup. Each test should create their own entities and needed data, that would be discarded after the test execution.

Some extraction of ContractCallTestSetup logic into the separate integration tests, might be an option, but probably the best approach would be adding new DB test data for each separate test from scratch. Avoid extracting common entities and methods in a parent class, as eventually we would construct the same problem of a common big and complex class with DB setup.

We should rely on the existing DomainBuilder as much as possible and avoid hardcoding fields of the built entity if possible. We should use dynamic data and validate the test against it.

Also, research about web3j-solidity-gradle-plugin and web3j-gradle-plugin plugins and investigate if we can make a use of them in the refactor of web3 module integration tests

Alternatives

No response

Tasks

  1. enhancement web3
    kselveliev
  2. enhancement web3
    kselveliev
  3. enhancement technical debt test web3
    bilyana-gospodinova
  4. enhancement technical debt test web3
    kselveliev
  5. enhancement technical debt test web3
    bilyana-gospodinova
  6. enhancement technical debt test web3
    bilyana-gospodinova
  7. enhancement technical debt test web3
    nickeynikolovv
  8. enhancement technical debt test web3
    IvanKavaldzhiev
  9. enhancement technical debt test web3
    bilyana-gospodinova
  10. enhancement technical debt test web3
    kselveliev
  11. enhancement technical debt test web3
    kselveliev
  12. enhancement technical debt test web3
    kselveliev
  13. enhancement technical debt test web3
    kselveliev
  14. enhancement technical debt test web3
    bilyana-gospodinova
  15. enhancement technical debt test web3
    kselveliev
  16. enhancement test web3
    kselveliev
  17. enhancement test web3
    kselveliev
  18. duplicate enhancement test web3
  19. enhancement test web3
    bilyana-gospodinova
  20. enhancement technical debt test web3
    kselveliev
  21. enhancement test web3
    kselveliev
  22. enhancement technical debt test web3
    nickeynikolovv
  23. enhancement technical debt test web3
    nickeynikolovv
  24. enhancement technical debt test web3
    nickeynikolovv
  25. enhancement limechain technical debt web3
    kselveliev
  26. enhancement test web3
    bilyana-gospodinova
  27. enhancement technical debt test web3
    nickeynikolovv
  28. enhancement technical debt web3
    bilyana-gospodinova
  29. enhancement test web3
    bilyana-gospodinova
@IvanKavaldzhiev IvanKavaldzhiev added enhancement Type: New feature technical debt web3 Area: Web3 API work package Limechain Work package limechain Work planned for the LimeChain team labels Apr 9, 2024
@steven-sheehy
Copy link
Member

steven-sheehy commented Apr 9, 2024

In addition to separation of test data across tests, I would like to also see separation of test data between tests within a class. This should be done by generating test input instead of relying upon hard-coded, static data. With this approach, there should be zero static constants at the top shared between different tests even within a test class.

The general principle in mirror node is to use the DomainBuilder to generate as much as possible of the data, only overriding specific fields that are necessary for the test. That is, IDs should not be overridden and left random except if you need to link object B to object A by setting b.setA(a.getId()), which still uses dynamic data. Then the test output should be compared against the dynamically generated input for correctness.

@steven-sheehy steven-sheehy added epic Type: Large user story that encompasses multiple tasks and removed limechain Work planned for the LimeChain team labels Jul 7, 2024
@steven-sheehy steven-sheehy added this to the 0.111.0 milestone Jul 21, 2024
@steven-sheehy steven-sheehy added test Test infrastructure, automated tests required, etc and removed work package Limechain Work package labels Jul 21, 2024
@steven-sheehy steven-sheehy modified the milestones: 0.111.0, 0.105.0 Jul 21, 2024
@steven-sheehy steven-sheehy modified the milestones: 0.105.0, 0.114.0 Sep 15, 2024
@steven-sheehy
Copy link
Member

All tasks complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature epic Type: Large user story that encompasses multiple tasks technical debt test Test infrastructure, automated tests required, etc web3 Area: Web3 API
Projects
Status: Done
Development

No branches or pull requests

7 participants