Browse Source

Move src/test/bitcoin-util-test.py to test/util/bitcoin-util-test.py

tags/v0.15.1
John Newbery 4 years ago
parent
commit
63d66ba20a
61 changed files with 146 additions and 152 deletions
  1. 3
    3
      .gitignore
  2. 56
    0
      Makefile.am
  3. 6
    3
      configure.ac
  4. 1
    3
      contrib/rpm/bitcoin.spec
  5. 2
    59
      src/Makefile.test.include
  6. 0
    9
      src/test/README.md
  7. 0
    45
      src/test/bitcoin-util-test.py
  8. 0
    2
      src/test/buildenv.py.in
  9. 35
    25
      test/README.md
  10. 3
    3
      test/util/bctest.py
  11. 36
    0
      test/util/bitcoin-util-test.py
  12. 4
    0
      test/util/buildenv.py.in
  13. 0
    0
      test/util/data/bitcoin-util-test.json
  14. 0
    0
      test/util/data/blanktxv1.hex
  15. 0
    0
      test/util/data/blanktxv1.json
  16. 0
    0
      test/util/data/blanktxv2.hex
  17. 0
    0
      test/util/data/blanktxv2.json
  18. 0
    0
      test/util/data/tt-delin1-out.hex
  19. 0
    0
      test/util/data/tt-delin1-out.json
  20. 0
    0
      test/util/data/tt-delout1-out.hex
  21. 0
    0
      test/util/data/tt-delout1-out.json
  22. 0
    0
      test/util/data/tt-locktime317000-out.hex
  23. 0
    0
      test/util/data/tt-locktime317000-out.json
  24. 0
    0
      test/util/data/tx394b54bb.hex
  25. 0
    0
      test/util/data/txcreate1.hex
  26. 0
    0
      test/util/data/txcreate1.json
  27. 0
    0
      test/util/data/txcreate2.hex
  28. 0
    0
      test/util/data/txcreate2.json
  29. 0
    0
      test/util/data/txcreatedata1.hex
  30. 0
    0
      test/util/data/txcreatedata1.json
  31. 0
    0
      test/util/data/txcreatedata2.hex
  32. 0
    0
      test/util/data/txcreatedata2.json
  33. 0
    0
      test/util/data/txcreatedata_seq0.hex
  34. 0
    0
      test/util/data/txcreatedata_seq0.json
  35. 0
    0
      test/util/data/txcreatedata_seq1.hex
  36. 0
    0
      test/util/data/txcreatedata_seq1.json
  37. 0
    0
      test/util/data/txcreatemultisig1.hex
  38. 0
    0
      test/util/data/txcreatemultisig1.json
  39. 0
    0
      test/util/data/txcreatemultisig2.hex
  40. 0
    0
      test/util/data/txcreatemultisig2.json
  41. 0
    0
      test/util/data/txcreatemultisig3.hex
  42. 0
    0
      test/util/data/txcreatemultisig3.json
  43. 0
    0
      test/util/data/txcreatemultisig4.hex
  44. 0
    0
      test/util/data/txcreatemultisig4.json
  45. 0
    0
      test/util/data/txcreateoutpubkey1.hex
  46. 0
    0
      test/util/data/txcreateoutpubkey1.json
  47. 0
    0
      test/util/data/txcreateoutpubkey2.hex
  48. 0
    0
      test/util/data/txcreateoutpubkey2.json
  49. 0
    0
      test/util/data/txcreateoutpubkey3.hex
  50. 0
    0
      test/util/data/txcreateoutpubkey3.json
  51. 0
    0
      test/util/data/txcreatescript1.hex
  52. 0
    0
      test/util/data/txcreatescript1.json
  53. 0
    0
      test/util/data/txcreatescript2.hex
  54. 0
    0
      test/util/data/txcreatescript2.json
  55. 0
    0
      test/util/data/txcreatescript3.hex
  56. 0
    0
      test/util/data/txcreatescript3.json
  57. 0
    0
      test/util/data/txcreatescript4.hex
  58. 0
    0
      test/util/data/txcreatescript4.json
  59. 0
    0
      test/util/data/txcreatesignv1.hex
  60. 0
    0
      test/util/data/txcreatesignv1.json
  61. 0
    0
      test/util/data/txcreatesignv2.hex

