diff --git a/install.sh b/install.sh index 3121c2c..6258097 100755 --- a/install.sh +++ b/install.sh @@ -1,9 +1,5 @@ #!/bin/bash -# jm_source="$PWD/.." -# jm_root="${jm_source}/jmvenv" -# jm_deps="${jm_source}/deps" - gpg_verify_key () { gpg --keyid-format long <"$1" | grep "$2" @@ -46,6 +42,7 @@ check_skip_build () read -p "Directory ${1} exists. Remove and recreate? (y/n) " q if [[ "${q}" =~ Y|y ]]; then rm -rf "./${1}" + mkdir -p "./${1}" return 1 else echo "skipping ${1}..." @@ -60,7 +57,8 @@ venv_setup () if check_skip_build 'jmvenv'; then return 0 fi - virtualenv -p python2 jmvenv + rm -rf "${jm_source}/deps" + virtualenv -p python2 "${jm_source}/jmvenv" } openssl_get () @@ -75,6 +73,14 @@ openssl_build () { ./config shared --prefix="${jm_root}" make -j + rm -rf "${jm_root}/ssl" \ + "${jm_root}/lib/engines" \ + "${jm_root}/lib/pkgconfig/openssl.pc" \ + "${jm_root}/lib/pkgconfig/libssl.pc" \ + "${jm_root}/lib/pkgconfig/libcrypto.pc" \ + "${jm_root}/include/openssl" \ + "${jm_root}/bin/c_rehash" \ + "${jm_root}/bin/openssl" if ! make test; then return 1 fi @@ -111,7 +117,7 @@ openssl_install () fi pushd "${openssl_version}" if openssl_build; then - make install + make install_sw else return 1 fi @@ -151,6 +157,7 @@ libffi_build () { ./autogen.sh ./configure --disable-docs --enable-shared --prefix="${jm_root}" + make uninstall make -j if ! make check; then return 1 @@ -198,7 +205,8 @@ libsodium_get () libsodium_build () { ./autogen.sh - ./configure --enable-shared --prefix="${jm_root}" + ./configure --enable-shared --prefix="${jm_root}" + make uninstall make -j if ! make check; then return 1 @@ -244,7 +252,7 @@ joinmarket_install () jm_pkgs=( 'jmbase' 'jmdaemon' 'jmbitcoin' 'jmclient' ) for pkg in ${jm_pkgs[@]}; do pushd "${pkg}" - pip install . + pip install . || return 1 popd done } @@ -277,10 +285,13 @@ main () fi if ! libsodium_install; then echo "Libsodium was not built. Exiting." + return 1 fi popd if ! joinmarket_install; then echo "Joinmarket was not installed. Exiting." + deactivate + return 1 fi deactivate echo "Joinmarket successfully installed diff --git a/test/run_tests.sh b/test/run_tests.sh new file mode 100755 index 0000000..9945216 --- /dev/null +++ b/test/run_tests.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +run_jm_tests () +{ + if [[ -z "${VIRTUAL_ENV}" ]]; then + echo "Source JM virtualenv before running tests: + + \`source ./jmvenv/bin/activate\`" + return 1 + fi + jm_source="${VIRTUAL_ENV}/.." + + pushd "${jm_source}" + git clone git://github.com/Joinmarket-Org/miniircd.git + if ! pip install -r ./requirements-dev.txt; then + echo "Packages in 'requirements-dev.txt' could not be installed. Exiting." + return 1 + fi + if [[ ! -L ./joinmarket.cfg && -e ./joinmarket.cfg ]]; then + mv ./joinmarket.cfg ./joinmarket.cfg.bak + echo "file 'joinmarket.cfg' moved to 'joinmarket.cfg.bak'" + fi + for dir in '/dev/shm' '/tmp' "${jm_source}/test"; do + if [[ -d "${dir}" && -r "${dir}" ]]; then + jm_test_datadir="${dir}/jm_test_home/.bitcoin" + break + fi + done + if [[ -z "${jm_test_datadir}" ]]; then + echo "No candidate directory for test files. Exiting." + return 1 + fi + unlink ./joinmarket.cfg + ln -s ./test/regtest_joinmarket.cfg ./joinmarket.cfg + orig_umask="$(umask -p)" + umask 077 + rm -rf "${jm_test_datadir}" + mkdir -p "${jm_test_datadir}" + cp -f ./test/bitcoin.conf "${jm_test_datadir}/bitcoin.conf" + ${orig_umask} + echo "datadir=${jm_test_datadir}" >> "${jm_test_datadir}/bitcoin.conf" + python -m py.test --cov=jmclient --cov=jmbitcoin --cov=jmbase --cov=jmdaemon --cov-report html --btcpwd=123456abcdef --btcconf=${jm_test_datadir}/bitcoin.conf --btcuser=bitcoinrpc --nirc=2 --ignore jmclient/test/test_wallets.py --ignore test/test_segwit.py + unlink ./joinmarket.cfg + if read bitcoind_pid <"${jm_test_datadir}/bitcoind.pid"; then + pkill -15 ${bitcoind_pid} || pkill -9 ${bitcoind_pid} + fi + rm -rf "${jm_test_datadir}" +} +run_jm_tests