Skip to content

Commit

Permalink
Add Stax function tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aido committed Sep 2, 2024
1 parent 7cb07d0 commit 5cc558f
Show file tree
Hide file tree
Showing 16 changed files with 846 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
download_app_binaries_artifact: compiled_app_binaries
test_dir: tests/functional
run_for_devices: '["nanos"]'
run_for_devices: '["nanos", "stax"]'

ledger_app_test_unit:
name: Unit tests
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.8.0] - 2024-08-25
## [1.8.0] - 2024-09-02

### Added

Expand All @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add Stax layouts for recovering BIP39 phrase
- Add screenshots and animations
- Add demo videos for Stax and Nano S
- Add Stax function tests

## [1.7.4] - 2024-06-20

Expand Down
10 changes: 10 additions & 0 deletions tests/deprecated/README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ cut -d# -f1 ./tests/deprecated/stax-bip39-12-word.test | while read LINE ; do ec
```bash
./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "profit result tip galaxy hawk immune hockey series melody grape unusual prize nothing federal dad crew pact sad"
```
##### nanos
```bash
while read -a LINE
do
curl -d '{"action":"press-and-release"}' -X ${LINE[0]} http://127.0.0.1:5000${LINE[1]}
done < ./test/speculos/nanos-bip39-18-word.test > /dev/null 2>&1 &
```
##### stax
```bash
cut -d# -f1 ./tests/deprecated/stax-bip39-18-word.test | while read LINE ; do echo -n $n; curl -d "${LINE}" -X POST http://127.0.0.1:5000/finger; ((n++)); done > /dev/null 2>&1 &
```
#### Speculos automation
```bash
./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-bip39-18-word.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "profit result tip galaxy hawk immune hockey series melody grape unusual prize nothing federal dad crew pact sad"
Expand All @@ -44,12 +49,17 @@ done < ./test/speculos/nanos-bip39-18-word.test > /dev/null 2>&1 &
```bash
./speculos.py ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate"
```
##### nanos
```bash
while read -a LINE
do
curl -d '{"action":"press-and-release"}' -X ${LINE[0]} http://127.0.0.1:5000${LINE[1]}
done < ./test/speculos/nanos-bip39-24-word.test > /dev/null 2>&1 &
```
##### stax
```bash
cut -d# -f1 ./tests/deprecated/stax-bip39-24-word.test | while read LINE ; do echo -n $n; curl -d "${LINE}" -X POST http://127.0.0.1:5000/finger; ((n++)); done > /dev/null 2>&1 &
```
#### Speculos automation
```bash
./speculos.py --automation file:../app-seed-tool/test/speculos/nanos-bip39-24-word.json ../app-seed-tool/build/nanos/bin/app.elf --model nanos --seed "toe priority custom gauge jacket theme arrest bargain gloom wide ill fit eagle prepare capable fish limb cigar reform other priority speak rough imitate"
Expand Down
Empty file modified tests/deprecated/nanos-bip39-12-word.json
100755 → 100644
Empty file.
Empty file modified tests/deprecated/nanos-bip39-18-word.json
100755 → 100644
Empty file.
Empty file modified tests/deprecated/nanos-bip39-24-word.json
100755 → 100644
Empty file.
Empty file modified tests/deprecated/nanos-sskr-128bit.json
100755 → 100644
Empty file.
Empty file modified tests/deprecated/nanos-sskr-256bit.json
100755 → 100644
Empty file.
Empty file modified tests/deprecated/stax-bip39-12-word.test
100755 → 100644
Empty file.
89 changes: 89 additions & 0 deletions tests/deprecated/stax-bip39-18-word.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{"action": "press-and-release", "x": 106, "y": 510}
{"action": "press-and-release", "x": 124, "y": 601}
{"action": "press-and-release", "x": 200, "y": 520}
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 160, "y": 520} # f
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 240, "y": 520} # h
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 60, "y": 464} # w
{"action": "press-and-release", "x": 320, "y": 520} # k
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 260, "y": 576} # m
{"action": "press-and-release", "x": 260, "y": 576} # m
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 240, "y": 520} # h
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 320, "y": 520} # k
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 260, "y": 576} # m
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 220, "y": 576} # n
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 20, "y": 576} # z
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 220, "y": 576} # n
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 240, "y": 520} # h
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 160, "y": 520} # f
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 120, "y": 520} # d
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 120, "y": 520} # d
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 120, "y": 520} # d
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 60, "y": 464} # w
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 120, "y": 520} # d
120 changes: 120 additions & 0 deletions tests/deprecated/stax-bip39-24-word.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{"action": "press-and-release", "x": 106, "y": 510}
{"action": "press-and-release", "x": 124, "y": 601}
{"action": "press-and-release", "x": 200, "y": 420}
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 280, "y": 520} # j
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 320, "y": 520} # k
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 240, "y": 520} # h
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 260, "y": 576} # m
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 180, "y": 576} # b
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 60, "y": 464} # w
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 120, "y": 520} # d
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 160, "y": 520} # f
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 160, "y": 520} # f
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 240, "y": 520} # h
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 360, "y": 520} # l
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 260, "y": 576} # m
{"action": "press-and-release", "x": 180, "y": 576} # b
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 100, "y": 576} # c
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 160, "y": 520} # f
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 240, "y": 520} # h
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 80, "y": 520} # s
{"action": "press-and-release", "x": 380, "y": 464} # p
{"action": "press-and-release", "x": 100, "y": 464} # e
{"action": "press-and-release", "x": 40, "y": 520} # a
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 140, "y": 464} # r
{"action": "press-and-release", "x": 340, "y": 464} # o
{"action": "press-and-release", "x": 260, "y": 464} # u
{"action": "press-and-release", "x": 200, "y": 520} # g
{"action": "press-and-release", "x": 100, "y": 280}
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 260, "y": 576} # m
{"action": "press-and-release", "x": 300, "y": 464} # i
{"action": "press-and-release", "x": 180, "y": 464} # t
{"action": "press-and-release", "x": 100, "y": 280}
Empty file modified tests/deprecated/stax-sskr-128bit.test
100755 → 100644
Empty file.
94 changes: 94 additions & 0 deletions tests/functional/test_bip39_12word.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,101 @@ def nanos_bip39_12word(backend, navigator):
backend.wait_for_text_on_screen("tuna next keep gyro", 1)
navigator.navigate_until_text(NavInsID.RIGHT_CLICK, [], "Quit", 20, screen_change_before_first_instruction=False)

