// Copyright (c) 2021 The Litecoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include BOOST_FIXTURE_TEST_SUITE(TestUTXO, MWEBTestingSetup) BOOST_AUTO_TEST_CASE(TxUTXO) { CAmount amount = 12345; BlindingFactor blind; Output output = Output::Create( &blind, SecretKey::Random(), StealthAddress::Random(), amount ); Commitment commit = Commitment::Switch(blind, amount); int32_t blockHeight = 20; mmr::LeafIndex leafIndex = mmr::LeafIndex::At(5); UTXO utxo{ blockHeight, mmr::LeafIndex(leafIndex), Output(output) }; // // Serialization // { std::vector serialized = utxo.Serialized(); Deserializer deserializer(serialized); BOOST_REQUIRE(deserializer.Read() == blockHeight); BOOST_REQUIRE(mmr::LeafIndex::At(deserializer.Read()) == leafIndex); BOOST_REQUIRE(deserializer.Read() == output); } // // Getters // { BOOST_REQUIRE(utxo.GetBlockHeight() == blockHeight); BOOST_REQUIRE(utxo.GetLeafIndex() == leafIndex); BOOST_REQUIRE(utxo.GetOutput() == output); BOOST_REQUIRE(utxo.GetCommitment() == commit); BOOST_REQUIRE(utxo.GetRangeProof() == output.GetRangeProof()); BOOST_REQUIRE(utxo.BuildProofData() == output.BuildProofData()); } } BOOST_AUTO_TEST_SUITE_END()