
#include "src/MicroCore.h"
#include "../src/CurrentBlockchainStatus.h"
#include "../src/ThreadRAII.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include "helpers.h"
#include "mocks.h"

namespace
{

using json = nlohmann::json;



//class OUTPUTIDENT_TEST : public ::testing::Test
//{
//public:

    //static void
    //SetUpTestCase()
    //{
        //string config_path {"../config/config.json"};
        //config_json = xmreg::BlockchainSetup::read_config(config_path);
    //}

//protected:


    //virtual void
    //SetUp()
    //{
        //bc_setup = xmreg::BlockchainSetup{net_type, do_not_relay, config_json};
        //cbs_mock = make_shared<MockCurrentBlockchainStatus>();
    //}

     //network_type net_type {network_type::TESTNET};
     //bool do_not_relay {false};
     //xmreg::BlockchainSetup bc_setup;

     //std::shared_ptr<MockCurrentBlockchainStatus> cbs_mock;

     //static json config_json;
//};

//json OUTPUTIDENT_TEST::config_json;




//string addr_9wq79 {"9wq792k9sxVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4bh2tCh"};
//string viewkey_9wq79 {"f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06"};

//TEST_F(OUTPUTIDENT_TEST, NonDefaultConstruction)
//{
    //ADDR_VIEWKEY_FROM_STRING(addr_9wq79, viewkey_9wq79, net_type);

    //transaction tx;
    //crypto::hash tx_hash;
    //bool is_coinbase {false};

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_coinbase};

    //EXPECT_TRUE(true);
//}

