Skip to content

Commit

Permalink
test: migrate to near-workspaces v3 (#194)
Browse files Browse the repository at this point in the history
Co-authored-by: arkff <15167258586@163.com>
Co-authored-by: Linguists <95207870+linguists@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 23, 2024
1 parent b320c5f commit ccd1eeb
Show file tree
Hide file tree
Showing 30 changed files with 9,425 additions and 12,394 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
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
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
@@ -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
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

0 comments on commit ccd1eeb

Please sign in to comment.