Skip to content

Commit

Permalink
Merge branch 'develop-sync' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dfordivam committed Mar 17, 2023
2 parents f2a8bdb + fc551d3 commit 1dc7783
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rust-app/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Menu for IdleMenuWithSettings {
use crate::menu::SettingsSubMenu::*;
match self.idle_menu {
AppMain => concat!("Alamgu Example ", env!("CARGO_PKG_VERSION")),
Settings(None) => "Settings",
Settings(None) => "Blind Signing",
Settings(Some(EnableBlindSigning)) => "Enable Blind Signing",
Settings(Some(DisableBlindSigning)) => "Disable Blind Signing",
Settings(Some(Back)) => "Back",
Expand Down
2 changes: 2 additions & 0 deletions rust-app/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod nanos {
#[link_section = ".nvm_data"]
static mut SETTINGS: NVMData<AtomicStorage<u8>> = NVMData::new(AtomicStorage::new(&0));

#[derive(Clone, Copy)]
pub struct Settings;

impl Settings {
Expand All @@ -31,6 +32,7 @@ mod nanos {

#[cfg(not(target_os = "nanos"))]
mod nanosplus {
#[derive(Clone, Copy)]
pub struct Settings(u8);

impl Settings {
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/basic_tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sendCommandAndAccept, BASE_URL } from "./common";
import { sendCommandAndAccept, BASE_URL, sendCommandExpectFail, toggleBlindSigningSettings } from "./common";
import { expect } from 'chai';
import { describe, it } from 'mocha';
import Axios from 'axios';
Expand Down
31 changes: 29 additions & 2 deletions ts-tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import Transport from "./http-transport";
import { Common } from "hw-app-alamgu";
import { expect } from 'chai';

const ignoredScreens = [ "W e l c o m e", "Cancel", "Working...", "Exit", "Alamgu Example 0.0.1"]
const ignoredScreens = [ "W e l c o m e", "Cancel", "Working...", "Exit", "Alamgu Example 0.0.1"
, "Blind Signing", "Enable Blind Signing", "Disable Blind Signing", "Back"
/* The next ones are specifically for S+ in which OCR is broken */
, "Blind igning", "Enable Blind igning", "Disable Blind igning"
];

const API_PORT: number = 5005;

Expand Down Expand Up @@ -146,4 +150,27 @@ const sendCommandAndAccept = async function(command : any, prompts : any[]) {
}
}

export { sendCommandAndAccept, BASE_URL }
const sendCommandExpectFail = async function(command : any) {
await setAcceptAutomationRules();
await Axios.delete(BASE_URL + "/events");

const transport = await Transport.open(BASE_URL + "/apdu");
const client = new Common(transport, "alamgu-example");
// client.sendChunks = client.sendWithBlocks; // Use Block protocol

try { await command(client); } catch(e) {
return;
}
expect.fail("Command should have failed");
}

let toggleBlindSigningSettings = async function() {
await Axios.post(BASE_URL + "/button/right", {"action":"press-and-release"});
await Axios.post(BASE_URL + "/button/both", {"action":"press-and-release"});
await Axios.post(BASE_URL + "/button/both", {"action":"press-and-release"});
await Axios.post(BASE_URL + "/button/right", {"action":"press-and-release"});
await Axios.post(BASE_URL + "/button/both", {"action":"press-and-release"});
await Axios.post(BASE_URL + "/button/left", {"action":"press-and-release"});
}

export { sendCommandAndAccept, BASE_URL, sendCommandExpectFail, toggleBlindSigningSettings }

0 comments on commit 1dc7783

Please sign in to comment.