aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/serialization.cpp
diff options
context:
space:
mode:
authorredfish <redfish@galactica.pw>2017-09-25 02:46:14 +0000
committerredfish <redfish@galactica.pw>2017-09-28 01:41:44 -0400
commit540d6fa3d5757e30bc251cbe9f2474e67c0a5d74 (patch)
tree83baac57511623349caccfb636d1ffcd536e25b6 /tests/unit_tests/serialization.cpp
parentMerge pull request #2496 (diff)
downloadmonero-540d6fa3d5757e30bc251cbe9f2474e67c0a5d74.tar.xz
tests: pass data dir as arg
This fixes test failure on builds that happen to be built in 'build/' instead of 'build/release'. Use boost filesystem path type.
Diffstat (limited to 'tests/unit_tests/serialization.cpp')
-rw-r--r--tests/unit_tests/serialization.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index 6f9fe7d11..e701a53ce 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -47,6 +47,7 @@
#include "serialization/binary_utils.h"
#include "wallet/wallet2.h"
#include "gtest/gtest.h"
+#include "unit_tests_utils.h"
using namespace std;
struct Struct
@@ -671,12 +672,12 @@ TEST(Serialization, portability_wallet)
const bool testnet = true;
const bool restricted = false;
tools::wallet2 w(testnet, restricted);
- string wallet_file = epee::string_tools::get_current_module_folder() + "/../../../../tests/data/wallet_9svHk1";
+ const boost::filesystem::path wallet_file = unit_test::data_dir / "wallet_9svHk1";
string password = "test";
bool r = false;
try
{
- w.load(wallet_file, password);
+ w.load(wallet_file.native(), password);
r = true;
}
catch (const exception& e)
@@ -791,9 +792,9 @@ TEST(Serialization, portability_wallet)
TEST(Serialization, portability_outputs)
{
// read file
- const std::string filename = epee::string_tools::get_current_module_folder() + "/../../../../tests/data/outputs";
+ const boost::filesystem::path filename = unit_test::data_dir / "outputs";
std::string data;
- bool r = epee::file_io_utils::load_file_to_string(filename, data);
+ bool r = epee::file_io_utils::load_file_to_string(filename.native(), data);
ASSERT_TRUE(r);
const size_t magiclen = strlen(OUTPUT_EXPORT_FILE_MAGIC);
ASSERT_FALSE(data.size() < magiclen || memcmp(data.data(), OUTPUT_EXPORT_FILE_MAGIC, magiclen));
@@ -906,10 +907,10 @@ TEST(Serialization, portability_outputs)
#define UNSIGNED_TX_PREFIX "Monero unsigned tx set\003"
TEST(Serialization, portability_unsigned_tx)
{
- const string filename = epee::string_tools::get_current_module_folder() + "/../../../../tests/data/unsigned_monero_tx";
+ const boost::filesystem::path filename = unit_test::data_dir / "unsigned_monero_tx";
std::string s;
const bool testnet = true;
- bool r = epee::file_io_utils::load_file_to_string(filename, s);
+ bool r = epee::file_io_utils::load_file_to_string(filename.native(), s);
ASSERT_TRUE(r);
const size_t magiclen = strlen(UNSIGNED_TX_PREFIX);
ASSERT_FALSE(strncmp(s.c_str(), UNSIGNED_TX_PREFIX, magiclen));
@@ -1054,10 +1055,10 @@ TEST(Serialization, portability_unsigned_tx)
#define SIGNED_TX_PREFIX "Monero signed tx set\003"
TEST(Serialization, portability_signed_tx)
{
- const string filename = epee::string_tools::get_current_module_folder() + "/../../../../tests/data/signed_monero_tx";
+ const boost::filesystem::path filename = unit_test::data_dir / "signed_monero_tx";
const bool testnet = true;
std::string s;
- bool r = epee::file_io_utils::load_file_to_string(filename, s);
+ bool r = epee::file_io_utils::load_file_to_string(filename.native(), s);
ASSERT_TRUE(r);
const size_t magiclen = strlen(SIGNED_TX_PREFIX);
ASSERT_FALSE(strncmp(s.c_str(), SIGNED_TX_PREFIX, magiclen));