Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Move ./ts-tests into ./packages/testsuite-* #79

Closed
fuxingloh opened this issue Sep 8, 2022 · 2 comments · Fixed by #169
Closed

Move ./ts-tests into ./packages/testsuite-* #79

fuxingloh opened this issue Sep 8, 2022 · 2 comments · Fixed by #169
Assignees
Labels
area/packages kind/feature New feature request packages/testsuite priority/important-soon Will be important soon triage/accepted Triage has been accepted

Comments

@fuxingloh
Copy link
Contributor

fuxingloh commented Sep 8, 2022

What would you like to be added:

As per the title, and following mono-repo design detailed in #42.

Part of #46 requirement.

Why is this needed:

Blocked by:

/triage accepted
/area packages
/packages testsuite

@fuxingloh fuxingloh added the kind/feature New feature request label Sep 8, 2022
@fuxingloh
Copy link
Contributor Author

/assign @canonbrother to you first although it's blocked by a lot of pending tasks

fuxingloh added a commit that referenced this issue Sep 13, 2022
…pace design (#86)

#### What this PR does / why we need it:

Move `ts-tests/*` to utilize pnpm and turbo mono-repo workspace design.
With this, we managed to keep configs (eslint, prettier, babel jest)
DRY. The PR "workspace-ize" `ts-tests` but ultimately many more PR is
required to break this package into multiple smaller mono repo packages.

Follow-up PRs required to address these:

- [ ] ESLINT will be added back once we move to "testsuite", also part
of #79
- [ ] #78 

---

**What's new?**

As suggested in
#66 (comment) I've
added hardhat compile turbo workflow.

`@birthdayresearch/sticky-turbo-jest` is a turbo-aware `jest-preset`; it
automatically run `dependsOn` script before running jest. By taking
advantage of content-aware hashing from turborepo. `dependsOn` only runs
if the pipeline `inputs` has changed.

When you run your test with `@birthdayresearch/sticky-turbo-jest`
preset, it uses `displayName` from your jest config to figure out which
`pipeline` to use. It will automatically pinpoint the corresponding
`dependsOn` and run all the scripts specified within.

> TLDR, when you run a dependent test, it automatically recompiles your
contract with hardhat when it detects changes in your `contracts/*.sol`
file. If it has the cached version, it will simply "output" the result
instead of rebuilding it.

https://sticky.birthday.dev/packages/sticky-turbo-jest

`package.json`:
```json
  "scripts": {
    "compile": "hardhat compile",
    "test": "jest"
  },
  "jest": {
    "displayName": "test",
    "preset": "@birthdayresearch/sticky-turbo-jest"
  },
```

`turbo.json`:
```json
    "compile": {
      "inputs": ["contracts/**"],
      "outputs": ["artifacts", "cache"]
    },
    "test": {
      "inputs": ["src/**", "**/*.unit.ts", "tests-e2e/**"],
      "dependsOn": ["^build", "compile"]
    },
```

#### Which issue(s) does this PR fixes?:

<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes part of #79
fuxingloh added a commit that referenced this issue Sep 14, 2022
#### What this PR does / why we need it:

Refactor and move `ts-tests` into mono-repo style packages to allow
separation of context and downstream usability. This is the continuation
of #42

`@defimetachain/testcontainers`

Provides easy to use and test lightweight, throwaway instances of
MetaChain provisioned automatically in a Docker
container.

`MetaChainContainer` and `StartedMetaChainContainer` follows the
convention defined
in
[testcontainers/testcontainers-node](https://github.com/testcontainers/testcontainers-node)

```ts
let container: StartedMetaChainContainer;
let rpc: ethers.providers.JsonRpcProvider;

beforeEach(async () => {
  container = await new MetaChainContainer().start();
});

afterEach(async () => {
  await container.stop();
});

it('should createBlock', async function () {
  await container.createBlock();
  expect(await rpc.getBlockNumber()).toStrictEqual(1);
});
```


#### Which issue(s) does this PR fixes?:
<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #78

#### Additional comments?:

The current implementation in `ts-tests` isn't yet migrated to use the
new standard and convention defined here. That should be done as part of
#79.
@fuxingloh fuxingloh added this to the MetaChain Iterative TestNet milestone Sep 14, 2022
canonbrother pushed a commit that referenced this issue Sep 28, 2022
…pace design (#86)

#### What this PR does / why we need it:

Move `ts-tests/*` to utilize pnpm and turbo mono-repo workspace design.
With this, we managed to keep configs (eslint, prettier, babel jest)
DRY. The PR "workspace-ize" `ts-tests` but ultimately many more PR is
required to break this package into multiple smaller mono repo packages.

Follow-up PRs required to address these:

- [ ] ESLINT will be added back once we move to "testsuite", also part
of #79
- [ ] #78 

---

**What's new?**

As suggested in
#66 (comment) I've
added hardhat compile turbo workflow.

`@birthdayresearch/sticky-turbo-jest` is a turbo-aware `jest-preset`; it
automatically run `dependsOn` script before running jest. By taking
advantage of content-aware hashing from turborepo. `dependsOn` only runs
if the pipeline `inputs` has changed.

When you run your test with `@birthdayresearch/sticky-turbo-jest`
preset, it uses `displayName` from your jest config to figure out which
`pipeline` to use. It will automatically pinpoint the corresponding
`dependsOn` and run all the scripts specified within.

> TLDR, when you run a dependent test, it automatically recompiles your
contract with hardhat when it detects changes in your `contracts/*.sol`
file. If it has the cached version, it will simply "output" the result
instead of rebuilding it.

https://sticky.birthday.dev/packages/sticky-turbo-jest

`package.json`:
```json
  "scripts": {
    "compile": "hardhat compile",
    "test": "jest"
  },
  "jest": {
    "displayName": "test",
    "preset": "@birthdayresearch/sticky-turbo-jest"
  },
```

`turbo.json`:
```json
    "compile": {
      "inputs": ["contracts/**"],
      "outputs": ["artifacts", "cache"]
    },
    "test": {
      "inputs": ["src/**", "**/*.unit.ts", "tests-e2e/**"],
      "dependsOn": ["^build", "compile"]
    },
```

#### Which issue(s) does this PR fixes?:

<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes part of #79
canonbrother pushed a commit that referenced this issue Sep 28, 2022
#### What this PR does / why we need it:

Refactor and move `ts-tests` into mono-repo style packages to allow
separation of context and downstream usability. This is the continuation
of #42

`@defimetachain/testcontainers`

Provides easy to use and test lightweight, throwaway instances of
MetaChain provisioned automatically in a Docker
container.

`MetaChainContainer` and `StartedMetaChainContainer` follows the
convention defined
in
[testcontainers/testcontainers-node](https://github.com/testcontainers/testcontainers-node)

```ts
let container: StartedMetaChainContainer;
let rpc: ethers.providers.JsonRpcProvider;

beforeEach(async () => {
  container = await new MetaChainContainer().start();
});

afterEach(async () => {
  await container.stop();
});

it('should createBlock', async function () {
  await container.createBlock();
  expect(await rpc.getBlockNumber()).toStrictEqual(1);
});
```


#### Which issue(s) does this PR fixes?:
<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #78

#### Additional comments?:

The current implementation in `ts-tests` isn't yet migrated to use the
new standard and convention defined here. That should be done as part of
#79.
@fuxingloh
Copy link
Contributor Author

/assign @DieHard073055 to work on this, I've removed @canonbrother from this issue since he is busy with other issues.

@fuxingloh fuxingloh changed the title Move ./ts-tests into ./packages/testsuite Move ./ts-tests into ./packages/testsuite-* Oct 31, 2022
@fuxingloh fuxingloh added the priority/important-soon Will be important soon label Nov 16, 2022
fuxingloh added a commit that referenced this issue Nov 29, 2022
…pc (#169)

<!--  Thanks for sending a pull request! -->

#### What this PR does / why we need it:
Details in the issue #79
#### Which issue(s) does this PR fixes?:
<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes #79 

#### Additional comments?:

Signed-off-by: Eshan Shafeeq <[email protected]>
Co-authored-by: Fuxing Loh <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/packages kind/feature New feature request packages/testsuite priority/important-soon Will be important soon triage/accepted Triage has been accepted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants