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: architecture redesign #115

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

Yashiru
Copy link
Contributor

@Yashiru Yashiru commented May 5, 2022

Context

Please consider that this draft PR is intended to give an idea of the work to be done for a complete test architecture redesign. No functional factorization has been really done.

The previous unit test architecture was not scalable and hard to read,
so we needed a scalable and readable acrhitecture in the same way that a test architecture with Foundry could be read (for a future migration).

The old architecture was very basic and similar to this:
old arch

The new architecture looks like this:
refac

The goals of this new architecture are:

  • Refactor all the features by utility and/or by operator
  • Divide the utils (present in the ./scripts directory) to extract the functionality specific to the test environment
  • Improve the readability of the architecture (trying to get closer to foundry style)
  • Improved scalability
  • Speed up test writing

New structure

This is what the new tree looks like:
1

shared

This directory contains all the resources shared between the unit tests.

See also:
Foundry book - Shared setup
Foundry book - Project layout

helpers

This directory contains all the functionality required in the unit tests.

  • Fixtures in the fixtures directory
  • Deployment specific features in the deployer.ts
  • Functionalities specific to the different contracts calls in the caller.ts.
  • Les variables constantes dans le constants.ts
  • The constant variables in the constants.ts
  • Test environment definitions with chai and waffle in provider.ts
fixtures

Ce dossier contient toutes les fixtures organiser par opérateur en fonction du fork.

  • The main.ts file allows to gather all the fixtures under the same access point in order to improve the readability of their use/imports.
  • The factoryAndOperatorsFixture.ts file gathers all fixtures used in the non forked test environment.
  • The factoryAndOperatorsForkingBSCFixture.ts file gathers all the fixtures used in the test environment forked from the BSC.
  • The other files define the fixtures for each operator.
utils

This directory contains all the additional test environment specific functionality coming from the utils.ts in the scripts directory.

  • The file orders.ts contains all the functions to build orders in order to submit them to the factory
  • The file records.ts contains all the functions to assign the factory to each operator

types

This folder contains all the data types used in the unit tests or in the helpers.

unit

This directory contains all unit tests.

Interesting files to watch (non-functional, structural only)

  • ./test/shared/helpers/fixtures/*
    • All operators fixtures refactorised files
  • ./test/shared/types/*
    • All operators fixtures type structure refactorised files (not roworked for readability)
  • ./test/shared/helpers/deployer.ts
    • Factorised deployments features
  • ./test/shared/helpers/types/FactoryAndOperatorsFixture.ts
    • Reworked readability FactoryAndOperatorsFixture type
  • ./test/shared/helpers/fixtures/factoryAndOperatorsFixture.ts
    • Factorised deployments with the deployer
  • ./test/unit/NestedAssetBatcher.unit.ts
    • Use of the reworked FactoryAndOperatorsFixture context to improve readability

@Yashiru Yashiru added the To review Let people know this PR is ready for a review label May 5, 2022
@Yashiru Yashiru requested review from adrien-supizet and removed request for oguimbal May 5, 2022 11:39
@Yashiru Yashiru added Draft Do not merge and removed To review Let people know this PR is ready for a review labels May 5, 2022
Copy link
Contributor

@adrien-supizet adrien-supizet left a comment

Choose a reason for hiding this comment

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

👍 This is great.
Can you estimate how much effort this redesign requires?
I'm under the impression that this will take quite some time. In that case, the most productive thing to do would be to start working on the Tetris version with this architecture in mind, but not reorganize the current repo.

@maximebrugel maximebrugel changed the title Tests architecture redesign test: architecture redesign May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Draft Do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants