aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/hardfork.cpp2
-rw-r--r--tests/unit_tests/keccak.cpp2
-rw-r--r--tests/unit_tests/ringct.cpp19
-rw-r--r--tests/unit_tests/serialization.cpp13
4 files changed, 33 insertions, 3 deletions
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp
index 47177db1c..fc488bb14 100644
--- a/tests/unit_tests/hardfork.cpp
+++ b/tests/unit_tests/hardfork.cpp
@@ -118,7 +118,7 @@ public:
virtual std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> get_output_histogram(const std::vector<uint64_t> &amounts, bool unlocked, uint64_t recent_cutoff, uint64_t min_count) const { return std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>>(); }
virtual bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, std::vector<uint64_t> &distribution, uint64_t &base) const { return false; }
- virtual void add_txpool_tx(const transaction &tx, const txpool_tx_meta_t& details) {}
+ virtual void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata &blob, const txpool_tx_meta_t& details) {}
virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& details) {}
virtual uint64_t get_txpool_tx_count(bool include_unrelayed_txes = true) const { return 0; }
virtual bool txpool_has_tx(const crypto::hash &txid) const { return false; }
diff --git a/tests/unit_tests/keccak.cpp b/tests/unit_tests/keccak.cpp
index 4276b0e1d..37da65d76 100644
--- a/tests/unit_tests/keccak.cpp
+++ b/tests/unit_tests/keccak.cpp
@@ -37,7 +37,7 @@ extern "C" {
#define TEST_KECCAK(sz, chunks) \
std::string data; \
data.resize(sz); \
- for (size_t i = 0; i < sz; ++i) \
+ for (size_t i = 0; i < data.size(); ++i) \
data[i] = i * 17; \
uint8_t md0[32], md1[32]; \
keccak((const uint8_t*)data.data(), data.size(), md0, 32); \
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index 3877ef785..52bdb00cf 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -1086,6 +1086,25 @@ TEST(ringct, zeroCommmit)
ASSERT_EQ(z, manual);
}
+static rct::key uncachedZeroCommit(uint64_t amount)
+{
+ const rct::key am = rct::d2h(amount);
+ const rct::key bH = rct::scalarmultH(am);
+ return rct::addKeys(rct::G, bH);
+}
+
+TEST(ringct, zeroCommitCache)
+{
+ ASSERT_EQ(rct::zeroCommit(0), uncachedZeroCommit(0));
+ ASSERT_EQ(rct::zeroCommit(1), uncachedZeroCommit(1));
+ ASSERT_EQ(rct::zeroCommit(2), uncachedZeroCommit(2));
+ ASSERT_EQ(rct::zeroCommit(10), uncachedZeroCommit(10));
+ ASSERT_EQ(rct::zeroCommit(200), uncachedZeroCommit(200));
+ ASSERT_EQ(rct::zeroCommit(1000000000), uncachedZeroCommit(1000000000));
+ ASSERT_EQ(rct::zeroCommit(3000000000000), uncachedZeroCommit(3000000000000));
+ ASSERT_EQ(rct::zeroCommit(900000000000000), uncachedZeroCommit(900000000000000));
+}
+
TEST(ringct, H)
{
ge_p3 p3;
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index 2f7b5aac7..b4517af2f 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -908,6 +908,17 @@ TEST(Serialization, portability_outputs)
ASSERT_TRUE(td2.m_pk_index == 0);
}
+struct unsigned_tx_set
+{
+ std::vector<tools::wallet2::tx_construction_data> txes;
+ tools::wallet2::transfer_container transfers;
+};
+template <class Archive>
+inline void serialize(Archive &a, unsigned_tx_set &x, const boost::serialization::version_type ver)
+{
+ a & x.txes;
+ a & x.transfers;
+}
#define UNSIGNED_TX_PREFIX "Monero unsigned tx set\003"
TEST(Serialization, portability_unsigned_tx)
{
@@ -918,7 +929,7 @@ TEST(Serialization, portability_unsigned_tx)
ASSERT_TRUE(r);
const size_t magiclen = strlen(UNSIGNED_TX_PREFIX);
ASSERT_FALSE(strncmp(s.c_str(), UNSIGNED_TX_PREFIX, magiclen));
- tools::wallet2::unsigned_tx_set exported_txs;
+ unsigned_tx_set exported_txs;
s = s.substr(magiclen);
r = false;
try