fix: rename functional to zemu
18
tests/zemu/.babelrc
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"@babel/plugin-proposal-class-properties"
|
||||
]
|
||||
],
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "current"
|
||||
}
|
||||
}
|
||||
],
|
||||
"@babel/preset-flow"
|
||||
],
|
||||
}
|
||||
13
tests/zemu/.flowconfig
Normal file
@@ -0,0 +1,13 @@
|
||||
[ignore]
|
||||
<PROJECT_ROOT>/lib
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
flow-typed
|
||||
|
||||
[lints]
|
||||
|
||||
[options]
|
||||
|
||||
[strict]
|
||||
4
tests/zemu/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/node_modules
|
||||
/snapshots-tmp
|
||||
/elfs
|
||||
/lib
|
||||
8
tests/zemu/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
all:
|
||||
./build_local_test_elfs.sh
|
||||
yarn install
|
||||
yarn test
|
||||
|
||||
.PHONY: all
|
||||
46
tests/zemu/build_local_test_elfs.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
TESTS_FULL_PATH=$(dirname "$(realpath "$0")")
|
||||
|
||||
# FILL THESE WITH YOUR OWN SDKs PATHS
|
||||
# NANOS_SDK=
|
||||
# NANOX_SDK=
|
||||
|
||||
# list of apps required by tests that we want to build here
|
||||
APPS=("ethereum" "ethereum_classic")
|
||||
|
||||
# list of SDKS
|
||||
NANO_SDKS=("$NANOS_SDK" "$NANOX_SDK")
|
||||
# list of target elf file name suffix
|
||||
FILE_SUFFIXES=("nanos" "nanox")
|
||||
|
||||
# move to the tests directory
|
||||
cd "$TESTS_FULL_PATH" || exit 1
|
||||
|
||||
# Do it only now since before the cd command, we might not have been inside the repository
|
||||
GIT_REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
TESTS_REL_PATH=$(realpath --relative-to="$GIT_REPO_ROOT" "$TESTS_FULL_PATH")
|
||||
|
||||
# create elfs directory if it doesn't exist
|
||||
mkdir -p elfs
|
||||
|
||||
# move to repo's root to build apps
|
||||
cd "$GIT_REPO_ROOT" || exit 1
|
||||
|
||||
for ((sdk_idx=0; sdk_idx < "${#NANO_SDKS[@]}"; sdk_idx++))
|
||||
do
|
||||
nano_sdk="${NANO_SDKS[$sdk_idx]}"
|
||||
elf_suffix="${FILE_SUFFIXES[$sdk_idx]}"
|
||||
echo "* Building elfs for $(basename "$nano_sdk")..."
|
||||
for appname in "${APPS[@]}"
|
||||
do
|
||||
echo "** Building app $appname..."
|
||||
make clean BOLOS_SDK="$nano_sdk"
|
||||
make -j DEBUG=1 NFT_TESTING_KEY=1 BOLOS_SDK="$nano_sdk" CHAIN="$appname"
|
||||
cp bin/app.elf "$TESTS_REL_PATH/elfs/${appname}_${elf_suffix}.elf"
|
||||
done
|
||||
done
|
||||
|
||||
echo "done"
|
||||
17
tests/zemu/globalsetup.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import Zemu from "@zondax/zemu";
|
||||
import fsExtra from "fs-extra";
|
||||
|
||||
const catchExit = async () => {
|
||||
process.on("SIGINT", () => {
|
||||
Zemu.stopAllEmuContainers(function () {
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = async () => {
|
||||
await catchExit();
|
||||
await Zemu.checkAndPullImage();
|
||||
await Zemu.stopAllEmuContainers();
|
||||
fsExtra.emptyDirSync("snapshots/tmp")
|
||||
};
|
||||
39
tests/zemu/jest.config.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// For a detailed explanation regarding each configuration property, visit:
|
||||
// https://jestjs.io/docs/en/configuration.html
|
||||
|
||||
module.exports = {
|
||||
modulePaths: ["<rootDir>/src", "<rootDir>/tests"],
|
||||
|
||||
moduleNameMapper: {
|
||||
"^jest$": "<rootDir>/jest.js",
|
||||
},
|
||||
|
||||
// Automatically clear mock calls and instances between every test
|
||||
clearMocks: true,
|
||||
|
||||
// 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>"],
|
||||
|
||||
runner: "jest-serial-runner",
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
testMatch: [
|
||||
"**/__tests__/**/*.[jt]s?(x)",
|
||||
"**/?(*.)+(spec|test).[tj]s?(x)",
|
||||
"**/?(*.)+(ispec|test).[tj]s?(x)",
|
||||
],
|
||||
|
||||
// Path of the file where tests can be """decorated"""
|
||||
setupFilesAfterEnv: ['<rootDir>/setupTests.js'],
|
||||
|
||||
// Stop immediatly when a test fail
|
||||
bail: true,
|
||||
};
|
||||
22
tests/zemu/jest.js
Normal file
@@ -0,0 +1,22 @@
|
||||
export default jest;
|
||||
export const { expect, test } = global;
|
||||
|
||||
export const sim_options_s = {
|
||||
model: "nanos",
|
||||
logging: true,
|
||||
start_delay: 2000,
|
||||
X11: true,
|
||||
custom: "",
|
||||
};
|
||||
|
||||
export const sim_options_x = {
|
||||
model: "nanox",
|
||||
logging: true,
|
||||
start_delay: 2000,
|
||||
X11: true,
|
||||
custom: "",
|
||||
};
|
||||
|
||||
export const Resolve = require("path").resolve;
|
||||
export const NANOS_ELF_PATH = Resolve("elfs/ethereum_nanos.elf");
|
||||
export const NANOX_ELF_PATH = Resolve("elfs/ethereum_nanox.elf");
|
||||
41
tests/zemu/package.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "swap-test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "test.js",
|
||||
"scripts": {
|
||||
"build": "babel src/ -d lib/",
|
||||
"prepublish": "yarn run build",
|
||||
"test": "jest src --verbose --runInBand --detectOpenHandles"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||
"@ledgerhq/hw-app-eth": "^6.5.0",
|
||||
"@ledgerhq/hw-transport-http": "^4.74.2",
|
||||
"@ledgerhq/logs": "^5.50.0",
|
||||
"@zondax/zemu": "^0.27.4",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"bip32-path": "^0.4.2",
|
||||
"core-js": "^3.7.0",
|
||||
"ethereum-tx-decoder": "^3.0.0",
|
||||
"ethers": "^5.5.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"google-protobuf": "^3.11.0",
|
||||
"jest-serial-runner": "^1.1.0",
|
||||
"js-sha256": "^0.9.0",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
"secp256k1": "^3.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.0",
|
||||
"@babel/core": "^7.7.2",
|
||||
"@babel/preset-env": "^7.7.1",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/preset-stage-0": "^7.0.0",
|
||||
"@babel/register": "^7.7.0",
|
||||
"flow-bin": "^0.112.0",
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
19
tests/zemu/setupTests.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import expect from 'expect'
|
||||
|
||||
expect.extend({
|
||||
toMatchSnapshot(received, original) {
|
||||
|
||||
if(received.data.equals(original.data)){
|
||||
return {
|
||||
message: () => `snapshots are equal`,
|
||||
pass: true
|
||||
}
|
||||
} else {
|
||||
console.log("snapshots are not equal")
|
||||
return {
|
||||
message: () => `snapshots are not equal`,
|
||||
pass: false
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00000.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00001.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00002.png
Normal file
|
After Width: | Height: | Size: 346 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00003.png
Normal file
|
After Width: | Height: | Size: 469 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00004.png
Normal file
|
After Width: | Height: | Size: 511 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00005.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00006.png
Normal file
|
After Width: | Height: | Size: 385 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00007.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00008.png
Normal file
|
After Width: | Height: | Size: 340 B |
1
tests/zemu/snapshots/nanos_approve_dai_tokens/00009.png
Symbolic link
@@ -0,0 +1 @@
|
||||
00007.png
|
||||
BIN
tests/zemu/snapshots/nanos_approve_dai_tokens/00010.png
Normal file
|
After Width: | Height: | Size: 349 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00000.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00001.png
Normal file
|
After Width: | Height: | Size: 399 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00002.png
Normal file
|
After Width: | Height: | Size: 305 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00003.png
Normal file
|
After Width: | Height: | Size: 502 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00004.png
Normal file
|
After Width: | Height: | Size: 485 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00005.png
Normal file
|
After Width: | Height: | Size: 387 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00006.png
Normal file
|
After Width: | Height: | Size: 410 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00007.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00008.png
Normal file
|
After Width: | Height: | Size: 340 B |
1
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00009.png
Symbolic link
@@ -0,0 +1 @@
|
||||
00007.png
|
||||
BIN
tests/zemu/snapshots/nanos_deposit_eth_compound_blind/00010.png
Normal file
|
After Width: | Height: | Size: 349 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00000.png
Normal file
|
After Width: | Height: | Size: 531 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00001.png
Normal file
|
After Width: | Height: | Size: 344 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00002.png
Normal file
|
After Width: | Height: | Size: 480 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00003.png
Normal file
|
After Width: | Height: | Size: 514 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00004.png
Normal file
|
After Width: | Height: | Size: 566 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00005.png
Normal file
|
After Width: | Height: | Size: 614 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00006.png
Normal file
|
After Width: | Height: | Size: 628 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00007.png
Normal file
|
After Width: | Height: | Size: 338 B |
BIN
tests/zemu/snapshots/nanos_disable_blind_signing/00008.png
Normal file
|
After Width: | Height: | Size: 531 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00000.png
Normal file
|
After Width: | Height: | Size: 349 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00001.png
Normal file
|
After Width: | Height: | Size: 274 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00002.png
Normal file
|
After Width: | Height: | Size: 357 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00003.png
Normal file
|
After Width: | Height: | Size: 396 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00004.png
Normal file
|
After Width: | Height: | Size: 361 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00005.png
Normal file
|
After Width: | Height: | Size: 434 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00006.png
Normal file
|
After Width: | Height: | Size: 411 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00007.png
Normal file
|
After Width: | Height: | Size: 281 B |
BIN
tests/zemu/snapshots/nanos_enable_blind_signing/00008.png
Normal file
|
After Width: | Height: | Size: 349 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00000.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00001.png
Normal file
|
After Width: | Height: | Size: 359 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00002.png
Normal file
|
After Width: | Height: | Size: 488 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00003.png
Normal file
|
After Width: | Height: | Size: 477 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00004.png
Normal file
|
After Width: | Height: | Size: 408 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00005.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00006.png
Normal file
|
After Width: | Height: | Size: 420 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00007.png
Normal file
|
After Width: | Height: | Size: 429 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00008.png
Normal file
|
After Width: | Height: | Size: 409 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00009.png
Normal file
|
After Width: | Height: | Size: 313 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00010.png
Normal file
|
After Width: | Height: | Size: 315 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00011.png
Normal file
|
After Width: | Height: | Size: 281 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00012.png
Normal file
|
After Width: | Height: | Size: 357 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00013.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00014.png
Normal file
|
After Width: | Height: | Size: 340 B |
1
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00015.png
Symbolic link
@@ -0,0 +1 @@
|
||||
00013.png
|
||||
BIN
tests/zemu/snapshots/nanos_starkware_usdt_deposit/00016.png
Normal file
|
After Width: | Height: | Size: 349 B |
|
After Width: | Height: | Size: 374 B |
|
After Width: | Height: | Size: 330 B |
|
After Width: | Height: | Size: 451 B |
|
After Width: | Height: | Size: 320 B |
|
After Width: | Height: | Size: 497 B |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 373 B |
|
After Width: | Height: | Size: 380 B |
|
After Width: | Height: | Size: 367 B |
|
After Width: | Height: | Size: 414 B |
|
After Width: | Height: | Size: 340 B |
@@ -0,0 +1 @@
|
||||
00009.png
|
||||
|
After Width: | Height: | Size: 349 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00000.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00001.png
Normal file
|
After Width: | Height: | Size: 337 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00002.png
Normal file
|
After Width: | Height: | Size: 451 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00003.png
Normal file
|
After Width: | Height: | Size: 320 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00004.png
Normal file
|
After Width: | Height: | Size: 497 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00005.png
Normal file
|
After Width: | Height: | Size: 504 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00006.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00007.png
Normal file
|
After Width: | Height: | Size: 323 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00008.png
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00009.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00010.png
Normal file
|
After Width: | Height: | Size: 340 B |
1
tests/zemu/snapshots/nanos_transfer_bsc/00011.png
Symbolic link
@@ -0,0 +1 @@
|
||||
00009.png
|
||||
BIN
tests/zemu/snapshots/nanos_transfer_bsc/00012.png
Normal file
|
After Width: | Height: | Size: 349 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00000.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00001.png
Normal file
|
After Width: | Height: | Size: 296 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00002.png
Normal file
|
After Width: | Height: | Size: 434 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00003.png
Normal file
|
After Width: | Height: | Size: 403 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00004.png
Normal file
|
After Width: | Height: | Size: 343 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00005.png
Normal file
|
After Width: | Height: | Size: 345 B |
BIN
tests/zemu/snapshots/nanos_transfer_eip1559/00006.png
Normal file
|
After Width: | Height: | Size: 414 B |