+ 3
- 3
.gitignore View File

@@ -101,9 +101,9 @@ coverage_percent.txt
linux-coverage-build
linux-build
win32-build
qa/pull-tester/tests_config.py
qa/pull-tester/tests_config.ini
qa/cache/*
test/functional/config.ini
test/util/buildenv.py
test/cache/*

!src/leveldb*/Makefile


+ 56
- 0
Makefile.am View File

@@ -225,8 +225,64 @@ dist_noinst_SCRIPTS = autogen.sh

EXTRA_DIST = $(top_srcdir)/share/genbuild.sh test/functional/test_runner.py test/functional $(DIST_CONTRIB) $(DIST_DOCS) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) $(BIN_CHECKS)

EXTRA_DIST += \
test/util/bctest.py \
test/util/bitcoin-util-test.py \
test/util/data/bitcoin-util-test.json \
test/util/data/blanktxv1.hex \
test/util/data/blanktxv1.json \
test/util/data/blanktxv2.hex \
test/util/data/blanktxv2.json \
test/util/data/tt-delin1-out.hex \
test/util/data/tt-delin1-out.json \
test/util/data/tt-delout1-out.hex \
test/util/data/tt-delout1-out.json \
test/util/data/tt-locktime317000-out.hex \
test/util/data/tt-locktime317000-out.json \
test/util/data/tx394b54bb.hex \
test/util/data/txcreate1.hex \
test/util/data/txcreate1.json \
test/util/data/txcreate2.hex \
test/util/data/txcreate2.json \
test/util/data/txcreatedata1.hex \
test/util/data/txcreatedata1.json \
test/util/data/txcreatedata2.hex \
test/util/data/txcreatedata2.json \
test/util/data/txcreatedata_seq0.hex \
test/util/data/txcreatedata_seq0.json \
test/util/data/txcreatedata_seq1.hex \
test/util/data/txcreatedata_seq1.json \
test/util/data/txcreatemultisig1.hex \
test/util/data/txcreatemultisig1.json \
test/util/data/txcreatemultisig2.hex \
test/util/data/txcreatemultisig2.json \
test/util/data/txcreatemultisig3.hex \
test/util/data/txcreatemultisig3.json \
test/util/data/txcreatemultisig4.hex \
test/util/data/txcreatemultisig4.json \
test/util/data/txcreateoutpubkey1.hex \
test/util/data/txcreateoutpubkey1.json \
test/util/data/txcreateoutpubkey2.hex \
test/util/data/txcreateoutpubkey2.json \
test/util/data/txcreateoutpubkey3.hex \
test/util/data/txcreateoutpubkey3.json \
test/util/data/txcreatescript1.hex \
test/util/data/txcreatescript1.json \
test/util/data/txcreatescript2.hex \
test/util/data/txcreatescript2.json \
test/util/data/txcreatescript3.hex \
test/util/data/txcreatescript3.json \
test/util/data/txcreatescript4.hex \
test/util/data/txcreatescript4.json \
test/util/data/txcreatesignv1.hex \
test/util/data/txcreatesignv1.json \
test/util/data/txcreatesignv2.hex

CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER)

# This file is problematic for out-of-tree builds if it exists.
DISTCLEANFILES = test/util/buildenv.pyc

.INTERMEDIATE: $(COVERAGE_INFO)

DISTCHECK_CONFIGURE_FLAGS = --enable-man

+ 6
- 3
configure.ac View File

