Skip to content

Commit 0263fc9

Browse files
authored
Merge pull request #3 from miketlk/tmp_testnet_support
Add testnet support
2 parents 0a02121 + 58d8ee7 commit 0263fc9

File tree

26 files changed

+635
-9
lines changed

26 files changed

+635
-9
lines changed

.github/workflows/build_and_functional_tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ jobs:
3333
with:
3434
download_app_binaries_artifact: "compiled_app_binaries"
3535
test_dir: "tests_liquid"
36-

.github/workflows/ci-workflow.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
make DEBUG=0 COIN=liquid BOLOS_SDK=${{ matrix.SDK }} && mv bin/ liquid-bin/
4242
make clean
4343
make DEBUG=0 COIN=liquid_regtest BOLOS_SDK=${{ matrix.SDK }} && mv bin/ liquid-regtest-bin/
44+
make clean
45+
make DEBUG=0 COIN=liquid_testnet BOLOS_SDK=${{ matrix.SDK }} && mv bin/ liquid-testnet-bin/
4446
- name: Upload Liquid app binary
4547
uses: actions/upload-artifact@v4
4648
with:
@@ -53,6 +55,12 @@ jobs:
5355
name: liquid-regtest-app-${{ matrix.model }}
5456
path: liquid-regtest-bin
5557

58+
- name: Upload Liquid Testnet app binary
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: liquid-testnet-app-${{ matrix.model }}
62+
path: liquid-testnet-bin
63+
5664
job_unit_test:
5765
name: Unit test
5866
needs: job_build
@@ -133,6 +141,39 @@ jobs:
133141
pip install --prefer-binary -r requirements.txt
134142
PYTHONPATH=$PYTHONPATH:/speculos pytest --tb=short -v --device=${{matrix.model}} --speculos_api_port 5000
135143
144+
job_test_testnet:
145+
name: Tests on testnet
146+
strategy:
147+
matrix:
148+
include:
149+
- model: nanos
150+
- model: nanox
151+
- model: nanosp
152+
153+
needs: job_build
154+
runs-on: ubuntu-latest
155+
156+
steps:
157+
- name: Clone
158+
uses: actions/checkout@v4
159+
160+
- name: Download Liquid app binary
161+
uses: actions/download-artifact@v4
162+
with:
163+
name: liquid-testnet-app-${{matrix.model}}
164+
path: build/${{ matrix.model == 'nanosp' && 'nanos2' || matrix.model }}/bin
165+
166+
- name: Install tests dependencies
167+
run: |
168+
sudo apt-get update && sudo apt-get install -y qemu-user-static tesseract-ocr libtesseract-dev
169+
pip install -U pip setuptools
170+
171+
- name: Run tests
172+
run: |
173+
cd tests_liquid_testnet
174+
pip install --prefer-binary -r requirements.txt
175+
PYTHONPATH=$PYTHONPATH:/speculos pytest --tb=short -v --device=${{matrix.model}} --speculos_api_port 5000
176+
136177
job_test_python_lib_legacyapp:
137178
if: false
138179
name: Tests with the Python library and legacy Bitcoin app

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tests/.test_bitcoin
1717
tests/snapshots-tmp
1818
tests_liquid/snapshots-tmp
1919
tests_liquid_main/snapshots-tmp
20+
tests_liquid_testnet/snapshots-tmp
2021

2122
# Fuzzing
2223
fuzzing/build/

Makefile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ endif
7878

7979
# Setting to allow building variant applications
8080
VARIANT_PARAM = COIN
81-
VARIANT_VALUES = bitcoin_testnet bitcoin liquid_regtest liquid
81+
VARIANT_VALUES = bitcoin_testnet bitcoin liquid_regtest liquid_testnet liquid
8282

8383
########################################
8484
# Application custom permissions #
@@ -126,14 +126,30 @@ DEFINES += COIN_P2PKH_VERSION=111
126126
DEFINES += COIN_P2SH_VERSION=75
127127
DEFINES += COIN_PREFIX_CONFIDENTIAL=4
128128
DEFINES += HAVE_LIQUID
129-
DEFINES += HAVE_LIQUID_TEST
130-
DEFINES += COIN_BLINDED_VERSION=4
129+
DEFINES += LIQUID_NET_REGTEST
131130
DEFINES += COIN_COINID_SHORT=\"L-BTC\"
132131
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"ert\"
133132
DEFINES += COIN_NATIVE_SEGWIT_PREFIX_CONFIDENTIAL=\"el\"
134133

135134
APPNAME = "Liquid Regtest"
136135

136+
else ifeq ($(COIN),liquid_testnet)
137+
138+
# Liquid testnet
139+
DEFINES += BIP32_PUBKEY_VERSION=0x043587CF
140+
DEFINES += BIP32_PRIVKEY_VERSION=0x04358394
141+
DEFINES += BIP44_COIN_TYPE=1
142+
DEFINES += COIN_P2PKH_VERSION=36
143+
DEFINES += COIN_P2SH_VERSION=19
144+
DEFINES += COIN_PREFIX_CONFIDENTIAL=23
145+
DEFINES += HAVE_LIQUID
146+
DEFINES += LIQUID_NET_TESTNET
147+
DEFINES += COIN_COINID_SHORT=\"L-BTC\"
148+
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"tex\"
149+
DEFINES += COIN_NATIVE_SEGWIT_PREFIX_CONFIDENTIAL=\"tlq\"
150+
151+
APPNAME = "Liquid Testnet"
152+
137153
else ifeq ($(COIN),liquid)
138154

