From 23522acc36ac7a32d75c91eb8df57ced659dc61d Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Tue, 2 Oct 2018 17:47:39 +0200 Subject: [PATCH] xmr: adding agent tests to travis --- .travis.yml | 8 ++++++++ Makefile | 3 +++ Pipfile | 3 +++ tests/run_tests_device_emu_monero.sh | 22 ++++++++++++++++++++++ travis-install-libsodium.sh | 21 +++++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100755 tests/run_tests_device_emu_monero.sh create mode 100755 travis-install-libsodium.sh diff --git a/.travis.yml b/.travis.yml index bf61f2800..fbbd52375 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,10 @@ addons: - python3.6-dev - python3.6-venv +cache: + directories: + - $HOME/libsodium + before_install: - python3.6 -m ensurepip --user - python3.6 -m pip install --user pipenv @@ -42,6 +46,9 @@ install: - curl -LO "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" - unzip "protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" -d protoc - export PATH="$(pwd)/protoc/bin:$PATH" + - ./travis-install-libsodium.sh + - export PKG_CONFIG_PATH=$HOME/libsodium/lib/pkgconfig:$PKG_CONFIG_PATH + - export LD_LIBRARY_PATH=$HOME/libsodium/lib:$LD_LIBRARY_PATH - pipenv install before_script: @@ -63,6 +70,7 @@ script: - test "$GOAL" != "unix" || pipenv run make build_unix_noui - test "$GOAL" != "unix" || pipenv run make test - test "$GOAL" != "unix" || pipenv run make test_emu + - test "$GOAL" != "unix" || pipenv run make test_emu_monero notifications: webhooks: diff --git a/Makefile b/Makefile index 090a3deb4..6f150830f 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,9 @@ test: ## run unit tests test_emu: ## run selected device tests from python-trezor cd tests ; ./run_tests_device_emu.sh $(TESTOPTS) +test_emu_monero: ## run selected monero device tests from monero-agent + cd tests ; ./run_tests_device_emu_monero.sh $(TESTOPTS) + pylint: ## run pylint on application sources and tests pylint -E $(shell find src tests -name *.py) diff --git a/Pipfile b/Pipfile index 50aceacef..1dc6243d6 100644 --- a/Pipfile +++ b/Pipfile @@ -25,5 +25,8 @@ termcolor = ">=0.1.2" Pillow = ">=5.2.0" Mako = ">=1.0.7" +# monero +monero_agent = {version = ">=1.6.3", extras = ["tcry", "dev"]} + [pipenv] allow_prereleases = true diff --git a/tests/run_tests_device_emu_monero.sh b/tests/run_tests_device_emu_monero.sh new file mode 100755 index 000000000..a8cff51bc --- /dev/null +++ b/tests/run_tests_device_emu_monero.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +MICROPYTHON=../build/unix/micropython +PYOPT=0 + +# run emulator +cd ../src +$MICROPYTHON -O$PYOPT main.py >/dev/null & +upy_pid=$! +sleep 1 + +export TREZOR_PATH=udp:127.0.0.1:21324 + +# run tests +cd .. + +export EC_BACKEND_FORCE=1 +export EC_BACKEND=1 +python3 -m unittest trezor_monero_test.test_trezor +error=$? +kill $upy_pid +exit $error diff --git a/travis-install-libsodium.sh b/travis-install-libsodium.sh new file mode 100755 index 000000000..3e73215fd --- /dev/null +++ b/travis-install-libsodium.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# libsodium-dev replacement +# +# The purpose of this file is to install libsodium in +# the Travis CI environment. Outside this environment, +# you would probably not want to install it like this. + +set -e +export LIBSODIUM_VER="1.0.16" + +# check if libsodium is already installed +if [ ! -d "$HOME/libsodium/lib" ]; then + wget "https://github.com/jedisct1/libsodium/releases/download/${LIBSODIUM_VER}/libsodium-${LIBSODIUM_VER}.tar.gz" + tar xvfz "libsodium-${LIBSODIUM_VER}.tar.gz" + cd "libsodium-${LIBSODIUM_VER}" + ./configure --prefix=$HOME/libsodium + make + make install +else + echo 'Using cached directory.' +fi