dfinity / cycles-ledger

The cycles ledger is a global ledger canister that enables principal IDs to hold cycles.
Apache License 2.0
8 stars 3 forks source link

chore: tests cleanup and ergonomics #107

Closed MarioDfinity closed 6 months ago

MarioDfinity commented 6 months ago
  1. remove useless parts of the tests.
  2. proper naming for client functions, e.g. icrc3_get_blocks instead get_raw_blocks. In general, each function has been changed to use the name of the canister method that it is calling.
  3. Add TestEnv to replace test setup (created StateMachine->install ledger->install depositor) with a single function and to avoid passing env and the canister id to every client function. E.g. icrc1_total_supply(env, ledger_id) is now env.icrc1_total_supply().
  4. Standardize how arguments are passed to functions. Most functions now take in input the Principal caller and a single argument which is the payload to serialize and pass in the call. Note that for egonomics reasons some functions, such as deposit and icrc3_get_blocks, take in input a different set of arguments that is easier to use in the tests.
  5. Avoid hardcoded arguments so that tests can actually test all permutations.
  6. Standardize the errors given by function calles. No more .unwrap() which wouldn't really tell you want the error is. Now each funciton will print out the call input and the resulting error.
  7. Replace CyclesLedgerInStateMachine with TestEnv to unify the client and gen mod. The Ledger installed in a StateMachine is now always represented by TestEnv.