139155
# Liquid
@@ -144,7 +160,7 @@ DEFINES += COIN_P2PKH_VERSION=57
144160
DEFINES += COIN_P2SH_VERSION=39
145161
DEFINES += COIN_PREFIX_CONFIDENTIAL=12
146162
DEFINES += HAVE_LIQUID
147-
DEFINES += COIN_BLINDED_VERSION=12
163+
DEFINES += LIQUID_NET_MAINNET
148164
DEFINES += COIN_COINID_SHORT=\"L-BTC\"
149165
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"ex\"
150166
DEFINES += COIN_NATIVE_SEGWIT_PREFIX_CONFIDENTIAL=\"lq\"
@@ -153,7 +169,7 @@ APPNAME = "Liquid"
153169

154170
else
155171
ifeq ($(filter clean,$(MAKECMDGOALS)),)
156-
$(error Unsupported COIN - use bitcoin_testnet, bitcoin, liquid_regtest, liquid)
172+
$(error Unsupported COIN - use bitcoin_testnet, bitcoin, liquid_regtest, liquid_testnet, liquid)
157173
endif
158174
endif
159175

src/liquid/liquid_assets.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,23 @@ STATIC_NO_TEST const asset_definition_t liquid_assets[] = {
5757

5858
/// Asset tag of L-BTC or TL-BTC depending on build
5959
const uint8_t liquid_bitcoin_tag[LIQUID_ASSET_TAG_LEN] = {
60-
#ifdef HAVE_LIQUID_TEST
61-
/// Asset tag of TL-BTC
60+
#if defined(LIQUID_NET_REGTEST)
61+
/// Asset tag of regtest TL-BTC
6262
0x5a, 0xc9, 0xf6, 0x5c, 0x0e, 0xfc, 0xc4, 0x77, 0x5e, 0x0b, 0xae,
6363
0xc4, 0xec, 0x03, 0xab, 0xdd, 0xe2, 0x24, 0x73, 0xcd, 0x3c, 0xf3,
6464
0x3c, 0x04, 0x19, 0xca, 0x29, 0x0e, 0x07, 0x51, 0xb2, 0x25
65-
#else
65+
#elif defined(LIQUID_NET_TESTNET)
66+
/// Asset tag of testnet TL-BTC
67+
0x14, 0x4c, 0x65, 0x43, 0x44, 0xaa, 0x71, 0x6d, 0x6f, 0x3a, 0xbc,
68+
0xc1, 0xca, 0x90, 0xe5, 0x64, 0x1e, 0x4e, 0x2a, 0x7f, 0x63, 0x3b,
69+
0xc0, 0x9f, 0xe3, 0xba, 0xf6, 0x45, 0x85, 0x81, 0x9a, 0x49
70+
#elif defined(LIQUID_NET_MAINNET)
6671
/// Asset tag of L-BTC
6772
0x6f, 0x02, 0x79, 0xe9, 0xed, 0x04, 0x1c, 0x3d, 0x71, 0x0a, 0x9f,
6873
0x57, 0xd0, 0xc0, 0x29, 0x28, 0x41, 0x64, 0x60, 0xc4, 0xb7, 0x22,
6974
0xae, 0x34, 0x57, 0xa1, 0x1e, 0xec, 0x38, 0x1c, 0x52, 0x6d
75+
#else
76+
#error Valid net must be selected for Liquid
7077
#endif
7178
};
7279

tests_liquid_testnet/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# End-to-end tests
2+
3+
These tests are implemented in Python and can be executed either using the [Speculos](https://github.com/LedgerHQ/speculos) emulator or a Ledger Nano S/X/SP.
4+
5+
All the commands in this folder are meant to be ran from the `tests` folder, not from the root.
6+
7+
Python dependencies are listed in [requirements.txt](requirements.txt), install them using [pip](https://pypi.org/project/pip/)
8+
9+
```
10+
pip install -r requirements.txt
11+
```
12+
13+
## Launch with Speculos
14+
15+
Build the app as normal for Liquid testnet network from the root folder. For convenience, you probably want to enable DEBUG:
16+
17+
```
18+
COIN=liquid_testnet DEBUG=1 make
19+
```
20+
21+
Then run all the tests from this folder, specifying the device: nanos, nanox, nanosp, or all:
22+
23+
```
24+
pytest --device yourdevice
25+
```
26+
You can enable the screen display with the option `--display`
27+
28+
## Launch with your Nano S/X/SP
29+
30+
Compile and install the app on your device as normal.
31+
32+
To run the tests on your Ledger device you also need to install an optional dependency
33+
34+
```
35+
pip install ledgercomm[hid]
36+
```
37+
38+
Be sure to have you device connected through USB (without any other software interacting with it) and run
39+
40+
```
41+
pytest --device yourdevice --backend ledgercomm
42+
```

tests_liquid_testnet/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)