You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmonero/tests/bcstatus_tests.cpp

735 lines
46 KiB

6 years ago
//
// Created by mwo on 15/06/18.
//
#include "../src/MicroCore.h"
#include "../src/CurrentBlockchainStatus.h"
#include "../src/ThreadRAII.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "helpers.h"
6 years ago
namespace
{
using json = nlohmann::json;
using namespace std;
using namespace cryptonote;
using namespace epee::string_tools;
using namespace std::chrono_literals;
using ::testing::AllOf;
using ::testing::Ge;
using ::testing::Le;
using ::testing::HasSubstr;
using ::testing::Not;
6 years ago
using ::testing::Return;
using ::testing::Throw;
using ::testing::DoAll;
using ::testing::SetArgReferee;
6 years ago
using ::testing::_;
6 years ago
using ::testing::internal::FilePath;
6 years ago
class MockMicroCore : public xmreg::MicroCore
{
public:
MOCK_METHOD2(init, bool(const string& _blockchain_path,
network_type nt));
MOCK_CONST_METHOD0(get_current_blockchain_height, uint64_t());
MOCK_CONST_METHOD2(get_block_from_height,
bool(uint64_t height, block& blk));
MOCK_CONST_METHOD2(get_blocks_range,
std::vector<block>(const uint64_t& h1,
const uint64_t& h2));
MOCK_CONST_METHOD3(get_transactions,
bool(const std::vector<crypto::hash>& txs_ids,
std::vector<transaction>& txs,
std::vector<crypto::hash>& missed_txs));
MOCK_CONST_METHOD1(have_tx, bool(crypto::hash const& tx_hash));
MOCK_CONST_METHOD2(tx_exists,
bool(crypto::hash const& tx_hash,
uint64_t& tx_id));
MOCK_CONST_METHOD2(get_output_tx_and_index,
tx_out_index(uint64_t const& amount,
uint64_t const& index));
MOCK_CONST_METHOD2(get_tx,
bool(crypto::hash const& tx_hash,
transaction& tx));
MOCK_METHOD3(get_output_key,
void(const uint64_t& amount,
const vector<uint64_t>& absolute_offsets,
vector<cryptonote::output_data_t>& outputs));
MOCK_CONST_METHOD1(get_tx_amount_output_indices,
std::vector<uint64_t>(uint64_t const& tx_id));
MOCK_CONST_METHOD2(get_random_outs_for_amounts,
bool(COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request const& req,
COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res));
MOCK_CONST_METHOD2(get_outs,
bool(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req,
COMMAND_RPC_GET_OUTPUTS_BIN::response& res));
MOCK_CONST_METHOD1(get_dynamic_per_kb_fee_estimate,
uint64_t(uint64_t const& grace_blocks));
MOCK_CONST_METHOD2(get_mempool_txs,
bool(vector<tx_info>& tx_infos,
vector<spent_key_image_info>& key_image_infos));
6 years ago
};
class MockRPCCalls : public xmreg::RPCCalls
{
public:
MockRPCCalls(string _deamon_url)
: xmreg::RPCCalls(_deamon_url)
{}
MOCK_METHOD3(commit_tx, bool(const string& tx_blob,
string& error_msg,
bool do_not_relay));
};
6 years ago
class BCSTATUS_TEST : public ::testing::TestWithParam<network_type>
6 years ago
{
public:
static void
SetUpTestCase()
{
string config_path {"../config/config.json"};
config_json = xmreg::BlockchainSetup::read_config(config_path);
6 years ago
}
protected:
virtual void
SetUp()
{
net_type = GetParam();
bc_setup = xmreg::BlockchainSetup {
net_type, do_not_relay, config_json};
6 years ago
mcore = std::make_unique<MockMicroCore>();
mcore_ptr = mcore.get();
rpc = std::make_unique<MockRPCCalls>("dummy deamon url");
rpc_ptr = rpc.get();
bcs = std::make_unique<xmreg::CurrentBlockchainStatus>(
bc_setup, std::move(mcore), std::move(rpc));
}
6 years ago
network_type net_type {network_type::STAGENET};
bool do_not_relay {false};
xmreg::BlockchainSetup bc_setup;
6 years ago
std::unique_ptr<MockMicroCore> mcore;
std::unique_ptr<MockRPCCalls> rpc;
6 years ago
std::unique_ptr<xmreg::CurrentBlockchainStatus> bcs;
MockMicroCore* mcore_ptr;
MockRPCCalls* rpc_ptr;
6 years ago
static json config_json;
};
6 years ago
json BCSTATUS_TEST::config_json;
TEST_P(BCSTATUS_TEST, DefaultConstruction)
6 years ago
{
xmreg::CurrentBlockchainStatus bcs {bc_setup, nullptr, nullptr};
6 years ago
EXPECT_TRUE(true);
}
6 years ago
6 years ago
TEST_P(BCSTATUS_TEST, InitMoneroBlockchain)
6 years ago
{
6 years ago
EXPECT_CALL(*mcore_ptr, init(_, _))
.WillOnce(Return(true));
EXPECT_TRUE(bcs->init_monero_blockchain());
}
TEST_P(BCSTATUS_TEST, GetBlock)
6 years ago
{
EXPECT_CALL(*mcore_ptr, get_block_from_height(_, _))
.WillOnce(Return(true));
uint64_t height = 1000;
block blk;
EXPECT_TRUE(bcs->get_block(height, blk));
}
ACTION(ThrowBlockDNE)
{
throw BLOCK_DNE("Mock Throw: Block does not exist!");
6 years ago
}
TEST_P(BCSTATUS_TEST, GetBlockRange)
6 years ago
{
vector<block> blocks_to_return {block(), block(), block()};
EXPECT_CALL(*mcore_ptr, get_blocks_range(_, _))
.WillOnce(Return(blocks_to_return));
uint64_t h1 = 1000;
uint64_t h2 = h1+2;
vector<block> blocks = bcs->get_blocks_range(h1, h2);
EXPECT_EQ(blocks, blocks_to_return);
EXPECT_CALL(*mcore_ptr, get_blocks_range(_, _))
.WillOnce(ThrowBlockDNE());
blocks = bcs->get_blocks_range(h1, h2);
EXPECT_TRUE(blocks.empty());
6 years ago
}
TEST_P(BCSTATUS_TEST, GetBlockTxs)
6 years ago
{
EXPECT_CALL(*mcore_ptr, get_transactions(_, _, _))
.WillOnce(Return(true));
const block dummy_blk;
vector<transaction> blk_txs;
vector<crypto::hash> missed_txs;
EXPECT_TRUE(bcs->get_block_txs(dummy_blk, blk_txs, missed_txs));
EXPECT_CALL(*mcore_ptr, get_transactions(_, _, _))
.WillOnce(Return(false));
EXPECT_FALSE(bcs->get_block_txs(dummy_blk, blk_txs, missed_txs));
}
TEST_P(BCSTATUS_TEST, GetTxs)
{
EXPECT_CALL(*mcore_ptr, get_transactions(_, _, _))
.WillOnce(Return(true));
vector<crypto::hash> txs_to_get;
vector<transaction> blk_txs;
vector<crypto::hash> missed_txs;
EXPECT_TRUE(bcs->get_txs(txs_to_get, blk_txs, missed_txs));
EXPECT_CALL(*mcore_ptr, get_transactions(_, _, _))
.WillOnce(Return(false));
EXPECT_FALSE(bcs->get_txs(txs_to_get, blk_txs, missed_txs));
6 years ago
}
6 years ago
TEST_P(BCSTATUS_TEST, TxExist)
{
EXPECT_CALL(*mcore_ptr, have_tx(_))
.WillOnce(Return(true));
EXPECT_TRUE(bcs->tx_exist(crypto::hash()));
uint64_t mock_tx_index_to_return {4444};
// return true and set tx_index (ret by ref) to mock_tx_index_to_return
EXPECT_CALL(*mcore_ptr, tx_exists(_, _))
.WillOnce(DoAll(SetArgReferee<1>(mock_tx_index_to_return),
Return(true)));
uint64_t tx_index {0};
EXPECT_TRUE(bcs->tx_exist(crypto::hash(), tx_index));
EXPECT_EQ(tx_index, mock_tx_index_to_return);
// just some dummy hash
string tx_hash_str
{"fc4b8d5956b30dc4a353b171b4d974697dfc32730778f138a8e7f16c11907691"};
tx_index = 0;
EXPECT_CALL(*mcore_ptr, tx_exists(_, _))
.WillOnce(DoAll(SetArgReferee<1>(mock_tx_index_to_return),
Return(true)));
EXPECT_TRUE(bcs->tx_exist(tx_hash_str, tx_index));
EXPECT_EQ(tx_index, mock_tx_index_to_return);
tx_hash_str = "wrong_hash";
EXPECT_FALSE(bcs->tx_exist(tx_hash_str, tx_index));
}
TEST_P(BCSTATUS_TEST, GetTxWithOutput)
{
// some dummy tx hash
RAND_TX_HASH();
const tx_out_index tx_idx_to_return = make_pair(tx_hash, 6);
EXPECT_CALL(*mcore_ptr, get_output_tx_and_index(_, _))
.WillOnce(Return(tx_idx_to_return));
EXPECT_CALL(*mcore_ptr, get_tx(_, _))
.WillOnce(Return(true));
const uint64_t mock_output_idx {4};
const uint64_t mock_amount {11110};
transaction tx_returned;
uint64_t out_idx_returned;
EXPECT_TRUE(bcs->get_tx_with_output(mock_output_idx, mock_amount,
tx_returned, out_idx_returned));
}
ACTION(ThrowOutputDNE)
{
throw OUTPUT_DNE("Mock Throw: Output does not exist!");
}
TEST_P(BCSTATUS_TEST, GetTxWithOutputFailure)
{
// some dummy tx hash
RAND_TX_HASH();
const tx_out_index tx_idx_to_return = make_pair(tx_hash, 6);
EXPECT_CALL(*mcore_ptr, get_output_tx_and_index(_, _))
.WillOnce(Return(tx_idx_to_return));
EXPECT_CALL(*mcore_ptr, get_tx(_, _))
.WillOnce(Return(false));
const uint64_t mock_output_idx {4};
const uint64_t mock_amount {11110};
transaction tx_returned;
uint64_t out_idx_returned;
EXPECT_FALSE(bcs->get_tx_with_output(mock_output_idx, mock_amount,
tx_returned, out_idx_returned));
// or
EXPECT_CALL(*mcore_ptr, get_output_tx_and_index(_, _))
.WillOnce(ThrowOutputDNE());
EXPECT_FALSE(bcs->get_tx_with_output(mock_output_idx, mock_amount,
tx_returned, out_idx_returned));
}
TEST_P(BCSTATUS_TEST, GetCurrentHeight)
{
uint64_t mock_current_height {1619148};
EXPECT_CALL(*mcore_ptr, get_current_blockchain_height())
.WillOnce(Return(mock_current_height));
bcs->update_current_blockchain_height();
EXPECT_EQ(bcs->get_current_blockchain_height(),
mock_current_height - 1);
}
TEST_P(BCSTATUS_TEST, IsTxSpendtimeUnlockedScenario1)
{
// there are two main scenerious here.
// Scenerio 1: tx_unlock_time is block height
// Scenerio 2: tx_unlock_time is timestamp.
const uint64_t mock_current_height {100};
EXPECT_CALL(*mcore_ptr, get_current_blockchain_height())
.WillOnce(Return(mock_current_height));
bcs->update_current_blockchain_height();
// SCENARIO 1: tx_unlock_time is block height
// expected unlock time is in future, thus a tx is still locked
uint64_t tx_unlock_time {mock_current_height
+ CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE};
uint64_t not_used_block_height {0}; // not used in the first
// part of the test case
EXPECT_FALSE(bcs->is_tx_unlocked(
tx_unlock_time, not_used_block_height));
// expected unlock time is in the future
// (1 blocks from now), thus a tx is locked
tx_unlock_time = mock_current_height + 1;
EXPECT_FALSE(bcs->is_tx_unlocked(
tx_unlock_time, not_used_block_height));
// expected unlock time is in the past
// (10 blocks behind), thus a tx is unlocked
tx_unlock_time = mock_current_height
- CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE;
EXPECT_TRUE(bcs->is_tx_unlocked(tx_unlock_time,
not_used_block_height));
// expected unlock time is same as as current height
// thus a tx is unlocked
tx_unlock_time = mock_current_height;
EXPECT_TRUE(bcs->is_tx_unlocked(tx_unlock_time,
not_used_block_height));
}
class MockTxUnlockChecker : public xmreg::TxUnlockChecker
{
public:
// mock system call to get current timestamp
MOCK_CONST_METHOD0(get_current_time, uint64_t());
//MOCK_CONST_METHOD1(get_leeway, uint64_t(uint64_t tx_block_height));
};
TEST_P(BCSTATUS_TEST, IsTxSpendtimeUnlockedScenario2)
{
// there are two main scenerious here.
// Scenerio 1: tx_unlock_time is block height
// Scenerio 2: tx_unlock_time is timestamp.
const uint64_t mock_current_height {100};
EXPECT_CALL(*mcore_ptr, get_current_blockchain_height())
.WillOnce(Return(mock_current_height));
bcs->update_current_blockchain_height();
// SCENARIO 2: tx_unlock_time is timestamp.
MockTxUnlockChecker mock_tx_unlock_checker;
const uint64_t current_timestamp {1000000000};
EXPECT_CALL(mock_tx_unlock_checker, get_current_time())
.WillRepeatedly(Return(1000000000));
uint64_t block_height = mock_current_height;
// tx unlock time is now
uint64_t tx_unlock_time {current_timestamp}; // mock timestamp
EXPECT_TRUE(bcs->is_tx_unlocked(tx_unlock_time, block_height,
mock_tx_unlock_checker));
// unlock time is 1 second more than needed
tx_unlock_time = current_timestamp
+ mock_tx_unlock_checker.get_leeway(
block_height, bcs->get_bc_setup().net_type) + 1;
EXPECT_FALSE(bcs->is_tx_unlocked(tx_unlock_time, block_height,
mock_tx_unlock_checker));
}
TEST_P(BCSTATUS_TEST, GetOutputKeys)
{
// we are going to expect two outputs
vector<output_data_t> outputs_to_return;
outputs_to_return.push_back(
output_data_t {
crypto::rand<crypto::public_key>(),
1000, 2222,
crypto::rand<rct::key>()});
outputs_to_return.push_back(
output_data_t {
crypto::rand<crypto::public_key>(),
3333, 5555,
crypto::rand<rct::key>()});
EXPECT_CALL(*mcore_ptr, get_output_key(_, _, _))
.WillOnce(SetArgReferee<2>(outputs_to_return));
const uint64_t mock_amount {1111};
const vector<uint64_t> mock_absolute_offsets;
vector<cryptonote::output_data_t> outputs;
EXPECT_TRUE(bcs->get_output_keys(mock_amount,
mock_absolute_offsets,
outputs));
EXPECT_EQ(outputs.back().pubkey, outputs_to_return.back().pubkey);
EXPECT_CALL(*mcore_ptr, get_output_key(_, _, _))
.WillOnce(ThrowOutputDNE());
EXPECT_FALSE(bcs->get_output_keys(mock_amount,
mock_absolute_offsets,
outputs));
}
TEST_P(BCSTATUS_TEST, GetAccountIntegratedAddressAsStr)
{
// bcs->get_account_integrated_address_as_str only forwards
// call to cryptonote function. so we just check if
// forwarding is correct, not wether the cryptonote
// function works correctly.
crypto::hash8 payment_id8 = crypto::rand<crypto::hash8>();
string payment_id8_str = pod_to_hex(payment_id8);
string expected_int_addr
= cryptonote::get_account_integrated_address_as_str(
bcs->get_bc_setup().net_type,
bcs->get_bc_setup().import_payment_address.address,
payment_id8);
string resulting_int_addr
= bcs->get_account_integrated_address_as_str(payment_id8);
EXPECT_EQ(expected_int_addr, resulting_int_addr);
resulting_int_addr
= bcs->get_account_integrated_address_as_str(
payment_id8_str);
EXPECT_EQ(expected_int_addr, resulting_int_addr);
resulting_int_addr
= bcs->get_account_integrated_address_as_str(
"wrong_payment_id8");
EXPECT_TRUE(resulting_int_addr.empty());
}
ACTION(ThrowTxDNE)
{
throw TX_DNE("Mock Throw: Tx does not exist!");
}
TEST_P(BCSTATUS_TEST, GetAmountSpecificIndices)
{
vector<uint64_t> out_indices_to_return {1,2,3};
EXPECT_CALL(*mcore_ptr, tx_exists(_, _))
.WillOnce(Return(true));
EXPECT_CALL(*mcore_ptr, get_tx_amount_output_indices(_))
.WillOnce(Return(out_indices_to_return));
vector<uint64_t> out_indices;
RAND_TX_HASH();
EXPECT_TRUE(bcs->get_amount_specific_indices(tx_hash, out_indices));
EXPECT_EQ(out_indices, out_indices_to_return);
EXPECT_CALL(*mcore_ptr, tx_exists(_, _))
.WillOnce(Return(false));
EXPECT_FALSE(bcs->get_amount_specific_indices(tx_hash, out_indices));
EXPECT_CALL(*mcore_ptr, tx_exists(_, _))
.WillOnce(ThrowTxDNE());
EXPECT_FALSE(bcs->get_amount_specific_indices(tx_hash, out_indices));
}
TEST_P(BCSTATUS_TEST, GetRandomOutputs)
{
using out_for_amount = COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
::outs_for_amount;
std::vector<out_for_amount> outputs_to_return;
outputs_to_return.push_back(out_for_amount {22, {}});
outputs_to_return.push_back(out_for_amount {66, {}});
COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response res;
res.outs = outputs_to_return;
EXPECT_CALL(*mcore_ptr, get_random_outs_for_amounts(_, _))
.WillOnce(DoAll(SetArgReferee<1>(res), Return(true)));
const vector<uint64_t> mock_amounts {444, 556, 77}; // any
const uint64_t mock_outs_count {3}; // any
std::vector<out_for_amount> found_outputs;
EXPECT_TRUE(bcs->get_random_outputs(
mock_amounts, mock_outs_count,
found_outputs));
EXPECT_EQ(found_outputs.size(), outputs_to_return.size());
EXPECT_EQ(found_outputs.back().amount,
outputs_to_return.back().amount);
EXPECT_CALL(*mcore_ptr, get_random_outs_for_amounts(_, _))
.WillOnce(Return(false));
EXPECT_FALSE(bcs->get_random_outputs(
mock_amounts, mock_outs_count,
found_outputs));
}
TEST_P(BCSTATUS_TEST, GetOutput)
{
using outkey = COMMAND_RPC_GET_OUTPUTS_BIN::outkey;
outkey output_key_to_return {
crypto::rand<crypto::public_key>(),
crypto::rand<rct::key>(),
true, 444,
crypto::rand<crypto::hash>()};
COMMAND_RPC_GET_OUTPUTS_BIN::response res;
res.outs.push_back(output_key_to_return);
EXPECT_CALL(*mcore_ptr, get_outs(_, _))
.WillOnce(DoAll(SetArgReferee<1>(res), Return(true)));
const uint64_t mock_amount {0};
const uint64_t mock_global_output_index {0};
outkey output_info;
EXPECT_TRUE(bcs->get_output(mock_amount,
mock_global_output_index,
output_info));
EXPECT_EQ(output_info.key, output_key_to_return.key);
EXPECT_CALL(*mcore_ptr, get_outs(_, _))
.WillOnce(Return(false));
EXPECT_FALSE(bcs->get_output(mock_amount,
mock_global_output_index,
output_info));
}
TEST_P(BCSTATUS_TEST, GetDynamicPerKbFeeEstimate)
{
EXPECT_CALL(*mcore_ptr, get_dynamic_per_kb_fee_estimate(_))
.WillOnce(Return(3333));
EXPECT_EQ(bcs->get_dynamic_per_kb_fee_estimate(), 3333);
}
TEST_P(BCSTATUS_TEST, CommitTx)
{
EXPECT_CALL(*rpc_ptr, commit_tx(_, _, _))
.WillOnce(Return(true));
string tx_blob {"mock blob"};
string error_msg;
EXPECT_TRUE(bcs->commit_tx(tx_blob, error_msg, true));
EXPECT_CALL(*rpc_ptr, commit_tx(_, _, _))
.WillOnce(Return(false));
EXPECT_FALSE(bcs->commit_tx(tx_blob, error_msg, true));
}
TEST_P(BCSTATUS_TEST, ReadMempool)
{
// stagenet tx: 4b40cfb2fdce2cd57a834a380901d55d70aba29dad13ac6c4dc82a895f439ecf
const string tx_4b40_hex {"0200010200089832f68b01b2a601a21ec01da83ffe0139a71678019703665175d1e067d20c738a8634aeaad6a7bc493a4b5a641b4962fa020002fb1d79f31791c9553c6dc1c066cde2361385021a5c33e7101d69a557cc3c34a1000292b1073ac7c2fdd851955e7fb76cbc7de4e812db745b5e795445594ea1c7d2a721010a9e82db48149442ac50cff52a39fda95f90b9683098b02e413a52b4d1f05f1c0180f3a3f93aaac0d8887ce542c01e49afbaf1f5ac8e1e4c8882011dd83fa33d1c9efa5f210d39e17c153a6a5825da329dcb31cd1acae98961d55038fb22e78fb93b95e6820a6904ff5b7bbfcf0cd1f6b9e9dd56f41062c7f5f43d9e1b3d69724eeca4bc3404a41ff0669f7f8ae725da8bbc2f8d0411605d2c3e959e3099414ffce1654418020d6ee74bb25042045e955b966e060a9f65b9cfccfbdcb4ee3101019a51f3a41372414c90383c9b84fb4ac690047ea67d70c917192abeb1fdf6c618aeafc732ae9a3e6c6f7fb274240ca04d24035a1d55b3fd1060dc3f4e64f9816868f36d2a0aeb76b64169bc9525d7d70b077c8b998b1204c6108e2917af893b0de24f4adb043eee433b096db8ef730de6e339a84f966b80b239821f350e2a8b10817fc19508da4f82bcb90fcf84cd47929ab1ba90bde5d252767736a4b23d26063cc6b2120dc636b2d4e3e7b3f6d7448882e01c10cf7bdd2117710dc49a59b49cf99212800093da22a6ab5bf693a80d4a662f35259f088a91a26ac261980c537238daa7a40477871f7481973edbcc86fa4885a4061d5c889d0986b4c0cb394165d4039081069f61cff822c7a227474d1609dbf05909f738803834b9e1b5ee68dcb825fcd906d880684e5fa684c8cb02495530fcaeeb35a405345f352ef3c8cf276c096d4303ee14cc0a48533afd1bcdf32dcfb25db4c45a19b10926dff72ace2c2a1d0759090acff99ad06e3f81c4d759a9f74d47fff9cb61d3784aa0eb57a250eec8d14800b85026f5b112740e2e8c257541bdfa4ea1f166b9d930e9705fa1d3f3c2be1e0fb242394d9230c7c457fc8422a6f919a06df5c52d954fa1bfdb57a0a2778d35020ef07490fc3c4f6e99ceaef97fcb3da049898944f3291b96a4f9ce491654340414565db2e0c6bd13eab933194b32336c09c478689cc4a7160b63ecb59937b2028e1649744c6ea69db01aed72fb8b39519cb28d764f158789cc539e01fd5f8f098597c8977e6d2b22c37b289c95dca13bece9e28f741ae2384ead8f0d6df7c30f311210523cb0b7e8c1173aee311362282f3c7d06ae2153969d073bec14ff3605d193bfe829e110df39b894fc4a8eb462d357098688748d579c85f9dc9e9cd20229c9865bc54ae8338433247c28875249e37d4d9b9ccbad611ce5948f1c7ea00fccdc41a9fbe942539a44111f160c9b1dc2653ecae0e4c30bada58d9164fa4c021b60fc0e2068510ef8ec56f7c8e036f2eb31ae0871c9a6aff7b8ad6a86054a06daf06393871f41859f51165f09d22fedd8a2326099a803491dbff5027f72540ed6981f505d1162d86c1ec716758bfbf4e1bfdbbe628b9340942a328209c86b0ec71981c90b407b146cbf065cfd8b0a1c2528aaf007c505a83779dacf8cb7500577a1f8f4a2c9a833d08b254c0c5edbbe87c9eaf266627d23bf518373dceba4099c13c6c468b99c16d56ea5eec12620867fdeb01be66bb0248a7ab7dd6434aa042392c4482e8694292bfc638f1a344d35c9cbfe121a25d2302db4db9688285905fcef9a892593840fe2ddebf0e059e341b2e7f107ee6a19fe386e3f9ea0da2801c5e9fe1b9c4b21155f6f2194ef36f2383097f9cf7ee0994873cfd92d098a33006547ef67bbeb2c1386fcbeec6f0b974532f2ac6e474b26683a37ed3919ec3108b578d3a552c32a362c0bea8bfe35c481f014721af9503a0663d95f5aa91b8802c32f60dbaa65978ad114a2fd45901a07fb4dded61d19e30c8c11e4efbdc1180a02d08d05a646bd8a4d160203da8d490ae0a0b4e631280401d635eb78e0416408c208436dcd653c11a75f365e2d012e0e69f0d4fe2fb2997726dad29468109001ed7c65464ba734e4b35f2ac85a4437fcafe0cdb6128e634970ba420e2e3296080636520e9fbf453e07cdd215117a2eeffed5a0ea0003761f5eb4c35aebf87b063f59d0571e149dc9d0c143a59415a7fe950d34b5024087145969abdc7f7140079bc25119825dda1bf080150bd40142d9635fd87e5dc691899d2686ccf6c9d106c7cdbf783fbbc83fc0feebe8abee3b458e7417a385215f1f89a2a89bef3b870c7a30a6cf4920ddd6eb50439c95c1f38fec867a41e628415ed142b7014991fd0818e8cf725b7075498e773790ccc882db0eb22453f0c9931debfb8d3adb09370f30e62b5fe94ffa7e55ff053488ad48f6e244ed6f043fae8f2225a024800c690ce15dd8017457d23c834b276d079d4a141f22db8fed4ea8f1e378fb741a2da30c09abc817ef0ad589428f966b8bdf92fb32fefa67f425ef1c58a2d4c881e8cc0156519256b87736ed84691b585687971c01a23da37ab76726602a01e771d9820add53f62168d51c7ec12ede030b61155f12e7c8d5573985a9e0884bcc41e0b50aa066b3337f2ab8e3b1031a1c843700413ef03d3734536547fc636055f5d15b0f804b3d25f90e4aaf199ee666d90199d0781526bb2040144b5a638411c1067d0bc5e3ef1911c5223fb0f5d0ce6387702b6957f9466b1a8be6879b8c7190ec1e0662cda6005a363f5d3d4585e6d9d15349be797353179b0a713b925dddfbd05609430601339bf31226cce63c763d887364aa6f1d640892f2a074338b741b7c3303e62c6fc16f544ceeed251dba
std::string tx_blob = xmreg::hex_to_tx_blob(tx_4b40_hex);
vector<tx_info> mempool_txs_to_return;
mempool_txs_to_return.push_back(tx_info{});
mempool_txs_to_return.back().tx_blob = tx_blob;
EXPECT_CALL(*mcore_ptr, get_mempool_txs(_, _))
.WillOnce(DoAll(
SetArgReferee<0>(mempool_txs_to_return),
Return(true)));
EXPECT_TRUE(bcs->read_mempool());
xmreg::CurrentBlockchainStatus::mempool_txs_t mempool_txs;
mempool_txs = bcs->get_mempool_txs();
TX_FROM_HEX(tx_4b40_hex);
EXPECT_EQ(get_transaction_hash(mempool_txs[0].second),
tx_hash);
}
TEST_P(BCSTATUS_TEST, ReadMempoolFailure)
{
vector<tx_info> mempool_txs_to_return;
mempool_txs_to_return.push_back(tx_info{});
mempool_txs_to_return.push_back(tx_info{});
mempool_txs_to_return.push_back(tx_info{});
EXPECT_CALL(*mcore_ptr, get_mempool_txs(_, _))
.WillOnce(DoAll(
SetArgReferee<0>(mempool_txs_to_return),
Return(true)));
EXPECT_FALSE(bcs->read_mempool());
EXPECT_CALL(*mcore_ptr, get_mempool_txs(_, _))
.WillOnce(DoAll(
SetArgReferee<0>(mempool_txs_to_return),
Return(false)));
EXPECT_FALSE(bcs->read_mempool());
}
TEST_P(BCSTATUS_TEST, SearchIfPaymentMade)
{
vector<tx_info> mempool_txs_to_return;
mempool_txs_to_return.push_back(tx_info{});
mempool_txs_to_return.push_back(tx_info{});
mempool_txs_to_return.push_back(tx_info{});
}
INSTANTIATE_TEST_CASE_P(
DifferentMoneroNetworks, BCSTATUS_TEST,
::testing::Values(
network_type::MAINNET,
network_type::TESTNET,
network_type::STAGENET));
6 years ago
}