CurrentBlockchainStatus::construct_output_rct_field tested

pull/93/merge
moneroexamples 6 years ago
parent 5f4795057b
commit ab6544ef6d

@ -69,15 +69,11 @@
include(CMakeParseArguments)
# Check prereqs
find_program( GCOV_PATH gcov )
find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl)
find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat )
find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
find_program( SIMPLE_PYTHON_EXECUTABLE python )
if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Aborting...")
endif() # NOT GCOV_PATH
if(NOT GCOVR_PATH)
message(FATAL_ERROR "gcovr not found! Aborting...")
endif() # NOT GCOVR_PATH
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
@ -90,9 +86,6 @@ endif()
set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
CACHE INTERNAL "")
#set(COVERAGE_COMPILER_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage"
# CACHE INTERNAL "")
set(CMAKE_CXX_FLAGS_COVERAGE
${COVERAGE_COMPILER_FLAGS}
@ -197,57 +190,6 @@ function(SETUP_TARGET_FOR_COVERAGE)
endfunction() # SETUP_TARGET_FOR_COVERAGE
# Defines a target for running and collection code coverage information
# Builds dependencies, runs the given executable and outputs reports.
# NOTE! The executable should always have a ZERO as exit code otherwise
# the coverage generation will not complete.
#
# SETUP_TARGET_FOR_COVERAGE_COBERTURA(
# NAME ctest_coverage # New target name
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
# DEPENDENCIES executable_target # Dependencies to build first
# )
function(SETUP_TARGET_FOR_COVERAGE_COBERTURA)
set(options NONE)
set(oneValueArgs NAME)
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT SIMPLE_PYTHON_EXECUTABLE)
message(FATAL_ERROR "python not found! Aborting...")
endif() # NOT SIMPLE_PYTHON_EXECUTABLE
if(NOT GCOVR_PATH)
message(FATAL_ERROR "gcovr not found! Aborting...")
endif() # NOT GCOVR_PATH
# Combine excludes to several -e arguments
set(COBERTURA_EXCLUDES "")
foreach(EXCLUDE ${COVERAGE_EXCLUDES})
set(COBERTURA_EXCLUDES "-e ${EXCLUDE} ${COBERTURA_EXCLUDES}")
endforeach()
add_custom_target(${Coverage_NAME}
# Run tests
${Coverage_EXECUTABLE}
# Running gcovr
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} ${COBERTURA_EXCLUDES}
-o ${Coverage_NAME}.xml
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${Coverage_DEPENDENCIES}
COMMENT "Running gcovr to produce Cobertura code coverage report."
)
# Show info where to find the report
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
COMMAND ;
COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml."
)
endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
function(APPEND_COVERAGE_COMPILER_FLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)

@ -962,11 +962,11 @@ CurrentBlockchainStatus::construct_output_rct_field(
const uint64_t out_amount)
{
transaction random_output_tx;
transaction random_output_tx;
uint64_t output_idx_in_tx;
// we got random outputs, but now we need to get rct data of those
// outputs, because by default frontend created ringct txs.
// outputs, because by default frontend creates ringct txs.
if (!CurrentBlockchainStatus::get_tx_with_output(
global_amount_index, out_amount,
@ -996,7 +996,7 @@ CurrentBlockchainStatus::construct_output_rct_field(
// for non ringct txs, we need to take it rct amount commitment
// and sent to the frontend. the mask is zero mask for those,
// as frontend will produce identy mask autmatically
//for non-ringct outputs
// for non-ringct outputs
output_data_t od = get_output_key(out_amount, global_amount_index);
@ -1040,7 +1040,7 @@ CurrentBlockchainStatus::get_txs_in_blocks(
blk.timestamp, true);
// now insert hashes of regular txs to be fatched later
// so for now, theys txs are null pointers
// so for now, these txs are null pointers
for (auto& tx_hash: blk.tx_hashes)
txs_data.emplace_back(tx_hash, transaction{},
blk_height, blk.timestamp, false);

@ -46,7 +46,7 @@ public:
using mempool_txs_t = vector<pair<uint64_t, transaction>>;
// tx_hash , tx, height , timestamp, is_coinbase
// tx_hash , tx, , height , timestamp, is_coinbase
using txs_tuple_t
= std::tuple<crypto::hash, transaction, uint64_t, uint64_t, bool>;
@ -238,6 +238,9 @@ public:
get_txs_in_blocks(vector<block> const& blocks,
vector<txs_tuple_t>& txs_data);
virtual TxSearch&
get_search_thread(string const& acc_address);
// default destructor is fine
virtual ~CurrentBlockchainStatus() = default;
@ -251,9 +254,6 @@ public:
protected:
virtual TxSearch&
get_search_thread(string const& acc_address);
// parameters used to connect/read monero blockchain
BlockchainSetup bc_setup;

@ -110,10 +110,10 @@ public:
return core_storage.get_db().get_output_tx_and_index(amount, index);
}
template<typename... T>
auto get_tx_block_height(T&&... args) const
virtual uint64_t
get_tx_block_height(crypto::hash const& tx_hash) const
{
return core_storage.get_db().get_tx_block_height(std::forward<T>(args)...);
return core_storage.get_db().get_tx_block_height(tx_hash);
}
virtual std::vector<uint64_t>

@ -784,15 +784,15 @@ YourMoneroRequests::get_random_outs(
return;
}
vector<COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount>
found_outputs;
using rpc_outs = COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS;
vector<rpc_outs::outs_for_amount> found_outputs;
if (current_bc_status->get_random_outputs(amounts, count, found_outputs))
{
json& j_amount_outs = j_response["amount_outs"];
for (const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
::outs_for_amount& outs: found_outputs)
for (const auto& outs: found_outputs)
{
json j_outs {{"amount", outs.amount},
{"outputs", json::array()}};
@ -800,8 +800,7 @@ YourMoneroRequests::get_random_outs(
json& j_outputs = j_outs["outputs"];
for (const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
::out_entry& out: outs.outs)
for (auto const& out: outs.outs)
{
uint64_t global_amount_index = out.global_amount_index;

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save