@ledgerhq/coin-tester 0.2.2-hotfix.0 → 0.2.3-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/coin-tester@0.2.1 build /home/runner/work/ledger-live/ledger-live/libs/coin-tester
2
+ > @ledgerhq/coin-tester@0.2.2 build /home/runner/work/ledger-live/ledger-live/libs/coin-tester
3
3
  > tsc && tsc -m ES6 --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @ledgerhq/coin-tester
2
2
 
3
+ ## 0.2.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#7593](https://github.com/LedgerHQ/ledger-live/pull/7593) [`187293c`](https://github.com/LedgerHQ/ledger-live/commit/187293c6cf6093f15f07d5effc1ded0843a9e6ab) Thanks [@lambertkevin](https://github.com/lambertkevin)! - Update `axios` to fixed version `1.7.3`
8
+
9
+ - Updated dependencies [[`187293c`](https://github.com/LedgerHQ/ledger-live/commit/187293c6cf6093f15f07d5effc1ded0843a9e6ab)]:
10
+ - @ledgerhq/hw-transport-node-speculos-http@6.29.3-next.0
11
+
12
+ ## 0.2.2
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies []:
17
+ - @ledgerhq/hw-transport-node-speculos-http@6.29.2
18
+
3
19
  ## 0.2.2-hotfix.0
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -3,7 +3,11 @@
3
3
  - [Setup](#setup)
4
4
  - [Run tests for a coin module](#runtests)
5
5
 
6
- ## Setup {#setup}
6
+ ## What is the coin config
7
+
8
+ Find more information [here](https://github.com/LedgerHQ/ledger-live/blob/develop/libs/coin-tester/coin-tester.md)
9
+
10
+ ## [Setup](#setup)
7
11
 
8
12
  ### Prerequisites
9
13
 
@@ -75,7 +79,7 @@ To coin Polkadot Coin tester we will need to build the local test node Docker im
75
79
  cd libs/coin-modules/coin-polkadot/src/test/coin-tester
76
80
  make build
77
81
  ```
78
- ## Run tests for a coin module {#runtests}
82
+ ## [Run tests for a coin module](#run-tests-for-a-coin-module)
79
83
 
80
84
  ```sh
81
85
  pnpm coin:<coin-module-name> coin-tester
package/coin-tester.md ADDED
@@ -0,0 +1,47 @@
1
+ # What is the coin tester
2
+
3
+ The coin tester is a deterministic tool to test the coin modules.
4
+
5
+ ## Motivation
6
+
7
+ Historically to test the coin modules we had to run Ledger Live and test manually the different operations supported on Ledger Live. However we wanted to make sure that the coin modules could be used in Ledger Live as well as any other software wallet. We thus needed a way to easily test the full capabilities of a coin modules without relying on the client specific use cases.
8
+
9
+ ## How it works
10
+
11
+ The coin tester executes **scenarios**. A scenario is a suite of transactions that are run together.
12
+
13
+ A scenario could look like:
14
+
15
+ > Send 1 Eth to Alice
16
+ > Send 1 NFT to Bob
17
+ > Stake 100 Eth to this staking pool
18
+
19
+ You'll just need to define the transactions as expected by the coin module and then let the coin module do the job
20
+
21
+ The coin modules works quite simply:
22
+
23
+ 1. Setup: During the setup we spawn the local test node and the transaction signer. It returns the [CurrencyBridge](https://github.com/LedgerHQ/ledger-live/wiki/LLC:CurrencyBridge), [AccountBridge](https://github.com/LedgerHQ/ledger-live/wiki/LLC:AccountBridge) and an account.
24
+ 2. (optional )We run additional checks if they are defined
25
+ 3. We loop through the array of transaction and execute the transactions. For each transaction we check that the coin module acted as expected.
26
+ 4. We teardown the setup
27
+
28
+ The coin tester being deterministic, the goal of the setup is to make sure we always tests in a known and controlled environment. The account we use should have the funds and assets (NFTs, Tokens, ERC20s, etc) to execute the scenarios transactions.
29
+
30
+ As transactions are ran in a local testnode we can't use a "real" explorer, we thus use the functions `beforeSync` and `mockIndexer` locally index transactions.
31
+ Everytime we do a synchronization we intercept the calls made to the explorer and populate the response with the local explorer.
32
+
33
+ ## Prerequisites to implement the coin tester for a coin module
34
+
35
+ - A coin module: All the logic to craft and broadcast a transaction. The coin module must be "coin configurable" meaning it must implement a `setConfiguration` function and use `getConfiguration` in the implementation.
36
+
37
+ - A tool that can spawn a fresh local test node. Best practice is to run it inside a Docker container.
38
+
39
+
40
+ ## Engine
41
+
42
+ The coin tester engine is located [here](https://github.com/LedgerHQ/ledger-live/blob/develop/libs/coin-tester/src/main.ts). The function `executeScenario` is then imported inside the coin module to run specific scenarios.
43
+
44
+ ## Examples
45
+
46
+ - [EVM](https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-evm/src/__tests__/coin-tester)
47
+ - [Polkadot](https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-polkadot/src/test/coin-tester)
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-tester",
3
- "version": "0.2.2-hotfix.0",
3
+ "version": "0.2.3-next.0",
4
4
  "description": "Deterministic testing of Ledger coin-modules",
5
5
  "license": "Apache-2.0",
6
6
  "dependencies": {
7
- "axios": "^1.5.0",
7
+ "axios": "1.7.3",
8
8
  "chalk": "^4.1.2",
9
9
  "docker-compose": "^0.24.2",
10
10
  "lodash": "^4.17.21",
11
11
  "rxjs": "7.8.1",
12
- "@ledgerhq/hw-transport-node-speculos-http": "^6.29.2-hotfix.0"
12
+ "@ledgerhq/hw-transport-node-speculos-http": "^6.29.3-next.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/jest": "^28.1.8",
@@ -17,8 +17,8 @@
17
17
  "jest": "^28.1.3",
18
18
  "ts-jest": "^28.0.8",
19
19
  "typescript": "^5.1.3",
20
- "@ledgerhq/types-cryptoassets": "^7.14.0",
21
- "@ledgerhq/types-live": "^6.49.0"
20
+ "@ledgerhq/types-cryptoassets": "^7.15.1-next.0",
21
+ "@ledgerhq/types-live": "^6.51.0-next.0"
22
22
  },
23
23
  "typesVersions": {
24
24
  "*": {