//TEST_F(OUTPUTIDENT_TEST, IncomingPreRingctTransaction)
//{
    //// private testnet tx_hash 01e3d29a5b6b6e1999b9e7e48b9abe101bb93055b701b23d98513fb0646e7570
    //string tx_hex {"0100020280e08d84ddcb0107041e6508060e1df9733757fb1563579b3a0ecefb4063dc66a75ad6bae3d0916ab862789c31f6aa0280e08d84ddcb01075f030f17031713f43315e59fbd6bacb3aa1a868edc33a0232f5031f6c573d6d7b23e752b6beee10580d0b8e1981a02e04e4d7d674381d16bf50bdc1581f75f7b2df591b7a40d73efd8f5b3c4be2a828088aca3cf02025c3fb06591f216cab833bb6deb2e173e0a9a138addf527eaff80912b8f4ff47280f882ad1602779945c0e6cbbc7def201e170a38bb9822109ddc01f330a5b00d12eb26b6fd4880e0bcefa757024f05eb53b5ebd60e502abd5a2fcb74b057b523acccd191df8076e27083ef619180c0caf384a302022dffb5574d937c1add2cf88bd374af40d577c7cc1a22c3c8805afd49840a60962101945fd9057dd42ef52164368eab1a5f430268e029f83815897d4f1e08b0e00873dbf5b4127be86ba01f23f021a40f29e29110f780fa0be36041ecf00b6c7b480edb090ba58dea640ca19aa4921a56c4b6dcbf11897c53db427dfdbc2f3072480b6c02f409b45c5d2401a19d8cfb13d9124d858d2774d9945f448f19e1e243e004588368813689c1c1be4e1242c633b7a2eb4936546fda57c99dac7fab81e40d0512e39d04ce285f96ac80f6d91ee39157189d73e198fa6b397bd34d8685dbf20e3f869043b686c291f8d4401f673978c683841ec39c45ce06564ccf87c68a080ad17bcce3d7240cd8d57ecbb190fef27578679cdd39ea3c868ab65d6d1d2c20062e921ceea054f755ceef8cd24e54078f9a5bedea2ca59d90ad277bd250c90605b3dd832aa15a4eb01080210ade74638f1558e203c644aa608147c9f596ce3c03023e99f9ca5b3cae41cbd230bc20f2b87f1e06967c852115abc7e56566ddaf09b5774568375fa0f27b45d946cfb2859f1c7a3ad6b7a8e097e955a6ee77c6db0b083dbda85b317dcd77e4be29079420bf683a91ac94feb0f788d5e3dfe72bef028768d76f9ebffd4cb2fd4a314e293df51cb43f12091632e93f4f97fdab7ab60dd50611233fbb1048dccd6478184b914710c894d8116620fcfd09d73ef304c90af210a4724c9e8adb2c47396a67944d6fe827a9b06f7a3c3b6cd2946f328cc306e0a0d194443734cc90fb94ccdb74f8fa7a19690793ddc2b0b06e52d0d4d8530ac227d58a2936fbbf18bbbc2af03443a44ff2a844be527371fedc03c50cce200e8e2b4fdb501e2fba103aafc2487be7faaa83f3894bdcfad873a6697ad930500bc56e28139ef4c6d9b8ee06390b4bcb1b6bfcc6e3136be89e3bdccff50d104906d354569aedfd8b2a5cb62b8738218760a9ebbc5dff3de038ab2e0369f28e3d0d921d28b388acdf69988b5c77120de5317be614da7c774f1f815a7137625da90f0342ca5df7bbc8515066c3d8fa37f1d69727f69e540ff66578bd0e6adf73fa074ce25809e47f06edc9d8ac9f49b4f02b8fd48ef8b03d7a6e823c6e2fc105ee0384a5a3a4bfefc41cf7240847e50121233de0083bbd904903b9879ecdd5a3b701a2196e13e438cf3980ab0b85c5e4e3595c46f034cb393b1e291e3e288678c90e9aac0abe0723520d47e94584ff65dfec8d4d1b1d2c378f87347f429a2178b10ad530bfe406441d7b21c1f0ea04920c9715434b16e6f5c561eab4e8b31040a30b280fc0e3ebc71d1d85a6711591487a50e4ca1362aae564c6e332b97da65c0c07"};

    //// the tx has only one output for 10 xmr, so we check
    //// if we can identify it.

    //TX_FROM_HEX(tx_hex);
    //ADDR_VIEWKEY_FROM_STRING(addr_9wq79, viewkey_9wq79, net_type);

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};
    //oi.identify_outputs();

    //EXPECT_EQ(oi.identified_outputs.size(), 1);
    //EXPECT_EQ(oi.identified_inputs.size(), 0);
    //EXPECT_EQ(oi.get_tx_hash_str(), tx_hash_str);
    //EXPECT_EQ(oi.get_tx_prefix_hash_str(), tx_prefix_hash_str);
    //EXPECT_EQ(oi.get_tx_pub_key_str(), tx_pub_key_str);
    //EXPECT_EQ(oi.get_mixin_no(), 7);
    //EXPECT_EQ(oi.total_received, 10000000000000ull);
    //EXPECT_FALSE(oi.tx_is_coinbase);
    //EXPECT_FALSE(oi.is_rct);

    //auto out_info = oi.identified_outputs[0];

    //EXPECT_EQ(pod_to_hex(out_info.pub_key),
              //"2dffb5574d937c1add2cf88bd374af40d577c7cc1a22c3c8805afd49840a6096");

    //EXPECT_EQ(out_info.amount, 10000000000000ull);
    //EXPECT_EQ(out_info.idx_in_tx, 4);
    //EXPECT_TRUE(out_info.rtc_outpk.empty());
    //EXPECT_TRUE(out_info.rtc_mask.empty());
    //EXPECT_TRUE(out_info.rtc_amount.empty());
//}



//// private testnet wallet 9wq792k9sxVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4bh2tCh
//// viewkey f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06
//// spendkey 509a9761fde8856fc38e79ca705d85f979143524f178f8e2e0eb539fc050e905
//// seed: deftly large tirade gumball android leech sidekick opened iguana voice gels focus poaching itches network espionage much jailed vaults winter oatmeal eleven science siren winter
//string addr_9wq792k {"9wq792k9sxVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4bh2tCh"};
//string viewkey_9wq792k {"f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06"};