@@ -1147,9 +1147,12 @@ AC_SUBST(EVENT_PTHREADS_LIBS)
AC_SUBST(ZMQ_LIBS)
AC_SUBST(PROTOBUF_LIBS)
AC_SUBST(QR_LIBS)
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist src/test/buildenv.py test/functional/config.ini])
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/functional/config.ini])
AC_CONFIG_FILES([test/util/buildenv.py],[chmod +x test/util/buildenv.py])
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py])
AC_CONFIG_LINKS([test/util/bitcoin-util-test.py:test/util/bitcoin-util-test.py])
AC_CONFIG_LINKS([test/util/bctest.py:test/util/bctest.py])

dnl boost's m4 checks do something really nasty: they export these vars. As a
dnl result, they leak into secp256k1's configure and crazy things happen.
@@ -1197,8 +1200,8 @@ esac
dnl Replace the BUILDDIR path with the correct Windows path if compiling on Native Windows
case ${OS} in
*Windows*)
sed 's/BUILDDIR="\/\([[a-z]]\)/BUILDDIR="\1:/' test/pull-tester/tests_config.py > test/pull-tester/tests_config-2.py
mv test/pull-tester/tests_config-2.py test/pull-tester/tests_config.py
sed 's/BUILDDIR="\/\([[a-z]]\)/BUILDDIR="\1:/' test/functional/config.ini > test/functional/config-2.ini
mv test/functional/config-2.ini test/functional/config.ini
;;
esac


+ 1
- 3
contrib/rpm/bitcoin.spec View File

@@ -311,9 +311,7 @@ rm -f %{buildroot}%{_bindir}/test_*

%check
make check
pushd src
srcdir=. test/bitcoin-util-test.py
popd
srcdir=src test/bitcoin-util-test.py
test/functional/test_runner.py --extended

%post libs -p /sbin/ldconfig

+ 2
- 59
src/Makefile.test.include View File

@@ -8,60 +8,6 @@ noinst_PROGRAMS += test/test_bitcoin_fuzzy
TEST_SRCDIR = test
TEST_BINARY=test/test_bitcoin$(EXEEXT)


EXTRA_DIST += \
test/bctest.py \
test/bitcoin-util-test.py \
test/data/bitcoin-util-test.json \
test/data/blanktxv1.hex \
test/data/blanktxv1.json \
test/data/blanktxv2.hex \
test/data/blanktxv2.json \
test/data/tt-delin1-out.hex \
test/data/tt-delin1-out.json \
test/data/tt-delout1-out.hex \
test/data/tt-delout1-out.json \
test/data/tt-locktime317000-out.hex \
test/data/tt-locktime317000-out.json \
test/data/tx394b54bb.hex \
test/data/txcreate1.hex \
test/data/txcreate1.json \
test/data/txcreate2.hex \
test/data/txcreate2.json \
test/data/txcreatedata1.hex \
test/data/txcreatedata1.json \
test/data/txcreatedata2.hex \
test/data/txcreatedata2.json \
test/data/txcreatedata_seq0.hex \
test/data/txcreatedata_seq0.json \
test/data/txcreatedata_seq1.hex \
test/data/txcreatedata_seq1.json \
test/data/txcreatemultisig1.hex \
test/data/txcreatemultisig1.json \
test/data/txcreatemultisig2.hex \
test/data/txcreatemultisig2.json \
test/data/txcreatemultisig3.hex \
test/data/txcreatemultisig3.json \
test/data/txcreatemultisig4.hex \
test/data/txcreatemultisig4.json \
test/data/txcreateoutpubkey1.hex \
test/data/txcreateoutpubkey1.json \
test/data/txcreateoutpubkey2.hex \
test/data/txcreateoutpubkey2.json \
test/data/txcreateoutpubkey3.hex \
test/data/txcreateoutpubkey3.json \
test/data/txcreatescript1.hex \
test/data/txcreatescript1.json \
test/data/txcreatescript2.hex \
test/data/txcreatescript2.json \
test/data/txcreatescript3.hex \
test/data/txcreatescript3.json \
test/data/txcreatescript4.hex \
test/data/txcreatescript4.json \
test/data/txcreatesignv1.hex \
test/data/txcreatesignv1.json \
test/data/txcreatesignv2.hex