def stax_bip39_12word(backend):
backend.wait_for_text_on_screen("Seed Tool", 10)
backend.finger_touch(106, 510, 1)
backend.wait_for_text_on_screen("BIP39 Check", 5)
backend.finger_touch(124, 601, 1)
backend.finger_touch(148, 601, 1)
backend.wait_for_text_on_screen("Enter word", 5)
backend.finger_touch(160, 520, 1) # f
backend.finger_touch(360, 520, 1) # l
backend.finger_touch(220, 464, 1) # y
backend.finger_touch(100, 280, 1)
backend.finger_touch(260, 576, 1) # m
backend.finger_touch(260, 464, 1) # u
backend.finger_touch(360, 520, 1) # l
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(100, 280, 1)
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(60, 576, 1) # x
backend.finger_touch(100, 576, 1) # c
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(100, 280, 1)
backend.finger_touch(140, 464, 1) # r
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(80, 520, 1) # s
backend.finger_touch(340, 464, 1) # o
backend.finger_touch(100, 280, 1)
backend.finger_touch(180, 464, 1) # t
backend.finger_touch(140, 464, 1) # r
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(40, 520, 1) # a
backend.finger_touch(100, 280, 1)
backend.finger_touch(380, 464, 1) # p
backend.finger_touch(360, 520, 1) # l
backend.finger_touch(260, 464, 1) # u
backend.finger_touch(220, 576, 1) # n
backend.finger_touch(100, 280, 1)
backend.finger_touch(220, 576, 1) # n
backend.finger_touch(340, 464, 1) # o
backend.finger_touch(80, 520, 1) # s
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(100, 280, 1)
backend.finger_touch(80, 520, 1) # s
backend.finger_touch(340, 464, 1) # o
backend.finger_touch(120, 520, 1) # d
backend.finger_touch(40, 520, 1) # a
backend.finger_touch(100, 280, 1)
backend.finger_touch(140, 464, 1) # r
backend.finger_touch(100, 464, 1) # e
backend.finger_touch(160, 520, 1) # f
backend.finger_touch(360, 520, 1) # l
backend.finger_touch(100, 280, 1)
backend.finger_touch(40, 520, 1) # a
backend.finger_touch(120, 520, 1) # d
backend.finger_touch(260, 464, 1) # u
backend.finger_touch(360, 520, 1) # l
backend.finger_touch(100, 280, 1)
backend.finger_touch(140, 464, 1) # r
backend.finger_touch(40, 520, 1) # a
backend.finger_touch(260, 576, 1) # m
backend.finger_touch(380, 464, 1) # p
backend.finger_touch(100, 280, 1)
backend.finger_touch(380, 464, 1) # p
backend.finger_touch(360, 520, 1) # l
backend.finger_touch(40, 520, 1) # a
backend.finger_touch(220, 576, 1) # n
backend.finger_touch(100, 280, 1)
backend.wait_for_text_on_screen("Correct Secret", 5)
backend.wait_for_text_on_screen("Recovery Phrase", 1)
backend.finger_touch(200, 630, 1)
backend.wait_for_text_on_screen("Generate SSKR", 5)
backend.finger_touch(200, 550, 1)
backend.wait_for_text_on_screen("Enter number of SSKR shares", 5)
backend.finger_touch(340, 300, 1) # 3
backend.finger_touch(340, 600,1)
backend.wait_for_text_on_screen("Enter threshold value", 5)
backend.finger_touch(195, 300, 1) # 2
backend.finger_touch(340, 600, 1)
backend.wait_for_text_on_screen("SSKR Share", 5)
backend.wait_for_text_on_screen("tuna next keep gyro", 1)
backend.wait_for_text_on_screen("1 of 3", 1)
backend.finger_touch(360, 630, 1)
backend.wait_for_text_on_screen("SSKR Share", 5)
backend.wait_for_text_on_screen("tuna next keep gyro", 1)
backend.wait_for_text_on_screen("2 of 3", 1)
backend.finger_touch(360, 630, 1)
backend.wait_for_text_on_screen("SSKR Share", 5)
backend.wait_for_text_on_screen("tuna next keep gyro", 1)
backend.wait_for_text_on_screen("3 of 3", 1)
backend.finger_touch(80, 630, 1)
backend.wait_for_text_on_screen("Seed Tool", 5)
backend.finger_touch(200, 630, 1)

@mark.use_on_backend("speculos")
def test_bip39_12word(firmware, backend, navigator, set_seed):
if firmware.device == "nanos":
nanos_bip39_12word(backend, navigator)
elif firmware.device == "stax":
stax_bip39_12word(backend)
Loading

0 comments on commit 5cc558f

Please sign in to comment.