//// ./xmr2csv --testnet -b /home/mwo/testnet/node_01/testnet/lmdb/ -a 9wq792k9sxVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4bh2tCh -v f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06
//string known_outputs_csv_9wq792k {"./res/outputs_testnet_9wq792k9.csv"};


//TEST_F(OUTPUTIDENT_TEST, OutgingPreRingctTransaction)
//{
    //// private testnet tx_hash 0889658a54ddfaa61f62fdc0393adc498e1227195d413de45c5f0e0da3f5068d
    //string tx_hex {"0100020280e08d84ddcb0107b902e401081b2c10418ba25b21dc2e9fd3d6d8dd69c14888ab0ed429f8cc86a7edba20bdd2bde61bab0280c0caf384a30207d10194012438201e78879c4ee5f780a4fcabc5ce20716080392fc4715db6334f956e210283beed920f0580c0caf384a302020ffede2e6e4a3d613f6ebcca9d3337d54c5b65f7095cc04faf6c9408206b463c80f882ad16021b48cdc46b84e348596f35a0fb4f0107da3a7e5f8b486be6a36fc90ff052117e80d0b8e1981a02e6de1aa8176921a8d5f8ef02a12004f5183f77a601c347f84e7be18c400572e18088aca3cf02022f061ade6afb847d57d29609255089b477d2c33c34d06e13ec5982d18eb785c580c0f9decfae010211c7792d1a8d8c23bbd0e2c4c79b28a711fa4d6ff64906013ddd2b8bca42a6d444022100000000000000000000000000000000000000000000006f70656e6d6f6e65726f0189bb4ab10d9ae0b84096fe0f4b95da56e3949b71c6eca5f284a4a02c83ed174675d6b1d2e529f5e4199bb738a47e7f50fc7acbf86a3908eb0c3023013ea9e808974dd6e0c0fe2c9853d316d63a35206628790b60997a22cefb9383762ba05a0fb11987072d29d76b172700ea6b9cb61ddbdea60372b35de748f9a7fc0d18f30a02b76e272c76446d828b6cef9a2df96f867792da27f08ca116dca121f73bcf09fe4fff1a1b8a099fffafefac87f10ecdaf02f48e0b903ced2d737bcb803f0c0525588ed99e71b21c35878ce0697990bf768bc35e0e6841bf1cf91c1fc116ee0a01343ec7e52ded6bdb89571b40590834d4c04715b4eb28102dad54b455dd6d03380e9eac3c058159e7fa4f5d3da30b3eda24c7e49a87e1523e5b478efdb8020fa03a4788d214a7ec64454366525ebf66ef8692a0db97a2ff96e1ad926e315105104c7ef19f59aff25265f54489f7e0fdde6205e6f62b4beb6b0d5a2a233a4807e5460bd83dfa3929b56bd84705cee12ce7bcaca09539bd128fc9e7513a3e63022297c65ef1ac04bb1807b85fa3ef38342aa8342ec33dfe4979a1590d372218034649bbb7975d6790e04105cef27a6337996896758f4fa6a962425fc802dd790114020c4f14efe604f00b8f829d6c82bd2c9719a60c39565944998d43f299070ab78325c8a20557e03dd2e50e516503d16bd436b5af949a978097e0ce347a700c13c5ce0d039ea7bfc7cc8e975c0710e74b6b0930ffd597eaf80c0fdc18711e0e6c8e1aed3c2bd4ff035df0745e69d30ec0dff351c0d780cda8873c010419d209c19d6fc4c366911170892c6e696709069e6469018ff2c61f5f42b283bd4c590a3e5f71f7934635c1e7cca1cbf0ec91517ce65673c1b6c6c961625537b2e93208db342fb9c2f246c6d636adf66bece8bae648be290140452d63c6d87fb3ff990c86725d7bc4968cac48f10d7b6a4d35b63e3040c42f6e76e7224fa308a042b10807cd36ffe28daca3e2a755645be3f588565f9ee79b19b7f8c572a872bb61fd08c9d6473dfe2a5ae4f100744ed91e2e8817ef417309c4d0f4a5023272b87b8b00c08ee85c037417b5241e6715db7b0e932ef7e08cba00914bf485a46690f0370016d3e2ca265accec86c295cd02c13d67fa6bcc1f51803d537eaef804bdeaef05316c79554916dc5afb6ac1581436a26ac5cd687d83b4ccbbfae8e230eac2aa0c2b87f2db0b70cea9ad4cf9cb3218c4aa37da05245bc401a1ea4afcdcd833d40fadc38c6d38bd75fe63a364a0bed1c9b6656b4f803b944e5947d1c398a9eed200"};

    //TX_FROM_HEX(tx_hex);
    //ADDR_VIEWKEY_FROM_STRING(addr_9wq792k, viewkey_9wq792k, net_type);


    //// the ring members data from the above tx
    ////
    //// this hex is obtained using onion explorer runnign with --enbale-as-hex flag
    //// it is hex, serializied representation of of map of key_images
    //// with corresponding ring members output_data_t info structure
    //// we do this so that we just mack all the calls, instead of
    //// accessing real blockchain for this data.
    //string ring_member_data_hex {"[encoded data, 4740 characters]"};

    //MockGettingOutputs::ring_members_mock_map_t mock_ring_members_data;

    //ASSERT_TRUE(xmreg::output_data_from_hex(ring_member_data_hex,
                                            //mock_ring_members_data));

    //MockGettingOutputs get_outputs(mock_ring_members_data);

    //EXPECT_CALL(*cbs_mock, get_output_keys(_,_,_))
                 //.WillRepeatedly(Invoke(&get_outputs,
                                         //&MockGettingOutputs
                                            //::get_output_keys));

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};

    //xmreg::TxSearch::known_outputs_t known_outputs;

    //ASSERT_TRUE(xmreg::check_and_adjust_path(known_outputs_csv_9wq792k));

    //ASSERT_TRUE(xmreg::populate_known_outputs_from_csv(
                //known_outputs_csv_9wq792k, known_outputs));

    //oi.identify_outputs();
    //oi.identify_inputs(known_outputs,
                       //cbs_mock.get());

    //EXPECT_EQ(oi.identified_inputs.size(), 2);

    //uint64_t found_input_amounts {0};

    //for (auto& in_info: oi.identified_inputs)
        //found_input_amounts += in_info.amount;

    //EXPECT_EQ(found_input_amounts, 17000000000000ull);
