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: migrate to near-workspaces v3 #194

Merged
merged 27 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
node-version: 16.13
cache: npm
- name: Install Dependencies
run: cd tests && npm install
run: npm install
# Run tests
- name: Run tests
run: make test
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ The [v1.0.0 contract release](https://github.com/linear-protocol/LiNEAR/releases

We adopt unit tests and heavily used the [`workspace-js`](https://github.com/near/workspaces-js) test framework to test the major scenarios and workflow of the LiNEAR smart contract in the [Sandbox](https://docs.near.org/docs/develop/contracts/sandbox) environment. Lint with `rustfmt` and `clippy` is also required when making changes to contract.

- Run `npm i` under `./tests` folder first to set up the environment
- Install node v16
- Run `npm i` to set up the environment
- Run lint with `rustfmt` and `clippy`: `make lint`
- Run all tests: `make test`
- Run LiNEAR simulation tests:
Expand Down
11 changes: 11 additions & 0 deletions ava.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require("util").inspect.defaultOptions.depth = 5; // Increase AVA's printing depth

module.exports = {
files: ["**/*.ava.ts"],
extensions: ["ts"],
require: ["ts-node/register"],
failWithoutAssertions: false,
timeout: "300000",
failFast: true,
verbose: true,
};
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ test-contracts: linear_test mock-staking-pool mock-fungible-token mock-dex mock-
@cp ./res/mock_whitelist.wasm ./tests/compiled-contracts/mock_whitelist.wasm

test-linear: test-contracts
cd tests && NEAR_PRINT_LOGS=$(LOGS) npx near-workspaces-ava --timeout=2m __tests__/linear/$(TEST_FILE).ava.ts --verbose
cd tests && NEAR_PRINT_LOGS=$(LOGS) npx ava --timeout=2m __tests__/linear/$(TEST_FILE).ava.ts --verbose

test-mock-staking-pool: mock-staking-pool
@mkdir -p ./tests/compiled-contracts/
cp ./res/mock_staking_pool.wasm ./tests/compiled-contracts/mock_staking_pool.wasm
cd tests && npx near-workspaces-ava __tests__/mock-staking-pool/**.ts --verbose
cd tests && npx ava __tests__/mock-staking-pool/**.ts --verbose

test-mock-fungible-token: mock-fungible-token
@mkdir -p ./tests/compiled-contracts/
cp ./res/mock_fungible_token.wasm ./tests/compiled-contracts/mock_fungible_token.wasm
cd tests && npx near-workspaces-ava __tests__/mock-fungible-token/**.ts --verbose
cd tests && npx ava __tests__/mock-fungible-token/**.ts --verbose
Loading
Loading