diff --git a/.travis.yml b/.travis.yml index 428d88d..933390a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,27 +4,36 @@ language: python python: '3.7' stages: - lint + - test env: -global: - - TEST_DIR=~/test_basicswap2/ - - PARTICL_BINDIR=/opt/binaries/particl-0.18.1.5/bin/ - - BITCOIN_BINDIR=/opt/binaries/bitcoin-0.18.1/bin/ - - LITECOIN_BINDIR=/opt/binaries/litecoin-0.17.1/bin/ + global: + - PART_VERSION=0.18.1.5 + - BTC_VERSION=0.18.1 + - LTC_VERSION=0.17.1 + - TEST_DIR=~/test_basicswap2/ + - TEST_RELOAD_PATH=~/test_basicswap1/ + - BIN_DIRS=~/binaries + - PARTICL_BINDIR=${BIN_DIRS}/particl-${PART_VERSION}/bin/ + - BITCOIN_BINDIR=${BIN_DIRS}/bitcoin-${BTC_VERSION}/bin/ + - LITECOIN_BINDIR=${BIN_DIRS}/litecoin-${LTC_VERSION}/bin/ +cache: + directories: + - "$BIN_DIRS" before_install: - sudo apt-get install -y wget gnupg2 before_script: - - if [ ! -d "/opt/binaries" ]; then mkdir -p "/opt/binaries" ; fi - - if [ ! -d "$BITCOIN_BINDIR" ]; then cd "/opt/binaries" && wget https://bitcoincore.org/bin/bitcoin-core-0.18.1/bitcoin-0.18.1-x86_64-linux-gnu.tar.gz && tar xvf bitcoin-0.18.1-x86_64-linux-gnu.tar.gz ; fi - - if [ ! -d "$LITECOIN_BINDIR" ]; then cd "/opt/binaries" && wget https://download.litecoin.org/litecoin-0.17.1/linux/litecoin-0.17.1-x86_64-linux-gnu.tar.gz && tar xvf litecoin-0.17.1-x86_64-linux-gnu.tar.gz ; fi - - if [ ! -d "$PARTICL_BINDIR" ]; then cd "/opt/binaries" && wget https://github.com/particl/particl-core/releases/download/v0.18.1.5/particl-0.18.1.5-x86_64-linux-gnu_nousb.tar.gz && tar xvf particl-0.18.1.5-x86_64-linux-gnu_nousb.tar.gz ; fi + - if [ ! -d "$BIN_DIRS" ]; then mkdir -p "$BIN_DIRS" ; fi + - if [ ! -d "$PARTICL_BINDIR" ]; then cd "$BIN_DIRS" && wget https://github.com/particl/particl-core/releases/download/v${PART_VERSION}/particl-${PART_VERSION}-x86_64-linux-gnu.tar.gz && tar xvf particl-${PART_VERSION}-x86_64-linux-gnu.tar.gz ; fi + - if [ ! -d "$BITCOIN_BINDIR" ]; then cd "$BIN_DIRS" && wget https://bitcoincore.org/bin/bitcoin-core-${BTC_VERSION}/bitcoin-${BTC_VERSION}-x86_64-linux-gnu.tar.gz && tar xvf bitcoin-${BTC_VERSION}-x86_64-linux-gnu.tar.gz ; fi + - if [ ! -d "$LITECOIN_BINDIR" ]; then cd "$BIN_DIRS" && wget https://download.litecoin.org/litecoin-${LTC_VERSION}/linux/litecoin-${LTC_VERSION}-x86_64-linux-gnu.tar.gz && tar xvf litecoin-${LTC_VERSION}-x86_64-linux-gnu.tar.gz ; fi script: - cd $TRAVIS_BUILD_DIR - - export PARTICL_BINDIR=/opt/binaries/particl-0.18.1.5/bin/ - - export BITCOIN_BINDIR=/opt/binaries/bitcoin-0.18.1/bin/ - - export LITECOIN_BINDIR=/opt/binaries/litecoin-0.17.1/bin/ - - export DATADIRS=~/test_basicswap2/ + - export DATADIRS="${TEST_DIR}" - mkdir -p ${DATADIRS}/bin/{particl,bitcoin} - - cp /opt/binaries/bitcoin-0.18.1-x86_64-linux-gnu.tar.gz ${DATADIRS}/bin/bitcoin + - cp "${BIN_DIRS}/bitcoin-${BTC_VERSION}-x86_64-linux-gnu.tar.gz" "${DATADIRS}/bin/bitcoin" + - mkdir -p ${TEST_RELOAD_PATH}/bin/{particl,bitcoin} + - cp "${BIN_DIRS}/particl-${PART_VERSION}-x86_64-linux-gnu.tar.gz" "${TEST_RELOAD_PATH}/bin/particl" + - cp "${BIN_DIRS}/bitcoin-${BTC_VERSION}-x86_64-linux-gnu.tar.gz" "${TEST_RELOAD_PATH}/bin/bitcoin" - python setup.py test after_success: - echo "End test" @@ -33,8 +42,6 @@ jobs: - stage: lint env: cache: false - language: python - python: '3.7' install: - travis_retry pip install flake8==3.5.0 - travis_retry pip install codespell==1.15.0 @@ -44,3 +51,5 @@ jobs: - codespell --check-filenames --disable-colors --quiet-level=7 -S .git,.eggs,gitianpubkeys after_success: - echo "End lint" + - stage: test + env: diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index f00db06..8afd611 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -1563,7 +1563,8 @@ class BasicSwap(): self.log.debug('Refund tx fee %s, rate %s', format8(tx_fee * COIN), str(fee_rate)) amount_out = prev_amount * COIN - tx_fee * COIN - assert(amount_out > 0), 'Amount out <= 0' + if amount_out <= 0: + raise ValueError('Refund amount out <= 0') if addr_refund_out is None: addr_refund_out = self.getReceiveAddressFromPool(coin_type, bid.bid_id, tx_type) diff --git a/tests/basicswap/test_prepare.py b/tests/basicswap/test_prepare.py index 2c21de7..85d5a9d 100644 --- a/tests/basicswap/test_prepare.py +++ b/tests/basicswap/test_prepare.py @@ -15,7 +15,7 @@ import shutil import json import bin.basicswap_prepare as prepareSystem -test_path = os.path.expanduser('~/test_basicswap') +test_path = os.path.expanduser(os.getenv('TEST_PREPARE_PATH', '~/test_basicswap')) logger = logging.getLogger() logger.level = logging.DEBUG diff --git a/tests/basicswap/test_reload.py b/tests/basicswap/test_reload.py index bf211f9..02a655c 100644 --- a/tests/basicswap/test_reload.py +++ b/tests/basicswap/test_reload.py @@ -168,6 +168,7 @@ class Test(unittest.TestCase): runSystem.main() def test_reload(self): + global stop_test processes = [] for i in range(3):