//}



//// stagenet private wallet 56VbjczrFCVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4Z6HAo6
//// viewkey f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06
//// spendkey 509a9761fde8856fc38e79ca705d85f979143524f178f8e2e0eb539fc050e905
//// seed: deftly large tirade gumball android leech sidekick opened iguana voice gels focus poaching itches network espionage much jailed vaults winter oatmeal eleven science siren winter


//string addr_56Vbjcz {"56VbjczrFCVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4Z6HAo6"};
//string viewkey_56Vbjcz {"f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06"};

//// ./xmr2csv --stagenet -b /home/mwo/stagenet/node_01/stagenet/lmdb/ -a 56VbjczrFCVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4Z6HAo6 -v f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06
//string known_outputs_csv_56bCoE {"./res/outputs_stagenet_56Vbjcz.csv"};


//TEST_F(OUTPUTIDENT_TEST, SweepUnmixableTransaction)
//{
    //// sweep_unmixable transaction made on v5
    //// private stagenet tx_hash af696f9a30fd0d436dfce3d57c6e37647752272769dcc0d194aa20b8a6ae74a6
    //string tx_hex {"01000302808095e789c6040100ec2245d2315165ca3a91da51fa002b5507f69b8ee1e555b6f6eaac0ad20fff2202c096b1020100a437de705e6fbfdb6bec4398cdba4dff6bb0c8c6df63c4beb4ae02aac615fe7b0280a094a58d1d01001d503f5cb31e451ebf4ef9b63b8c63cc500acab66d1a9f77518c485ded98f50209808c8d9e02020b448a5786be20d9a00a6755b58731198d7a6c0ed7b95cc34746d7a494a4b106f0a20402cea836e49a83bfe8a49c3bd56abe798fa237f35e8461dd1ce7dcfb8bd5b845dca0c21e024ed38b1a948b8ce0f97a8a678e92c24cec543794c4d3f8802670c2b661cb77f480a0d9e61d02bc39ce2271070ebef256e392e5aaab3c7feb3104dcad5ff882942c1a926da90c808095e789c60402b4b86255abb6c6f8c5c7e30dc08ba0ba7eca238b3444b54c757de554ec8b649580b489130261d5e374d2b305266d7edbb28acf536d78dee151e0e727436cbfdaa9bb8e55398088aca3cf020233aabe91db1381b46c8389dd675188ba9f11da292b5341d324b1b97bc7bffa0280a4e803023bc9a0c13f6f4d36f06bdfcd08194fdd1c08f7e9a4838530780b03678524599b80d0b8e1981a02ac89c9e71c93e6c292bc22185f3de25fc925f37119a4ec8d9980082072f408892101d9b33806437cf186d61b6ff0bd8abdc30b96cfa7999e3d244bc6d0f202a9ee280859aab9dca3fbf3ce304fdcbaedb1e1df2319e9b807c492837579d029f54a0ab551d3aaf6ddbc811d13e4c1abf441c29d2dad28c6b7e14d5bf1345d27a8e40c0c0bf7d21149b9cd1f669985ba99055350eac0233ab0365ef72ed9eca65ec2044d7590c40f7ee365bc70d4f10445219df80cf9066894fa955050b913dc22ff0d5fa6aed1e24b0b3cad8e158d128c102c33df277c1af00cade9b1843de9d01000bd7d3e4221476226f84b54694a895fec3fff83ff567147991303de6bfb2f6301"};

    //TX_FROM_HEX(tx_hex);
    //ADDR_VIEWKEY_FROM_STRING(addr_56Vbjcz, viewkey_56Vbjcz,
                             //network_type::STAGENET);


    //// the ring members data from the above tx
    ////
    //// this hex is obtained using onion explorer runnign with --enbale-as-hex flag
    //// it is hex, serializied representation of of map of key_images
    //// with corresponding ring members output_data_t info structure
    //// we do this so that we just mack all the calls, instead of
    //// accessing real blockchain for this data.
    //string ring_member_data_hex {"011673657269616c697a6174696f6e3a3a617263686976650000000001030000000102000003404b4c000001010001a06538343030376337306637623738643732643934326531383734663063393862383261323731656164656437383734353862616334363138643464396366303330303030303030303030303030303030313930633030303030303030303030306330626534666238373762396365353038373731333233626366316662393438343731306565323330323030303663336538636161633665346630326661626601020000050010a5d4e801010001a06636383534363563653565616239663862393163316566656465353961343161306134346161313538343634623630373339383935616633366236346233653230303030303030303030303030303030316331653030303030303030303030306262366637303632636133303664363732613733306532613266323139626462653430633966623366653464363031333639326166393363646232653063643101020000060040e59c301201010001a064316539643262333336303132633736306462316262666236633933326437633338326132663738666566333535303163313463393965653861613835366538303030303030303030303030303030306630303930303030303030303030303030326661333533616138346561386334346338303233303635643739343136303662316661356332363464636366343664633634393465626539363036663230"};

    //MockGettingOutputs::ring_members_mock_map_t mock_ring_members_data;

    //ASSERT_TRUE(xmreg::output_data_from_hex(ring_member_data_hex,
                                            //mock_ring_members_data));

    //MockGettingOutputs get_outputs(mock_ring_members_data);

    //EXPECT_CALL(*cbs_mock, get_output_keys(_,_,_))
                 //.WillRepeatedly(Invoke(&get_outputs,
                                         //&MockGettingOutputs
                                            //::get_output_keys));

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};

    //xmreg::TxSearch::known_outputs_t known_outputs;

    //ASSERT_TRUE(xmreg::check_and_adjust_path(known_outputs_csv_56bCoE));

    //ASSERT_TRUE(xmreg::populate_known_outputs_from_csv(
                //known_outputs_csv_56bCoE, known_outputs));


    //oi.identify_outputs();

    //EXPECT_EQ(oi.identified_outputs.size(), 9);
    //EXPECT_EQ(oi.get_mixin_no(), 1);
    //EXPECT_EQ(oi.total_received, 20998648570000ull);
    //EXPECT_FALSE(oi.is_rct);

    //EXPECT_EQ(pod_to_hex(oi.identified_outputs[0].pub_key),
              //"0b448a5786be20d9a00a6755b58731198d7a6c0ed7b95cc34746d7a494a4b106");

    //EXPECT_EQ(pod_to_hex(oi.identified_outputs.back().pub_key),
              //"ac89c9e71c93e6c292bc22185f3de25fc925f37119a4ec8d9980082072f40889");


    //oi.identify_inputs(known_outputs,
                       //cbs_mock.get());

    //EXPECT_EQ(oi.identified_inputs.size(), 3);

    //uint64_t found_input_amounts {0};

    //for (auto& in_info: oi.identified_inputs)
        //found_input_amounts += in_info.amount;

    //EXPECT_EQ(found_input_amounts, 21000005000000ull);
