@ledgerhq/coin-tester 0.2.2 → 0.2.3-nightly.1
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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +6 -2
- package/coin-tester.md +47 -0
- package/package.json +4 -4
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ledgerhq/coin-tester
|
|
2
2
|
|
|
3
|
+
## 0.2.3-nightly.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.3-nightly.1
|
|
9
|
+
|
|
10
|
+
## 0.2.3-nightly.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies []:
|
|
15
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.3-nightly.0
|
|
16
|
+
|
|
3
17
|
## 0.2.2
|
|
4
18
|
|
|
5
19
|
### 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
|
-
##
|
|
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
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-tester",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3-nightly.1",
|
|
4
4
|
"description": "Deterministic testing of Ledger coin-modules",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,7 +9,7 @@
|
|
|
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.
|
|
12
|
+
"@ledgerhq/hw-transport-node-speculos-http": "^6.29.3-nightly.1"
|
|
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.
|
|
21
|
-
"@ledgerhq/types-live": "^6.
|
|
20
|
+
"@ledgerhq/types-cryptoassets": "^7.15.1-nightly.0",
|
|
21
|
+
"@ledgerhq/types-live": "^6.50.1-nightly.0"
|
|
22
22
|
},
|
|
23
23
|
"typesVersions": {
|
|
24
24
|
"*": {
|