2016-01-18 15:33:29 +00:00
|
|
|
// Copyright (c) 2011-2016 The Cryptonote developers
|
2015-09-18 11:55:31 +00:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2014-08-13 10:51:37 +00:00
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
2014-03-03 22:07:58 +00:00
|
|
|
#include "gtest/gtest.h"
|
2015-07-30 15:22:07 +00:00
|
|
|
#include "CryptoNoteProtocol/CryptoNoteProtocolDefinitions.h"
|
|
|
|
#include "Serialization/SerializationTools.h"
|
2014-03-03 22:07:58 +00:00
|
|
|
|
|
|
|
TEST(protocol_pack, protocol_pack_command)
|
|
|
|
{
|
|
|
|
std::string buff;
|
2015-05-27 12:08:46 +00:00
|
|
|
CryptoNote::NOTIFY_RESPONSE_CHAIN_ENTRY::request r;
|
2014-03-03 22:07:58 +00:00
|
|
|
r.start_height = 1;
|
|
|
|
r.total_height = 3;
|
2015-07-15 12:23:00 +00:00
|
|
|
for(int i = 1; i < 10000; i += i*10) {
|
2015-07-30 15:22:07 +00:00
|
|
|
r.m_block_ids.resize(i, CryptoNote::NULL_HASH);
|
2015-07-15 12:23:00 +00:00
|
|
|
buff = CryptoNote::storeToBinaryKeyValue(r);
|
2014-03-03 22:07:58 +00:00
|
|
|
|
2015-05-27 12:08:46 +00:00
|
|
|
CryptoNote::NOTIFY_RESPONSE_CHAIN_ENTRY::request r2;
|
2015-07-30 15:22:07 +00:00
|
|
|
CryptoNote::loadFromBinaryKeyValue(r2, buff);
|
2014-03-03 22:07:58 +00:00
|
|
|
ASSERT_TRUE(r.m_block_ids.size() == i);
|
|
|
|
ASSERT_TRUE(r.start_height == 1);
|
|
|
|
ASSERT_TRUE(r.total_height == 3);
|
|
|
|
}
|
|
|
|
}
|