diff --git a/.gitignore b/.gitignore index 3735321..8670801 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ app.json app_nanos.json app_nanosplus.json app_nanox.json +app_stax.json +app_flex.json # Temporary directory with snapshots taken during test runs tests/snapshots-tmp/ diff --git a/Cargo.lock b/Cargo.lock index 5425d5b..f348bd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,18 +2,24 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "app-boilerplate-rust" -version = "1.2.4" +version = "1.3.0" dependencies = [ "hex", "include_gif", @@ -25,9 +31,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bindgen" @@ -48,7 +54,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.41", + "syn 2.0.66", "which", ] @@ -60,9 +66,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "byteorder" @@ -72,12 +78,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cexpr" @@ -96,9 +99,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clang-sys" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +checksum = "a483f3cbf7cec2e153d424d0e92329d816becc6421389bd494375c6065921b9b" dependencies = [ "glob", "libc", @@ -111,20 +114,45 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "const-zero" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3c6565524986fe3225da0beb9b4aa55ebc73cd57ff8cb4ccf016ca4c8d006af" + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "either" -version = "1.9.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", +] + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", ] [[package]] @@ -173,19 +201,20 @@ dependencies = [ [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "include_gif" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "132290d08a42868f8f90e96a9206e955b0aae1e5a5df54c0029e8c2ab8652625" +checksum = "c18f099f85187e07161246cc0346968f76084266ddc1f286d11a7bad67ec4b59" dependencies = [ + "flate2", "gif", "syn 1.0.109", ] @@ -204,10 +233,11 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "ledger_device_sdk" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f99d39260bbde6dfef6a2420440b79f7a486ab2fbf43d251600a759697a79361" +checksum = "138fb26a695ad99f3c9aa5d3265f8f121aeb9c65ebf2d1b1413d2b45ecd8345b" dependencies = [ + "const-zero", "include_gif", "ledger_secure_sdk_sys", "num-traits", @@ -218,47 +248,48 @@ dependencies = [ [[package]] name = "ledger_secure_sdk_sys" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e201ddad57baebaf48c694341d1e0aa910d3516cafee32fc385fa73c01381c" +checksum = "c421b2537a2181fa5a48d48529e9c5b55c494bc0d114c0be0d12c3783a4c9382" dependencies = [ "bindgen", "cc", + "glob", ] [[package]] name = "libc" -version = "0.2.151" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "winapi", + "windows-targets", ] [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "minimal-lexical" @@ -266,6 +297,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + [[package]] name = "nom" version = "7.1.3" @@ -278,9 +318,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -305,28 +345,28 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.41", + "syn 2.0.66", ] [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -339,9 +379,9 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "regex" -version = "1.10.2" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -351,9 +391,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -362,9 +402,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustc-hash" @@ -374,28 +414,28 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -403,7 +443,7 @@ dependencies = [ [[package]] name = "serde-json-core" version = "0.5.1" -source = "git+https://github.com/rust-embedded-community/serde-json-core#e695aa6be4761acada3ba30d99be46add277ec7f" +source = "git+https://github.com/rust-embedded-community/serde-json-core#9327a14e74ad3b4fd37a9ac34e72b61aa5fcc9bf" dependencies = [ "heapless", "ryu", @@ -412,20 +452,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.66", ] [[package]] name = "shlex" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "stable_deref_trait" @@ -446,9 +486,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -463,9 +503,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "weezl" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "which" @@ -479,162 +519,81 @@ dependencies = [ "rustix", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "windows_i686_msvc" -version = "0.48.5" +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index 88fcf03..d28add1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "app-boilerplate-rust" -version = "1.2.4" +version = "1.3.0" authors = ["yhql", "agrojean-ledger"] edition = "2021" [dependencies] -ledger_device_sdk = "1.8.0" -include_gif = "1.0.1" +ledger_device_sdk = "1.9.0" +include_gif = "1.1.0" serde = {version="1.0.192", default_features = false, features = ["derive"]} serde-json-core = { git = "https://github.com/rust-embedded-community/serde-json-core"} hex = { version = "0.4.3", default-features = false, features = ["serde"] } @@ -33,4 +33,10 @@ icon = "crab.gif" icon = "crab_14x14.gif" [package.metadata.ledger.nanosplus] -icon = "crab_14x14.gif" \ No newline at end of file +icon = "crab_14x14.gif" + +[package.metadata.ledger.stax] +icon = "crab_32x32.gif" + +[package.metadata.ledger.flex] +icon = "crab_40x40.gif" diff --git a/README.md b/README.md index e5e3b91..2681888 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Rule enforcer](https://github.com/LedgerHQ/app-boilerplate-rust/actions/workflows/guidelines_enforcer.yml/badge.svg) ![Build and tests](https://github.com/LedgerHQ/app-boilerplate-rust/actions/workflows/build_and_functional_tests.yml/badge.svg) -This is a boilerplate application written in Rust which can be forked to start a new project for the Ledger Nano S/X/SP devices. +This is a boilerplate application written in Rust which can be forked to start a new project for the Ledger Nano S/X/SP, Stax and Flex devices. * Implements standard features (display address, transaction signature...), * Has functional tests using [Ragger](https://github.com/LedgerHQ/ragger), diff --git a/crab_32x32.gif b/crab_32x32.gif new file mode 100755 index 0000000..c1dbbf1 Binary files /dev/null and b/crab_32x32.gif differ diff --git a/crab_40x40.gif b/crab_40x40.gif new file mode 100644 index 0000000..c2532c5 Binary files /dev/null and b/crab_40x40.gif differ diff --git a/crab_64x64.gif b/crab_64x64.gif new file mode 100644 index 0000000..d5bdcef Binary files /dev/null and b/crab_64x64.gif differ diff --git a/ledger_app.toml b/ledger_app.toml index 5cff00b..5266444 100644 --- a/ledger_app.toml +++ b/ledger_app.toml @@ -1,7 +1,7 @@ [app] build_directory = "./" sdk = "Rust" -devices = ["nanos", "nanox", "nanos+"] +devices = ["nanos", "nanox", "nanos+", "stax", "flex"] [tests] pytest_directory = "./tests/" diff --git a/src/app_ui/address.rs b/src/app_ui/address.rs index 44b2429..1c2ff63 100644 --- a/src/app_ui/address.rs +++ b/src/app_ui/address.rs @@ -17,8 +17,18 @@ use crate::AppSW; use core::str::from_utf8_mut; -use ledger_device_sdk::ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14}; -use ledger_device_sdk::ui::gadgets::{Field, MultiFieldReview}; + +#[cfg(not(any(target_os = "stax", target_os = "flex")))] +use ledger_device_sdk::ui::{ + bitmaps::{CROSSMARK, EYE, VALIDATE_14}, + gadgets::{Field, MultiFieldReview}, +}; + +#[cfg(any(target_os = "stax", target_os = "flex"))] +use ledger_device_sdk::nbgl::{NbglAddressReview, NbglGlyph}; + +#[cfg(any(target_os = "stax", target_os = "flex"))] +use include_gif::include_gif; // Display only the last 20 bytes of the address const DISPLAY_ADDR_BYTES_LEN: usize = 20; @@ -34,20 +44,34 @@ pub fn ui_display_pk(addr: &[u8]) -> Result { let addr_hex = from_utf8_mut(&mut addr_hex).unwrap(); addr_hex[2..].make_ascii_uppercase(); - let my_field = [Field { - name: "Address", - value: addr_hex, - }]; - - let my_review = MultiFieldReview::new( - &my_field, - &["Confirm Address"], - Some(&EYE), - "Approve", - Some(&VALIDATE_14), - "Reject", - Some(&CROSSMARK), - ); - - Ok(my_review.show()) + #[cfg(not(any(target_os = "stax", target_os = "flex")))] + { + let my_field = [Field { + name: "Address", + value: addr_hex, + }]; + + let my_review = MultiFieldReview::new( + &my_field, + &["Confirm Address"], + Some(&EYE), + "Approve", + Some(&VALIDATE_14), + "Reject", + Some(&CROSSMARK), + ); + + Ok(my_review.show()) + } + + #[cfg(any(target_os = "stax", target_os = "flex"))] + { + // Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph. + const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL)); + // Display the address confirmation screen. + Ok(NbglAddressReview::new() + .glyph(&FERRIS) + .verify_str("Verify CRAB address") + .show(addr_hex)) + } } diff --git a/src/app_ui/menu.rs b/src/app_ui/menu.rs index 92bcb8c..a2fd288 100644 --- a/src/app_ui/menu.rs +++ b/src/app_ui/menu.rs @@ -17,11 +17,23 @@ use include_gif::include_gif; use ledger_device_sdk::io::{Comm, Event}; -use ledger_device_sdk::ui::bitmaps::{Glyph, BACK, CERTIFICATE, DASHBOARD_X}; -use ledger_device_sdk::ui::gadgets::{EventOrPageIndex, MultiPageMenu, Page}; + +#[cfg(not(any(target_os = "stax", target_os = "flex")))] +use ledger_device_sdk::ui::{ + bitmaps::{Glyph, BACK, CERTIFICATE, DASHBOARD_X}, + gadgets::{EventOrPageIndex, MultiPageMenu, Page}, +}; + +#[cfg(any(target_os = "stax", target_os = "flex"))] +use crate::settings::Settings; +#[cfg(any(target_os = "stax", target_os = "flex"))] +use ledger_device_sdk::nbgl::{NbglGlyph, NbglHomeAndSettings}; use crate::Instruction; +// use ledger_device_sdk::nvm::*; + +#[cfg(not(any(target_os = "stax", target_os = "flex")))] fn ui_about_menu(comm: &mut Comm) -> Event { let pages = [ &Page::from((["Rust Boilerplate", "(c) 2023 Ledger"], true)), @@ -36,6 +48,7 @@ fn ui_about_menu(comm: &mut Comm) -> Event { } } +#[cfg(not(any(target_os = "stax", target_os = "flex")))] pub fn ui_menu_main(comm: &mut Comm) -> Event { const APP_ICON: Glyph = Glyph::from_include(include_gif!("crab.gif")); let pages = [ @@ -55,3 +68,22 @@ pub fn ui_menu_main(comm: &mut Comm) -> Event { } } } + +#[cfg(any(target_os = "stax", target_os = "flex"))] +pub fn ui_menu_main(_: &mut Comm) -> Event { + // Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph. + const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL)); + + let settings_strings = [["Display Memo", "Allow display of transaction memo."]]; + let mut settings: Settings = Default::default(); + // Display the home screen. + NbglHomeAndSettings::new() + .glyph(&FERRIS) + .settings(settings.get_mut_ref(), &settings_strings) + .infos( + "Boilerplate", + env!("CARGO_PKG_VERSION"), + env!("CARGO_PKG_AUTHORS"), + ) + .show() +} diff --git a/src/app_ui/sign.rs b/src/app_ui/sign.rs index 68ea1d6..abefde1 100644 --- a/src/app_ui/sign.rs +++ b/src/app_ui/sign.rs @@ -17,8 +17,20 @@ use crate::handlers::sign_tx::Tx; use crate::utils::concatenate; use crate::AppSW; -use ledger_device_sdk::ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14}; -use ledger_device_sdk::ui::gadgets::{Field, MultiFieldReview}; + +#[cfg(not(any(target_os = "stax", target_os = "flex")))] +use ledger_device_sdk::ui::{ + bitmaps::{CROSSMARK, EYE, VALIDATE_14}, + gadgets::{Field, MultiFieldReview}, +}; + +#[cfg(any(target_os = "stax", target_os = "flex"))] +use crate::settings::Settings; +#[cfg(any(target_os = "stax", target_os = "flex"))] +use include_gif::include_gif; +#[cfg(any(target_os = "stax", target_os = "flex"))] +use ledger_device_sdk::nbgl::{Field, NbglGlyph, NbglReview}; + use numtoa::NumToA; const MAX_COIN_LENGTH: usize = 10; @@ -64,15 +76,41 @@ pub fn ui_display_tx(tx: &Tx) -> Result { ]; // Create transaction review - let my_review = MultiFieldReview::new( - &my_fields, - &["Review ", "Transaction"], - Some(&EYE), - "Approve", - Some(&VALIDATE_14), - "Reject", - Some(&CROSSMARK), - ); + #[cfg(not(any(target_os = "stax", target_os = "flex")))] + { + let my_review = MultiFieldReview::new( + &my_fields, + &["Review ", "Transaction"], + Some(&EYE), + "Approve", + Some(&VALIDATE_14), + "Reject", + Some(&CROSSMARK), + ); + + Ok(my_review.show()) + } + + #[cfg(any(target_os = "stax", target_os = "flex"))] + { + // Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph. + const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL)); + // Create NBGL review. Maximum number of fields and string buffer length can be customised + // with constant generic parameters of NbglReview. Default values are 32 and 1024 respectively. + let mut review: NbglReview = NbglReview::new() + .titles( + "Review transaction\nto send CRAB", + "", + "Sign transaction\nto send CRAB", + ) + .glyph(&FERRIS); - Ok(my_review.show()) + // If first setting switch is disabled do not display the transaction memo + let settings: Settings = Default::default(); + if settings.get_element(0) == 0 { + Ok(review.show(&my_fields[0..2])) + } else { + Ok(review.show(&my_fields)) + } + } } diff --git a/src/main.rs b/src/main.rs index 18467e5..5445208 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,8 @@ mod handlers { pub mod sign_tx; } +mod settings; + use app_ui::menu::ui_menu_main; use handlers::{ get_public_key::handler_get_public_key, @@ -38,10 +40,14 @@ use handlers::{ }; use ledger_device_sdk::io::{ApduHeader, Comm, Event, Reply, StatusWords}; #[cfg(feature = "pending_review_screen")] +#[cfg(not(any(target_os = "stax", target_os = "flex")))] use ledger_device_sdk::ui::gadgets::display_pending_review; - +#[cfg(not(any(target_os = "stax", target_os = "flex")))] ledger_device_sdk::set_panic!(ledger_device_sdk::exiting_panic); +#[cfg(any(target_os = "stax", target_os = "flex"))] +use ledger_device_sdk::nbgl::init_comm; + // P2 for last APDU to receive. const P2_SIGN_TX_LAST: u8 = 0x00; // P2 for more APDU to receive. @@ -124,9 +130,15 @@ extern "C" fn sample_main() { // BadCla status word. let mut comm = Comm::new().set_expected_cla(0xe0); + // Initialize reference to Comm instance for NBGL + // API calls. + #[cfg(any(target_os = "stax", target_os = "flex"))] + init_comm(&mut comm); + // Developer mode / pending review popup // must be cleared with user interaction #[cfg(feature = "pending_review_screen")] + #[cfg(not(any(target_os = "stax", target_os = "flex")))] display_pending_review(&mut comm); let mut tx_ctx = TxContext::new(); diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 0000000..d05d47c --- /dev/null +++ b/src/settings.rs @@ -0,0 +1,41 @@ +use ledger_device_sdk::nvm::*; +use ledger_device_sdk::NVMData; + +// This is necessary to store the object in NVM and not in RAM +const SETTINGS_SIZE: usize = 10; +#[link_section = ".nvm_data"] +static mut DATA: NVMData> = + NVMData::new(AtomicStorage::new(&[0u8; 10])); + +#[derive(Clone, Copy)] +pub struct Settings; + +impl Default for Settings { + fn default() -> Self { + Settings + } +} + +impl Settings { + #[inline(never)] + #[allow(unused)] + pub fn get_mut_ref(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> { + return unsafe { DATA.get_mut() }; + } + + #[allow(unused)] + pub fn get_element(&self, index: usize) -> u8 { + let settings = unsafe { DATA.get_mut() }; + settings.get_ref()[index] + } + + #[allow(unused)] + // Not used in this boilerplate, but can be used to set a value in the settings + pub fn set_element(&self, index: usize, value: u8) { + let mut updated_data: [u8; SETTINGS_SIZE] = unsafe { *DATA.get_mut().get_ref() }; + updated_data[index] = value; + unsafe { + DATA.get_mut().update(&updated_data); + } + } +} diff --git a/tests/conftest.py b/tests/conftest.py index 7f60b44..573a16f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,14 +22,10 @@ # ragger/conftest/configuration.py @pytest.fixture(scope="class", autouse=True) def clear_pending_review(firmware, navigator): - print("Clearing pending review") # Press a button to clear the pending review if firmware.device.startswith("nano"): + print("Clearing pending review") instructions = [ NavInsID.BOTH_CLICK, ] - else: - instructions = [ - NavInsID.TAPPABLE_CENTER_TAP, - ] - navigator.navigate(instructions,screen_change_before_first_instruction=False) + navigator.navigate(instructions,screen_change_before_first_instruction=False) diff --git a/tests/requirements.txt b/tests/requirements.txt index 0913153..185fe96 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,5 @@ pytest ragger[speculos,ledgerwallet]>=1.11.4 ecdsa>=0.16.1,<0.17.0 -pysha3>=1.0.0,<2.0.0 +safe-pysha3>=1.0.0,<2.0.0 +tomli>=2.0.1 diff --git a/tests/snapshots/flex/test_app_mainmenu/00000.png b/tests/snapshots/flex/test_app_mainmenu/00000.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_app_mainmenu/00000.png differ diff --git a/tests/snapshots/flex/test_app_mainmenu/00001.png b/tests/snapshots/flex/test_app_mainmenu/00001.png new file mode 100644 index 0000000..ca9fbbe Binary files /dev/null and b/tests/snapshots/flex/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/flex/test_app_mainmenu/00002.png b/tests/snapshots/flex/test_app_mainmenu/00002.png new file mode 100644 index 0000000..4f4e59c Binary files /dev/null and b/tests/snapshots/flex/test_app_mainmenu/00002.png differ diff --git a/tests/snapshots/flex/test_app_mainmenu/00003.png b/tests/snapshots/flex/test_app_mainmenu/00003.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_app_mainmenu/00003.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png new file mode 100644 index 0000000..da583a1 Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00000.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png new file mode 100644 index 0000000..d92b9c7 Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00001.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00002.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00002.png new file mode 100644 index 0000000..4321e60 Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00002.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_accepted/00003.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png new file mode 100644 index 0000000..da583a1 Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00000.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png new file mode 100644 index 0000000..d92b9c7 Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00001.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00002.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00002.png new file mode 100644 index 0000000..45c08d4 Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00002.png differ diff --git a/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png b/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_get_public_key_confirm_refused/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00000.png b/tests/snapshots/flex/test_sign_tx_long_tx/00000.png new file mode 100644 index 0000000..d3dc9d8 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_long_tx/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00001.png b/tests/snapshots/flex/test_sign_tx_long_tx/00001.png new file mode 100644 index 0000000..fa1a974 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_long_tx/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00002.png b/tests/snapshots/flex/test_sign_tx_long_tx/00002.png new file mode 100644 index 0000000..bcff0a9 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_long_tx/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00003.png b/tests/snapshots/flex/test_sign_tx_long_tx/00003.png new file mode 100644 index 0000000..5c96f4c Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_long_tx/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00004.png b/tests/snapshots/flex/test_sign_tx_long_tx/00004.png new file mode 100644 index 0000000..be51a9d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_long_tx/00004.png differ diff --git a/tests/snapshots/flex/test_sign_tx_long_tx/00005.png b/tests/snapshots/flex/test_sign_tx_long_tx/00005.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_long_tx/00005.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00000.png b/tests/snapshots/flex/test_sign_tx_refused/00000.png new file mode 100644 index 0000000..e95c8bb Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_refused/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00001.png b/tests/snapshots/flex/test_sign_tx_refused/00001.png new file mode 100644 index 0000000..5d919f7 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_refused/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00002.png b/tests/snapshots/flex/test_sign_tx_refused/00002.png new file mode 100644 index 0000000..a85ffc7 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_refused/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00003.png b/tests/snapshots/flex/test_sign_tx_refused/00003.png new file mode 100644 index 0000000..08bca22 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_refused/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00004.png b/tests/snapshots/flex/test_sign_tx_refused/00004.png new file mode 100644 index 0000000..6bbdf2f Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_refused/00004.png differ diff --git a/tests/snapshots/flex/test_sign_tx_refused/00005.png b/tests/snapshots/flex/test_sign_tx_refused/00005.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_refused/00005.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00000.png b/tests/snapshots/flex/test_sign_tx_short_tx/00000.png new file mode 100644 index 0000000..e95c8bb Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00001.png b/tests/snapshots/flex/test_sign_tx_short_tx/00001.png new file mode 100644 index 0000000..a2bfbaa Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00002.png b/tests/snapshots/flex/test_sign_tx_short_tx/00002.png new file mode 100644 index 0000000..a85ffc7 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00003.png b/tests/snapshots/flex/test_sign_tx_short_tx/00003.png new file mode 100644 index 0000000..be51a9d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx/00004.png b/tests/snapshots/flex/test_sign_tx_short_tx/00004.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx/00004.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png new file mode 100644 index 0000000..e95c8bb Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00000.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png new file mode 100644 index 0000000..2d0c474 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00001.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png new file mode 100644 index 0000000..a85ffc7 Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00002.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00003.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00003.png new file mode 100644 index 0000000..be51a9d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00003.png differ diff --git a/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png new file mode 100644 index 0000000..8a9212d Binary files /dev/null and b/tests/snapshots/flex/test_sign_tx_short_tx_no_memo/00004.png differ diff --git a/tests/snapshots/nanos/test_app_mainmenu/00001.png b/tests/snapshots/nanos/test_app_mainmenu/00001.png index 071ed26..2562d89 100644 Binary files a/tests/snapshots/nanos/test_app_mainmenu/00001.png and b/tests/snapshots/nanos/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/nanosp/test_app_mainmenu/00001.png b/tests/snapshots/nanosp/test_app_mainmenu/00001.png index 2f706db..2cdf2d1 100644 Binary files a/tests/snapshots/nanosp/test_app_mainmenu/00001.png and b/tests/snapshots/nanosp/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/nanox/test_app_mainmenu/00001.png b/tests/snapshots/nanox/test_app_mainmenu/00001.png index 2f706db..2cdf2d1 100644 Binary files a/tests/snapshots/nanox/test_app_mainmenu/00001.png and b/tests/snapshots/nanox/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00000.png b/tests/snapshots/stax/test_app_mainmenu/00000.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_app_mainmenu/00000.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00001.png b/tests/snapshots/stax/test_app_mainmenu/00001.png new file mode 100644 index 0000000..1b31f9b Binary files /dev/null and b/tests/snapshots/stax/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00002.png b/tests/snapshots/stax/test_app_mainmenu/00002.png new file mode 100644 index 0000000..7317fdb Binary files /dev/null and b/tests/snapshots/stax/test_app_mainmenu/00002.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00003.png b/tests/snapshots/stax/test_app_mainmenu/00003.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_app_mainmenu/00003.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00000.png b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00000.png new file mode 100644 index 0000000..ca87897 Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00000.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00001.png b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00001.png new file mode 100644 index 0000000..b82d053 Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00001.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png new file mode 100644 index 0000000..3f906b2 Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00003.png b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00003.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00003.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_refused/00000.png b/tests/snapshots/stax/test_get_public_key_confirm_refused/00000.png new file mode 100644 index 0000000..ca87897 Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_refused/00000.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_refused/00001.png b/tests/snapshots/stax/test_get_public_key_confirm_refused/00001.png new file mode 100644 index 0000000..b82d053 Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_refused/00001.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_refused/00002.png b/tests/snapshots/stax/test_get_public_key_confirm_refused/00002.png new file mode 100644 index 0000000..b0eba3f Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_refused/00002.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_refused/00003.png b/tests/snapshots/stax/test_get_public_key_confirm_refused/00003.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_get_public_key_confirm_refused/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_long_tx/00000.png b/tests/snapshots/stax/test_sign_tx_long_tx/00000.png new file mode 100644 index 0000000..089d7a1 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_long_tx/00000.png differ diff --git a/tests/snapshots/stax/test_sign_tx_long_tx/00001.png b/tests/snapshots/stax/test_sign_tx_long_tx/00001.png new file mode 100644 index 0000000..91e73c3 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_long_tx/00001.png differ diff --git a/tests/snapshots/stax/test_sign_tx_long_tx/00002.png b/tests/snapshots/stax/test_sign_tx_long_tx/00002.png new file mode 100644 index 0000000..4549382 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_long_tx/00002.png differ diff --git a/tests/snapshots/stax/test_sign_tx_long_tx/00003.png b/tests/snapshots/stax/test_sign_tx_long_tx/00003.png new file mode 100644 index 0000000..895718b Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_long_tx/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_long_tx/00004.png b/tests/snapshots/stax/test_sign_tx_long_tx/00004.png new file mode 100644 index 0000000..2ba6d27 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_long_tx/00004.png differ diff --git a/tests/snapshots/stax/test_sign_tx_long_tx/00005.png b/tests/snapshots/stax/test_sign_tx_long_tx/00005.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_long_tx/00005.png differ diff --git a/tests/snapshots/stax/test_sign_tx_refused/00000.png b/tests/snapshots/stax/test_sign_tx_refused/00000.png new file mode 100644 index 0000000..b86bed3 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_refused/00000.png differ diff --git a/tests/snapshots/stax/test_sign_tx_refused/00001.png b/tests/snapshots/stax/test_sign_tx_refused/00001.png new file mode 100644 index 0000000..55c7550 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_refused/00001.png differ diff --git a/tests/snapshots/stax/test_sign_tx_refused/00002.png b/tests/snapshots/stax/test_sign_tx_refused/00002.png new file mode 100644 index 0000000..b8cf835 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_refused/00002.png differ diff --git a/tests/snapshots/stax/test_sign_tx_refused/00003.png b/tests/snapshots/stax/test_sign_tx_refused/00003.png new file mode 100644 index 0000000..babad98 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_refused/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_refused/00004.png b/tests/snapshots/stax/test_sign_tx_refused/00004.png new file mode 100644 index 0000000..cebc8be Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_refused/00004.png differ diff --git a/tests/snapshots/stax/test_sign_tx_refused/00005.png b/tests/snapshots/stax/test_sign_tx_refused/00005.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_refused/00005.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx/00000.png b/tests/snapshots/stax/test_sign_tx_short_tx/00000.png new file mode 100644 index 0000000..b86bed3 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx/00000.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx/00001.png b/tests/snapshots/stax/test_sign_tx_short_tx/00001.png new file mode 100644 index 0000000..f98f8bf Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx/00001.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx/00002.png b/tests/snapshots/stax/test_sign_tx_short_tx/00002.png new file mode 100644 index 0000000..b8cf835 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx/00002.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx/00003.png b/tests/snapshots/stax/test_sign_tx_short_tx/00003.png new file mode 100644 index 0000000..2ba6d27 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx/00004.png b/tests/snapshots/stax/test_sign_tx_short_tx/00004.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx/00004.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00000.png b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00000.png new file mode 100644 index 0000000..b86bed3 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00000.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00001.png b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00001.png new file mode 100644 index 0000000..91bfbb1 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00001.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00002.png b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00002.png new file mode 100644 index 0000000..b8cf835 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00002.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00003.png b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00003.png new file mode 100644 index 0000000..2ba6d27 Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00004.png b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00004.png new file mode 100644 index 0000000..1c08a3a Binary files /dev/null and b/tests/snapshots/stax/test_sign_tx_short_tx_no_memo/00004.png differ diff --git a/tests/test_app_mainmenu.py b/tests/test_app_mainmenu.py index de7f3ce..af00e25 100644 --- a/tests/test_app_mainmenu.py +++ b/tests/test_app_mainmenu.py @@ -14,8 +14,9 @@ def test_app_mainmenu(firmware, navigator, test_name): ] else: instructions = [ - NavInsID.USE_CASE_HOME_INFO, - NavInsID.USE_CASE_SETTINGS_SINGLE_PAGE_EXIT + NavInsID.USE_CASE_HOME_SETTINGS, + NavInsID.USE_CASE_SUB_SETTINGS_NEXT, + NavInsID.USE_CASE_SUB_SETTINGS_EXIT ] navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, test_name, instructions, screen_change_before_first_instruction=False) diff --git a/tests/test_pubkey_cmd.py b/tests/test_pubkey_cmd.py index f295411..21e6883 100644 --- a/tests/test_pubkey_cmd.py +++ b/tests/test_pubkey_cmd.py @@ -20,27 +20,13 @@ def test_get_public_key_no_confirm(backend): # In this test we check that the GET_PUBLIC_KEY works in confirmation mode -def test_get_public_key_confirm_accepted(firmware, backend, navigator, test_name): +def test_get_public_key_confirm_accepted(backend, scenario_navigator): client = BoilerplateCommandSender(backend) path = "m/44'/1'/0'/0/0" + with client.get_public_key_with_confirmation(path=path): - if firmware.device.startswith("nano"): - navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, - [NavInsID.BOTH_CLICK], - "Approve", - ROOT_SCREENSHOT_PATH, - test_name) - else: - instructions = [ - NavInsID.USE_CASE_REVIEW_TAP, - NavIns(NavInsID.TOUCH, (200, 335)), - NavInsID.USE_CASE_ADDRESS_CONFIRMATION_EXIT_QR, - NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM, - NavInsID.USE_CASE_STATUS_DISMISS - ] - navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, - test_name, - instructions) + scenario_navigator.address_review_approve() + response = client.get_async_response().data _, public_key, _, _ = unpack_get_public_key_response(response) @@ -49,39 +35,14 @@ def test_get_public_key_confirm_accepted(firmware, backend, navigator, test_name # In this test we check that the GET_PUBLIC_KEY in confirmation mode replies an error if the user refuses -def test_get_public_key_confirm_refused(firmware, backend, navigator, test_name): +def test_get_public_key_confirm_refused(backend, scenario_navigator): client = BoilerplateCommandSender(backend) path = "m/44'/1'/0'/0/0" - if firmware.device.startswith("nano"): - with pytest.raises(ExceptionRAPDU) as e: - with client.get_public_key_with_confirmation(path=path): - navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, - [NavInsID.BOTH_CLICK], - "Reject", - ROOT_SCREENSHOT_PATH, - test_name) - # Assert that we have received a refusal - assert e.value.status == Errors.SW_DENY - assert len(e.value.data) == 0 - else: - instructions_set = [ - [ - NavInsID.USE_CASE_REVIEW_REJECT, - NavInsID.USE_CASE_STATUS_DISMISS - ], - [ - NavInsID.USE_CASE_REVIEW_TAP, - NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CANCEL, - NavInsID.USE_CASE_STATUS_DISMISS - ] - ] - for i, instructions in enumerate(instructions_set): - with pytest.raises(ExceptionRAPDU) as e: - with client.get_public_key_with_confirmation(path=path): - navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, - test_name + f"/part{i}", - instructions) - # Assert that we have received a refusal - assert e.value.status == Errors.SW_DENY - assert len(e.value.data) == 0 + with pytest.raises(ExceptionRAPDU) as e: + with client.get_public_key_with_confirmation(path=path): + scenario_navigator.address_review_reject() + + # Assert that we have received a refusal + assert e.value.status == Errors.SW_DENY + assert len(e.value.data) == 0 diff --git a/tests/test_sign_cmd.py b/tests/test_sign_cmd.py index 92b00ef..ef71cb8 100644 --- a/tests/test_sign_cmd.py +++ b/tests/test_sign_cmd.py @@ -4,16 +4,61 @@ from application_client.boilerplate_command_sender import BoilerplateCommandSender, Errors from application_client.boilerplate_response_unpacker import unpack_get_public_key_response, unpack_sign_tx_response from ragger.error import ExceptionRAPDU -from ragger.navigator import NavInsID +from ragger.navigator import NavIns, NavInsID from utils import ROOT_SCREENSHOT_PATH, check_signature_validity -# In this tests we check the behavior of the device when asked to sign a transaction +# In these tests we check the behavior of the device when asked to sign a transaction +# In this test a transaction is sent to the device to be signed and validated on screen. +# The transaction is short and will be sent in one chunk. +# We will ensure that the displayed information is correct by using screenshots comparison. +def test_sign_tx_short_tx(backend, scenario_navigator, firmware, navigator): + # Use the app interface instead of raw interface + client = BoilerplateCommandSender(backend) + # The path used for this entire test + path: str = "m/44'/1'/0'/0/0" + + # First we need to get the public key of the device in order to build the transaction + rapdu = client.get_public_key(path=path) + _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) + + # Create the transaction that will be sent to the device for signing + transaction = Transaction( + nonce=1, + coin="CRAB", + value=777, + to="de0b295669a9fd93d5f28d9ec85e40f4cb697bae", + memo="For u EthDev" + ).serialize() + + # Enable display of transaction memo (NBGL devices only) + if not firmware.device.startswith("nano"): + navigator.navigate([NavInsID.USE_CASE_HOME_SETTINGS, + NavIns(NavInsID.TOUCH, (200, 113)), + NavInsID.USE_CASE_SUB_SETTINGS_EXIT], + screen_change_before_first_instruction=False, + screen_change_after_last_instruction=False) -# In this test se send to the device a transaction to sign and validate it on screen + # Send the sign device instruction. + # As it requires on-screen validation, the function is asynchronous. + # It will yield the result when the navigation is done + with client.sign_tx(path=path, transaction=transaction): + # Validate the on-screen request by performing the navigation appropriate for this device + scenario_navigator.review_approve() + + # The device as yielded the result, parse it and ensure that the signature is correct + response = client.get_async_response().data + _, der_sig, _ = unpack_sign_tx_response(response) + assert check_signature_validity(public_key, der_sig, transaction) + +# In this test a transaction is sent to the device to be signed and validated on screen. # The transaction is short and will be sent in one chunk # We will ensure that the displayed information is correct by using screenshots comparison -def test_sign_tx_short_tx(firmware, backend, navigator, test_name): +# The transaction memo should not be displayed as we have not enabled it in the app settings. +def test_sign_tx_short_tx_no_memo(backend, scenario_navigator, firmware): + if firmware.device.startswith("nano"): + pytest.skip("Skipping this test for Nano devices") + # Use the app interface instead of raw interface client = BoilerplateCommandSender(backend) # The path used for this entire test @@ -37,19 +82,7 @@ def test_sign_tx_short_tx(firmware, backend, navigator, test_name): # It will yield the result when the navigation is done with client.sign_tx(path=path, transaction=transaction): # Validate the on-screen request by performing the navigation appropriate for this device - if firmware.device.startswith("nano"): - navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, - [NavInsID.BOTH_CLICK], - "Approve", - ROOT_SCREENSHOT_PATH, - test_name) - else: - navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, - [NavInsID.USE_CASE_REVIEW_CONFIRM, - NavInsID.USE_CASE_STATUS_DISMISS], - "Hold to sign", - ROOT_SCREENSHOT_PATH, - test_name) + scenario_navigator.review_approve() # The device as yielded the result, parse it and ensure that the signature is correct response = client.get_async_response().data @@ -58,10 +91,11 @@ def test_sign_tx_short_tx(firmware, backend, navigator, test_name): assert check_signature_validity(public_key, der_sig, transaction) -# In this test se send to the device a transaction to sign and validate it on screen +# In this test a transaction is sent to the device to be signed and validated on screen. # This test is mostly the same as the previous one but with different values. # In particular the long memo will force the transaction to be sent in multiple chunks -def test_sign_tx_long_tx(firmware, backend, navigator, test_name): +# def test_sign_tx_long_tx(firmware, backend, navigator, test_name): +def test_sign_tx_long_tx(backend, scenario_navigator, firmware, navigator): # Use the app interface instead of raw interface client = BoilerplateCommandSender(backend) path: str = "m/44'/1'/0'/0/0" @@ -79,21 +113,22 @@ def test_sign_tx_long_tx(firmware, backend, navigator, test_name): "As the maximum chunk size is 255 bytes we will make this memo greater than 255 characters. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam.") ).serialize() + + # Enable display of transaction memo (NBGL devices only) + if not firmware.device.startswith("nano"): + navigator.navigate([NavInsID.USE_CASE_HOME_SETTINGS, + NavIns(NavInsID.TOUCH, (200, 113)), + NavInsID.USE_CASE_SUB_SETTINGS_EXIT], + screen_change_before_first_instruction=False, + screen_change_after_last_instruction=False) + # Send the sign device instruction. + # As it requires on-screen validation, the function is asynchronous. + # It will yield the result when the navigation is done with client.sign_tx(path=path, transaction=transaction): - if firmware.device.startswith("nano"): - navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, - [NavInsID.BOTH_CLICK], - "Approve", - ROOT_SCREENSHOT_PATH, - test_name) - else: - navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, - [NavInsID.USE_CASE_REVIEW_CONFIRM, - NavInsID.USE_CASE_STATUS_DISMISS], - "Hold to sign", - ROOT_SCREENSHOT_PATH, - test_name) + # Validate the on-screen request by performing the navigation appropriate for this device + scenario_navigator.review_approve() + response = client.get_async_response().data _, der_sig, _ = unpack_sign_tx_response(response) assert check_signature_validity(public_key, der_sig, transaction) @@ -101,7 +136,7 @@ def test_sign_tx_long_tx(firmware, backend, navigator, test_name): # Transaction signature refused test # The test will ask for a transaction signature that will be refused on screen -def test_sign_tx_refused(firmware, backend, navigator, test_name): +def test_sign_tx_refused(backend, scenario_navigator): # Use the app interface instead of raw interface client = BoilerplateCommandSender(backend) path: str = "m/44'/1'/0'/0/0" @@ -117,29 +152,10 @@ def test_sign_tx_refused(firmware, backend, navigator, test_name): memo="This transaction will be refused by the user" ).serialize() - if firmware.device.startswith("nano"): - with pytest.raises(ExceptionRAPDU) as e: - with client.sign_tx(path=path, transaction=transaction): - navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, - [NavInsID.BOTH_CLICK], - "Reject", - ROOT_SCREENSHOT_PATH, - test_name) - - # Assert that we have received a refusal - assert e.value.status == Errors.SW_DENY - assert len(e.value.data) == 0 - else: - for i in range(3): - instructions = [NavInsID.USE_CASE_REVIEW_TAP] * i - instructions += [NavInsID.USE_CASE_REVIEW_REJECT, - NavInsID.USE_CASE_CHOICE_CONFIRM, - NavInsID.USE_CASE_STATUS_DISMISS] - with pytest.raises(ExceptionRAPDU) as e: - with client.sign_tx(path=path, transaction=transaction): - navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, - test_name + f"/part{i}", - instructions) - # Assert that we have received a refusal - assert e.value.status == Errors.SW_DENY - assert len(e.value.data) == 0 + with pytest.raises(ExceptionRAPDU) as e: + with client.sign_tx(path=path, transaction=transaction): + scenario_navigator.review_reject() + + # Assert that we have received a refusal + assert e.value.status == Errors.SW_DENY + assert len(e.value.data) == 0 diff --git a/tests/test_version_cmd.py b/tests/test_version_cmd.py index 042756d..4d2ecfa 100644 --- a/tests/test_version_cmd.py +++ b/tests/test_version_cmd.py @@ -1,16 +1,16 @@ +import tomli from application_client.boilerplate_command_sender import BoilerplateCommandSender from application_client.boilerplate_response_unpacker import unpack_get_version_response -# Taken from the Cargo.toml, to update every time the version is bumped -MAJOR = 1 -MINOR = 2 -PATCH = 4 - # In this test we check the behavior of the device when asked to provide the app version def test_version(backend): + + with open("Cargo.toml", "rb") as f: + data = tomli.load(f) + version = tuple(map(int, data['package']['version'].split('.'))) # Use the app interface instead of raw interface client = BoilerplateCommandSender(backend) # Send the GET_VERSION instruction rapdu = client.get_version() # Use an helper to parse the response, assert the values - assert unpack_get_version_response(rapdu.data) == (MAJOR, MINOR, PATCH) + assert unpack_get_version_response(rapdu.data) == (version) diff --git a/tests/usage.md b/tests/usage.md index be8890f..201d146 100644 --- a/tests/usage.md +++ b/tests/usage.md @@ -20,7 +20,7 @@ You can use for this the container `ghcr.io/ledgerhq/ledger-app-builder/ledger-a docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest cd # replace with the name of your app, (eg boilerplate) docker run --user "$(id -u)":"$(id -g)" --rm -ti -v "$(realpath .):/app" --privileged -v "/dev/bus/usb:/dev/bus/usb" ledger-app-builder-lite:latest -make clean && make BOLOS_SDK=$_SDK # replace with one of [NANOS, NANOX, NANOSP, STAX] +make clean && make BOLOS_SDK=$_SDK # replace with one of [NANOS, NANOX, NANOSP, STAX, FLEX] exit ``` @@ -41,7 +41,7 @@ You can use for this the container `ghcr.io/ledgerhq/ledger-app-builder/ledger-a docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest cd app-/ # replace with the name of your app, (eg boilerplate) docker run --user "$(id -u)":"$(id -g)" --rm -ti -v "$(realpath .):/app" --privileged -v "/dev/bus/usb:/dev/bus/usb" ledger-app-builder-lite:latest -make clean && make BOLOS_SDK=$_SDK load # replace with one of [NANOS, NANOX, NANOSP, STAX] +make clean && make BOLOS_SDK=$_SDK load # replace with one of [NANOS, NANOX, NANOSP, STAX, FLEX] exit ``` @@ -65,7 +65,7 @@ Standard useful pytest options Custom pytest options ``` - --device run the test on the specified device [nanos,nanox,nanosp,stax,all]. This parameter is mandatory + --device run the test on the specified device [nanos,nanox,nanosp,stax,flex,all]. This parameter is mandatory --backend run the tests against the backend [speculos, ledgercomm, ledgerwallet]. Speculos is the default --display on Speculos, enables the display of the app screen using QT --golden_run on Speculos, screen comparison functions will save the current screen instead of comparing