aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--CMakeLists.txt17
-rw-r--r--Dockerfile49
-rw-r--r--Makefile4
-rw-r--r--README.md57
-rw-r--r--src/simplewallet/simplewallet.cpp54
-rw-r--r--tests/CMakeLists.txt14
7 files changed, 146 insertions, 54 deletions
diff --git a/.travis.yml b/.travis.yml
index 36c48f8d6..3eb75bea7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -36,8 +36,11 @@ matrix:
- pip install --user cpp-coveralls
install:
- sudo apt-get -y install libboost-{chrono,program-options,date-time,thread,system,filesystem,regex,serialization}1.58{-dev,.0}
+ env:
+ # exclude long-running and failing tests (#895)
+ - ARGS=" -E 'coretests|libwallet_api_tests' "
script:
- - make -j2 debug-test
+ - make -j2 coverage
after_success:
- travis_wait coveralls -e external -e tests -e cmake -e contrib -e translations -e utils --gcov-options '\-lp' &> /dev/null
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb587f9a1..e1ac8422a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -358,8 +358,15 @@ else()
set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert")
endif()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}")
+ option(COVERAGE "Enable profiling for test coverage report" 0)
+
+ if(COVERAGE)
+ message(STATUS "Building with profiling for test coverage report")
+ set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage --coverage")
+ endif()
+
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}")
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
# is fixed in the code (Issue #847), force compiler to be conservative.
@@ -459,10 +466,12 @@ else()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0")
endif()
+
+ set(DEBUG_FLAGS "-g3")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8))
- set(DEBUG_FLAGS "-g3 -Og -fprofile-arcs -ftest-coverage --coverage")
+ set(DEBUG_FLAGS "${DEBUG_FLAGS} -Og ")
else()
- set(DEBUG_FLAGS "-g3 -O0 -fprofile-arcs -ftest-coverage --coverage")
+ set(DEBUG_FLAGS "${DEBUG_FLAGS} -O0 ")
endif()
if(NOT DEFINED USE_LTO_DEFAULT)
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..8f6f4294e
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,49 @@
+FROM debian:testing
+MAINTAINER eiabea <developer@eiabea.com>
+
+# Install clone dependencies
+RUN set -e && \
+ apt-get update -q && \
+ apt-get install -q -y --no-install-recommends ca-certificates git && \
+ git clone https://github.com/monero-project/bitmonero.git src && \
+ apt-get purge -y git && \
+ apt-get clean -q -y && \
+ apt-get autoclean -q -y && \
+ apt-get autoremove -q -y
+
+WORKDIR /src
+
+# Install make dependencies
+RUN set -e && \
+ apt-get update -q && \
+ apt-get install -q -y --no-install-recommends build-essential ca-certificates g++ gcc cmake \
+ pkg-config libunbound2 libevent-2.0-5 libgtest-dev libboost-all-dev libdb5.3++-dev libdb5.3-dev libssl-dev && \
+ make -j 4 && \
+ apt-get purge -y g++ gcc cmake pkg-config && \
+ apt-get clean -q -y && \
+ apt-get autoclean -q -y && \
+ apt-get autoremove -q -y && \
+ mkdir /bitmonero && \
+ mv /src/build/release/bin/* /bitmonero && \
+ rm -rf /src
+
+WORKDIR /bitmonero
+
+# Contains the blockchain
+VOLUME /root/.bitmonero
+
+# Generate your wallet via accessing the container and run:
+# cd /wallet
+# /./bitmonero/simplewallet
+VOLUME /wallet
+
+ENV LOG_LEVEL 0
+ENV P2P_BIND_IP 0.0.0.0
+ENV P2P_BIND_PORT 18080
+ENV RPC_BIND_IP 127.0.0.1
+ENV RPC_BIND_PORT 18081
+
+EXPOSE 18080
+EXPOSE 18081
+
+CMD ./bitmonerod --log-level=$LOG_LEVEL --p2p-bind-ip=$P2P_BIND_IP --p2p-bind-port=$P2P_BIND_PORT --rpc-bind-ip=$RPC_BIND_IP --rpc-bind-port=$RPC_BIND_PORT \ No newline at end of file
diff --git a/Makefile b/Makefile
index 142111465..fc79958f6 100644
--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,10 @@ release-all:
mkdir -p build/release
cd build/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
+coverage:
+ mkdir -p build/debug
+ cd build/debug && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug -D COVERAGE=ON ../.. && $(MAKE) && $(MAKE) test
+
release-static-arm6:
mkdir -p build/release
cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
diff --git a/README.md b/README.md
index 3b8f7128b..98c0ea558 100644
--- a/README.md
+++ b/README.md
@@ -65,8 +65,18 @@ Packages are available for
* OS X via [Homebrew](http://brew.sh)
- brew tap sammy007/cryptonight
- brew install bitmonero --build-from-source
+ brew tap sammy007/cryptonight
+ brew install bitmonero --build-from-source
+
+* Docker
+
+ docker build -t monero .
+
+ # either run in foreground
+ docker run -it -v /bitmonero/chain:/root/.bitmonero -v /bitmonero/wallet:/wallet -p 18080:18080 monero
+
+ # or in background
+ docker run -it -d -v /bitmonero/chain:/root/.bitmonero -v /bitmonero/wallet:/wallet -p 18080:18080 monero
Packaging for your favorite distribution would be a welcome contribution!
@@ -74,21 +84,34 @@ Packaging for your favorite distribution would be a welcome contribution!
### Dependencies
-* GCC `>=4.7.3`
-* CMake `>=3.0.0`
-* pkg-config
-* libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is)
-* libevent `>=2.0`
-* Boost `>=1.58`
-* BerkeleyDB `>=4.8` (note: on Ubuntu this means installing libdb-dev and libdb++-dev)
-* libunwind (optional, for stack trace on exception)
-* miniupnpc (optional, for NAT punching)
-* ldns `>=1.6.17` (optional, for statically-linked binaries)
-* expat `>=1.1` (optional, for statically-linked binaries)
-* bison or yacc (optional, for statically-linked binaries)
-* GTest `>=1.5` (optional, for running test suite) (NOTE: `libgtest-dev` package in Ubuntu ships without binaries and requires a manual build; `gtest` on Arch includes binaries)
-* Doxygen (optional, for generating documentation)
-* graphviz (optional, for generating documentation)
+The following table summarizes the tools and libraries required to build. A
+few of the libraries are also included in this repository (marked as
+"Vendored"). By default, the build uses the library installed on the system,
+and ignores the vendored sources. However, if no library is found installed on
+the system, then the vendored source will be built and used. The vendored
+sources are also used for statically-linked builds because distribution
+packages often include only shared library binaries (`.so`) but not static
+library archives (`.a`).
+
+| Dep | Min. Version | Vendored | Debian/Ubuntu Pkg | Arch Pkg | Optional | Purpose |
+| -------------- | ------------- | ---------| ------------------ | -------------- | -------- | -------------- |
+| GCC | 4.7.3 | NO | `build-essential` | `base-devel` | NO | |
+| CMake | 3.0.0 | NO | `cmake` | `cmake` | NO | |
+| pkg-config | any | NO | `pkg-config` | `base-devel` | NO | |
+| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | NO | |
+| BerkeleyDB | 4.8 | NO | `libdb{,++}-dev` | `db` | NO | |
+| libevent | 2.0 | NO | `libevent-dev` | `libevent` | NO | |
+| libunbound | 1.4.16 | YES | `libunbound-dev` | `unbound` | NO | |
+| libminiupnpc | 2.0 | YES | `libminiupnpc-dev` | `miniupnpc` | YES | NAT punching |
+| libunwind | any | NO | `libunwind-dev` | `libunwind` | YES | stack traces |
+| ldns | 1.6.17 | NO | `libldns-dev` | `ldns` | YES | ? |
+| expat | 1.1 | NO | `libexpat1-dev` | `expat` | YES | ? |
+| GTest | 1.5 | YES | `libgtest-dev`^ | `gtest` | YES | test suite |
+| Doxygen | any | NO | `doxygen` | `doxygen` | YES | documentation |
+| Graphviz | any | NO | `graphviz` | `graphviz` | YES | documentation |
+
+[^] On Debian/Ubuntu `libgtest-dev` only includes sources and headers. You must
+build the library binary manually.
### Build instructions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 44b5b0c70..c1b0a2a95 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -77,6 +77,8 @@ typedef cryptonote::simple_wallet sw;
#define DEFAULT_MIX 4
+#define KEY_IMAGE_EXPORT_FILE_MAGIC "Monero key image export\001"
+
// workaround for a suspected bug in pthread/kernel on MacOS X
#ifdef __APPLE__
#define DEFAULT_MAX_CONCURRENCY 1
@@ -3583,11 +3585,14 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args)
try
{
std::vector<std::pair<crypto::key_image, crypto::signature>> ski = m_wallet->export_key_images();
- std::string data;
+ std::string data(KEY_IMAGE_EXPORT_FILE_MAGIC, strlen(KEY_IMAGE_EXPORT_FILE_MAGIC));
+ const cryptonote::account_public_address &keys = m_wallet->get_account().get_keys().m_account_address;
+ data += std::string((const char *)&keys.m_spend_public_key, sizeof(crypto::public_key));
+ data += std::string((const char *)&keys.m_view_public_key, sizeof(crypto::public_key));
for (const auto &i: ski)
{
- data += epee::string_tools::pod_to_hex(i.first);
- data += epee::string_tools::pod_to_hex(i.second);
+ data += std::string((const char *)&i.first, sizeof(crypto::key_image));
+ data += std::string((const char *)&i.second, sizeof(crypto::signature));
}
bool r = epee::file_io_utils::save_string_to_file(filename, data);
if (!r)
@@ -3623,34 +3628,41 @@ bool simple_wallet::import_key_images(const std::vector<std::string> &args)
fail_msg_writer() << tr("failed to read file ") << filename;
return true;
}
+ const size_t magiclen = strlen(KEY_IMAGE_EXPORT_FILE_MAGIC);
+ if (data.size() < magiclen || memcmp(data.data(), KEY_IMAGE_EXPORT_FILE_MAGIC, magiclen))
+ {
+ fail_msg_writer() << "Bad key image export file magic in " << filename;
+ return true;
+ }
+ const size_t headerlen = magiclen + 2 * sizeof(crypto::public_key);
+ if (data.size() < headerlen)
+ {
+ fail_msg_writer() << "Bad data size from file " << filename;
+ return true;
+ }
+ const crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[magiclen];
+ const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[magiclen + sizeof(crypto::public_key)];
+ const cryptonote::account_public_address &keys = m_wallet->get_account().get_keys().m_account_address;
+ if (public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key)
+ {
+ fail_msg_writer() << "Key images from " << filename << " are for a different account";
+ return true;
+ }
- const size_t record_size = sizeof(crypto::key_image)*2 + sizeof(crypto::signature)*2;
- if (data.size() % record_size)
+ const size_t record_size = sizeof(crypto::key_image) + sizeof(crypto::signature);
+ if ((data.size() - headerlen) % record_size)
{
fail_msg_writer() << "Bad data size from file " << filename;
return true;
}
- size_t nki = data.size() / record_size;
+ size_t nki = (data.size() - headerlen) / record_size;
std::vector<std::pair<crypto::key_image, crypto::signature>> ski;
ski.reserve(nki);
for (size_t n = 0; n < nki; ++n)
{
- cryptonote::blobdata bd;
-
- if(!epee::string_tools::parse_hexstr_to_binbuff(std::string(&data[n * record_size], sizeof(crypto::key_image)*2), bd))
- {
- fail_msg_writer() << tr("failed to parse key image");
- return false;
- }
- crypto::key_image key_image = *reinterpret_cast<const crypto::key_image*>(bd.data());
-
- if(!epee::string_tools::parse_hexstr_to_binbuff(std::string(&data[n * record_size + sizeof(crypto::key_image)*2], sizeof(crypto::signature)*2), bd))
- {
- fail_msg_writer() << tr("failed to parse signature");
- return false;
- }
- crypto::signature signature = *reinterpret_cast<const crypto::signature*>(bd.data());
+ crypto::key_image key_image = *reinterpret_cast<const crypto::key_image*>(&data[headerlen + n * record_size]);
+ crypto::signature signature = *reinterpret_cast<const crypto::signature*>(&data[headerlen + n * record_size + sizeof(crypto::key_image)]);
ski.push_back(std::make_pair(key_image, signature));
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 33d6c233d..75e75f258 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -62,9 +62,7 @@ else ()
FOLDER "${folder}")
endif ()
-if (NOT DEFINED ENV{TRAVIS})
- add_subdirectory(core_tests)
-endif ()
+add_subdirectory(core_tests)
add_subdirectory(crypto)
add_subdirectory(functional_tests)
add_subdirectory(performance_tests)
@@ -73,9 +71,7 @@ add_subdirectory(unit_tests)
add_subdirectory(difficulty)
add_subdirectory(hash)
add_subdirectory(net_load_tests)
-
-# Disabled until issue #895 is resolved
-#add_subdirectory(libwallet_api_tests)
+add_subdirectory(libwallet_api_tests)
# add_subdirectory(daemon_tests)
@@ -99,16 +95,12 @@ add_test(
COMMAND hash-target-tests)
set(enabled_tests
+ coretests
difficulty
hash
performance_tests
core_proxy
unit_tests)
-# Skip the core_tests in Travis-CI because they will take too long
-if (NOT DEFINED ENV{TRAVIS})
- list(APPEND enabled_tests coretests)
-endif()
-
add_custom_target(tests DEPENDS enabled_tests)
set_property(TARGET tests PROPERTY FOLDER "${folder}")