//}

//// ./xmr2csv --stagenet -b /home/mwo/stagenet/node_01/stagenet/lmdb/ -a 56VbjczrFCVZiLn66S3Qzv8QfmtcwkdXgM5cWGsXAPxoQeMQ79md51PLPCijvzk1iHbuHi91pws5B7iajTX9KTtJ4Z6HAo6 -v f747f4a4838027c9af80e6364a941b60c538e67e9ea198b6ec452b74c276de06
//string known_outputs_csv_2_56bCoE {"./res/outputs_stagenet_2_56Vbjcz.csv"};


//TEST_F(OUTPUTIDENT_TEST, OutgingMixRingctTransaction)
//{
    //// rintct txs with mixture of key images (pre- and post-ringct)
    //// private stagenet tx_hash 33bb33518ee4a328173a12e9cb37b7fdccee33935653419589dea30e0f54ad72
    //string tx_hex {"[encoded data, 44422 characters]"};

    //TX_FROM_HEX(tx_hex);
    //ADDR_VIEWKEY_FROM_STRING(addr_56Vbjcz, viewkey_56Vbjcz,
                             //network_type::STAGENET);


    //// the ring members data from the above tx
    ////
    //// this hex is obtained using onion explorer runnign with --enbale-as-hex flag
    //// it is hex, serializied representation of of map of key_images
    //// with corresponding ring members output_data_t info structure
    //// we do this so that we just mack all the calls, instead of
    //// accessing real blockchain for this data.
    //string ring_member_data_hex {"[encoded data, 39648 characters]"};

    //MockGettingOutputs::ring_members_mock_map_t mock_ring_members_data;

    //ASSERT_TRUE(xmreg::output_data_from_hex(ring_member_data_hex,
                                            //mock_ring_members_data));

    //MockGettingOutputs get_outputs(mock_ring_members_data);

    //EXPECT_CALL(*cbs_mock, get_output_keys(_,_,_))
                 //.WillRepeatedly(Invoke(&get_outputs,
                                         //&MockGettingOutputs
                                            //::get_output_keys)); 

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};

    //xmreg::TxSearch::known_outputs_t known_outputs;

    //ASSERT_TRUE(xmreg::check_and_adjust_path(known_outputs_csv_2_56bCoE));

    //ASSERT_TRUE(xmreg::populate_known_outputs_from_csv(
                //known_outputs_csv_2_56bCoE, known_outputs));


    //oi.identify_outputs();

    //EXPECT_EQ(oi.identified_outputs.size(), 1);
    //EXPECT_EQ(oi.get_mixin_no(), 7);
    //EXPECT_EQ(oi.total_received, 42433713670000);
    //EXPECT_TRUE(oi.is_rct);

    //oi.identify_inputs(known_outputs, cbs_mock.get());

    //// numer of inputs is basically number
    //// of all possible maches of our mixins.
    //// this number is basically the number of
    //// "output match?" strings - 1 in the explorer

    //EXPECT_EQ(oi.identified_inputs.size(), 41);

    //uint64_t found_input_amounts {0};

    //for (auto& in_info: oi.identified_inputs)
        //found_input_amounts += in_info.amount;

    //EXPECT_EQ(found_input_amounts, 1669459856930000ull);

    //// check when there are no found ring members candidates
    //xmreg::TxSearch::known_outputs_t empty_known_outputs;

    //EXPECT_CALL(*cbs_mock, get_output_keys(_,_,_))
                 //.WillRepeatedly(Invoke(&get_outputs,
                                         //&MockGettingOutputs
                                            //::get_output_keys));

    //xmreg::OutputInputIdentification oi2 {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};

    //oi2.identify_inputs(empty_known_outputs,
                        //cbs_mock.get());

    //EXPECT_EQ(oi2.identified_inputs.size(), 0);
