near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 22 forks source link

feat: cache root testnet accounts and destroy the ones created in tests #43

Closed willemneal closed 3 years ago

willemneal commented 3 years ago
  1. Cache root testnet accounts.

  2. Clean up test accounts like alice and bob at the end of the test run. This involved adding an AccountManager and subclass TestnetManager to keep track of accounts created during the test run. AccountManager also handles all things related to accounts and signing. In the future we may want to use two separate classes for these two needs (spawning/cleaning accounts; handling transactions & signing for a given account).

  3. Restructure the project with the goal of removing circular dependencies. This includes adding new interface NearAccount.

  4. Tests can now skip beforeAll, since the runner instance will wait for the function passed to create to complete before executing run calls. That is, beforeAll is no longer required, and this can be defined at the top level of tests:

    const runner = Runner.create(async ({root}) => ({
     contract: await root.createAndDeploy(
       'status-message',
       path.join(__dirname, 'build', 'debug', 'status_message.wasm'),
     ),
     ali: await root.createAccount('ali'),
    }));
  5. Use jest.concurrent to make tests actually-concurrent (they weren't before) which speeds up test runs significantly and ensures that all near-runner works as designed

  6. Use near-units to wrap account balances and clean up assertions about account balances. Example:

    expect(originalBalance.toBigInt()).toBeLessThan(newBalance.toBigInt());
  7. Add new JSON RPC wrapper