Skip to content

Commit

Permalink
add zemu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed May 2, 2020
1 parent 03c7c50 commit 0a71fbb
Show file tree
Hide file tree
Showing 34 changed files with 1,127 additions and 1,450 deletions.
11 changes: 11 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://www.jetbrains.com/help/clion/configuring-debugger-options.html#gdbinit-lldbinit
#
# You need to create `$HOME/.gdbinit` with the following content:
# set auto-load local-gdbinit on
# add-auto-load-safe-path /

set architecture arm
handle SIGILL nostop pass noprint
add-symbol-file app/bin/app.elf 0x40000000
set backtrace limit 20
b *0x40000000
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ cmake-build-fuzz/
app/src/glyphs.c

app/src/glyphs.h
/build
9 changes: 0 additions & 9 deletions deps/ledger-zxlib/app/common/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,6 @@ view_error_t h_review_update_data() {
viewdata.value, MAX_CHARS_PER_VALUE1_LINE,
viewdata.pageIdx, &viewdata.pageCount);

// if (err == tx_no_data && viewdata.pageIdx > viewdata.pageCount) {
// // Retry capping
// viewdata.pageIdx = viewdata.pageCount;
// err = tx_getItem(viewdata.itemIdx,
// viewdata.key, MAX_CHARS_PER_KEY_LINE,
// viewdata.value, MAX_CHARS_PER_VALUE1_LINE,
// viewdata.pageIdx, &viewdata.pageCount);
// }

if (err == tx_no_data) {
return view_no_data;
}
Expand Down
13 changes: 8 additions & 5 deletions deps/ledger-zxlib/include/zxmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern void explicit_bzero(void *__s, size_t __n) __THROW __nonnull ((1));
#endif
#define __Z_INLINE inline __attribute__((always_inline)) static

void handle_stack_overflow();

#if defined(LEDGER_SPECIFIC)
#include "bolos_target.h"
#endif
Expand Down Expand Up @@ -61,6 +63,10 @@ extern void explicit_bzero(void *__s, size_t __n) __THROW __nonnull ((1));
#include "os_io_seproxyhal.h"
#endif

#define CHECK_APP_CANARY() { if (app_stack_canary != APP_STACK_CANARY_MAGIC) handle_stack_overflow(); }
#define APP_STACK_CANARY_MAGIC 0xDEAD0031
extern unsigned int app_stack_canary;

#define WAIT_EVENT() io_seproxyhal_spi_recv(G_io_seproxyhal_spi_buffer, sizeof(G_io_seproxyhal_spi_buffer), 0)

#define UX_WAIT() \
Expand All @@ -84,6 +90,8 @@ extern void explicit_bzero(void *__s, size_t __n) __THROW __nonnull ((1));

#else

#define CHECK_APP_CANARY() {}

#define MEMMOVE memmove
#define MEMSET memset
#define MEMCPY memcpy
Expand All @@ -110,11 +118,6 @@ __Z_INLINE void __memzero(void *buffer, size_t s) { memset(buffer, 0, s); }
MEMCPY_NV((void*) PIC(DST), (void *) PIC(&nvset_tmp), sizeof(TYPE)); \
}

#define APP_STACK_CANARY_MAGIC 0xDEAD0031
extern unsigned int app_stack_canary;
void handle_stack_overflow();
#define CHECK_APP_CANARY() { if (app_stack_canary != APP_STACK_CANARY_MAGIC) handle_stack_overflow(); }

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define __SWAP(v) (((v) & 0x000000FFu) << 24u | ((v) & 0x0000FF00u) << 8u | ((v) & 0x00FF0000u) >> 8u | ((v) & 0xFF000000u) >> 24u)
#define HtoNL(v) __SWAP( v )
Expand Down
15 changes: 15 additions & 0 deletions tests_zemu/globalsetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Zemu from "@zondax/zemu";

const catchExit = async () => {
process.on("SIGINT", () => {
Zemu.stopAllEmuContainers(function () {
process.exit();
});
});
};

module.exports = async () => {
await catchExit();
await Zemu.checkAndPullImage();
await Zemu.stopAllEmuContainers();
};
2 changes: 2 additions & 0 deletions tests_zemu/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

globalSetup: "<rootDir>/globalsetup.js",

// A list of paths to directories that Jest should use to search for files in
roots: ["<rootDir>"],

Expand Down
18 changes: 9 additions & 9 deletions tests_zemu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"description": "",
"main": "index.js",
"scripts": {
"pull": "docker pull zondax/builder-bolos-emu:latest",
"test": "jest --detectOpenHandles"
},
"repository": {
Expand All @@ -17,25 +16,26 @@
"zondax"
],
"dependencies": {
"@zondax/zemu": "^0.0.7",
"ledger-cosmos-js": "^2.1.7"
"ledger-cosmos-js": "^2",
"@zondax/zemu": "^0.2.4"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/node": "^7.8.7",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.2.6",
"babel-jest": "24",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-vue": "^6.2.2",
"jest": "^25.2.7 ",
"jest-serial-runner": "^1.1.0 "
"eslint-plugin-prettier": "^3.1.3",
"jest": "24",
"jest-serial-runner": "^1.1.0 ",
"secp256k1": "^4.0.1",
"crypto-js": "4.0.0"
}
}
Binary file added tests_zemu/snapshots/show-address/0.png
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 tests_zemu/snapshots/show-address/1.png
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 tests_zemu/snapshots/show-address/2.png
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 tests_zemu/snapshots/show-address/3.png
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 tests_zemu/snapshots/show-address/4.png
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 tests_zemu/snapshots/show-address/5.png
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 tests_zemu/snapshots/show-address/tmp0.png
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 tests_zemu/snapshots/sign-basic/0.png
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 tests_zemu/snapshots/sign-basic/1.png
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 tests_zemu/snapshots/sign-basic/10.png
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 tests_zemu/snapshots/sign-basic/11.png
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 tests_zemu/snapshots/sign-basic/12.png
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 tests_zemu/snapshots/sign-basic/13.png
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 tests_zemu/snapshots/sign-basic/14.png
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 tests_zemu/snapshots/sign-basic/15.png
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 tests_zemu/snapshots/sign-basic/2.png
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 tests_zemu/snapshots/sign-basic/3.png
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 tests_zemu/snapshots/sign-basic/4.png
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 tests_zemu/snapshots/sign-basic/5.png
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 tests_zemu/snapshots/sign-basic/6.png
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 tests_zemu/snapshots/sign-basic/7.png
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 tests_zemu/snapshots/sign-basic/8.png
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 tests_zemu/snapshots/sign-basic/9.png
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 tests_zemu/snapshots/signTransaction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0a71fbb

Please sign in to comment.