Skip to content

Commit

Permalink
Merge pull request #4 from blooo-io/feat/LAPP-5-implement-minttoken-t…
Browse files Browse the repository at this point in the history
…ests

Feat/lapp 5 implement minttoken tests
  • Loading branch information
lisaoulmi authored Nov 24, 2021
2 parents c332c7f + 976dc2a commit 0f75ce4
Show file tree
Hide file tree
Showing 71 changed files with 14,741 additions and 1,655 deletions.
78 changes: 39 additions & 39 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,46 @@ jobs:
make clean
make BOLOS_SDK=$NANOS_SDK
job_build_debug_nano_x:
name: Build debug Nano X
runs-on: ubuntu-latest
# job_build_debug_nano_x:
# name: Build debug Nano X
# runs-on: ubuntu-latest

container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
# container:
# image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest

steps:
- name: Clone
uses: actions/checkout@v2
with:
submodules: recursive
# steps:
# - name: Clone
# uses: actions/checkout@v2
# with:
# submodules: recursive

- name: Build plugin for Nano X
run: |
make clean
make BOLOS_SDK=$NANOX_SDK
# - name: Build plugin for Nano X
# run: |
# make clean
# make BOLOS_SDK=$NANOX_SDK

jobs-e2e-tests:
needs: [job_build_debug_nano_s, job_build_debug_nano_x]
runs-on: ubuntu-latest
steps:
- name: Test
run: |
id
echo $HOME
echo $DISPLAY
- name: Checkout
uses: actions/checkout@v2
- run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
- name: Install node
uses: actions/setup-node@v2
with:
node-version: "14.4.0"
- name: Install yarn
run: |
npm install -g yarn
- name: Build/Install build js deps
run: |
cd tests && yarn install
- name: Run zemu tests
run: |
cd tests && yarn test
# jobs-e2e-tests:
# needs: [job_build_debug_nano_s, job_build_debug_nano_x]
# runs-on: ubuntu-latest
# steps:
# - name: Test
# run: |
# id
# echo $HOME
# echo $DISPLAY
# - name: Checkout
# uses: actions/checkout@v2
# - run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
# - name: Install node
# uses: actions/setup-node@v2
# with:
# node-version: "14.4.0"
# - name: Install yarn
# run: |
# npm install -g yarn
# - name: Build/Install build js deps
# run: |
# cd tests && yarn install
# - name: Run zemu tests
# run: |
# cd tests && yarn test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ obj/

# Editors
.idea/
.vscode

# Python
*.pyc[cod]
Expand All @@ -21,3 +20,4 @@ __pycache__/
# JS
tests/node_modules
tests/lib
tests/snapshots-tmp
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
39 changes: 27 additions & 12 deletions Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ endif

include $(BOLOS_SDK)/Makefile.defines

# EDIT THIS: Put your plugin name
APPNAME = "Poap"

APP_LOAD_PARAMS += --appFlags 0x800 --path "44'/60'" --path "45'" --curve secp256k1

APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS)

APPVERSION_M = 1
APPVERSION_N = 0
APPVERSION_P = 0
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"
APPVERSION_N = 1
APPVERSION_P = 2
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)

APPNAME = "Poap"

# EDIT THIS: Change the name of the gif, and generate you own GIFs!
#prepare hsm generation
ifeq ($(TARGET_NAME), TARGET_NANOX)
ICONNAME=icons/nanox_app_poap.gif
else
Expand Down Expand Up @@ -73,12 +71,25 @@ else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
endif


# Enabling debug PRINTF
DEBUG:= 0
ifneq ($(DEBUG),0)
DEFINES += PRINTF=semihosted_printf
CFLAGS += -include src/dbg/debug.h
DEFINES += HAVE_STACK_OVERFLOW_CHECK
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=4 IO_HID_EP_LENGTH=64 HAVE_USB_APDU

ifeq ($(DEBUG),10)
$(warning Using semihosted PRINTF. Only run with speculos!)
CFLAGS += -include src/dbg/debug.h
DEFINES += HAVE_PRINTF PRINTF=semihosted_printf
else
ifeq ($(TARGET_NAME),TARGET_NANOX)
DEFINES += HAVE_PRINTF PRINTF=mcu_usb_printf
else
DEFINES += HAVE_PRINTF PRINTF=screen_printf
endif

endif
else
DEFINES += PRINTF\(...\)=
endif
Expand All @@ -102,6 +113,7 @@ endif

CC := $(CLANGPATH)clang

#CFLAGS += -O0
CFLAGS += -O3 -Os

AS := $(GCCPATH)arm-none-eabi-gcc
Expand All @@ -116,6 +128,10 @@ include $(BOLOS_SDK)/Makefile.glyphs
### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
APP_SOURCE_PATH += src ethereum-plugin-sdk
SDK_SOURCE_PATH += lib_ux
ifeq ($(TARGET_NAME),TARGET_NANOX)
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
endif


# remove UX warnings from SDK even though the plugin doesn't use it
DEFINES += HAVE_UX_FLOW
Expand All @@ -140,5 +156,4 @@ include $(BOLOS_SDK)/Makefile.rules
dep/%.d: %.c Makefile

listvariants:
# EDIT THIS: replace `poap` by the lowercase name of your plugin
@echo VARIANTS NONE poap
Binary file added glyphs/icon_back.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_back_x.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_certificate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_crossmark.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_dashboard.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_dashboard_x.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_down.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_eye.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_left.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_right.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_toggle_reset.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_toggle_set.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_up.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_validate_14.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/icon_warning.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions node_modules/.yarn-integrity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions src/dbg/debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include "printf.h"

void debug_write(const char *buf) {
asm volatile(
"movs r0, #0x04\n"
"movs r1, %0\n"
"svc 0xab\n" ::"r"(buf)
: "r0", "r1");
}

int semihosted_printf(const char *format, ...) {
char buf[128 + 1];

va_list args;
va_start(args, format);

int ret = vsnprintf(buf, sizeof(buf) - 1, format, args);

va_end(args);

debug_write("semi-hosting: ");
if (ret > 0) {
buf[ret] = 0;
debug_write(buf);
}

return ret;
}

static const char G_HEX[] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f',
};

// %.*H doesn't work with semi-hosted printf, so here's a utility function to print bytes in hex
// format.
void print_bytes(const uint8_t *bytes, uint16_t len) {
unsigned char nibble1, nibble2;
char str[] = {0, 0, 0};

debug_write("bytes: ");
for (uint16_t count = 0; count < len; count++) {
nibble1 = (bytes[count] >> 4) & 0xF;
nibble2 = bytes[count] & 0xF;
str[0] = G_HEX[nibble1];
str[1] = G_HEX[nibble2];
debug_write(str);
debug_write(" ");
}
debug_write("\n");
}
5 changes: 3 additions & 2 deletions src/dbg/debug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <stdint.h>
void debug_write(const char *buf);

// Printf that uses speculos semi-hosting features.
void semihosted_printf(const char *format, ...);
int semihosted_printf(const char *format, ...);
void print_bytes(const uint8_t *bytes, uint16_t len);
Loading

0 comments on commit 0f75ce4

Please sign in to comment.