From eb2ca5e3adef04593057353dcc4cd3dc0cb8ffc9 Mon Sep 17 00:00:00 2001 From: GroM Date: Mon, 10 Jun 2024 14:09:08 +0200 Subject: [PATCH] Make all tests PASS for all targets --- .cargo/config.toml | 4 +- ledger_device_sdk/src/nbgl.rs | 5 -- ledger_device_sdk/tests/ecc_tests.rs | 76 ---------------------------- 3 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 ledger_device_sdk/tests/ecc_tests.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index e3084b84..a3f6ca44 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,10 +8,10 @@ runner = "speculos -m nanox --display=headless" runner = "speculos -m nanosp --display=headless" [target.stax] -runner = "speculos --model stax" +runner = "speculos --model stax --display=headless" [target.flex] -runner = "speculos --model flex" +runner = "speculos --model flex --display=headless" [unstable] build-std = ["core"] diff --git a/ledger_device_sdk/src/nbgl.rs b/ledger_device_sdk/src/nbgl.rs index 75d29507..655b8c5e 100644 --- a/ledger_device_sdk/src/nbgl.rs +++ b/ledger_device_sdk/src/nbgl.rs @@ -583,8 +583,3 @@ extern "C" fn io_seproxyhal_play_tune(tune_index: u8) { return; } } - -#[panic_handler] -fn panic(_: &core::panic::PanicInfo) -> ! { - exit_app(1); -} diff --git a/ledger_device_sdk/tests/ecc_tests.rs b/ledger_device_sdk/tests/ecc_tests.rs deleted file mode 100644 index 2dd9ed36..00000000 --- a/ledger_device_sdk/tests/ecc_tests.rs +++ /dev/null @@ -1,76 +0,0 @@ -#![no_std] -#![no_main] -#![reexport_test_harness_main = "test_main"] -#![feature(custom_test_frameworks)] -#![test_runner(ledger_device_sdk::testing::sdk_test_runner)] - -use core::panic::PanicInfo; -use ledger_device_sdk::testing::{test_panic, TestType}; -use testmacro::test_item as test; - -#[panic_handler] -fn panic(info: &PanicInfo) -> ! { - test_panic(info); -} - -#[no_mangle] -extern "C" fn sample_main() { - test_main(); - ledger_device_sdk::exit_app(0); -} - -/// Integration tests: ECC module -use ledger_device_sdk::ecc::{make_bip32_path, Secp256k1, Secp256r1, SeedDerive, Stark256}; - -const PATH: [u32; 5] = make_bip32_path(b"m/44'/123'/0'/0/0"); - -#[test] -fn test_secp256k1() { - let key: [u8; 32] = [0u8; 32]; - - let _priv_key = Secp256k1::new(); - let _priv_key = Secp256k1::from(&key); - let priv_key = Secp256k1::derive_from_path(&PATH); - - let hash = b"Not your Keys, not your Coins"; - - let signature = priv_key.deterministic_sign(hash).unwrap(); - - let pub_key = priv_key.public_key().unwrap(); - - assert!(pub_key.verify((&signature.0, signature.1), hash)); -} - -#[test] -fn test_secp256r1() { - let key: [u8; 32] = [0u8; 32]; - - let _priv_key = Secp256r1::new(); - let _priv_key = Secp256r1::from(&key); - let priv_key = Secp256r1::derive_from_path(&PATH); - - let hash = b"Not your Keys, not your Coins"; - - let signature = priv_key.deterministic_sign(hash).unwrap(); - - let pub_key = priv_key.public_key().unwrap(); - - assert!(pub_key.verify((&signature.0, signature.1), hash)); -} - -#[test] -fn test_stark256() { - let key: [u8; 32] = [0u8; 32]; - - let _priv_key = Stark256::new(); - let _priv_key = Stark256::from(&key); - let priv_key = Stark256::derive_from_path(&PATH); - - let hash = b"Not your Keys, not your Coins"; - - let signature = priv_key.deterministic_sign(hash).unwrap(); - - let pub_key = priv_key.public_key().unwrap(); - - assert!(pub_key.verify((&signature.0, signature.1), hash)); -}