1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#include "gtest/gtest.h"
#include <array>
#include <cstdint>
#include <string>
#include <boost/uuid/uuid_io.hpp>
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_config.h"
#include "cryptonote_core/cryptonote_tx_utils.h"
#include "hardforks/hardforks.h"
#include "string_tools.h"
namespace
{
struct network_vector
{
cryptonote::network_type type;
const char* uuid;
uint64_t standard_prefix;
uint64_t integrated_prefix;
uint64_t subaddress_prefix;
uint16_t p2p_port;
uint16_t rpc_port;
uint16_t zmq_port;
uint32_t genesis_nonce;
const char* genesis_hash;
};
const std::array<network_vector, 3> networks{{
{cryptonote::MAINNET, "fc3291ba-8666-4b87-8ebb-d59b72d4fcaa", 86, 87, 88,
6174, 6175, 6176, 818137480, "3850cb9e2fb2ba3c680b24cee7574765acd6be1cc4d84a4360c7c53e83e3270d"},
{cryptonote::TESTNET, "adc2a271-5539-43d9-b3c2-7aadaf6b938c", 111, 112, 113,
16174, 16175, 16176, 818137481, "d89bd4d42729aa9f68fd8d6bc86c3b12686a3fcd5ec83a392844efc067d5c040"},
{cryptonote::STAGENET, "b1dcac5a-9d11-4653-8122-e67eec8b59ac", 131, 132, 133,
26174, 26175, 26176, 818137482, "0d917308bb74557f9ccefd1360b9875a39df00363474fe4da9ae8e5f989170b7"}
}};
}
TEST(monzero_consensus, monetary_policy)
{
EXPECT_EQ(11, CRYPTONOTE_DISPLAY_DECIMAL_POINT);
EXPECT_EQ(UINT64_C(100000000000), COIN);
EXPECT_EQ(UINT64_C(10000000000000000000), MONEY_SUPPLY);
EXPECT_EQ(20, EMISSION_SPEED_FACTOR_PER_MINUTE);
EXPECT_EQ(UINT64_C(163000000000), FINAL_SUBSIDY_PER_MINUTE);
EXPECT_EQ(120, DIFFICULTY_TARGET_V1);
EXPECT_EQ(120, DIFFICULTY_TARGET_V2);
EXPECT_EQ(60, CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW);
EXPECT_EQ(10, CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
EXPECT_EQ(2, CURRENT_TRANSACTION_VERSION);
}
TEST(monzero_consensus, protected_network_vectors)
{
for (const network_vector& expected : networks)
{
const cryptonote::config_t& actual = cryptonote::get_config(expected.type);
EXPECT_EQ(expected.uuid, boost::uuids::to_string(actual.NETWORK_ID));
EXPECT_EQ(expected.standard_prefix, actual.CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
EXPECT_EQ(expected.integrated_prefix, actual.CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX);
EXPECT_EQ(expected.subaddress_prefix, actual.CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX);
EXPECT_EQ(expected.p2p_port, actual.P2P_DEFAULT_PORT);
EXPECT_EQ(expected.rpc_port, actual.RPC_DEFAULT_PORT);
EXPECT_EQ(expected.zmq_port, actual.ZMQ_RPC_DEFAULT_PORT);
EXPECT_EQ(expected.genesis_nonce, actual.GENESIS_NONCE);
cryptonote::block genesis;
ASSERT_TRUE(cryptonote::generate_genesis_block(genesis, actual.GENESIS_TX, actual.GENESIS_NONCE));
EXPECT_EQ(expected.genesis_hash,
epee::string_tools::pod_to_hex(cryptonote::get_block_hash(genesis)));
}
}
TEST(monzero_consensus, protected_hard_fork_schedule)
{
const std::array<std::pair<const hardfork_t*, size_t>, 3> schedules{{
{mainnet_hard_forks, num_mainnet_hard_forks},
{testnet_hard_forks, num_testnet_hard_forks},
{stagenet_hard_forks, num_stagenet_hard_forks}
}};
for (const auto& schedule : schedules)
{
ASSERT_EQ(16, schedule.second);
for (size_t index = 0; index < schedule.second; ++index)
{
const uint8_t expected_version = static_cast<uint8_t>(index + 1);
EXPECT_EQ(expected_version, schedule.first[index].version);
EXPECT_EQ(index + 1, schedule.first[index].height);
EXPECT_EQ(0, schedule.first[index].threshold);
}
}
}
|