parent
ed1785a985
commit
e1cbb8a970
@ -0,0 +1,28 @@
|
||||
syntax = "proto2";
|
||||
package hw.trezor.messages.helloworld;
|
||||
|
||||
// Sugar for easier handling in Java
|
||||
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
||||
option java_outer_classname = "TrezorMessageHelloWorld";
|
||||
|
||||
import "messages.proto";
|
||||
|
||||
|
||||
/**
|
||||
* Request: Hello world request for text
|
||||
* @next HelloWorldResponse
|
||||
* @next Failure
|
||||
*/
|
||||
message HelloWorldRequest {
|
||||
required string name = 1;
|
||||
optional uint32 amount = 2 [default=1];
|
||||
optional bool show_display = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response: Hello world text
|
||||
* @end
|
||||
*/
|
||||
message HelloWorldResponse {
|
||||
required string text = 1;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.messages import HelloWorldResponse
|
||||
from trezor.ui.layouts import confirm_text
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from trezor.messages import HelloWorldRequest
|
||||
|
||||
|
||||
async def hello_world(msg: HelloWorldRequest) -> HelloWorldResponse:
|
||||
text = _get_text_from_msg(msg)
|
||||
if msg.show_display:
|
||||
await confirm_text(
|
||||
"confirm_hello_world",
|
||||
"Hello world",
|
||||
text,
|
||||
description="Hello world example",
|
||||
)
|
||||
return HelloWorldResponse(text=text)
|
||||
|
||||
|
||||
def _get_text_from_msg(msg: HelloWorldRequest) -> str:
|
||||
return msg.amount * f"Hello {msg.name}!\n"
|
@ -0,0 +1,14 @@
|
||||
from common import *
|
||||
|
||||
from trezor.messages import HelloWorldRequest
|
||||
from apps.misc.hello_world import _get_text_from_msg
|
||||
|
||||
|
||||
class TestHelloWorld(unittest.TestCase):
|
||||
def test_get_text_from_msg(self):
|
||||
msg = HelloWorldRequest(name="Satoshi", amount=2, show_display=False)
|
||||
self.assertEqual(_get_text_from_msg(msg), "Hello Satoshi!\nHello Satoshi!\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -0,0 +1,28 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
import click
|
||||
|
||||
from .. import hello_world
|
||||
from . import with_client
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client import TrezorClient
|
||||
|
||||
|
||||
@click.group(name="helloworld")
|
||||
def cli() -> None:
|
||||
"""Hello world commands."""
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument("name")
|
||||
@click.option("-a", "--amount", type=int, help="How many times to greet.")
|
||||
@click.option(
|
||||
"-d", "--show-display", is_flag=True, help="Whether to show confirmation screen."
|
||||
)
|
||||
@with_client
|
||||
def say_hello(
|
||||
client: "TrezorClient", name: str, amount: Optional[int], show_display: bool
|
||||
) -> str:
|
||||
"""Simply say hello to the supplied name."""
|
||||
return hello_world.say_hello(client, name, amount, show_display=show_display)
|
@ -0,0 +1,24 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from . import messages
|
||||
from .tools import expect
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .client import TrezorClient
|
||||
from .protobuf import MessageType
|
||||
|
||||
|
||||
@expect(messages.HelloWorldResponse, field="text", ret_type=str)
|
||||
def say_hello(
|
||||
client: "TrezorClient",
|
||||
name: str,
|
||||
amount: Optional[int],
|
||||
show_display: bool,
|
||||
) -> "MessageType":
|
||||
return client.call(
|
||||
messages.HelloWorldRequest(
|
||||
name=name,
|
||||
amount=amount,
|
||||
show_display=show_display,
|
||||
)
|
||||
)
|
@ -0,0 +1,462 @@
|
||||
// This file is generated by rust-protobuf 3.3.0. Do not edit
|
||||
// .proto file is parsed by protoc 3.19.6
|
||||
// @generated
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/702
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(clippy::all)]
|
||||
|
||||
#![allow(unused_attributes)]
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
|
||||
#![allow(box_pointers)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(trivial_casts)]
|
||||
#![allow(unused_results)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
//! Generated file from `messages-hello.proto`
|
||||
|
||||
/// Generated files are compatible only with the same version
|
||||
/// of protobuf runtime.
|
||||
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_3_0;
|
||||
|
||||
// @@protoc_insertion_point(message:hw.trezor.messages.helloworld.HelloWorldRequest)
|
||||
#[derive(PartialEq,Clone,Default,Debug)]
|
||||
pub struct HelloWorldRequest {
|
||||
// message fields
|
||||
// @@protoc_insertion_point(field:hw.trezor.messages.helloworld.HelloWorldRequest.name)
|
||||
pub name: ::std::option::Option<::std::string::String>,
|
||||
// @@protoc_insertion_point(field:hw.trezor.messages.helloworld.HelloWorldRequest.amount)
|
||||
pub amount: ::std::option::Option<u32>,
|
||||
// @@protoc_insertion_point(field:hw.trezor.messages.helloworld.HelloWorldRequest.show_display)
|
||||
pub show_display: ::std::option::Option<bool>,
|
||||
// special fields
|
||||
// @@protoc_insertion_point(special_field:hw.trezor.messages.helloworld.HelloWorldRequest.special_fields)
|
||||
pub special_fields: ::protobuf::SpecialFields,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a HelloWorldRequest {
|
||||
fn default() -> &'a HelloWorldRequest {
|
||||
<HelloWorldRequest as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl HelloWorldRequest {
|
||||
pub fn new() -> HelloWorldRequest {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
// required string name = 1;
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
match self.name.as_ref() {
|
||||
Some(v) => v,
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_name(&mut self) {
|
||||
self.name = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_name(&self) -> bool {
|
||||
self.name.is_some()
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_name(&mut self, v: ::std::string::String) {
|
||||
self.name = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_name(&mut self) -> &mut ::std::string::String {
|
||||
if self.name.is_none() {
|
||||
self.name = ::std::option::Option::Some(::std::string::String::new());
|
||||
}
|
||||
self.name.as_mut().unwrap()
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_name(&mut self) -> ::std::string::String {
|
||||
self.name.take().unwrap_or_else(|| ::std::string::String::new())
|
||||
}
|
||||
|
||||
// optional uint32 amount = 2;
|
||||
|
||||
pub fn amount(&self) -> u32 {
|
||||
self.amount.unwrap_or(1u32)
|
||||
}
|
||||
|
||||
pub fn clear_amount(&mut self) {
|
||||
self.amount = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_amount(&self) -> bool {
|
||||
self.amount.is_some()
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_amount(&mut self, v: u32) {
|
||||
self.amount = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// optional bool show_display = 3;
|
||||
|
||||
pub fn show_display(&self) -> bool {
|
||||
self.show_display.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn clear_show_display(&mut self) {
|
||||
self.show_display = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_show_display(&self) -> bool {
|
||||
self.show_display.is_some()
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_show_display(&mut self, v: bool) {
|
||||
self.show_display = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
|
||||
let mut fields = ::std::vec::Vec::with_capacity(3);
|
||||
let mut oneofs = ::std::vec::Vec::with_capacity(0);
|
||||
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
|
||||
"name",
|
||||
|m: &HelloWorldRequest| { &m.name },
|
||||
|m: &mut HelloWorldRequest| { &mut m.name },
|
||||
));
|
||||
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
|
||||
"amount",
|
||||
|m: &HelloWorldRequest| { &m.amount },
|
||||
|m: &mut HelloWorldRequest| { &mut m.amount },
|
||||
));
|
||||
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
|
||||
"show_display",
|
||||
|m: &HelloWorldRequest| { &m.show_display },
|
||||
|m: &mut HelloWorldRequest| { &mut m.show_display },
|
||||
));
|
||||
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<HelloWorldRequest>(
|
||||
"HelloWorldRequest",
|
||||
fields,
|
||||
oneofs,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for HelloWorldRequest {
|
||||
const NAME: &'static str = "HelloWorldRequest";
|
||||
|
||||
fn is_initialized(&self) -> bool {
|
||||
if self.name.is_none() {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
|
||||
while let Some(tag) = is.read_raw_tag_or_eof()? {
|
||||
match tag {
|
||||
10 => {
|
||||
self.name = ::std::option::Option::Some(is.read_string()?);
|
||||
},
|
||||
16 => {
|
||||
self.amount = ::std::option::Option::Some(is.read_uint32()?);
|
||||
},
|
||||
24 => {
|
||||
self.show_display = ::std::option::Option::Some(is.read_bool()?);
|
||||
},
|
||||
tag => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
|
||||
},
|
||||
};
|
||||
}
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
|
||||
// Compute sizes of nested messages
|
||||
#[allow(unused_variables)]
|
||||
fn compute_size(&self) -> u64 {
|
||||
let mut my_size = 0;
|
||||
if let Some(v) = self.name.as_ref() {
|
||||
my_size += ::protobuf::rt::string_size(1, &v);
|
||||
}
|
||||
if let Some(v) = self.amount {
|
||||
my_size += ::protobuf::rt::uint32_size(2, v);
|
||||
}
|
||||
if let Some(v) = self.show_display {
|
||||
my_size += 1 + 1;
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
|
||||
self.special_fields.cached_size().set(my_size as u32);
|
||||
my_size
|
||||
}
|
||||
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
|
||||
if let Some(v) = self.name.as_ref() {
|
||||
os.write_string(1, v)?;
|
||||
}
|
||||
if let Some(v) = self.amount {
|
||||
os.write_uint32(2, v)?;
|
||||
}
|
||||
if let Some(v) = self.show_display {
|
||||
os.write_bool(3, v)?;
|
||||
}
|
||||
os.write_unknown_fields(self.special_fields.unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
|
||||
fn special_fields(&self) -> &::protobuf::SpecialFields {
|
||||
&self.special_fields
|
||||
}
|
||||
|
||||
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
|
||||
&mut self.special_fields
|
||||
}
|
||||
|
||||
fn new() -> HelloWorldRequest {
|
||||
HelloWorldRequest::new()
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.name = ::std::option::Option::None;
|
||||
self.amount = ::std::option::Option::None;
|
||||
self.show_display = ::std::option::Option::None;
|
||||
self.special_fields.clear();
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static HelloWorldRequest {
|
||||
static instance: HelloWorldRequest = HelloWorldRequest {
|
||||
name: ::std::option::Option::None,
|
||||
amount: ::std::option::Option::None,
|
||||
show_display: ::std::option::Option::None,
|
||||
special_fields: ::protobuf::SpecialFields::new(),
|
||||
};
|
||||
&instance
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::MessageFull for HelloWorldRequest {
|
||||
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
|
||||
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
|
||||
descriptor.get(|| file_descriptor().message_by_package_relative_name("HelloWorldRequest").unwrap()).clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Display for HelloWorldRequest {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for HelloWorldRequest {
|
||||
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(message:hw.trezor.messages.helloworld.HelloWorldResponse)
|
||||
#[derive(PartialEq,Clone,Default,Debug)]
|
||||
pub struct HelloWorldResponse {
|
||||
// message fields
|
||||
// @@protoc_insertion_point(field:hw.trezor.messages.helloworld.HelloWorldResponse.text)
|
||||
pub text: ::std::option::Option<::std::string::String>,
|
||||
// special fields
|
||||
// @@protoc_insertion_point(special_field:hw.trezor.messages.helloworld.HelloWorldResponse.special_fields)
|
||||
pub special_fields: ::protobuf::SpecialFields,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a HelloWorldResponse {
|
||||
fn default() -> &'a HelloWorldResponse {
|
||||
<HelloWorldResponse as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl HelloWorldResponse {
|
||||
pub fn new() -> HelloWorldResponse {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
// required string text = 1;
|
||||
|
||||
pub fn text(&self) -> &str {
|
||||
match self.text.as_ref() {
|
||||
Some(v) => v,
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_text(&mut self) {
|
||||
self.text = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_text(&self) -> bool {
|
||||
self.text.is_some()
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_text(&mut self, v: ::std::string::String) {
|
||||
self.text = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_text(&mut self) -> &mut ::std::string::String {
|
||||
if self.text.is_none() {
|
||||
self.text = ::std::option::Option::Some(::std::string::String::new());
|
||||
}
|
||||
self.text.as_mut().unwrap()
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_text(&mut self) -> ::std::string::String {
|
||||
self.text.take().unwrap_or_else(|| ::std::string::String::new())
|
||||
}
|
||||
|
||||
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
|
||||
let mut fields = ::std::vec::Vec::with_capacity(1);
|
||||
let mut oneofs = ::std::vec::Vec::with_capacity(0);
|
||||
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
|
||||
"text",
|
||||
|m: &HelloWorldResponse| { &m.text },
|
||||
|m: &mut HelloWorldResponse| { &mut m.text },
|
||||
));
|
||||
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<HelloWorldResponse>(
|
||||
"HelloWorldResponse",
|
||||
fields,
|
||||
oneofs,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for HelloWorldResponse {
|
||||
const NAME: &'static str = "HelloWorldResponse";
|
||||
|
||||
fn is_initialized(&self) -> bool {
|
||||
if self.text.is_none() {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> {
|
||||
while let Some(tag) = is.read_raw_tag_or_eof()? {
|
||||
match tag {
|
||||
10 => {
|
||||
self.text = ::std::option::Option::Some(is.read_string()?);
|
||||
},
|
||||
tag => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
|
||||
},
|
||||
};
|
||||
}
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
|
||||
// Compute sizes of nested messages
|
||||
#[allow(unused_variables)]
|
||||
fn compute_size(&self) -> u64 {
|
||||
let mut my_size = 0;
|
||||
if let Some(v) = self.text.as_ref() {
|
||||
my_size += ::protobuf::rt::string_size(1, &v);
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
|
||||
self.special_fields.cached_size().set(my_size as u32);
|
||||
my_size
|
||||
}
|
||||
|
||||
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> {
|
||||
if let Some(v) = self.text.as_ref() {
|
||||
os.write_string(1, v)?;
|
||||
}
|
||||
os.write_unknown_fields(self.special_fields.unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
|
||||
fn special_fields(&self) -> &::protobuf::SpecialFields {
|
||||
&self.special_fields
|
||||
}
|
||||
|
||||
fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
|
||||
&mut self.special_fields
|
||||
}
|
||||
|
||||
fn new() -> HelloWorldResponse {
|
||||
HelloWorldResponse::new()
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.text = ::std::option::Option::None;
|
||||
self.special_fields.clear();
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static HelloWorldResponse {
|
||||
static instance: HelloWorldResponse = HelloWorldResponse {
|
||||
text: ::std::option::Option::None,
|
||||
special_fields: ::protobuf::SpecialFields::new(),
|
||||
};
|
||||
&instance
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::MessageFull for HelloWorldResponse {
|
||||
fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
|
||||
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new();
|
||||
descriptor.get(|| file_descriptor().message_by_package_relative_name("HelloWorldResponse").unwrap()).clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Display for HelloWorldResponse {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for HelloWorldResponse {
|
||||
type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x14messages-hello.proto\x12\x1dhw.trezor.messages.helloworld\x1a\x0em\
|
||||
essages.proto\"e\n\x11HelloWorldRequest\x12\x12\n\x04name\x18\x01\x20\
|
||||
\x02(\tR\x04name\x12\x19\n\x06amount\x18\x02\x20\x01(\r:\x011R\x06amount\
|
||||
\x12!\n\x0cshow_display\x18\x03\x20\x01(\x08R\x0bshowDisplay\"(\n\x12Hel\
|
||||
loWorldResponse\x12\x12\n\x04text\x18\x01\x20\x02(\tR\x04textB>\n#com.sa\
|
||||
toshilabs.trezor.lib.protobufB\x17TrezorMessageHelloWorld\
|
||||
";
|
||||
|
||||
/// `FileDescriptorProto` object which was a source for this generated file
|
||||
fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new();
|
||||
file_descriptor_proto_lazy.get(|| {
|
||||
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
|
||||
})
|
||||
}
|
||||
|
||||
/// `FileDescriptor` object which allows dynamic access to files
|
||||
pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor {
|
||||
static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new();
|
||||
static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new();
|
||||
file_descriptor.get(|| {
|
||||
let generated_file_descriptor = generated_file_descriptor_lazy.get(|| {
|
||||
let mut deps = ::std::vec::Vec::with_capacity(1);
|
||||
deps.push(super::messages::file_descriptor().clone());
|
||||
let mut messages = ::std::vec::Vec::with_capacity(2);
|
||||
messages.push(HelloWorldRequest::generated_message_descriptor_data());
|
||||
messages.push(HelloWorldResponse::generated_message_descriptor_data());
|
||||
let mut enums = ::std::vec::Vec::with_capacity(0);
|
||||
::protobuf::reflect::GeneratedFileDescriptor::new_generated(
|
||||
file_descriptor_proto(),
|
||||
deps,
|
||||
messages,
|
||||
enums,
|
||||
)
|
||||
});
|
||||
::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor)
|
||||
})
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
# This file is part of the Trezor project.
|
||||
#
|
||||
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import hello_world
|
||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||
|
||||
VECTORS = ( # name, amount, show_display
|
||||
("George", 2, True),
|
||||
("John", 3, False),
|
||||
("Hannah", None, False),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
@pytest.mark.parametrize("name, amount, show_display", VECTORS)
|
||||
def test_hello_world(
|
||||
client: Client, name: str, amount: Optional[int], show_display: bool
|
||||
):
|
||||
with client:
|
||||
greeting_text = hello_world.say_hello(
|
||||
client, name=name, amount=amount, show_display=show_display
|
||||
)
|
||||
greeting_lines = greeting_text.strip().splitlines()
|
||||
|
||||
assert len(greeting_lines) == amount or 1
|
||||
assert all(name in line for line in greeting_lines)
|
Loading…
Reference in new issue