aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core_tests/bulletproofs.cpp1
-rw-r--r--tests/core_tests/chaingen.cpp194
-rw-r--r--tests/core_tests/chaingen.h17
-rw-r--r--tests/core_tests/multisig.cpp2
-rw-r--r--tests/core_tests/rct.cpp1
-rw-r--r--tests/core_tests/v2_tests.cpp1
-rw-r--r--tests/core_tests/wallet_tools.cpp3
-rwxr-xr-xtests/functional_tests/address_book.py64
-rwxr-xr-xtests/functional_tests/blockchain.py5
-rw-r--r--tests/functional_tests/make_test_signature.cc2
-rwxr-xr-xtests/functional_tests/sign_message.py31
-rwxr-xr-xtests/functional_tests/transfer.py4
-rw-r--r--tests/net_load_tests/clt.cpp34
-rw-r--r--tests/net_load_tests/net_load_tests.h1
-rw-r--r--tests/net_load_tests/srv.cpp2
-rw-r--r--tests/unit_tests/bulletproofs.cpp9
-rw-r--r--tests/unit_tests/levin.cpp96
-rw-r--r--tests/unit_tests/net.cpp6
-rw-r--r--tests/unit_tests/serialization.cpp1
19 files changed, 331 insertions, 143 deletions
diff --git a/tests/core_tests/bulletproofs.cpp b/tests/core_tests/bulletproofs.cpp
index fd3f5114b..0a5b98605 100644
--- a/tests/core_tests/bulletproofs.cpp
+++ b/tests/core_tests/bulletproofs.cpp
@@ -64,7 +64,6 @@ bool gen_bp_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
false, "Failed to generate block");
events.push_back(blocks[n]);
prev_block = blocks + n;
- LOG_PRINT_L0("Initial miner tx " << n << ": " << obj_to_json_str(blocks[n].miner_tx));
}
// rewind
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index 35e449e10..f935d4f64 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -47,6 +47,12 @@
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_basic/miner.h"
+#include "blockchain_db/blockchain_db.h"
+#include "cryptonote_core/cryptonote_core.h"
+#include "cryptonote_core/tx_pool.h"
+#include "cryptonote_core/blockchain.h"
+#include "blockchain_db/testdb.h"
+
#include "chaingen.h"
#include "device/device.hpp"
using namespace std;
@@ -55,6 +61,126 @@ using namespace epee;
using namespace crypto;
using namespace cryptonote;
+namespace
+{
+ /**
+ * Dummy TestDB to store height -> (block, hash) information
+ * for the use only in the test_generator::fill_nonce() function,
+ * which requires blockchain object to correctly compute PoW on HF12+ blocks
+ * as the mining function requires it to obtain a valid seedhash.
+ */
+ class TestDB: public cryptonote::BaseTestDB
+ {
+ private:
+ struct block_t
+ {
+ cryptonote::block bl;
+ crypto::hash hash;
+ };
+
+ public:
+ TestDB() { m_open = true; }
+
+ virtual void add_block( const cryptonote::block& blk
+ , size_t block_weight
+ , uint64_t long_term_block_weight
+ , const cryptonote::difficulty_type& cumulative_difficulty
+ , const uint64_t& coins_generated
+ , uint64_t num_rct_outs
+ , const crypto::hash& blk_hash
+ ) override
+ {
+ blocks.push_back({blk, blk_hash});
+ }
+
+ virtual uint64_t height() const override { return blocks.empty() ? 0 : blocks.size() - 1; }
+
+ // Required for randomx
+ virtual crypto::hash get_block_hash_from_height(const uint64_t &height) const override
+ {
+ if (height < blocks.size())
+ {
+ MDEBUG("Get hash for block height: " << height << " hash: " << blocks[height].hash);
+ return blocks[height].hash;
+ }
+
+ MDEBUG("Get hash for block height: " << height << " zero-hash");
+ crypto::hash hash = crypto::null_hash;
+ *(uint64_t*)&hash = height;
+ return hash;
+ }
+
+ virtual crypto::hash top_block_hash(uint64_t *block_height = NULL) const override
+ {
+ const uint64_t h = height();
+ if (block_height != nullptr)
+ {
+ *block_height = h;
+ }
+
+ return get_block_hash_from_height(h);
+ }
+
+ virtual cryptonote::block get_top_block() const override
+ {
+ if (blocks.empty())
+ {
+ cryptonote::block b;
+ return b;
+ }
+
+ return blocks[blocks.size()-1].bl;
+ }
+
+ virtual void pop_block(cryptonote::block &blk, std::vector<cryptonote::transaction> &txs) override { if (!blocks.empty()) blocks.pop_back(); }
+ virtual void set_hard_fork_version(uint64_t height, uint8_t version) override { if (height >= hf.size()) hf.resize(height + 1); hf[height] = version; }
+ virtual uint8_t get_hard_fork_version(uint64_t height) const override { if (height >= hf.size()) return 255; return hf[height]; }
+
+ private:
+ std::vector<block_t> blocks;
+ std::vector<uint8_t> hf;
+ };
+
+}
+
+static std::unique_ptr<cryptonote::Blockchain> init_blockchain(const std::vector<test_event_entry> & events, cryptonote::network_type nettype)
+{
+ std::unique_ptr<cryptonote::Blockchain> bc;
+ v_hardforks_t hardforks;
+ cryptonote::test_options test_options_tmp{nullptr, 0};
+ const cryptonote::test_options * test_options = &test_options_tmp;
+ if (!extract_hard_forks(events, hardforks))
+ {
+ MDEBUG("Extracting hard-forks from blocks");
+ extract_hard_forks_from_blocks(events, hardforks);
+ }
+
+ hardforks.push_back(std::make_pair((uint8_t)0, (uint64_t)0)); // terminator
+ test_options_tmp.hard_forks = hardforks.data();
+ test_options = &test_options_tmp;
+
+ cryptonote::tx_memory_pool txpool(*bc);
+ bc.reset(new cryptonote::Blockchain(txpool));
+
+ cryptonote::Blockchain *blockchain = bc.get();
+ auto bdb = new TestDB();
+
+ BOOST_FOREACH(const test_event_entry &ev, events)
+ {
+ if (typeid(block) != ev.type())
+ {
+ continue;
+ }
+
+ const block *blk = &boost::get<block>(ev);
+ auto blk_hash = get_block_hash(*blk);
+ bdb->add_block(*blk, 1, 1, 1, 0, 0, blk_hash);
+ }
+
+ bool r = blockchain->init(bdb, nettype, true, test_options, 2, nullptr);
+ CHECK_AND_ASSERT_THROW_MES(r, "could not init blockchain from events");
+ return bc;
+}
void test_generator::get_block_chain(std::vector<block_info>& blockchain, const crypto::hash& head, size_t n) const
{
@@ -184,13 +310,7 @@ bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, co
//blk.tree_root_hash = get_tx_tree_hash(blk);
- // Nonce search...
- blk.nonce = 0;
- while (!miner::find_nonce_for_given_block([](const cryptonote::block &b, uint64_t height, unsigned int threads, crypto::hash &hash){
- return cryptonote::get_block_longhash(NULL, b, hash, height, threads);
- }, blk, get_test_difficulty(hf_ver), height))
- blk.timestamp++;
-
+ fill_nonce(blk, get_test_difficulty(hf_ver), height);
add_block(blk, txs_weight, block_weights, already_generated_coins, hf_ver ? hf_ver.get() : 1);
return true;
@@ -268,6 +388,32 @@ bool test_generator::construct_block_manually_tx(cryptonote::block& blk, const c
return construct_block_manually(blk, prev_block, miner_acc, bf_tx_hashes, 0, 0, 0, crypto::hash(), 0, transaction(), tx_hashes, txs_weight);
}
+void test_generator::fill_nonce(cryptonote::block& blk, const difficulty_type& diffic, uint64_t height)
+{
+ const cryptonote::Blockchain *blockchain = nullptr;
+ std::unique_ptr<cryptonote::Blockchain> bc;
+
+ if (blk.major_version >= RX_BLOCK_VERSION && diffic > 1)
+ {
+ if (m_events == nullptr)
+ {
+ MDEBUG("events not set, RandomX PoW can fail due to zero seed hash");
+ }
+ else
+ {
+ bc = init_blockchain(*m_events, m_nettype);
+ blockchain = bc.get();
+ }
+ }
+
+ blk.nonce = 0;
+ while (!miner::find_nonce_for_given_block([blockchain](const cryptonote::block &b, uint64_t height, unsigned int threads, crypto::hash &hash){
+ return cryptonote::get_block_longhash(blockchain, b, hash, height, threads);
+ }, blk, diffic, height)) {
+ blk.timestamp++;
+ }
+}
+
namespace
{
uint64_t get_inputs_amount(const vector<tx_source_entry> &s)
@@ -796,15 +942,6 @@ void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& event
fill_tx_sources_and_destinations(events, blk_head, from, to.get_keys().m_account_address, amount, fee, nmix, sources, destinations);
}
-void fill_nonce(cryptonote::block& blk, const difficulty_type& diffic, uint64_t height)
-{
- blk.nonce = 0;
- while (!miner::find_nonce_for_given_block([](const cryptonote::block &b, uint64_t height, unsigned int threads, crypto::hash &hash){
- return cryptonote::get_block_longhash(NULL, b, hash, height, threads);
- }, blk, diffic, height))
- blk.timestamp++;
-}
-
cryptonote::tx_destination_entry build_dst(const var_addr_t& to, bool is_subaddr, uint64_t amount)
{
tx_destination_entry de;
@@ -983,6 +1120,31 @@ bool extract_hard_forks(const std::vector<test_event_entry>& events, v_hardforks
return !hard_forks.empty();
}
+bool extract_hard_forks_from_blocks(const std::vector<test_event_entry>& events, v_hardforks_t& hard_forks)
+{
+ int hf = -1;
+ int64_t height = 0;
+
+ for(auto & ev : events)
+ {
+ if (typeid(block) != ev.type())
+ {
+ continue;
+ }
+
+ const block *blk = &boost::get<block>(ev);
+ if (blk->major_version != hf)
+ {
+ hf = blk->major_version;
+ hard_forks.push_back(std::make_pair(blk->major_version, (uint64_t)height));
+ }
+
+ height += 1;
+ }
+
+ return !hard_forks.empty();
+}
+
void get_confirmed_txs(const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx, map_hash2tx_t& confirmed_txs)
{
std::unordered_set<crypto::hash> confirmed_hashes;
diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h
index bc0e61365..80ce7404b 100644
--- a/tests/core_tests/chaingen.h
+++ b/tests/core_tests/chaingen.h
@@ -47,6 +47,7 @@
#include "include_base_utils.h"
#include "common/boost_serialization_helper.h"
#include "common/command_line.h"
+#include "common/threadpool.h"
#include "cryptonote_basic/account_boost_serialization.h"
#include "cryptonote_basic/cryptonote_basic.h"
@@ -227,8 +228,8 @@ public:
bf_hf_version= 1 << 8
};
- test_generator() {}
- test_generator(const test_generator &other): m_blocks_info(other.m_blocks_info) {}
+ test_generator(): m_events(nullptr) {}
+ test_generator(const test_generator &other): m_blocks_info(other.m_blocks_info), m_events(other.m_events), m_nettype(other.m_nettype) {}
void get_block_chain(std::vector<block_info>& blockchain, const crypto::hash& head, size_t n) const;
void get_last_n_block_weights(std::vector<size_t>& block_weights, const crypto::hash& head, size_t n) const;
uint64_t get_already_generated_coins(const crypto::hash& blk_id) const;
@@ -253,9 +254,14 @@ public:
uint8_t hf_version = 1);
bool construct_block_manually_tx(cryptonote::block& blk, const cryptonote::block& prev_block,
const cryptonote::account_base& miner_acc, const std::vector<crypto::hash>& tx_hashes, size_t txs_size);
+ void fill_nonce(cryptonote::block& blk, const cryptonote::difficulty_type& diffic, uint64_t height);
+ void set_events(const std::vector<test_event_entry> * events) { m_events = events; }
+ void set_network_type(const cryptonote::network_type nettype) { m_nettype = nettype; }
private:
std::unordered_map<crypto::hash, block_info> m_blocks_info;
+ const std::vector<test_event_entry> * m_events;
+ cryptonote::network_type m_nettype;
friend class boost::serialization::access;
@@ -407,7 +413,6 @@ cryptonote::account_public_address get_address(const cryptonote::tx_destination_
inline cryptonote::difficulty_type get_test_difficulty(const boost::optional<uint8_t>& hf_ver=boost::none) {return !hf_ver || hf_ver.get() <= 1 ? 1 : 2;}
inline uint64_t current_difficulty_window(const boost::optional<uint8_t>& hf_ver=boost::none){ return !hf_ver || hf_ver.get() <= 1 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2; }
-void fill_nonce(cryptonote::block& blk, const cryptonote::difficulty_type& diffic, uint64_t height);
cryptonote::tx_destination_entry build_dst(const var_addr_t& to, bool is_subaddr=false, uint64_t amount=0);
std::vector<cryptonote::tx_destination_entry> build_dsts(const var_addr_t& to1, bool sub1=false, uint64_t am1=0);
@@ -490,6 +495,7 @@ void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& event
uint64_t get_balance(const cryptonote::account_base& addr, const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx);
bool extract_hard_forks(const std::vector<test_event_entry>& events, v_hardforks_t& hard_forks);
+bool extract_hard_forks_from_blocks(const std::vector<test_event_entry>& events, v_hardforks_t& hard_forks);
/************************************************************************/
/* */
@@ -511,7 +517,7 @@ public:
, m_events(events)
, m_validator(validator)
, m_ev_index(0)
- , m_tx_relay(cryptonote::relay_method::flood)
+ , m_tx_relay(cryptonote::relay_method::fluff)
{
}
@@ -544,7 +550,7 @@ public:
}
else
{
- m_tx_relay = cryptonote::relay_method::flood;
+ m_tx_relay = cryptonote::relay_method::fluff;
}
return true;
@@ -770,6 +776,7 @@ inline bool do_replay_events_get_core(std::vector<test_event_entry>& events, cry
t_test_class validator;
bool ret = replay_events_through_core<t_test_class>(c, events, validator);
+ tools::threadpool::getInstance().recycle();
// c.deinit();
return ret;
}
diff --git a/tests/core_tests/multisig.cpp b/tests/core_tests/multisig.cpp
index e0c90423d..ba6e2d270 100644
--- a/tests/core_tests/multisig.cpp
+++ b/tests/core_tests/multisig.cpp
@@ -180,8 +180,6 @@ bool gen_multisig_tx_validation_base::generate_with(std::vector<test_event_entry
false, "Failed to generate block");
events.push_back(blocks[n]);
prev_block = blocks + n;
- LOG_PRINT_L0("Initial miner tx " << n << ": " << obj_to_json_str(blocks[n].miner_tx));
- LOG_PRINT_L0("in block: " << obj_to_json_str(blocks[n]));
}
// rewind
diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp
index dc77e408f..23638f62d 100644
--- a/tests/core_tests/rct.cpp
+++ b/tests/core_tests/rct.cpp
@@ -63,7 +63,6 @@ bool gen_rct_tx_validation_base::generate_with_full(std::vector<test_event_entry
false, "Failed to generate block");
events.push_back(blocks[n]);
prev_block = blocks + n;
- LOG_PRINT_L0("Initial miner tx " << n << ": " << obj_to_json_str(blocks[n].miner_tx));
}
// rewind
diff --git a/tests/core_tests/v2_tests.cpp b/tests/core_tests/v2_tests.cpp
index 8c2b51acf..d00d9b6f4 100644
--- a/tests/core_tests/v2_tests.cpp
+++ b/tests/core_tests/v2_tests.cpp
@@ -85,7 +85,6 @@ bool gen_v2_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
tx_source_entry& src = sources.back();
src.amount = blocks[0].miner_tx.vout[out_idx[out_idx_idx]].amount;
- std::cout << "using " << print_money(src.amount) << " output at index " << out_idx[out_idx_idx] << std::endl;
for (int m = 0; m <= mixin; ++m) {
int idx;
if (is_valid_decomposed_amount(src.amount))
diff --git a/tests/core_tests/wallet_tools.cpp b/tests/core_tests/wallet_tools.cpp
index 21a9455c0..fdc4753f9 100644
--- a/tests/core_tests/wallet_tools.cpp
+++ b/tests/core_tests/wallet_tools.cpp
@@ -10,9 +10,6 @@ using namespace epee;
using namespace crypto;
using namespace cryptonote;
-// Shared random generator
-static std::default_random_engine RND(crypto::rand<unsigned>());
-
void wallet_accessor_test::set_account(tools::wallet2 * wallet, cryptonote::account_base& account)
{
wallet->clear();
diff --git a/tests/functional_tests/address_book.py b/tests/functional_tests/address_book.py
index 8d8711ffc..f9ec217af 100755
--- a/tests/functional_tests/address_book.py
+++ b/tests/functional_tests/address_book.py
@@ -73,14 +73,13 @@ class AddressBookTest():
# add one
res = wallet.add_address_book('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', description = 'self')
- assert res.index == 0
+ assert res.index == 0, res
for get_all in [True, False]:
res = wallet.get_address_book() if get_all else wallet.get_address_book([0])
assert len(res.entries) == 1
e = res.entries[0]
assert e.index == 0
- assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
- assert e.payment_id == '' or e.payment_id == '0' * 16 or e.payment_id == '0' * 64
+ assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', e
assert e.description == 'self'
# add a duplicate
@@ -91,7 +90,6 @@ class AddressBookTest():
assert res.entries[0].index == 0
assert res.entries[1].index == 1
assert res.entries[0].address == res.entries[1].address
- assert res.entries[0].payment_id == res.entries[1].payment_id
assert res.entries[0].description == res.entries[1].description
e = res.entries[1]
res = wallet.get_address_book([1])
@@ -118,7 +116,6 @@ class AddressBookTest():
assert len(res.entries) == 1
assert res.entries[0].index == 0
assert res.entries[0].address == e.address
- assert res.entries[0].payment_id == e.payment_id
assert res.entries[0].description == e.description
# delete (new) first
@@ -165,38 +162,13 @@ class AddressBookTest():
assert res.entries[0] == e
assert res.entries[1] == e
- # payment IDs
- res = wallet.add_address_book('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', payment_id = '0' * 64)
- assert res.index == 2
- ok = False
- try: res = wallet.add_address_book('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', payment_id = 'x' * 64)
- except: ok = True
- assert ok
- ok = False
- try: res = wallet.add_address_book('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', payment_id = '0' * 65)
- except: ok = True
- assert ok
- ok = False
- try: res = wallet.add_address_book('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', payment_id = '0' * 63)
- except: ok = True
- assert ok
- ok = False
- try: res = wallet.add_address_book('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', payment_id = '0' * 16)
- except: ok = True
- assert ok
-
# various address types
res = wallet.make_integrated_address()
integrated_address = res.integrated_address
- integrated_address_payment_id = res.payment_id
- ok = False
- try: res = wallet.add_address_book(integrated_address, payment_id = '0' * 64)
- except: ok = True
- assert ok
res = wallet.add_address_book(integrated_address)
- assert res.index == 3
+ assert res.index == 2
res = wallet.add_address_book('87KfgTZ8ER5D3Frefqnrqif11TjVsTPaTcp37kqqKMrdDRUhpJRczeR7KiBmSHF32UJLP3HHhKUDmEQyJrv2mV8yFDCq8eB')
- assert res.index == 4
+ assert res.index == 3
# get them back
res = wallet.get_address_book([0])
@@ -209,16 +181,9 @@ class AddressBookTest():
assert res.entries[0].description == u'あまやかす'
res = wallet.get_address_book([2])
assert len(res.entries) == 1
- assert res.entries[0].address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
+ assert res.entries[0].address == integrated_address
res = wallet.get_address_book([3])
assert len(res.entries) == 1
- if False: # for now, the address book splits integrated addresses
- assert res.entries[0].address == integrated_address
- else:
- assert res.entries[0].address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
- assert res.entries[0].payment_id == integrated_address_payment_id + '0' * 48
- res = wallet.get_address_book([4])
- assert len(res.entries) == 1
assert res.entries[0].address == '87KfgTZ8ER5D3Frefqnrqif11TjVsTPaTcp37kqqKMrdDRUhpJRczeR7KiBmSHF32UJLP3HHhKUDmEQyJrv2mV8yFDCq8eB'
# edit
@@ -227,15 +192,12 @@ class AddressBookTest():
e = res.entries[0]
assert e.index == 1
assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
- assert e.payment_id == '0' * 64
assert e.description == u'あまやかす'
- res = wallet.edit_address_book(1, payment_id = '1' * 64)
res = wallet.get_address_book([1])
assert len(res.entries) == 1
e = res.entries[0]
assert e.index == 1
assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
- assert e.payment_id == '1' * 64
assert e.description == u'あまやかす'
res = wallet.edit_address_book(1, description = '')
res = wallet.get_address_book([1])
@@ -243,7 +205,6 @@ class AddressBookTest():
e = res.entries[0]
assert e.index == 1
assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
- assert e.payment_id == '1' * 64
assert e.description == ''
res = wallet.edit_address_book(1, description = 'えんしゅう')
res = wallet.get_address_book([1])
@@ -251,7 +212,6 @@ class AddressBookTest():
e = res.entries[0]
assert e.index == 1
assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
- assert e.payment_id == '1' * 64
assert e.description == u'えんしゅう'
res = wallet.edit_address_book(1, address = '44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A')
res = wallet.get_address_book([1])
@@ -259,25 +219,12 @@ class AddressBookTest():
e = res.entries[0]
assert e.index == 1
assert e.address == '44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A'
- assert e.payment_id == '1' * 64
- assert e.description == u'えんしゅう'
- res = wallet.edit_address_book(1, payment_id = '')
- res = wallet.get_address_book([1])
- assert len(res.entries) == 1
- e = res.entries[0]
- assert e.index == 1
- assert e.address == '44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A'
- assert e.payment_id == '0' * 64
assert e.description == u'えんしゅう'
ok = False
try: res = wallet.edit_address_book(1, address = '')
except: ok = True
assert ok
ok = False
- try: res = wallet.edit_address_book(1, payment_id = 'asdnd')
- except: ok = True
- assert ok
- ok = False
try: res = wallet.edit_address_book(1, address = 'address')
except: ok = True
assert ok
@@ -287,7 +234,6 @@ class AddressBookTest():
assert e == res.entries[0]
# empty
- wallet.delete_address_book(4)
wallet.delete_address_book(0)
res = wallet.get_address_book([0]) # entries above the deleted one collapse one slot up
assert len(res.entries) == 1
diff --git a/tests/functional_tests/blockchain.py b/tests/functional_tests/blockchain.py
index 78e0d8952..b8f8bac1a 100755
--- a/tests/functional_tests/blockchain.py
+++ b/tests/functional_tests/blockchain.py
@@ -203,10 +203,15 @@ class BlockchainTest():
res_sum = daemon.get_coinbase_tx_sum(i, 1)
res_header = daemon.getblockheaderbyheight(i)
assert res_sum.emission_amount == res_header.block_header.reward
+ assert res_sum.emission_amount_top64 == 0
+ assert res_sum.emission_amount == int(res_sum.wide_emission_amount, 16)
+ assert res_sum.fee_amount == int(res_sum.wide_fee_amount, 16)
res = daemon.get_coinbase_tx_sum(0, 1)
assert res.emission_amount == 17592186044415
+ assert res.emission_amount_top64 == 0
assert res.fee_amount == 0
+ assert res.fee_amount_top64 == 0
sum_blocks = height + nblocks - 1
res = daemon.get_coinbase_tx_sum(0, sum_blocks)
extrapolated = 17592186044415 + 17592186044415 * 2 * (sum_blocks - 1)
diff --git a/tests/functional_tests/make_test_signature.cc b/tests/functional_tests/make_test_signature.cc
index 8c0333233..789523de5 100644
--- a/tests/functional_tests/make_test_signature.cc
+++ b/tests/functional_tests/make_test_signature.cc
@@ -32,6 +32,7 @@
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
if (argc > 2)
{
fprintf(stderr, "usage: %s <secret_key>\n", argv[0]);
@@ -57,4 +58,5 @@ int main(int argc, const char **argv)
std::string signature = cryptonote::make_rpc_payment_signature(skey);
printf("%s\n", signature.c_str());
return 0;
+ CATCH_ENTRY_L0("main()", 1);
}
diff --git a/tests/functional_tests/sign_message.py b/tests/functional_tests/sign_message.py
index de8f0cee2..9dd70f8bc 100755
--- a/tests/functional_tests/sign_message.py
+++ b/tests/functional_tests/sign_message.py
@@ -43,7 +43,8 @@ from framework.wallet import Wallet
class MessageSigningTest():
def run_test(self):
self.create()
- self.check_signing()
+ self.check_signing(False)
+ self.check_signing(True)
def create(self):
print('Creating wallets')
@@ -65,20 +66,34 @@ class MessageSigningTest():
assert res.address == self.address[i]
assert res.seed == seeds[i]
- def check_signing(self):
- print('Signing/verifing messages')
+ def check_signing(self, subaddress):
+ print('Signing/verifing messages with ' + ('subaddress' if subaddress else 'standard address'))
messages = ['foo', '']
+ if subaddress:
+ address = []
+ for i in range(2):
+ res = self.wallet[i].create_account()
+ if i == 0:
+ account_index = res.account_index
+ res = self.wallet[i].create_address(account_index = account_index)
+ if i == 0:
+ address_index = res.address_index
+ address.append(res.address)
+ else:
+ address = [self.address[0], self.address[1]]
+ account_index = 0
+ address_index = 0
for message in messages:
- res = self.wallet[0].sign(message)
+ res = self.wallet[0].sign(message, account_index = account_index, address_index = address_index)
signature = res.signature
for i in range(2):
- res = self.wallet[i].verify(message, self.address[0], signature)
+ res = self.wallet[i].verify(message, address[0], signature)
assert res.good
- res = self.wallet[i].verify('different', self.address[0], signature)
+ res = self.wallet[i].verify('different', address[0], signature)
assert not res.good
- res = self.wallet[i].verify(message, self.address[1], signature)
+ res = self.wallet[i].verify(message, address[1], signature)
assert not res.good
- res = self.wallet[i].verify(message, self.address[0], signature + 'x')
+ res = self.wallet[i].verify(message, address[0], signature + 'x')
assert not res.good
if __name__ == '__main__':
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index 0c942f48b..3bed69b98 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -169,7 +169,7 @@ class TransferTest():
assert e.subaddr_indices == [{'major': 0, 'minor': 0}]
assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
assert e.double_spend_seen == False
- assert e.confirmations == 0
+ assert not 'confirmations' in e or e.confirmations == 0
running_balances[0] -= 1000000000000 + fee
@@ -282,7 +282,7 @@ class TransferTest():
assert e.subaddr_indices == [{'major': 0, 'minor': 0}]
assert e.address == '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW'
assert e.double_spend_seen == False
- assert e.confirmations == 0
+ assert not 'confirmations' in e or e.confirmations == 0
assert e.amount == amount
assert e.fee == fee
diff --git a/tests/net_load_tests/clt.cpp b/tests/net_load_tests/clt.cpp
index fc2280f23..e154363e7 100644
--- a/tests/net_load_tests/clt.cpp
+++ b/tests/net_load_tests/clt.cpp
@@ -202,11 +202,11 @@ namespace
// Connect to server
std::atomic<int> conn_status(0);
- m_cmd_conn_id = boost::uuids::nil_uuid();
+ m_context = {};
ASSERT_TRUE(m_tcp_server.connect_async("127.0.0.1", srv_port, CONNECTION_TIMEOUT, [&](const test_connection_context& context, const boost::system::error_code& ec) {
if (!ec)
{
- m_cmd_conn_id = context.m_connection_id;
+ m_context = context;
}
else
{
@@ -217,11 +217,11 @@ namespace
EXPECT_TRUE(busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&]{ return 0 != conn_status.load(std::memory_order_seq_cst); })) << "connect_async timed out";
ASSERT_EQ(1, conn_status.load(std::memory_order_seq_cst));
- ASSERT_FALSE(m_cmd_conn_id.is_nil());
+ ASSERT_FALSE(m_context.m_connection_id.is_nil());
conn_status.store(0, std::memory_order_seq_cst);
CMD_RESET_STATISTICS::request req;
- ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_RESET_STATISTICS::response>(m_cmd_conn_id, CMD_RESET_STATISTICS::ID, req,
+ ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_RESET_STATISTICS::response>(m_context, CMD_RESET_STATISTICS::ID, req,
m_tcp_server.get_config_object(), [&](int code, const CMD_RESET_STATISTICS::response& rsp, const test_connection_context&) {
conn_status.store(code, std::memory_order_seq_cst);
}));
@@ -250,16 +250,16 @@ namespace
// Connect to server and invoke shutdown command
std::atomic<int> conn_status(0);
- boost::uuids::uuid cmd_conn_id = boost::uuids::nil_uuid();
+ test_connection_context cmd_context;
tcp_server.connect_async("127.0.0.1", srv_port, CONNECTION_TIMEOUT, [&](const test_connection_context& context, const boost::system::error_code& ec) {
- cmd_conn_id = context.m_connection_id;
+ cmd_context = context;
conn_status.store(!ec ? 1 : -1, std::memory_order_seq_cst);
});
if (!busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&]{ return 0 != conn_status.load(std::memory_order_seq_cst); })) return;
if (1 != conn_status.load(std::memory_order_seq_cst)) return;
- epee::net_utils::notify_remote_command2(cmd_conn_id, CMD_SHUTDOWN::ID, CMD_SHUTDOWN::request(), tcp_server.get_config_object());
+ epee::net_utils::notify_remote_command2(cmd_context, CMD_SHUTDOWN::ID, CMD_SHUTDOWN::request(), tcp_server.get_config_object());
busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&]{ return 0 != commands_handler.close_connection_counter(); });
}
@@ -299,7 +299,7 @@ namespace
{
std::atomic<int> req_status(0);
CMD_GET_STATISTICS::request req;
- ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_GET_STATISTICS::response>(m_cmd_conn_id, CMD_GET_STATISTICS::ID, req,
+ ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_GET_STATISTICS::response>(m_context, CMD_GET_STATISTICS::ID, req,
m_tcp_server.get_config_object(), [&](int code, const CMD_GET_STATISTICS::response& rsp, const test_connection_context&) {
if (0 < code)
{
@@ -338,14 +338,14 @@ namespace
{
CMD_SEND_DATA_REQUESTS::request req;
req.request_size = request_size;
- epee::net_utils::notify_remote_command2(m_cmd_conn_id, CMD_SEND_DATA_REQUESTS::ID, req, m_tcp_server.get_config_object());
+ epee::net_utils::notify_remote_command2(m_context, CMD_SEND_DATA_REQUESTS::ID, req, m_tcp_server.get_config_object());
}
protected:
test_tcp_server m_tcp_server;
test_levin_commands_handler m_commands_handler;
size_t m_thread_count;
- boost::uuids::uuid m_cmd_conn_id;
+ test_connection_context m_context;
};
}
@@ -434,7 +434,7 @@ TEST_F(net_load_test_clt, a_lot_of_client_connections_and_connections_closed_by_
// Close connections
CMD_CLOSE_ALL_CONNECTIONS::request req;
- ASSERT_TRUE(epee::net_utils::notify_remote_command2(m_cmd_conn_id, CMD_CLOSE_ALL_CONNECTIONS::ID, req, m_tcp_server.get_config_object()));
+ ASSERT_TRUE(epee::net_utils::notify_remote_command2(m_context, CMD_CLOSE_ALL_CONNECTIONS::ID, req, m_tcp_server.get_config_object()));
// Wait for all opened connections to close
busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&](){ return m_commands_handler.new_connection_counter() - RESERVED_CONN_CNT <= m_commands_handler.close_connection_counter(); });
@@ -455,10 +455,10 @@ TEST_F(net_load_test_clt, a_lot_of_client_connections_and_connections_closed_by_
// Close rest connections
m_tcp_server.get_config_object().foreach_connection([&](test_connection_context& ctx) {
- if (ctx.m_connection_id != m_cmd_conn_id)
+ if (ctx.m_connection_id != m_context.m_connection_id)
{
CMD_DATA_REQUEST::request req;
- bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx.m_connection_id, CMD_DATA_REQUEST::ID, req,
+ bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx, CMD_DATA_REQUEST::ID, req,
m_tcp_server.get_config_object(), [=](int code, const CMD_DATA_REQUEST::response& rsp, const test_connection_context&) {
if (code <= 0)
{
@@ -548,7 +548,7 @@ TEST_F(net_load_test_clt, permament_open_and_close_and_connections_closed_by_ser
CMD_START_OPEN_CLOSE_TEST::request req_start;
req_start.open_request_target = CONNECTION_COUNT;
req_start.max_opened_conn_count = MAX_OPENED_CONN_COUNT;
- ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_START_OPEN_CLOSE_TEST::response>(m_cmd_conn_id, CMD_START_OPEN_CLOSE_TEST::ID, req_start,
+ ASSERT_TRUE(epee::net_utils::async_invoke_remote_command2<CMD_START_OPEN_CLOSE_TEST::response>(m_context, CMD_START_OPEN_CLOSE_TEST::ID, req_start,
m_tcp_server.get_config_object(), [&](int code, const CMD_START_OPEN_CLOSE_TEST::response&, const test_connection_context&) {
test_state.store(0 < code ? 1 : -1, std::memory_order_seq_cst);
}));
@@ -582,7 +582,7 @@ TEST_F(net_load_test_clt, permament_open_and_close_and_connections_closed_by_ser
// Ask server to close rest connections
CMD_CLOSE_ALL_CONNECTIONS::request req;
- ASSERT_TRUE(epee::net_utils::notify_remote_command2(m_cmd_conn_id, CMD_CLOSE_ALL_CONNECTIONS::ID, req, m_tcp_server.get_config_object()));
+ ASSERT_TRUE(epee::net_utils::notify_remote_command2(m_context, CMD_CLOSE_ALL_CONNECTIONS::ID, req, m_tcp_server.get_config_object()));
// Wait for almost all connections to be closed by server
busy_wait_for(DEFAULT_OPERATION_TIMEOUT, [&](){ return m_commands_handler.new_connection_counter() <= m_commands_handler.close_connection_counter() + RESERVED_CONN_CNT; });
@@ -601,10 +601,10 @@ TEST_F(net_load_test_clt, permament_open_and_close_and_connections_closed_by_ser
// Close rest connections
m_tcp_server.get_config_object().foreach_connection([&](test_connection_context& ctx) {
- if (ctx.m_connection_id != m_cmd_conn_id)
+ if (ctx.m_connection_id != m_context.m_connection_id)
{
CMD_DATA_REQUEST::request req;
- bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx.m_connection_id, CMD_DATA_REQUEST::ID, req,
+ bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx, CMD_DATA_REQUEST::ID, req,
m_tcp_server.get_config_object(), [=](int code, const CMD_DATA_REQUEST::response& rsp, const test_connection_context&) {
if (code <= 0)
{
diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h
index cdc2d267a..4a76f2ec6 100644
--- a/tests/net_load_tests/net_load_tests.h
+++ b/tests/net_load_tests/net_load_tests.h
@@ -47,6 +47,7 @@ namespace net_load_tests
{
struct test_connection_context : epee::net_utils::connection_context_base
{
+ test_connection_context(): epee::net_utils::connection_context_base(boost::uuids::nil_uuid(), {}, false, false), m_closed(false) {}
volatile bool m_closed;
};
diff --git a/tests/net_load_tests/srv.cpp b/tests/net_load_tests/srv.cpp
index fe32ec5cb..b42b1e1b0 100644
--- a/tests/net_load_tests/srv.cpp
+++ b/tests/net_load_tests/srv.cpp
@@ -147,7 +147,7 @@ namespace
CMD_DATA_REQUEST::request req2;
req2.data.resize(req.request_size);
- bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx.m_connection_id, CMD_DATA_REQUEST::ID, req2,
+ bool r = epee::net_utils::async_invoke_remote_command2<CMD_DATA_REQUEST::response>(ctx, CMD_DATA_REQUEST::ID, req2,
m_tcp_server.get_config_object(), [=](int code, const CMD_DATA_REQUEST::response& rsp, const test_connection_context&) {
if (code <= 0)
{
diff --git a/tests/unit_tests/bulletproofs.cpp b/tests/unit_tests/bulletproofs.cpp
index 760769551..a73b80848 100644
--- a/tests/unit_tests/bulletproofs.cpp
+++ b/tests/unit_tests/bulletproofs.cpp
@@ -179,15 +179,6 @@ TEST(bulletproofs, invalid_31)
ASSERT_FALSE(rct::bulletproof_VERIFY(proof));
}
-TEST(bulletproofs, invalid_gamma_0)
-{
- rct::key invalid_amount = rct::zero();
- invalid_amount[8] = 1;
- rct::key gamma = rct::zero();
- rct::Bulletproof proof = bulletproof_PROVE(invalid_amount, gamma);
- ASSERT_FALSE(rct::bulletproof_VERIFY(proof));
-}
-
static const char * const torsion_elements[] =
{
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa",
diff --git a/tests/unit_tests/levin.cpp b/tests/unit_tests/levin.cpp
index e5ca4e41e..38707f075 100644
--- a/tests/unit_tests/levin.cpp
+++ b/tests/unit_tests/levin.cpp
@@ -271,12 +271,12 @@ namespace
EXPECT_EQ(connection_ids_.size(), connections_->get_connections_count());
}
- cryptonote::levin::notify make_notifier(const std::size_t noise_size, bool is_public)
+ cryptonote::levin::notify make_notifier(const std::size_t noise_size, bool is_public, bool pad_txs)
{
epee::byte_slice noise = nullptr;
if (noise_size)
noise = epee::levin::make_noise_notify(noise_size);
- return cryptonote::levin::notify{io_service_, connections_, std::move(noise), is_public};
+ return cryptonote::levin::notify{io_service_, connections_, std::move(noise), is_public, pad_txs};
}
boost::uuids::random_generator random_generator_;
@@ -434,12 +434,16 @@ TEST_F(levin_notify, defaulted)
EXPECT_FALSE(status.has_noise);
EXPECT_FALSE(status.connections_filled);
}
- EXPECT_FALSE(notifier.send_txs({}, random_generator_(), false));
+ EXPECT_TRUE(notifier.send_txs({}, random_generator_()));
+
+ std::vector<cryptonote::blobdata> txs(2);
+ txs[0].resize(100, 'e');
+ EXPECT_FALSE(notifier.send_txs(std::move(txs), random_generator_()));
}
-TEST_F(levin_notify, flood)
+TEST_F(levin_notify, fluff_without_padding)
{
- cryptonote::levin::notify notifier = make_notifier(0, true);
+ cryptonote::levin::notify notifier = make_notifier(0, true, false);
for (unsigned count = 0; count < 10; ++count)
add_connection(count % 2 == 0);
@@ -464,10 +468,13 @@ TEST_F(levin_notify, flood)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), false));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id()));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
+ notifier.run_fluff();
+ ASSERT_LT(0u, io_service_.poll());
+
EXPECT_EQ(0u, context->process_send_queue());
for (++context; context != contexts_.end(); ++context)
EXPECT_EQ(1u, context->process_send_queue());
@@ -480,14 +487,42 @@ TEST_F(levin_notify, flood)
EXPECT_TRUE(notification._.empty());
}
}
+}
+
+TEST_F(levin_notify, fluff_with_padding)
+{
+ cryptonote::levin::notify notifier = make_notifier(0, true, true);
+
+ for (unsigned count = 0; count < 10; ++count)
+ add_connection(count % 2 == 0);
+
+ {
+ const auto status = notifier.get_status();
+ EXPECT_FALSE(status.has_noise);
+ EXPECT_FALSE(status.connections_filled);
+ }
+ notifier.new_out_connection();
+ io_service_.poll();
+ {
+ const auto status = notifier.get_status();
+ EXPECT_FALSE(status.has_noise);
+ EXPECT_FALSE(status.connections_filled); // not tracked
+ }
+
+ std::vector<cryptonote::blobdata> txs(2);
+ txs[0].resize(100, 'e');
+ txs[1].resize(200, 'f');
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), true));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id()));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
+ notifier.run_fluff();
+ ASSERT_LT(0u, io_service_.poll());
+
EXPECT_EQ(0u, context->process_send_queue());
for (++context; context != contexts_.end(); ++context)
EXPECT_EQ(1u, context->process_send_queue());
@@ -502,9 +537,9 @@ TEST_F(levin_notify, flood)
}
}
-TEST_F(levin_notify, private_flood)
+TEST_F(levin_notify, private_fluff_without_padding)
{
- cryptonote::levin::notify notifier = make_notifier(0, false);
+ cryptonote::levin::notify notifier = make_notifier(0, false, false);
for (unsigned count = 0; count < 10; ++count)
add_connection(count % 2 == 0);
@@ -529,10 +564,14 @@ TEST_F(levin_notify, private_flood)
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), false));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id()));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
+ notifier.run_fluff();
+ io_service_.reset();
+ ASSERT_LT(0u, io_service_.poll());
+
EXPECT_EQ(0u, context->process_send_queue());
for (++context; context != contexts_.end(); ++context)
{
@@ -548,14 +587,43 @@ TEST_F(levin_notify, private_flood)
EXPECT_TRUE(notification._.empty());
}
}
+}
+
+TEST_F(levin_notify, private_fluff_with_padding)
+{
+ cryptonote::levin::notify notifier = make_notifier(0, false, true);
+
+ for (unsigned count = 0; count < 10; ++count)
+ add_connection(count % 2 == 0);
+
+ {
+ const auto status = notifier.get_status();
+ EXPECT_FALSE(status.has_noise);
+ EXPECT_FALSE(status.connections_filled);
+ }
+ notifier.new_out_connection();
+ io_service_.poll();
+ {
+ const auto status = notifier.get_status();
+ EXPECT_FALSE(status.has_noise);
+ EXPECT_FALSE(status.connections_filled); // not tracked
+ }
+
+ std::vector<cryptonote::blobdata> txs(2);
+ txs[0].resize(100, 'e');
+ txs[1].resize(200, 'f');
ASSERT_EQ(10u, contexts_.size());
{
auto context = contexts_.begin();
- EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), true));
+ EXPECT_TRUE(notifier.send_txs(txs, context->get_id()));
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
+ notifier.run_fluff();
+ io_service_.reset();
+ ASSERT_LT(0u, io_service_.poll());
+
EXPECT_EQ(0u, context->process_send_queue());
for (++context; context != contexts_.end(); ++context)
{
@@ -582,7 +650,7 @@ TEST_F(levin_notify, noise)
txs[0].resize(1900, 'h');
const boost::uuids::uuid incoming_id = random_generator_();
- cryptonote::levin::notify notifier = make_notifier(2048, false);
+ cryptonote::levin::notify notifier = make_notifier(2048, false, true);
{
const auto status = notifier.get_status();
@@ -608,7 +676,7 @@ TEST_F(levin_notify, noise)
EXPECT_EQ(0u, receiver_.notified_size());
}
- EXPECT_TRUE(notifier.send_txs(txs, incoming_id, false));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming_id));
notifier.run_stems();
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
@@ -627,7 +695,7 @@ TEST_F(levin_notify, noise)
}
txs[0].resize(3000, 'r');
- EXPECT_TRUE(notifier.send_txs(txs, incoming_id, true));
+ EXPECT_TRUE(notifier.send_txs(txs, incoming_id));
notifier.run_stems();
io_service_.reset();
ASSERT_LT(0u, io_service_.poll());
diff --git a/tests/unit_tests/net.cpp b/tests/unit_tests/net.cpp
index 262541bd2..221dc631d 100644
--- a/tests/unit_tests/net.cpp
+++ b/tests/unit_tests/net.cpp
@@ -271,7 +271,7 @@ TEST(tor_address, epee_serializev_v2)
EXPECT_EQ(std::strlen(v2_onion), host.size());
host.push_back('k');
- EXPECT_TRUE(stg.set_value("host", host, stg.open_section("tor", nullptr, false)));
+ EXPECT_TRUE(stg.set_value("host", std::move(host), stg.open_section("tor", nullptr, false)));
EXPECT_TRUE(command.load(stg)); // poor error reporting from `KV_SERIALIZE`
}
@@ -322,7 +322,7 @@ TEST(tor_address, epee_serializev_v3)
EXPECT_EQ(std::strlen(v3_onion), host.size());
host.push_back('k');
- EXPECT_TRUE(stg.set_value("host", host, stg.open_section("tor", nullptr, false)));
+ EXPECT_TRUE(stg.set_value("host", std::move(host), stg.open_section("tor", nullptr, false)));
EXPECT_TRUE(command.load(stg)); // poor error reporting from `KV_SERIALIZE`
}
@@ -373,7 +373,7 @@ TEST(tor_address, epee_serialize_unknown)
EXPECT_EQ(std::strlen(net::tor_address::unknown_str()), host.size());
host.push_back('k');
- EXPECT_TRUE(stg.set_value("host", host, stg.open_section("tor", nullptr, false)));
+ EXPECT_TRUE(stg.set_value("host", std::move(host), stg.open_section("tor", nullptr, false)));
EXPECT_TRUE(command.load(stg)); // poor error reporting from `KV_SERIALIZE`
}
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index 23f028464..b711526e6 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -735,7 +735,6 @@ TEST(Serialization, portability_wallet)
auto address_book_row = w.m_address_book.begin();
ASSERT_TRUE(epee::string_tools::pod_to_hex(address_book_row->m_address.m_spend_public_key) == "9bc53a6ff7b0831c9470f71b6b972dbe5ad1e8606f72682868b1dda64e119fb3");
ASSERT_TRUE(epee::string_tools::pod_to_hex(address_book_row->m_address.m_view_public_key) == "49fece1ef97dc0c0f7a5e2106e75e96edd910f7e86b56e1e308cd0cf734df191");
- ASSERT_TRUE(epee::string_tools::pod_to_hex(address_book_row->m_payment_id) == "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
ASSERT_TRUE(address_book_row->m_description == "testnet wallet 9y52S6");
}
}