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

chore(ts-tests): add e2e contracts #66

Merged
merged 63 commits into from
Sep 12, 2022
Merged

Conversation

canonbrother
Copy link
Contributor

@canonbrother canonbrother commented Sep 5, 2022

What this PR does / why we need it:

Develop and test on a simple smart contract functionality on substrate-based blockchain.

Which issue(s) does this PR fixes?:

Fixes #

Additional comments?:

canonbrother and others added 30 commits August 22, 2022 14:56
move to constant
Bumps [actions/github-script](https://github.com/actions/github-script) from 6.1.0 to 6.1.1.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](actions/github-script@v6.1.0...d50f485)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* syntax err

* support multi platf
* syntax err

* support multi platf
ts-tests/package.json Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
ts-tests/package.json Outdated Show resolved Hide resolved
ts-tests/containers/MetaDContainer.ts Outdated Show resolved Hide resolved
ts-tests/__tests__/contract.tests.ts Show resolved Hide resolved
@weiyuan95
Copy link

weiyuan95 commented Sep 8, 2022

Regarding the failing test on macos, it looks like running more than 3 containers at once isn't possible. Anything more than 3, it seems like the container crashes. Any idea why? @canonbrother

Some logs, if that helps. Container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 is the one that can't start properly.

2022-09-08T09:51:50.659Z testcontainers ERROR Failed to exec container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 with command "/bin/sh -c nc -vz -w 1 localhost 19933": Error: (HTTP code 409) container stopped/paused - Container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 is not running 
2022-09-08T09:51:50.659Z testcontainers ERROR Container failed to be ready: Error: (HTTP code 409) container stopped/paused - Container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 is not running 
2022-09-08T09:51:50.667Z testcontainers ERROR Failed to exec container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 with command "/bin/bash -c </dev/tcp/localhost/19933": Error: (HTTP code 409) container stopped/paused - Container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 is not running 
2022-09-08T09:51:50.667Z testcontainers ERROR Failed to exec container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 with command "/bin/sh -c cat /proc/net/tcp* | awk '{print $2}' | grep -i :4ddd": Error: (HTTP code 409) container stopped/paused - Container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 is not running 
2022-09-08T09:51:50.677Z testcontainers INFO  Container has already been stopped: 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7

@canonbrother
Copy link
Contributor Author

Regarding the failing test on macos, it looks like running more than 3 containers at once isn't possible. Anything more than 3, it seems like the container crashes. Any idea why? @canonbrother

Some logs, if that helps. Container 1c528e9664a6fcefb9bf4e0e8d697d4a39ef0fd3bb24aec093aab8eb152276c7 is the one that can't start properly.

yep.. @DieHard073055 pinged me this issue.. the container stopped before the test finished while running >3 tests on MacOs... still checking on my end

@weiyuan95
Copy link

Needs a rebase @canonbrother. Other than that LGTM other than the tests which seem to be failing only on macOS for some reason.

Copy link

@cwkang1998 cwkang1998 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@weiyuan95 weiyuan95 left a comment

Choose a reason for hiding this comment

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

:shipit: LGTM :shipit:

@weiyuan95
Copy link

LGTM

Your approval has no power here! 🤣

ts-tests/package.json Show resolved Hide resolved
@canonbrother
Copy link
Contributor Author

Needs a rebase @canonbrother. Other than that LGTM other than the tests which seem to be failing only on macOS for some reason.

Exit Code 137: Indicates failures as container receivd SIGKILL (manual intervention or 'oom-killer' [OUT-OF-MEMORY]
assign more memory on Mac docker will do

@weiyuan95
Copy link

Needs a rebase @canonbrother. Other than that LGTM other than the tests which seem to be failing only on macOS for some reason.

Exit Code 137: Indicates failures as container receivd SIGKILL (manual intervention or 'oom-killer' [OUT-OF-MEMORY] assign more memory on Mac docker will do

Makes sense, time to request for 256gb ram 😏

@fuxingloh fuxingloh merged commit 31bb3b8 into main Sep 12, 2022
@fuxingloh fuxingloh deleted the canonbrother/e2e-contracts branch September 12, 2022 07:03
fuxingloh added a commit that referenced this pull request 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
canonbrother added a commit that referenced this pull request Sep 28, 2022
#### What this PR does / why we need it:

Develop and test on a simple smart contract functionality on
substrate-based blockchain.

#### 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 #

#### Additional comments?:

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
canonbrother pushed a commit that referenced this pull request 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/chore Non feature change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants