SON131 - Compilation fix and adding new operation in tests

This commit is contained in:
satyakoneru 2020-02-12 11:29:52 +00:00
parent c226924ef9
commit 5f5a1a1860
4 changed files with 73 additions and 3 deletions

View file

@ -266,6 +266,7 @@ void database::initialize_evaluators()
register_evaluator<delete_sidechain_address_evaluator>();
register_evaluator<bitcoin_transaction_send_evaluator>();
register_evaluator<bitcoin_transaction_sign_evaluator>();
register_evaluator<bitcoin_send_transaction_process_evaluator>();
}
void database::initialize_indexes()

View file

@ -106,7 +106,7 @@ void_result bitcoin_send_transaction_process_evaluator::do_evaluate(const bitcoi
{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass
FC_ASSERT(op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "Payer should be the son btc account");
const auto &btidx = db.get_index_type<bitcoin_transaction_index>().indices().get<by_id>();
const auto& btidx = db().get_index_type<bitcoin_transaction_index>().indices().get<by_id>();
const auto btobj = btidx.find(op.bitcoin_transaction_id);
FC_ASSERT(btobj != btidx.end(), "Bitcoin Transaction Object not found");
FC_ASSERT(btobj->processed == false, "Bitcoin Transaction already processed");
@ -119,9 +119,9 @@ object_id_type bitcoin_send_transaction_process_evaluator::do_apply(const bitcoi
{
try
{
const auto &btidx = db.get_index_type<bitcoin_transaction_index>().indices().get<by_id>();
const auto &btidx = db().get_index_type<bitcoin_transaction_index>().indices().get<by_id>();
auto btobj = btidx.find(op.bitcoin_transaction_id);
if (btobj != btindx.end())
if (btobj != btidx.end())
{
db().modify(*btobj, [&op](bitcoin_transaction_object &bto) {
bto.processed = true;

View file

@ -47,6 +47,7 @@
#include <graphene/chain/son_wallet_object.hpp>
#include <graphene/chain/son_wallet_transfer_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/sidechain_transaction_object.hpp>
#include <fc/smart_ref_impl.hpp>
#include <iostream>

View file

@ -291,6 +291,74 @@ BOOST_AUTO_TEST_CASE(bitcoin_transaction_send_test)
BOOST_REQUIRE(sigs[son_obj2->id][0] == b1);
BOOST_REQUIRE(sigs[son_obj2->id][1] == b2);
BOOST_REQUIRE(sigs[son_obj2->id][2] == b3);
{
BOOST_TEST_MESSAGE("Send bitcoin_send_transaction_process_operation");
bitcoin_send_transaction_process_operation process_op;
process_op.bitcoin_transaction_id = bitcoin_transaction_id_type(0);
process_op.payer = db.get_global_properties().parameters.get_son_btc_account_id();
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = alice_id;
proposal_op.proposed_ops.push_back(op_wrapper(process_op));
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
proposal_op.expiration_time = time_point_sec(db.head_block_time().sec_since_epoch() + lifetime);
trx.operations.push_back(proposal_op);
set_expiration(db, trx);
sign(trx, alice_private_key);
PUSH_TX(db, trx, ~0);
trx.clear();
}
generate_block();
BOOST_REQUIRE(idx.size() == 1);
obj = idx.find(proposal_id_type(1));
BOOST_REQUIRE(obj != idx.end());
{
BOOST_TEST_MESSAGE("Send proposal_update_operation");
proposal_update_operation puo;
puo.fee_paying_account = bob_id;
puo.proposal = obj->id;
puo.active_approvals_to_add = { bob_id };
trx.operations.push_back(puo);
set_expiration(db, trx);
sign(trx, bob_private_key);
PUSH_TX(db, trx, ~0);
trx.clear();
}
generate_block();
BOOST_REQUIRE(idx.size() == 1);
obj = idx.find(proposal_id_type(1));
BOOST_REQUIRE(obj != idx.end());
BOOST_REQUIRE(btobj != btidx.end());
BOOST_REQUIRE(btobj->processed == false);
{
BOOST_TEST_MESSAGE("Send proposal_update_operation");
proposal_update_operation puo;
puo.fee_paying_account = alice_id;
puo.proposal = obj->id;
puo.active_approvals_to_add = { alice_id };
trx.operations.push_back(puo);
set_expiration(db, trx);
sign(trx, alice_private_key);
PUSH_TX(db, trx, ~0);
trx.clear();
}
generate_block();
BOOST_REQUIRE(idx.size() == 0);
BOOST_REQUIRE(btobj != btidx.end());
BOOST_REQUIRE(btobj->processed == true);
}
FC_LOG_AND_RETHROW()
}