//}


//TEST_F(OUTPUTIDENT_TEST, OutgingRingctTransaction)
//{
    //// rintct txs with mixture of key images (pre- and post-ringct)
    //// private stagenet tx_hash 7d492770e6b008dd74267c52c15d25c22aac1bdb5289d20e4633351c56063e34
    //string tx_hex {"[encoded data, 27554 characters]"};

    //TX_FROM_HEX(tx_hex);
    //ADDR_VIEWKEY_FROM_STRING(addr_56Vbjcz, viewkey_56Vbjcz,
                             //network_type::STAGENET);


    //// the ring members data from the above tx
    ////
    //// this hex is obtained using onion explorer runnign with --enbale-as-hex flag
    //// it is hex, serializied representation of of map of key_images
    //// with corresponding ring members output_data_t info structure
    //// we do this so that we just mack all the calls, instead of
    //// accessing real blockchain for this data.
    //string ring_member_data_hex {"[encoded data, 4740 characters]"};

    //MockGettingOutputs::ring_members_mock_map_t mock_ring_members_data;

    //ASSERT_TRUE(xmreg::output_data_from_hex(ring_member_data_hex,
                                            //mock_ring_members_data));

    //MockGettingOutputs get_outputs(mock_ring_members_data);

    //EXPECT_CALL(*cbs_mock, get_output_keys(_,_,_))
                 //.WillRepeatedly(Invoke(&get_outputs,
                                         //&MockGettingOutputs
                                            //::get_output_keys));

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};

    //xmreg::TxSearch::known_outputs_t known_outputs;

    //ASSERT_TRUE(xmreg::check_and_adjust_path(known_outputs_csv_2_56bCoE));

    //ASSERT_TRUE(xmreg::populate_known_outputs_from_csv(
                //known_outputs_csv_2_56bCoE, known_outputs));


    //oi.identify_outputs();

    //EXPECT_EQ(oi.identified_outputs.size(), 1);
    //EXPECT_EQ(oi.get_mixin_no(), 7);
    //EXPECT_EQ(oi.total_received, 3296300490000ull);
    //EXPECT_TRUE(oi.is_rct);

    //oi.identify_inputs(known_outputs,
                       //cbs_mock.get());

    //// numer of inputs is basically number
    //// of all possible maches of our mixins.
    //// this number is basically the number of
    //// "output match?" strings - 1 in the explorer

    //EXPECT_EQ(oi.identified_inputs.size(), 2);

    //uint64_t found_input_amounts {0};

    //for (auto& in_info: oi.identified_inputs)
        //found_input_amounts += in_info.amount;

    //EXPECT_EQ(found_input_amounts, 103312985270000ull);

    //// check when get_output_returns returns false

    //EXPECT_CALL(*cbs_mock, get_output_keys(_,_,_))
                 //.WillRepeatedly(Return(false));

    //xmreg::OutputInputIdentification oi2 {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};

    //oi2.identify_inputs(known_outputs,
                        //cbs_mock.get());

    //EXPECT_EQ(oi2.identified_inputs.size(), 0);