JSON_TEST_FILES = \
test/data/script_tests.json \
test/data/base58_keys_valid.json \
@@ -191,9 +137,6 @@ CLEAN_BITCOIN_TEST = test/*.gcda test/*.gcno $(GENERATED_TEST_FILES)

CLEANFILES += $(CLEAN_BITCOIN_TEST)

# This file is problematic for out-of-tree builds if it exists.
DISTCLEANFILES += test/buildenv.pyc

bitcoin_test: $(TEST_BINARY)

bitcoin_test_check: $(TEST_BINARY) FORCE
@@ -203,8 +146,8 @@ bitcoin_test_clean : FORCE
rm -f $(CLEAN_BITCOIN_TEST) $(test_test_bitcoin_OBJECTS) $(TEST_BINARY)

check-local:
@echo "Running test/bitcoin-util-test.py..."
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(PYTHON) $(srcdir)/test/bitcoin-util-test.py
@echo "Running test/util/bitcoin-util-test.py..."
$(PYTHON) $(top_builddir)/test/util/bitcoin-util-test.py
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
if EMBEDDED_UNIVALUE
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check

+ 0
- 9
src/test/README.md View File

@@ -50,12 +50,3 @@ examine `uint256_tests.cpp`.
For further reading, I found the following website to be helpful in
explaining how the boost unit test framework works:
[http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/](http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/).

### bitcoin-util-test.py

The test directory also contains the bitcoin-util-test.py tool, which tests bitcoin utils (currently just bitcoin-tx). This test gets run automatically during the `make check` build process. It is also possible to run the test manually from the src directory:

```
test/bitcoin-util-test.py --srcdir=[current directory]

```

+ 0
- 45
src/test/bitcoin-util-test.py View File

@@ -1,45 +0,0 @@
#!/usr/bin/env python
# Copyright 2014 BitPay Inc.
# Copyright 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from __future__ import division,print_function,unicode_literals
import os
import bctest
import buildenv
import argparse
import logging

help_text="""Test framework for bitcoin utils.

Runs automatically during `make check`.

Can also be run manually from the src directory by specifying the source directory:

test/bitcoin-util-test.py --srcdir='srcdir' [--verbose]
"""

if __name__ == '__main__':
# Try to get the source directory from the environment variables. This will
# be set for `make check` automated runs. If environment variable is not set,
# then get the source directory from command line args.
try:
srcdir = os.environ["srcdir"]
verbose = False
except:
parser = argparse.ArgumentParser(description=help_text)
parser.add_argument('-s', '--srcdir')
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args()
srcdir = args.srcdir
verbose = args.verbose

if verbose:
level = logging.DEBUG
else:
level = logging.ERROR
formatter = '%(asctime)s - %(levelname)s - %(message)s'
# Add the format/level to the logger
logging.basicConfig(format = formatter, level=level)

bctest.bctester(srcdir + "/test/data", "bitcoin-util-test.json", buildenv)

+ 0
- 2
src/test/buildenv.py.in View File

@@ -1,2 +0,0 @@
#!/usr/bin/env python
exeext="@EXEEXT@"

+ 35
- 25
test/README.md View File

@@ -1,29 +1,32 @@
The [functional](/test/functional/) folder contains a script test_runner
to call multiple functional tests from its folder.
This directory contains integration tests that test bitcoind and its
utilities in their entirety. It does not contain unit tests, which
can be found in [/src/test](/src/test), [/src/wallet/test](/src/wallet/test),
etc.

Every pull request to the bitcoin repository is built and run through
the regression test suite. You can also run all or only individual
tests locally.
There are currently two sets of tests in this directory:

Test dependencies
=================
Before running the tests, the following must be installed.
- [functional](/test/functional) which test the functionality of
bitcoind and bitcoin-qt by interacting with them through the RPC and P2P
interfaces.
- [util](test/util) which tests the bitcoin utilities, currently only
bitcoin-tx.

Unix
----
The python3-zmq library is required. On Ubuntu or Debian it can be installed via:
```
sudo apt-get install python3-zmq
```
The util tests are run as part of `make check` target. The functional
tests are run by the travis continuous build process whenever a pull
request is opened. Both sets of tests can also be run locally.

OS X
------
```
pip3 install pyzmq
```
Functional Test dependencies
============================
The ZMQ functional test requires a python ZMQ library. To install it:

- on Unix, run `sudo apt-get install python3-zmq`
- on mac OS, run `pip3 install pyzmq`

Running tests
=============
Running tests locally
=====================

Functional tests
----------------

You can run any single test by calling

@@ -80,8 +83,15 @@ rm -rf cache
killall bitcoind
```

Writing tests
=============
You are encouraged to write tests for new or existing features.
Further information about the test framework and individual functional
Util tests
----------

Util tests can be run locally by running `test/util/bitcoin-util-test.py`.
Use the `-v` option for verbose output.

Writing functional tests
========================

You are encouraged to write functional tests for new or existing features.
Further information about the functional test framework and individual
tests is found in [test/functional](/test/functional).

src/test/bctest.py → test/util/bctest.py View File

@@ -23,14 +23,14 @@ def parse_output(a, fmt):
else:
raise NotImplementedError("Don't know how to compare %s" % fmt)

def bctest(testDir, testObj, exeext):
def bctest(testDir, testObj, buildenv):
"""Runs a single test, comparing output and RC to expected output and RC.

Raises an error if input can't be read, executable fails, or output/RC
are not as expected. Error is caught by bctester() and reported.
"""
# Get the exec names and arguments
execprog = testObj['exec'] + exeext
execprog = buildenv.BUILDDIR + "/src/" + testObj['exec'] + buildenv.exeext
execargs = testObj['args']
execrun = [execprog] + execargs

@@ -112,7 +112,7 @@ def bctester(testDir, input_basename, buildenv):

for testObj in input_data:
try:
bctest(testDir, testObj, buildenv.exeext)
bctest(testDir, testObj, buildenv)
logging.info("PASSED: " + testObj["description"])
except:
logging.info("FAILED: " + testObj["description"])

+ 36
- 0
test/util/bitcoin-util-test.py View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python
# Copyright 2014 BitPay Inc.
# Copyright 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from __future__ import division,print_function,unicode_literals
import os
import sys
import argparse
import logging

help_text="""Test framework for bitcoin utils.

Runs automatically during `make check`.

Can also be run manually."""

if __name__ == '__main__':
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import buildenv
import bctest

parser = argparse.ArgumentParser(description=help_text)
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args()
verbose = args.verbose

if verbose:
level = logging.DEBUG
else:
level = logging.ERROR
formatter = '%(asctime)s - %(levelname)s - %(message)s'
# Add the format/level to the logger
logging.basicConfig(format = formatter, level=level)

bctest.bctester(buildenv.SRCDIR + "/test/util/data", "bitcoin-util-test.json", buildenv)

+ 4
- 0
test/util/buildenv.py.in View File

@@ -0,0 +1,4 @@
#!/usr/bin/env python
exeext="@EXEEXT@"
SRCDIR="@abs_top_srcdir@"
BUILDDIR="@abs_top_builddir@"

src/test/data/bitcoin-util-test.json → test/util/data/bitcoin-util-test.json View File


src/test/data/blanktxv1.hex → test/util/data/blanktxv1.hex View File


src/test/data/blanktxv1.json → test/util/data/blanktxv1.json View File


src/test/data/blanktxv2.hex → test/util/data/blanktxv2.hex View File


src/test/data/blanktxv2.json → test/util/data/blanktxv2.json View File


src/test/data/tt-delin1-out.hex → test/util/data/tt-delin1-out.hex View File


src/test/data/tt-delin1-out.json → test/util/data/tt-delin1-out.json View File


src/test/data/tt-delout1-out.hex → test/util/data/tt-delout1-out.hex View File


src/test/data/tt-delout1-out.json → test/util/data/tt-delout1-out.json View File


src/test/data/tt-locktime317000-out.hex → test/util/data/tt-locktime317000-out.hex View File


src/test/data/tt-locktime317000-out.json → test/util/data/tt-locktime317000-out.json View File


src/test/data/tx394b54bb.hex → test/util/data/tx394b54bb.hex View File


src/test/data/txcreate1.hex → test/util/data/txcreate1.hex View File


src/test/data/txcreate1.json → test/util/data/txcreate1.json View File


src/test/data/txcreate2.hex → test/util/data/txcreate2.hex View File


src/test/data/txcreate2.json → test/util/data/txcreate2.json View File


src/test/data/txcreatedata1.hex → test/util/data/txcreatedata1.hex View File


src/test/data/txcreatedata1.json → test/util/data/txcreatedata1.json View File


src/test/data/txcreatedata2.hex → test/util/data/txcreatedata2.hex View File


src/test/data/txcreatedata2.json → test/util/data/txcreatedata2.json View File


src/test/data/txcreatedata_seq0.hex → test/util/data/txcreatedata_seq0.hex View File


src/test/data/txcreatedata_seq0.json → test/util/data/txcreatedata_seq0.json View File


src/test/data/txcreatedata_seq1.hex → test/util/data/txcreatedata_seq1.hex View File


src/test/data/txcreatedata_seq1.json → test/util/data/txcreatedata_seq1.json View File


src/test/data/txcreatemultisig1.hex → test/util/data/txcreatemultisig1.hex View File


src/test/data/txcreatemultisig1.json → test/util/data/txcreatemultisig1.json View File


src/test/data/txcreatemultisig2.hex → test/util/data/txcreatemultisig2.hex View File


src/test/data/txcreatemultisig2.json → test/util/data/txcreatemultisig2.json View File


src/test/data/txcreatemultisig3.hex → test/util/data/txcreatemultisig3.hex View File


src/test/data/txcreatemultisig3.json → test/util/data/txcreatemultisig3.json View File


src/test/data/txcreatemultisig4.hex → test/util/data/txcreatemultisig4.hex View File


src/test/data/txcreatemultisig4.json → test/util/data/txcreatemultisig4.json View File


src/test/data/txcreateoutpubkey1.hex → test/util/data/txcreateoutpubkey1.hex View File


src/test/data/txcreateoutpubkey1.json → test/util/data/txcreateoutpubkey1.json View File


src/test/data/txcreateoutpubkey2.hex → test/util/data/txcreateoutpubkey2.hex View File


src/test/data/txcreateoutpubkey2.json → test/util/data/txcreateoutpubkey2.json View File


src/test/data/txcreateoutpubkey3.hex → test/util/data/txcreateoutpubkey3.hex View File


src/test/data/txcreateoutpubkey3.json → test/util/data/txcreateoutpubkey3.json View File


src/test/data/txcreatescript1.hex → test/util/data/txcreatescript1.hex View File


src/test/data/txcreatescript1.json → test/util/data/txcreatescript1.json View File


src/test/data/txcreatescript2.hex → test/util/data/txcreatescript2.hex View File


src/test/data/txcreatescript2.json → test/util/data/txcreatescript2.json View File


src/test/data/txcreatescript3.hex → test/util/data/txcreatescript3.hex View File


src/test/data/txcreatescript3.json → test/util/data/txcreatescript3.json View File


src/test/data/txcreatescript4.hex → test/util/data/txcreatescript4.hex View File


src/test/data/txcreatescript4.json → test/util/data/txcreatescript4.json View File


src/test/data/txcreatesignv1.hex → test/util/data/txcreatesignv1.hex View File


src/test/data/txcreatesignv1.json → test/util/data/txcreatesignv1.json View File


src/test/data/txcreatesignv2.hex → test/util/data/txcreatesignv2.hex View File


Loading…
Cancel
Save