Browse Source

Merge #64: More robust install.sh, tests runner and .travis.yml for new tests

f3e321a fail on virtualenv setup, fix cov test run on travis (fivepiece)
10f20ed add exports and pkg-config paths to run_tests.sh, use curl instead of git to fetch miniircd, only run cov tests on travis runs (fivepiece)
8027853 add exports and upgrade pip versions for older operating systems (fivepiece)
9e65d2e dependency check can find missing packages (fivepiece)
28507bd change travis test branch to master (fivepiece)
15433df add test result files to gitignore (fivepiece)
ad7309e .travis.yml uses install.sh and run_tests.sh (fivepiece)
69d274f add run_tests.sh (fivepiece)
4f4f0e5 modular install.sh (fivepiece)
master
Adam Gibson 8 years ago
parent
commit
d1db9a2f41
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 11
      .gitignore
  2. 50
      .travis.yml
  3. 441
      install.sh
  4. 55
      test/run_tests.sh

11
.gitignore vendored

@ -9,4 +9,13 @@ htmlcov/
scripts/joinmarket.cfg scripts/joinmarket.cfg
scripts/cmttools/commitments.json scripts/cmttools/commitments.json
scripts/blacklist scripts/blacklist
alicekey
alicepubkey
bobkey
commitments_debug.txt
deps/
jmvenv/
logs/
miniircd/
nums_basepoints.txt
schedulefortesting

50
.travis.yml

@ -2,49 +2,19 @@ sudo: required
dist: trusty dist: trusty
language: python language: python
python: python:
- "2.7_with_system_site_packages" - "2.7_with_system_site_packages"
before_install: before_install:
- sudo apt-get install -y curl - sudo apt-add-repository ppa:bitcoin/bitcoin -y
- sudo apt-get install -y python-dev - sudo apt-get update -q
- sudo apt-get install -y libssl-dev - sudo apt-get install --no-install-recommends --no-upgrade -qq bitcoind
- sudo apt-add-repository ppa:bitcoin/bitcoin -y
- sudo apt-get update -q
- sudo apt-get install --no-install-recommends --no-upgrade -qq bitcoind
- sudo apt-get install -y build-essential
- sudo apt-get install -y automake
- sudo apt-get install -y pkg-config
- sudo apt-get install -y libtool
- sudo apt-get install -y libffi-dev
install: install:
- pip install -r requirements-dev.txt - ./install.sh
- python setupall.py --daemon before_script:
- python setupall.py --client-bitcoin - source jmvenv/bin/activate
script: script:
#install and test libsodium - ./test/run_tests.sh
- git clone git://github.com/jedisct1/libsodium.git
- cd libsodium
- git checkout tags/1.0.4
- ./autogen.sh
- ./configure
- make check
- sudo make install
- cd ..
#set up joinmarket.cfg
- cp test/regtest_joinmarket.cfg joinmarket.cfg
#install miniircd
- git clone git://github.com/Joinmarket-Org/miniircd.git
#setup bitcoin config file
- mkdir /home/travis/.bitcoin
- cp test/bitcoin.conf /home/travis/.bitcoin/.
- chmod 600 /home/travis/.bitcoin/bitcoin.conf
- mkdir logs
- mkdir wallets
- python -m py.test --cov=jmclient --cov=jmbitcoin --cov=jmbase --cov=jmdaemon --cov-report html --btcpwd=123456abcdef --btcconf=/home/travis/.bitcoin/bitcoin.conf --btcuser=bitcoinrpc --nirc=2 --ignore jmclient/test/test_wallets.py --ignore test/test_segwit.py
after_success: after_success:
- coveralls - coveralls
branches: branches:
only: only:
- master - master
- segwitwallets

441
install.sh