//}


//TEST_F(OUTPUTIDENT_TEST, IncomingPreRingctCoinbaseTransaction)
//{
    //// private testnet tx_hash af9652cb7682d0b73d4ec588d3d17b5ebfe4773dbb69228fa716242a223fdec0
    //string tx_hex {"01f20201ffb60206a4fa8cd60302225670b42320e616c5c7b801a09b4414456a608808b3f712378d90c4a0bd38cd80f882ad1602137972ff6725442bae4f92d6640e2a8036b1c5652afdbe5439789f3c584ef40b80c0fc82aa0202befb33d6df13977c325dc548022a401c37c024dbd88e244bc6825418f8994df78090cad2c60e02e1b0c0394f0652e13f471b422eeb092acb245d5fc679759ca66667ce179f478c80e08d84ddcb010292ed8812901ad9fac78390e008141ebad73a30af51178915de6e1586239a121980c0caf384a302028134f3543a21a2a78dbd2629e47601accd4f703e0b402f07213cffae2d592ab2210169aa02bef903707e96e7591cf9117879ce456b27d44cd0b70ef6d90636f040bd"};

    //// the tx has six outputs for 10 xmr, so we check
    //// if we can identify it.

    //TX_FROM_HEX(tx_hex);
    //ADDR_VIEWKEY_FROM_STRING(addr_9wq79, viewkey_9wq79, net_type);

    //xmreg::OutputInputIdentification oi {&address, &viewkey, &tx,
                                         //tx_hash, is_tx_coinbase};
    //oi.identify_outputs();

    //EXPECT_EQ(oi.identified_outputs.size(), 6);
    //EXPECT_EQ(oi.identified_inputs.size(), 0);
    //EXPECT_EQ(oi.total_received, 17586985873700ull);
    //EXPECT_TRUE(oi.tx_is_coinbase);

    //EXPECT_EQ(pod_to_hex(oi.identified_outputs[0].pub_key),
              //"225670b42320e616c5c7b801a09b4414456a608808b3f712378d90c4a0bd38cd");

    //EXPECT_EQ(pod_to_hex(oi.identified_outputs.back().pub_key),
              //"8134f3543a21a2a78dbd2629e47601accd4f703e0b402f07213cffae2d592ab2");
