Add stake tests (#60)
* update unit tests * add stake transaction functional test
This commit is contained in:
@@ -29,11 +29,13 @@
|
||||
set(functional_tests_sources
|
||||
main.cpp
|
||||
transactions_flow_test.cpp
|
||||
stake_tx.cpp
|
||||
transactions_generation_from_blockchain.cpp)
|
||||
|
||||
set(functional_tests_headers
|
||||
transactions_flow_test.h
|
||||
transactions_generation_from_blockchain.h)
|
||||
transactions_generation_from_blockchain.h
|
||||
stake_tx.h)
|
||||
|
||||
monero_add_minimal_executable(functional_tests
|
||||
${functional_tests_sources}
|
||||
|
||||
@@ -37,20 +37,24 @@ using namespace epee;
|
||||
#include "common/command_line.h"
|
||||
#include "common/util.h"
|
||||
#include "transactions_flow_test.h"
|
||||
#include "stake_tx.h"
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
namespace
|
||||
{
|
||||
const command_line::arg_descriptor<bool> arg_test_transactions_flow = {"test_transactions_flow", ""};
|
||||
const command_line::arg_descriptor<bool> arg_test_stake_tx = {"test_stake_tx", "Test stake transactions"};
|
||||
|
||||
const command_line::arg_descriptor<std::string> arg_working_folder = {"working-folder", "", "."};
|
||||
const command_line::arg_descriptor<std::string> arg_source_wallet = {"source-wallet", "", "", true};
|
||||
const command_line::arg_descriptor<std::string> arg_dest_wallet = {"dest-wallet", "", "", true};
|
||||
const command_line::arg_descriptor<std::string> arg_daemon_addr_a = {"daemon-addr-a", "", "127.0.0.1:8080"};
|
||||
const command_line::arg_descriptor<std::string> arg_daemon_addr_b = {"daemon-addr-b", "", "127.0.0.1:8082"};
|
||||
const command_line::arg_descriptor<std::string> arg_daemon_addr_stake = {"daemon-addr-stake", "", "127.0.0.1:29081"};
|
||||
|
||||
const command_line::arg_descriptor<uint64_t> arg_transfer_amount = {"transfer_amount", "", 60000000000000};
|
||||
const command_line::arg_descriptor<uint64_t> arg_stake_amount = {"stake_amount", "Amount to stake", 100000000};
|
||||
const command_line::arg_descriptor<size_t> arg_mix_in_factor = {"mix-in-factor", "", 15};
|
||||
const command_line::arg_descriptor<size_t> arg_tx_count = {"tx-count", "", 100};
|
||||
const command_line::arg_descriptor<size_t> arg_tx_per_second = {"tx-per-second", "", 20};
|
||||
@@ -71,14 +75,17 @@ int main(int argc, char* argv[])
|
||||
command_line::add_arg(desc_options, command_line::arg_help);
|
||||
|
||||
command_line::add_arg(desc_options, arg_test_transactions_flow);
|
||||
command_line::add_arg(desc_options, arg_test_stake_tx);
|
||||
|
||||
command_line::add_arg(desc_options, arg_working_folder);
|
||||
command_line::add_arg(desc_options, arg_source_wallet);
|
||||
command_line::add_arg(desc_options, arg_dest_wallet);
|
||||
command_line::add_arg(desc_options, arg_daemon_addr_a);
|
||||
command_line::add_arg(desc_options, arg_daemon_addr_b);
|
||||
command_line::add_arg(desc_options, arg_daemon_addr_stake);
|
||||
|
||||
command_line::add_arg(desc_options, arg_transfer_amount);
|
||||
command_line::add_arg(desc_options, arg_stake_amount);
|
||||
command_line::add_arg(desc_options, arg_mix_in_factor);
|
||||
command_line::add_arg(desc_options, arg_tx_count);
|
||||
command_line::add_arg(desc_options, arg_tx_per_second);
|
||||
@@ -126,6 +133,23 @@ int main(int argc, char* argv[])
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (command_line::get_arg(vm, arg_test_stake_tx))
|
||||
{
|
||||
std::string working_folder = command_line::get_arg(vm, arg_working_folder);
|
||||
std::string wallet_name;
|
||||
if(command_line::has_arg(vm, arg_source_wallet))
|
||||
wallet_name = command_line::get_arg(vm, arg_source_wallet);
|
||||
std::string daemon_addr_stake = command_line::get_arg(vm, arg_daemon_addr_stake);
|
||||
uint64_t amount_to_stake = command_line::get_arg(vm, arg_stake_amount);
|
||||
|
||||
if(!stake_transaction_test(working_folder, wallet_name, daemon_addr_stake, amount_to_stake))
|
||||
return 1;
|
||||
|
||||
std::string s;
|
||||
std::cin >> s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << desc_options << std::endl;
|
||||
|
||||
@@ -0,0 +1,438 @@
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "include_base_utils.h"
|
||||
using namespace epee;
|
||||
#include "wallet/wallet2.h"
|
||||
|
||||
#include "transactions_flow_test.h"
|
||||
#include "stake_tx.h"
|
||||
|
||||
using namespace cryptonote;
|
||||
|
||||
// fixed-difficulty should be at least 7.
|
||||
|
||||
|
||||
bool stop_mining(epee::net_utils::http::http_simple_client& http_client){
|
||||
COMMAND_RPC_STOP_MINING::request stop_mine_req = AUTO_VAL_INIT(stop_mine_req);
|
||||
COMMAND_RPC_STOP_MINING::response stop_mine_rsp = AUTO_VAL_INIT(stop_mine_rsp);
|
||||
bool r = net_utils::invoke_http_json("/stop_mining", stop_mine_req, stop_mine_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to stop mining");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool stake_transaction_test(std::string& working_folder,
|
||||
std::string wallet_name,
|
||||
std::string& daemon_addr_a,
|
||||
uint64_t amount_to_stake) {
|
||||
LOG_PRINT_L0("-----------------------STARTING STAKE TRANSACTION TEST-----------------------");
|
||||
tools::wallet2 w1(network_type::TESTNET);
|
||||
w1.inactivity_lock_timeout(0);
|
||||
w1.ask_password(tools::wallet2::AskPasswordType::AskPasswordNever);
|
||||
w1.setup_background_mining(tools::wallet2::BackgroundMiningSetupType::BackgroundMiningNo); // disable background mining
|
||||
if(wallet_name.empty())
|
||||
wallet_name = generate_random_wallet_name();
|
||||
|
||||
try
|
||||
{
|
||||
w1.generate(working_folder + "/" + wallet_name, "");
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("failed to generate wallet: " << e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
w1.init(daemon_addr_a);
|
||||
|
||||
epee::net_utils::http::http_simple_client http_client;
|
||||
bool r = http_client.set_server(daemon_addr_a, boost::none);
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to connect to daemon");
|
||||
|
||||
// stop mining just in case
|
||||
stop_mining(http_client);
|
||||
|
||||
// get current height
|
||||
COMMAND_RPC_GET_HEIGHT::request height_req = AUTO_VAL_INIT(height_req);
|
||||
COMMAND_RPC_GET_HEIGHT::response height_rsp = AUTO_VAL_INIT(height_rsp);
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to get height from daemon");
|
||||
|
||||
// pop blocks to make sure of the start height
|
||||
COMMAND_RPC_POP_BLOCKS::request pop_blocks_req = AUTO_VAL_INIT(pop_blocks_req);
|
||||
COMMAND_RPC_POP_BLOCKS::response pop_blocks_rsp = AUTO_VAL_INIT(pop_blocks_rsp);
|
||||
pop_blocks_req.nblocks = height_rsp.height - 1; //keep at least one block
|
||||
r = net_utils::invoke_http_json("/pop_blocks", pop_blocks_req, pop_blocks_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to pop blocks");
|
||||
|
||||
// flush tx pool to make sure of the start state
|
||||
COMMAND_RPC_FLUSH_TRANSACTION_POOL::request flush_req = AUTO_VAL_INIT(flush_req);
|
||||
COMMAND_RPC_FLUSH_TRANSACTION_POOL::response flush_rsp = AUTO_VAL_INIT(flush_rsp);
|
||||
r = net_utils::invoke_http_json_rpc("/json_rpc", "flush_txpool", flush_req, flush_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to flush tx pool");
|
||||
|
||||
w1.rescan_blockchain(true, true, false);
|
||||
MGINFO_GREEN("Using wallets: " << ENDL
|
||||
<< "Source: " << w1.get_account().get_public_address_str(TESTNET) << ENDL << "Path: " << working_folder + "/" + wallet_name << ENDL);
|
||||
|
||||
//lets make some money
|
||||
COMMAND_RPC_START_MINING::request start_mining_req = AUTO_VAL_INIT(start_mining_req);
|
||||
COMMAND_RPC_START_MINING::response start_mining_rsp = AUTO_VAL_INIT(start_mining_rsp);
|
||||
start_mining_req.miner_address = w1.get_account().get_public_address_str(TESTNET);
|
||||
start_mining_req.threads_count = 1;
|
||||
r = net_utils::invoke_http_json("/start_mining", start_mining_req, start_mining_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to start mining getrandom_outs");
|
||||
CHECK_AND_ASSERT_MES(start_mining_rsp.status == CORE_RPC_STATUS_OK, false, "failed to start mining");
|
||||
|
||||
// mine until we reach to block 710
|
||||
height_rsp.height = 1;
|
||||
while (height_rsp.height < 710)
|
||||
{
|
||||
misc_utils::sleep_no_w(1000); // The difficulty should be high enough to stop mining before reaching block 800.”
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to get height from daemon 1");
|
||||
}
|
||||
|
||||
// stop mining
|
||||
stop_mining(http_client);
|
||||
|
||||
// refresh wallet
|
||||
uint64_t blocks_fetched = 0;
|
||||
bool received_money;
|
||||
w1.refresh(true, 0, blocks_fetched, received_money);
|
||||
|
||||
MGINFO_GREEN("balance: " << w1.balance(0, "SAL", false));
|
||||
|
||||
// create and submit CN SAL stake transaction ~ block 710
|
||||
std::vector<cryptonote::tx_destination_entry> dsts;
|
||||
cryptonote::tx_destination_entry de;
|
||||
de.addr = w1.get_account().get_keys().m_account_address;
|
||||
de.amount = amount_to_stake;
|
||||
de.is_subaddress = false;
|
||||
dsts.push_back(de);
|
||||
try
|
||||
{
|
||||
std::vector<tools::wallet2::pending_tx> ptx;
|
||||
ptx = w1.create_transactions_2(dsts, "SAL", "SAL", cryptonote::transaction_type::STAKE, 15, 0, 0, std::vector<uint8_t>(), 0, {});
|
||||
for (auto &p: ptx)
|
||||
w1.commit_tx(p);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
LOG_ERROR("failed to create/commit CN stake transaction at height: " << height_rsp.height << "with SAL");
|
||||
return false;
|
||||
}
|
||||
|
||||
// lets make some money
|
||||
r = net_utils::invoke_http_json("/start_mining", start_mining_req, start_mining_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to start mining getrandom_outs");
|
||||
CHECK_AND_ASSERT_MES(start_mining_rsp.status == CORE_RPC_STATUS_OK, false, "failed to start mining");
|
||||
|
||||
// mine until we reach to block 1010
|
||||
while (height_rsp.height < 1010) // difficulty should be high enough to stop mining before reaching block 1080
|
||||
{
|
||||
misc_utils::sleep_no_w(1000);
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to get height from daemon");
|
||||
}
|
||||
|
||||
// stop mining if not stopped already
|
||||
stop_mining(http_client);
|
||||
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
|
||||
// Check the height to ensure we are receiving yield payments before the Carrot hard fork at block 1100
|
||||
if (!r)
|
||||
{
|
||||
LOG_ERROR("failed to get height from daemon");
|
||||
return false;
|
||||
}
|
||||
if (height_rsp.height > 1080)
|
||||
{
|
||||
LOG_PRINT_L0("----!! The current height (" << height_rsp.height << ") exceeds the acceptable range for this test. Please restart the node with an increased fixed difficulty. !!----");
|
||||
}
|
||||
|
||||
|
||||
// refresh wallet
|
||||
blocks_fetched = 0;
|
||||
received_money = false;
|
||||
bool ok = false;
|
||||
if(!w1.refresh(true, blocks_fetched, received_money, ok))
|
||||
{
|
||||
LOG_ERROR( "failed to refresh source wallet from " << daemon_addr_a );
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if we have received yield from CN SAL stake transaction ~1010
|
||||
tools::wallet2::transfer_container incoming_transfers;
|
||||
// scan payments
|
||||
w1.get_transfers(incoming_transfers);
|
||||
CHECK_AND_ASSERT_MES(!incoming_transfers.empty(), false, "failed to get payments");
|
||||
bool found = false;
|
||||
for (const auto& p: incoming_transfers)
|
||||
{
|
||||
if (p.m_tx.type == cryptonote::transaction_type::PROTOCOL)
|
||||
{
|
||||
if (p.m_amount > amount_to_stake)
|
||||
{
|
||||
LOG_PRINT_L0("found yield from CN SAL stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("invalid yield amount from CN SAL stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
return false;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(found, false, "failed to find yield from CN SAL stake transaction");
|
||||
|
||||
//create and submit CN SAL1 stake transaction
|
||||
dsts.clear();
|
||||
de.addr = w1.get_account().get_keys().m_account_address;
|
||||
de.amount = amount_to_stake;
|
||||
de.is_subaddress = false;
|
||||
dsts.push_back(de);
|
||||
try
|
||||
{
|
||||
std::vector<tools::wallet2::pending_tx> ptx;
|
||||
ptx = w1.create_transactions_2(dsts, "SAL1", "SAL1", cryptonote::transaction_type::STAKE, 15, 0, 0, std::vector<uint8_t>(), 0, {});
|
||||
for (auto &p: ptx)
|
||||
w1.commit_tx(p);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
LOG_ERROR("failed to create/commit CN stake transaction at height: " << height_rsp.height << "with SAL1");
|
||||
return false;
|
||||
}
|
||||
|
||||
// lets make some money
|
||||
r = net_utils::invoke_http_json("/start_mining", start_mining_req, start_mining_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to start mining getrandom_outs");
|
||||
CHECK_AND_ASSERT_MES(start_mining_rsp.status == CORE_RPC_STATUS_OK, false, "failed to start mining");
|
||||
|
||||
// mine until we reach to block 1091
|
||||
while (height_rsp.height < 1091)
|
||||
{
|
||||
misc_utils::sleep_no_w(100);
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(1));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to get height from daemon");
|
||||
}
|
||||
|
||||
// stop mining if not stopped already
|
||||
stop_mining(http_client);
|
||||
|
||||
// refresh wallet
|
||||
blocks_fetched = 0;
|
||||
received_money = false;
|
||||
ok = false;
|
||||
if(!w1.refresh(true, blocks_fetched, received_money, ok))
|
||||
{
|
||||
LOG_ERROR( "failed to refresh source wallet from " << daemon_addr_a );
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if we have received yield from CN SAL stake transaction
|
||||
incoming_transfers.clear();
|
||||
// scan payments
|
||||
w1.get_transfers(incoming_transfers);
|
||||
CHECK_AND_ASSERT_MES(!incoming_transfers.empty(), false, "failed to get payments");
|
||||
found = false;
|
||||
for (const auto& p: incoming_transfers)
|
||||
{
|
||||
if (p.m_block_height < 1010) continue; // skip payments from the first stake transaction
|
||||
if (p.m_tx.type == cryptonote::transaction_type::PROTOCOL)
|
||||
{
|
||||
if (p.m_amount > amount_to_stake)
|
||||
{
|
||||
LOG_PRINT_L0("found yield from CN SAL1 stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("invalid yield amount from CN SAL1 stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
return false;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(found, false, "failed to find yield from CN SAL1 stake transaction");
|
||||
|
||||
// pop blocks to make sure of the start height
|
||||
pop_blocks_req = AUTO_VAL_INIT(pop_blocks_req);
|
||||
pop_blocks_req.nblocks = height_rsp.height - 1090; //keep at least 1090 blocks
|
||||
r = net_utils::invoke_http_json("/pop_blocks", pop_blocks_req, pop_blocks_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to pop blocks");
|
||||
|
||||
// flush tx pool to make sure of the start state
|
||||
r = net_utils::invoke_http_json_rpc("/json_rpc", "flush_txpool", flush_req, flush_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to flush tx pool");
|
||||
|
||||
// rescan blockchain to ensure wallet is in sync after popping blocks
|
||||
w1.rescan_blockchain(true, true, false);
|
||||
MGINFO_GREEN("Using wallets: " << ENDL
|
||||
<< "Source: " << w1.get_account().get_public_address_str(TESTNET) << ENDL << "Path: " << working_folder + "/" + wallet_name << ENDL);
|
||||
|
||||
// Create and stake CN SAL1 stake transaction and get yield after the Carrot hard fork at block 1100 ~ block 1090
|
||||
dsts.clear();
|
||||
de.addr = w1.get_account().get_keys().m_account_address;
|
||||
de.amount = amount_to_stake;
|
||||
de.is_subaddress = false;
|
||||
dsts.push_back(de);
|
||||
try
|
||||
{
|
||||
std::vector<tools::wallet2::pending_tx> ptx;
|
||||
ptx = w1.create_transactions_2(dsts, "SAL1", "SAL1", cryptonote::transaction_type::STAKE, 15, 0, 0, std::vector<uint8_t>(), 0, {});
|
||||
for (auto &p: ptx)
|
||||
w1.commit_tx(p);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
LOG_ERROR("failed to create/commit CN stake transaction at height: " << height_rsp.height << "with SAL1");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// lets make some money
|
||||
r = net_utils::invoke_http_json("/start_mining", start_mining_req, start_mining_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to start mining getrandom_outs");
|
||||
CHECK_AND_ASSERT_MES(start_mining_rsp.status == CORE_RPC_STATUS_OK, false, "failed to start mining");
|
||||
|
||||
// mine until we reach to block 1100
|
||||
while (height_rsp.height < 1100)
|
||||
{
|
||||
misc_utils::sleep_no_w(1000);
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to get height from daemon");
|
||||
}
|
||||
|
||||
// stop mining if not stopped already
|
||||
stop_mining(http_client);
|
||||
|
||||
// Carrot will not be able to connect to the network until the node is restarted
|
||||
LOG_PRINT_L0("---------------------- PLEASE RESTART THE NODE NOW ----------------------");
|
||||
misc_utils::sleep_no_w(1000); // wait for the log to be printed
|
||||
LOG_PRINT_L2("Press any key to continue once the node is back online");
|
||||
std::string input;
|
||||
std::cin >> input;
|
||||
|
||||
// restart the http client connection
|
||||
r = http_client.set_server(daemon_addr_a, boost::none);
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to connect to daemon");
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "Daemon is not yet back online");
|
||||
|
||||
LOG_PRINT_L0("Daemon is back online, continuing tests");
|
||||
LOG_PRINT_L2("Carrot has been enabled.");
|
||||
|
||||
// restart the wallet connection
|
||||
w1.init(daemon_addr_a);
|
||||
|
||||
// Create and stake Carrot SAL1 stake transaction ~ block 1100
|
||||
dsts.clear();
|
||||
de.addr = w1.get_account().get_keys().m_carrot_main_address;
|
||||
de.amount = amount_to_stake;
|
||||
de.is_subaddress = false;
|
||||
dsts.push_back(de);
|
||||
try
|
||||
{
|
||||
std::vector<tools::wallet2::pending_tx> ptx;
|
||||
ptx = w1.create_transactions_2(dsts, "SAL1", "SAL1", cryptonote::transaction_type::STAKE, 15, 0, 0, std::vector<uint8_t>(), 0, {});
|
||||
for (auto &p: ptx)
|
||||
w1.commit_tx(p);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
LOG_ERROR("failed to create/commit Carrot stake transaction at height: " << height_rsp.height << " with SAL1");
|
||||
return false;
|
||||
}
|
||||
|
||||
// lets make some money
|
||||
start_mining_req.miner_address = w1.get_account().get_carrot_public_address_str(TESTNET);
|
||||
start_mining_req.threads_count = 1;
|
||||
r = net_utils::invoke_http_json("/start_mining", start_mining_req, start_mining_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to start mining getrandom_outs");
|
||||
CHECK_AND_ASSERT_MES(start_mining_rsp.status == CORE_RPC_STATUS_OK, false, "failed to start mining");
|
||||
|
||||
// mine until we reach to block 1300
|
||||
while (height_rsp.height < 1300)
|
||||
{
|
||||
misc_utils::sleep_no_w(1000);
|
||||
r = net_utils::invoke_http_json("/get_height", height_req, height_rsp, http_client, std::chrono::seconds(10));
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to get height from daemon");
|
||||
}
|
||||
|
||||
// stop mining
|
||||
stop_mining(http_client);
|
||||
|
||||
// refresh wallet
|
||||
blocks_fetched = 0;
|
||||
received_money = false;
|
||||
ok = false;
|
||||
if(!w1.refresh(true, blocks_fetched, received_money, ok))
|
||||
{
|
||||
LOG_ERROR( "failed to refresh source wallet from " << daemon_addr_a );
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if we have received yield from Carrot SAL1 stake transaction
|
||||
incoming_transfers.clear();
|
||||
// scan payments
|
||||
w1.get_transfers(incoming_transfers);
|
||||
CHECK_AND_ASSERT_MES(!incoming_transfers.empty(), false, "failed to get payments");
|
||||
found = false;
|
||||
for (const auto& p: incoming_transfers)
|
||||
{
|
||||
if (p.m_block_height > 1112 || p.m_block_height < 1090) continue; // Skip payments originating from CryptoNote stake transactions
|
||||
if (p.m_tx.type == cryptonote::transaction_type::PROTOCOL)
|
||||
{
|
||||
if (p.m_amount > amount_to_stake)
|
||||
{
|
||||
LOG_PRINT_L0("found yield from Carrot SAL1 stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
LOG_PRINT_L2("Stake was made before the Carrot hard fork and yield received after Carrot hard fork");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("invalid yield amount from Carrot SAL1 stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
return false;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(found, false, "failed to find yield from Carrot SAL1 stake transaction");
|
||||
|
||||
|
||||
// check if we have received yield from Carrot SAL1 stake transaction
|
||||
incoming_transfers.clear();
|
||||
// scan payments
|
||||
w1.get_transfers(incoming_transfers);
|
||||
CHECK_AND_ASSERT_MES(!incoming_transfers.empty(), false, "failed to get payments");
|
||||
found = false;
|
||||
for (const auto& p: incoming_transfers)
|
||||
{
|
||||
if (p.m_block_height <= 1112) continue; // // Skip payments originating from CryptoNote stake transactions
|
||||
if (p.m_tx.type == cryptonote::transaction_type::PROTOCOL)
|
||||
{
|
||||
if (p.m_amount > amount_to_stake)
|
||||
{
|
||||
LOG_PRINT_L0("found yield from Carrot SAL1 stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
LOG_PRINT_L0("All yields from stake transactions have been successfully found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("invalid yield amount from Carrot SAL1 stake transaction: " << p.m_amount - amount_to_stake << " at height: " << p.m_block_height);
|
||||
return false;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(found, false, "failed to find yield from Carrot SAL1 stake transaction");
|
||||
LOG_PRINT_L2("All yields from stake transactions have been successfully found!");
|
||||
LOG_PRINT_L0("-----------------------STAKE TRANSACTION TEST PASSED-----------------------");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2014-2022, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
bool stake_transaction_test(std::string& working_folder,
|
||||
std::string wallet_name,
|
||||
std::string& daemon_addr_a,
|
||||
uint64_t amount_to_stake);
|
||||
@@ -28,6 +28,8 @@
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
std::string generate_random_wallet_name();
|
||||
|
||||
bool transactions_flow_test(std::string& working_folder,
|
||||
std::string path_source_wallet,
|
||||
std::string path_target_wallet,
|
||||
|
||||
@@ -323,13 +323,10 @@ TEST(carrot_core, main_address_special_scan_completeness)
|
||||
const crypto::key_image tx_first_key_image = rct::rct2ki(rct::pkGen());
|
||||
|
||||
RCTOutputEnoteProposal enote_proposal;
|
||||
RCTOutputEnoteProposal return_enote;
|
||||
get_output_proposal_special_v1(proposal,
|
||||
keys.k_view_incoming_dev,
|
||||
tx_first_key_image,
|
||||
cryptonote::transaction_type::TRANSFER, // tx_type
|
||||
std::nullopt,
|
||||
return_enote,
|
||||
enote_proposal);
|
||||
|
||||
ASSERT_EQ(proposal.amount, enote_proposal.amount);
|
||||
@@ -403,13 +400,10 @@ TEST(carrot_core, subaddress_special_scan_completeness)
|
||||
const crypto::key_image tx_first_key_image = rct::rct2ki(rct::pkGen());
|
||||
|
||||
RCTOutputEnoteProposal enote_proposal;
|
||||
RCTOutputEnoteProposal return_enote;
|
||||
get_output_proposal_special_v1(proposal,
|
||||
keys.k_view_incoming_dev,
|
||||
tx_first_key_image,
|
||||
cryptonote::transaction_type::TRANSFER, // tx_type
|
||||
std::nullopt,
|
||||
return_enote,
|
||||
enote_proposal);
|
||||
|
||||
ASSERT_EQ(proposal.amount, enote_proposal.amount);
|
||||
@@ -460,7 +454,7 @@ TEST(carrot_core, subaddress_special_scan_completeness)
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
TEST(carrot_core, main_address_internal_scan_completeness)
|
||||
{
|
||||
mock::mock_carrot_and_legacy_keys keys;
|
||||
carrot::carrot_and_legacy_account keys;
|
||||
keys.generate();
|
||||
|
||||
const CarrotDestinationV1 main_address = keys.cryptonote_address();
|
||||
@@ -481,10 +475,13 @@ TEST(carrot_core, main_address_internal_scan_completeness)
|
||||
const crypto::key_image tx_first_key_image = rct::rct2ki(rct::pkGen());
|
||||
|
||||
RCTOutputEnoteProposal enote_proposal;
|
||||
RCTOutputEnoteProposal return_proposal;
|
||||
get_output_proposal_internal_v1(proposal,
|
||||
keys.s_view_balance_dev,
|
||||
tx_first_key_image,
|
||||
std::nullopt,
|
||||
cryptonote::transaction_type::TRANSFER, // tx_type
|
||||
return_proposal,
|
||||
enote_proposal);
|
||||
|
||||
ASSERT_EQ(proposal.amount, enote_proposal.amount);
|
||||
@@ -498,15 +495,19 @@ TEST(carrot_core, main_address_internal_scan_completeness)
|
||||
crypto::secret_key recovered_amount_blinding_factor;
|
||||
CarrotEnoteType recovered_enote_type;
|
||||
janus_anchor_t recovered_internal_message;
|
||||
crypto::public_key return_address_out;
|
||||
bool is_return_out;
|
||||
const bool scan_success = try_scan_carrot_enote_internal_receiver(enote_proposal.enote,
|
||||
keys.s_view_balance_dev,
|
||||
keys,
|
||||
recovered_sender_extension_g,
|
||||
recovered_sender_extension_t,
|
||||
recovered_address_spend_pubkey,
|
||||
recovered_amount,
|
||||
recovered_amount_blinding_factor,
|
||||
recovered_enote_type,
|
||||
recovered_internal_message);
|
||||
recovered_internal_message,
|
||||
return_address_out,
|
||||
is_return_out);
|
||||
|
||||
ASSERT_TRUE(scan_success);
|
||||
|
||||
@@ -527,7 +528,7 @@ TEST(carrot_core, main_address_internal_scan_completeness)
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
TEST(carrot_core, subaddress_internal_scan_completeness)
|
||||
{
|
||||
mock::mock_carrot_and_legacy_keys keys;
|
||||
carrot::carrot_and_legacy_account keys;
|
||||
keys.generate();
|
||||
|
||||
const uint32_t j_major = crypto::rand_idx(mock::MAX_SUBADDRESS_MAJOR_INDEX);
|
||||
@@ -551,10 +552,13 @@ TEST(carrot_core, subaddress_internal_scan_completeness)
|
||||
const crypto::key_image tx_first_key_image = rct::rct2ki(rct::pkGen());
|
||||
|
||||
RCTOutputEnoteProposal enote_proposal;
|
||||
RCTOutputEnoteProposal return_proposal;
|
||||
get_output_proposal_internal_v1(proposal,
|
||||
keys.s_view_balance_dev,
|
||||
tx_first_key_image,
|
||||
std::nullopt,
|
||||
cryptonote::transaction_type::TRANSFER, // tx_type
|
||||
return_proposal,
|
||||
enote_proposal);
|
||||
|
||||
ASSERT_EQ(proposal.amount, enote_proposal.amount);
|
||||
@@ -568,15 +572,19 @@ TEST(carrot_core, subaddress_internal_scan_completeness)
|
||||
crypto::secret_key recovered_amount_blinding_factor;
|
||||
CarrotEnoteType recovered_enote_type;
|
||||
janus_anchor_t recovered_internal_message;
|
||||
crypto::public_key return_address_out;
|
||||
bool is_return_out;
|
||||
const bool scan_success = try_scan_carrot_enote_internal_receiver(enote_proposal.enote,
|
||||
keys.s_view_balance_dev,
|
||||
keys,
|
||||
recovered_sender_extension_g,
|
||||
recovered_sender_extension_t,
|
||||
recovered_address_spend_pubkey,
|
||||
recovered_amount,
|
||||
recovered_amount_blinding_factor,
|
||||
recovered_enote_type,
|
||||
recovered_internal_message);
|
||||
recovered_internal_message,
|
||||
return_address_out,
|
||||
is_return_out);
|
||||
|
||||
ASSERT_TRUE(scan_success);
|
||||
|
||||
|
||||
@@ -808,11 +808,11 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_10)
|
||||
tx_proposal.self_sender_index = 2;
|
||||
|
||||
// 1 subaddress payment (subtractable)
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{
|
||||
.destination = acc0.first.subaddress({{2, 3}}),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// 1 main address payment
|
||||
acc1.second.emplace_back().first = CarrotPaymentProposalV1{
|
||||
@@ -826,7 +826,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_10)
|
||||
.destination = acc3.first.cryptonote_address(gen_payment_id()),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// specify fee per weight
|
||||
tx_proposal.fee_per_weight = 314159;
|
||||
@@ -914,11 +914,11 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12)
|
||||
tx_proposal.self_sender_index = 2;
|
||||
|
||||
// 2 subaddress payment (1 subtractable)
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{
|
||||
acc0.second.emplace_back().first =CarrotPaymentProposalV1{
|
||||
.destination = acc0.first.subaddress({{2, 3}}),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
acc0.second.push_back(acc0.second.front());
|
||||
acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm
|
||||
acc0.second.back().second = false; //set not subtractable, first already is
|
||||
@@ -937,7 +937,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12)
|
||||
.destination = acc3.first.cryptonote_address(gen_payment_id()),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// 1 main address selfsend
|
||||
tx_proposal.explicit_selfsend_proposals.emplace_back().first.proposal = CarrotPaymentProposalSelfSendV1{
|
||||
@@ -955,7 +955,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_12)
|
||||
.enote_type = CarrotEnoteType::CHANGE
|
||||
},
|
||||
.subaddr_index = {{4, 19}}
|
||||
}, true};
|
||||
};
|
||||
|
||||
// specify fee per weight
|
||||
tx_proposal.fee_per_weight = 314159;
|
||||
@@ -1021,11 +1021,11 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_14)
|
||||
tx_proposal.self_sender_index = 2;
|
||||
|
||||
// 1 subaddress payment (subtractable)
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{
|
||||
.destination = acc0.first.subaddress({{2, 3}}),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// 1 main address payment
|
||||
acc1.second.emplace_back().first = CarrotPaymentProposalV1{
|
||||
@@ -1039,7 +1039,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_14)
|
||||
.destination = acc3.first.cryptonote_address(gen_payment_id()),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// specify fee per weight
|
||||
tx_proposal.fee_per_weight = 314159;
|
||||
@@ -1071,11 +1071,11 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_15)
|
||||
tx_proposal.self_sender_index = 2;
|
||||
|
||||
// 2 subaddress payment (subtractable)
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{
|
||||
.destination = acc0.first.subaddress({{2, 3}}),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
acc0.second.push_back(acc0.second.front());
|
||||
acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm
|
||||
|
||||
@@ -1084,7 +1084,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_15)
|
||||
.destination = acc1.first.cryptonote_address(),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
acc1.second.push_back(acc1.second.front());
|
||||
acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm
|
||||
|
||||
@@ -1093,7 +1093,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_15)
|
||||
.destination = acc3.first.cryptonote_address(gen_payment_id()),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// specify fee per weight
|
||||
tx_proposal.fee_per_weight = 314159;
|
||||
@@ -1125,11 +1125,11 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_16)
|
||||
tx_proposal.self_sender_index = 2;
|
||||
|
||||
// 2 subaddress payment (subtractable)
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{ = {CarrotPaymentProposalV1{
|
||||
acc0.second.emplace_back().first = CarrotPaymentProposalV1{
|
||||
.destination = acc0.first.subaddress({{2, 3}}),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
acc0.second.push_back(acc0.second.front());
|
||||
acc0.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm
|
||||
|
||||
@@ -1138,7 +1138,7 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_16)
|
||||
.destination = acc1.first.cryptonote_address(),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
acc1.second.push_back(acc1.second.front());
|
||||
acc1.second.back().first.randomness = gen_janus_anchor(); //mangle anchor_norm
|
||||
|
||||
@@ -1147,14 +1147,16 @@ TEST(carrot_impl, multi_account_transfer_over_transaction_16)
|
||||
.destination = acc3.first.cryptonote_address(gen_payment_id()),
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.randomness = gen_janus_anchor()
|
||||
}, true};
|
||||
};
|
||||
|
||||
// 1 main address selfsend (subtractable)
|
||||
tx_proposal.explicit_selfsend_proposals.emplace_back() = {CarrotPaymentProposalSelfSendV1{
|
||||
.destination_address_spend_pubkey = acc2.first.carrot_account_spend_pubkey,
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.enote_type = CarrotEnoteType::PAYMENT,
|
||||
// no internal messages for legacy self-sends
|
||||
tx_proposal.explicit_selfsend_proposals.emplace_back() = {CarrotPaymentProposalVerifiableSelfSendV1{
|
||||
.proposal = CarrotPaymentProposalSelfSendV1{
|
||||
.destination_address_spend_pubkey = acc2.first.carrot_account_spend_pubkey,
|
||||
.amount = crypto::rand_idx<rct::xmr_amount>(1000000),
|
||||
.enote_type = CarrotEnoteType::PAYMENT,
|
||||
// no internal messages for legacy self-sends
|
||||
}
|
||||
}, true};
|
||||
|
||||
// 1 subaddress selfsend (subtractable)
|
||||
|
||||
@@ -359,15 +359,20 @@ void mock_scan_enote_set(const std::vector<CarrotEnoteV1> &enotes,
|
||||
const CarrotEnoteV1 &enote = enotes.at(output_index);
|
||||
|
||||
mock_scan_result_t scan_result{};
|
||||
carrot::carrot_and_legacy_account account;
|
||||
crypto::public_key return_address_out;
|
||||
bool is_return_out;
|
||||
const bool r = try_scan_carrot_enote_internal_receiver(enote,
|
||||
keys.s_view_balance_dev,
|
||||
account,
|
||||
scan_result.sender_extension_g,
|
||||
scan_result.sender_extension_t,
|
||||
scan_result.address_spend_pubkey,
|
||||
scan_result.amount,
|
||||
scan_result.amount_blinding_factor,
|
||||
scan_result.enote_type,
|
||||
scan_result.internal_message);
|
||||
scan_result.internal_message,
|
||||
return_address_out,
|
||||
is_return_out);
|
||||
|
||||
scan_result.output_index = output_index;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ static auto auto_wiper(T &obj)
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_origin_tx(
|
||||
mock::mock_carrot_and_legacy_keys &alice,
|
||||
carrot::carrot_and_legacy_account &alice,
|
||||
CarrotDestinationV1 &bob_address
|
||||
) {
|
||||
// spend input
|
||||
@@ -62,9 +62,10 @@ std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_origin_
|
||||
|
||||
// make change output
|
||||
RCTOutputEnoteProposal enote_proposal_change;
|
||||
RCTOutputEnoteProposal return_proposal;
|
||||
get_output_proposal_internal_v1(
|
||||
CarrotPaymentProposalSelfSendV1{
|
||||
.destination_address_spend_pubkey = alice.carrot_account_spend_pubkey,
|
||||
.destination_address_spend_pubkey = alice.get_keys().m_carrot_account_address.m_spend_public_key,
|
||||
.amount = crypto::rand<rct::xmr_amount>(),
|
||||
.enote_type = CarrotEnoteType::CHANGE,
|
||||
.enote_ephemeral_pubkey = gen_x25519_pubkey(),
|
||||
@@ -72,6 +73,8 @@ std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_origin_
|
||||
alice.s_view_balance_dev,
|
||||
tx_first_key_image,
|
||||
std::nullopt,
|
||||
cryptonote::transaction_type::TRANSFER, // tx_type
|
||||
return_proposal,
|
||||
enote_proposal_change
|
||||
);
|
||||
|
||||
@@ -138,7 +141,7 @@ std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_origin_
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_return_tx(
|
||||
mock::mock_carrot_and_legacy_keys &bob,
|
||||
carrot::carrot_and_legacy_account &bob,
|
||||
std::vector<RCTOutputEnoteProposal> &origin_tx_outputs
|
||||
) {
|
||||
// [0] enote is change, [1] enote bob received
|
||||
@@ -169,7 +172,7 @@ std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_return_
|
||||
received_output,
|
||||
std::nullopt,
|
||||
origin_tx_shared_secret_unctx,
|
||||
{&bob.carrot_account_spend_pubkey, 1},
|
||||
{&bob.get_keys().m_carrot_account_address.m_spend_public_key, 1},
|
||||
bob.k_view_incoming_dev,
|
||||
recovered_sender_extension_g,
|
||||
recovered_sender_extension_t,
|
||||
@@ -182,7 +185,7 @@ std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_return_
|
||||
EXPECT_TRUE(scan_success);
|
||||
|
||||
// check we can spend it
|
||||
EXPECT_TRUE(bob.can_open_fcmp_onetime_address(bob.carrot_account_spend_pubkey,
|
||||
EXPECT_TRUE(bob.can_open_fcmp_onetime_address(bob.get_keys().m_carrot_account_address.m_spend_public_key,
|
||||
recovered_sender_extension_g,
|
||||
recovered_sender_extension_t,
|
||||
received_output.onetime_address));
|
||||
@@ -237,7 +240,7 @@ std::tuple<std::vector<RCTOutputEnoteProposal>, crypto::public_key> make_return_
|
||||
TEST(carrot_sparc, main_address_return_payment_normal_scan_completeness)
|
||||
{
|
||||
// these will generate a new format carrot address.
|
||||
mock::mock_carrot_and_legacy_keys alice, bob;
|
||||
carrot::carrot_and_legacy_account alice, bob;
|
||||
alice.generate();
|
||||
bob.generate();
|
||||
|
||||
@@ -332,20 +335,23 @@ TEST(carrot_sparc, main_address_return_payment_normal_scan_completeness)
|
||||
crypto::secret_key recovered_amount_blinding_factor_change;
|
||||
CarrotEnoteType recovered_enote_type_change;
|
||||
janus_anchor_t recovered_internal_message_out_change;
|
||||
crypto::public_key return_address_out;
|
||||
bool is_return_out;
|
||||
const bool scan_success_change = try_scan_carrot_enote_internal_receiver(change_output,
|
||||
alice.s_view_balance_dev,
|
||||
alice,
|
||||
recovered_sender_extension_g_change,
|
||||
recovered_sender_extension_t_change,
|
||||
recovered_address_spend_pubkey_change,
|
||||
recovered_amount_change,
|
||||
recovered_amount_blinding_factor_change,
|
||||
recovered_enote_type_change,
|
||||
recovered_internal_message_out_change);
|
||||
|
||||
recovered_internal_message_out_change,
|
||||
return_address_out,
|
||||
is_return_out);
|
||||
ASSERT_TRUE(scan_success_change);
|
||||
|
||||
// check spendability of the change output
|
||||
EXPECT_TRUE(alice.can_open_fcmp_onetime_address(alice.carrot_account_spend_pubkey,
|
||||
EXPECT_TRUE(alice.can_open_fcmp_onetime_address(alice.get_keys().m_carrot_account_address.m_spend_public_key,
|
||||
recovered_sender_extension_g_change,
|
||||
recovered_sender_extension_t_change,
|
||||
change_output.onetime_address));
|
||||
@@ -353,7 +359,7 @@ TEST(carrot_sparc, main_address_return_payment_normal_scan_completeness)
|
||||
// check spendability of the return_payment
|
||||
crypto::secret_key sum_g;
|
||||
sc_add(to_bytes(sum_g), to_bytes(recovered_sender_extension_g_change), to_bytes(k_return));
|
||||
ASSERT_TRUE(alice.can_open_fcmp_onetime_address(alice.carrot_account_spend_pubkey,
|
||||
ASSERT_TRUE(alice.can_open_fcmp_onetime_address(alice.get_keys().m_carrot_account_address.m_spend_public_key,
|
||||
sum_g,
|
||||
recovered_sender_extension_t_change,
|
||||
return_output.onetime_address));
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
|
||||
using namespace cryptonote;
|
||||
|
||||
const uint64_t AMOUNT_BURNT = 1000000000000; // 1 SAL
|
||||
const uint64_t STAKE_REWARD = 10000000000000; // 10 SAL
|
||||
const uint64_t STAKE_PAYOUT = 216001000000000000; // 216k SAL
|
||||
const uint64_t AMOUNT_BURNT = 1000000000000; // 10000 SAL
|
||||
const uint64_t STAKE_REWARD = 10000000000000; // 100000 SAL
|
||||
const uint64_t STAKE_PAYOUT = 216001000000000000; // 2160000k SAL
|
||||
const uint64_t STAKE_LOCK_PERIOD = get_config(network_type::FAKECHAIN).STAKE_LOCK_PERIOD;
|
||||
const auto AUDIT_HARD_FORKS = get_config(network_type::FAKECHAIN).AUDIT_HARD_FORKS;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ TEST(wallet_tx_builder, input_selection_basic)
|
||||
tools::wallet2::transfer_container transfers;
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
tools::wallet2::transfer_details &td = tools::add_element(transfers);
|
||||
tools::wallet2::transfer_details &td = transfers.emplace_back();
|
||||
td = gen_transfer_details();
|
||||
td.m_block_height = transfers.size(); // small ascending block heights
|
||||
}
|
||||
@@ -206,7 +206,7 @@ TEST(wallet_tx_builder, make_carrot_transaction_proposals_wallet2_transfer_2)
|
||||
std::unordered_map<crypto::key_image, std::size_t> allowed_transfers;
|
||||
for (size_t i = 0; i < FCMP_PLUS_PLUS_MAX_INPUTS + 2; ++i)
|
||||
{
|
||||
tools::wallet2::transfer_details &td = tools::add_element(transfers);
|
||||
tools::wallet2::transfer_details &td = transfers.emplace_back();
|
||||
td = gen_transfer_details();
|
||||
td.m_subaddr_index.major = (i % 2 == 0) ? spending_subaddr_account : (spending_subaddr_account - 1);
|
||||
td.m_subaddr_index.minor = crypto::rand_range<std::uint32_t>(0, carrot::mock::MAX_SUBADDRESS_MINOR_INDEX);
|
||||
|
||||
Reference in New Issue
Block a user