@ -1,132 +1,311 @@
#!/bin/bash #!/bin/bash
set -e
clear gpg_verify_key ()
{
#Adapted from https://github.com/tailsjoin/tailsjoin/blob/master/tailsjoin-fullnode.sh gpg --keyid-format long <"$1" | grep "$2"
}
# Check for root.
if [[ $(id -u) = "0" ]]; then gpg_add_to_keyring ()
echo " {
YOU SHOULD NOT RUN THIS SCRIPT AS ROOT! gpg --dearmor <"$1" >>"${jm_deps}/keyring.gpg"
YOU WILL BE PROMPTED FOR THE ADMIN PASS WHEN NEEDED. }
"
read -p "PRESS ENTER TO EXIT SCRIPT, AND RUN AGAIN AS NON-ROOT USER. " gpg_verify_sig ()
exit 0 {
fi gpg --no-default-keyring --keyring "${jm_deps}/keyring.gpg" --verify "$1"
}
# Make sure user has chosen the correct script. deb_deps_check ()
echo " {
THIS SCRIPT WILL INSTALL JOINMARKET-CS AND DEPENDENCIES. apt-cache policy ${deb_deps[@]} | grep "Installed.*none"
ADMIN PASS WILL BE REQUIRED MULTIPLE TIMES. }
"
read -p "PRESS ENTER TO CONTINUE. " deb_deps_install ()
clear {
deb_deps=( 'python-virtualenv' 'curl' 'python-dev' 'python-pip' 'build-essential' 'automake' 'pkg-config' 'libtool' )
# Update apt-get sources. if deb_deps_check; then
echo " clear
ENTER PASSWORD TO UPDATE SOURCES. echo "
" sudo password required to run :
sudo apt-get update
clear \`apt-get install ${deb_deps[@]}\`
"
if ! sudo apt-get install ${deb_deps[@]}; then
# Install dependencies for building libsodium. return 1
echo " fi
ENTER PASSWORD TO INSTALL: python-virtualenv curl python-dev python-pip git build-essential automake pkg-config libtool libffi-dev libssl-dev fi
" }
sudo apt-get install -y python-virtualenv curl python-dev python-pip git build-essential automake pkg-config libtool libffi-dev libssl-dev
clear check_skip_build ()
{
# Get libsodium, sig, and import key. if ! mkdir "$1"; then
echo " read -p "Directory ${1} exists. Remove and recreate? (y/n) " q
DOWNLOADING LIBSODIUM SOURCE AND SIGNING KEY... if [[ "${q}" =~ Y|y ]]; then
" rm -rf "./${1}"
gpg --keyserver pgp.mit.edu --recv-keys 54A2B8892CC3D6A597B92B6C210627AABA709FE1 mkdir -p "./${1}"
echo "54A2B8892CC3D6A597B92B6C210627AABA709FE1:6" | gpg --import-ownertrust - return 1
curl -L -O http://download.libsodium.org/libsodium/releases/libsodium-1.0.12.tar.gz -O http://download.libsodium.org/libsodium/releases/libsodium-1.0.12.tar.gz.sig else
clear echo "skipping ${1}..."
return 0
fi
# Verify download. fi
echo " return 1
VERIFYING THE DOWNLOAD... }
"
gpg --verify libsodium-1.0.12.tar.gz.sig libsodium-1.0.12.tar.gz venv_setup ()
echo " {
PLEASE REVIEW THE TEXT ABOVE. if check_skip_build 'jmvenv'; then
IT WILL EITHER SAY GOOD SIG OR BAD SIG. return 0
" fi
read -p "IS IT A GOOD SIG? (y/n) " x rm -rf "${jm_source}/deps"
if [[ "$x" = "n" || "$x" = "N" ]]; then virtualenv -p python2 "${jm_source}/jmvenv" || return 1
echo " source "${jm_source}/jmvenv/bin/activate" || return 1
YOU REJECTED THE LIBSODIUM SIGNATURE, GIVING UP... pip install --upgrade pip
" pip install --upgrade setuptools
srm -drv libsodium* deactivate
exit 0 }
fi
clear openssl_get ()
{
for file in "${openssl_lib_tar}" "${openssl_lib_sha}" "${openssl_lib_sig}"; do
# Build and install libsodium. curl -L -O "${openssl_url}/${file}"
tar xf libsodium*.tar.gz done
rm -rf libsodium*.tar.gz* curl -L "${openssl_signer_key_url}" -o openssl_signer.key
}
echo "
BUILDING LIBSODIUM... openssl_build ()
" {
cd libsodium-1.0.12/ && ./configure && make ./config shared --prefix="${jm_root}"
echo " make -j
LIBSODIUM SUCCESSFULLY BUILT. ENTER PASSWORD TO INSTALL. rm -rf "${jm_root}/ssl" \
" "${jm_root}/lib/engines" \
sudo make install "${jm_root}/lib/pkgconfig/openssl.pc" \
cd .. "${jm_root}/lib/pkgconfig/libssl.pc" \
rm -rf libsodium* "${jm_root}/lib/pkgconfig/libcrypto.pc" \
clear "${jm_root}/include/openssl" \
"${jm_root}/bin/c_rehash" \
# Verify the signature on joinmarket-clientserver "${jm_root}/bin/openssl"
# Currently commented out - doesn't apply if you've already downloaded the repo if ! make test; then
# either as zip or clone; can check valid signature on github (OK?) return 1
#gpg --keyserver pgp.mit.edu --recv-keys 46689728A9F64B391FA871B7B3AE09F1E9A3197A fi
#echo "46689728A9F64B391FA871B7B3AE09F1E9A3197A:6" | gpg --import-ownertrust - }
#Todo: handle signing by another key and check the release tag, not commit.
#git verify-commit HEAD || { openssl_install ()
# echo 'Latest code commit does not have a valid signature; quitting' {
# exit 0 openssl_version='openssl-1.0.2l'
#} openssl_lib_tar="${openssl_version}.tar.gz"
openssl_lib_sha="${openssl_lib_tar}.sha256"
#Run the python installation of joinmarket-clientserver; openssl_lib_sig="${openssl_lib_tar}.asc"
#note that this is a 'full' installation, which is the default openssl_url='https://www.openssl.org/source'
#for an ordinary user; this should be enhanced to allow custom openssl_signer_key_url='https://pgp.mit.edu/pks/lookup?op=get&search=0xD9C4D26D0E604491'
#installation styles. openssl_signer_key_id='D9C4D26D0E604491'
#Installs into a virtualenv, so instructions to run must be included. openssl_root="${jm_deps}/openssl"
if ! mkdir venv; then
echo "virtualenv directory already exists; assuming valid." if check_skip_build 'openssl'; then
fi return 0
virtualenv jmvenv fi
source jmvenv/bin/activate pushd openssl
#required for older pips, e.g. on Ubuntu 14.04 openssl_get
pip install --upgrade setuptools if ! grep $(sha256sum "${openssl_lib_tar}") "${openssl_lib_sha}"; then
#Doing manually instead of as in setupall.py return 1
cd jmbase fi
pip install . if gpg_verify_key openssl_signer.key "${openssl_signer_key_id}"; then
cd .. gpg_add_to_keyring openssl_signer.key
cd jmdaemon else
pip install . return 1
cd .. fi
cd jmbitcoin if gpg_verify_sig "${openssl_lib_sig}"; then
pip install . tar xaf "${openssl_lib_tar}"
cd .. else
cd jmclient return 1
pip install . fi
cd .. pushd "${openssl_version}"
if openssl_build; then
# Final notes. make install_sw
echo " else
JOINMARKET SUCCESSFULLY INSTALLED. return 1
BEFORE RUNNING SCRIPTS, TYPE: fi
source jmvenv/bin/activate popd
FROM THIS DIRECTORY, TO ACTIVATE THE VIRTUALENV. popd
" }
read -p "PRESS ENTER TO EXIT SCRIPT. "
exit 0; # add '--disable-docs' to libffi ./configure so makeinfo isn't needed
# https://github.com/libffi/libffi/pull/190/commits/fa7a257113e2cfc963a0be9dca5d7b4c73999dcc
libffi_patch_disable_docs ()
{
cat <<'EOF' > Makefile.am.patch
56c56,59
< info_TEXINFOS = doc/libffi.texi
---
> info_TEXINFOS =
> if BUILD_DOCS
> #info_TEXINFOS += doc/libffi.texi
> endif
EOF
cat <<'EOF' > configure.ac.patch
545a546,552
> AC_ARG_ENABLE(docs,
> AC_HELP_STRING([--disable-docs],
> [Disable building of docs (default: no)]),
> [enable_docs=no],
> [enable_docs=yes])
> AM_CONDITIONAL(BUILD_DOCS, [test x$enable_docs = xyes])
>
EOF
patch Makefile.am Makefile.am.patch
patch configure.ac configure.ac.patch
}
libffi_build ()
{
./autogen.sh
./configure --disable-docs --enable-shared --prefix="${jm_root}"
make uninstall
make -j
if ! make check; then
return 1
fi
}
libffi_install ()
{
libffi_version='libffi-3.2.1'
libffi_lib_tar="v3.2.1.tar.gz"
libffi_lib_sha='96d08dee6f262beea1a18ac9a3801f64018dc4521895e9198d029d6850febe23'
libffi_url="https://github.com/libffi/libffi/archive"
if check_skip_build 'libffi'; then
return 0
fi
pushd libffi
curl -L -O "${libffi_url}/${libffi_lib_tar}"
if sha256sum -c <<<"${libffi_lib_sha} ${libffi_lib_tar}"; then
tar xaf "${libffi_lib_tar}"
else
return 1
fi
pushd "${libffi_version}"
if ! libffi_patch_disable_docs; then
return 1
fi
if libffi_build; then
make install
else
return 1
fi
popd
popd
}
libsodium_get ()
{
for file in "${sodium_lib_tar}" "${sodium_lib_sig}"; do
curl -L -O "${sodium_url}/${file}"
done
curl -L "${sodium_signer_key_url}" -o libsodium_signer.key
}
libsodium_build ()
{
./autogen.sh
./configure --enable-shared --prefix="${jm_root}"
make uninstall
make -j
if ! make check; then
return 1
fi
}
libsodium_install ()
{
sodium_version='libsodium-1.0.13'
sodium_lib_tar="${sodium_version}.tar.gz"
sodium_lib_sig="${sodium_lib_tar}.sig"
sodium_url='https://download.libsodium.org/libsodium/releases'
sodium_signer_key_url='https://pgp.mit.edu/pks/lookup?op=get&search=0x210627AABA709FE1'
sodium_signer_key_id='62F25B592B6F76DA'
if check_skip_build 'libsodium'; then
return 0
fi
pushd libsodium
libsodium_get
if gpg_verify_key libsodium_signer.key "${sodium_signer_key_id}"; then
gpg_add_to_keyring libsodium_signer.key
else
return 1
fi
if gpg_verify_sig "${sodium_lib_sig}"; then
tar xaf "${sodium_lib_tar}"
else
return 1
fi
pushd "${sodium_version}"
if libsodium_build; then
make install
else
return 1
fi
popd
popd
}
joinmarket_install ()
{
jm_pkgs=( 'jmbase' 'jmdaemon' 'jmbitcoin' 'jmclient' )
for pkg in ${jm_pkgs[@]}; do
pushd "${pkg}"
pip install . || return 1
popd
done
}
main ()
{
jm_source="$PWD"
jm_root="${jm_source}/jmvenv"
jm_deps="${jm_source}/deps"
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${jm_root}/lib/pkgconfig"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${jm_root}/lib"
export C_INCLUDE_PATH="${C_INCLUDE_PATH}:${jm_root}/include"
if ! deb_deps_install; then
echo "Dependecies could not be installed. Exiting."
return 1
fi
if ! venv_setup; then
echo "Joinmarket virtualenv could not be setup. Exiting."
return 1
fi
source "${jm_root}/bin/activate"
mkdir -p deps
pushd deps
rm -f ./keyring.gpg
if ! openssl_install; then
echo "Openssl was not built. Exiting."
return 1
fi
if ! libffi_install; then
echo "Libffi was not built. Exiting."
return 1
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
Before executing scripts or tests, run:
\`source jmvenv/bin/activate\`
from this directiry, to acticate virtualenv."
}
main

55
test/run_tests.sh

@ -0,0 +1,55 @@
#!/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}/.."
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${VIRTUAL_ENV}/lib/pkgconfig"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${VIRTUAL_ENV}/lib"
export C_INCLUDE_PATH="${C_INCLUDE_PATH}:${VIRTUAL_ENV}/include"
pushd "${jm_source}"
curl -L https://github.com/JoinMarket-Org/miniircd/archive/master.tar.gz -o miniircd.tar.gz
rm -rf ./miniircd
mkdir -p miniircd
tar xaf miniircd.tar.gz -C ./miniircd --strip-components=1
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 ${HAS_JOSH_K_SEAL_OF_APPROVAL+--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
Loading…
Cancel
Save