//}




//class TXSEARCH_TEST : public ::testing::TestWithParam<network_type>
//{
//public:

    //static void
    //SetUpTestCase()
    //{
        //string config_path {"../config/config.json"};
        //config_json = xmreg::BlockchainSetup::read_config(config_path);
    //}

//protected:

    //virtual void
    //SetUp()
    //{
        //net_type = GetParam();

        //bc_setup = xmreg::BlockchainSetup {
                //net_type, do_not_relay, config_json};

        //mcore = std::make_unique<MockMicroCore>();
        //mcore_ptr = mcore.get();

        //rpc = std::make_unique<MockRPCCalls>("dummy deamon url");
        //rpc_ptr = rpc.get();

        //tp = std::make_unique<TP::ThreadPool>();
        //tp_ptr = tp.get();

        //bcs = std::make_unique<xmreg::CurrentBlockchainStatus>(
                    //bc_setup, std::move(mcore), std::move(rpc),
                    //std::move(tp));
    //}

     //network_type net_type {network_type::STAGENET};
     //bool do_not_relay {false};
     //xmreg::BlockchainSetup bc_setup;
     //std::unique_ptr<MockMicroCore> mcore;
     //std::unique_ptr<MockRPCCalls> rpc;
     //std::unique_ptr<xmreg::CurrentBlockchainStatus> bcs;
     //std::unique_ptr<TP::ThreadPool> tp;

     //MockMicroCore* mcore_ptr;
     //MockRPCCalls* rpc_ptr;
     //TP::ThreadPool* tp_ptr;

     //static json config_json;
//};

//json TXSEARCH_TEST::config_json;



}
