Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/proof_tests.cpp
Show First 20 Lines • Show All 880 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(deserialization) { | ||||
gArgs.ForceSetArg("-legacyavaproof", "0"); | gArgs.ForceSetArg("-legacyavaproof", "0"); | ||||
BOOST_CHECK(!Proof::useLegacy(gArgs)); | BOOST_CHECK(!Proof::useLegacy(gArgs)); | ||||
checkCases(regularFormatTestCases); | checkCases(regularFormatTestCases); | ||||
gArgs.ClearForcedArg("-legacyavaproof"); | gArgs.ClearForcedArg("-legacyavaproof"); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(serialization_roundtrip) { | |||||
auto checkSerializationRoundTrip = [&](const ProofRef &proof) { | |||||
Proof unserProof; | |||||
bilingual_str error; | |||||
BOOST_CHECK(Proof::FromHex(unserProof, proof->ToHex(), error)); | |||||
BOOST_CHECK(error.empty()); | |||||
BOOST_CHECK_EQUAL(proof->getId(), unserProof.getId()); | |||||
BOOST_CHECK(proof->getSignature() == unserProof.getSignature()); | |||||
}; | |||||
for (const std::string &legacy : {"0", "1"}) { | |||||
gArgs.ForceSetArg("-legacyavaproof", legacy); | |||||
checkSerializationRoundTrip(ProofRef::make()); | |||||
for (size_t i = 0; i < 100; i++) { | |||||
checkSerializationRoundTrip(buildRandomProof( | |||||
GetRand(std::numeric_limits<uint32_t>::max()))); | |||||
} | |||||
} | |||||
gArgs.ClearForcedArg("-legacyavaproof"); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(verify) { | BOOST_AUTO_TEST_CASE(verify) { | ||||
CCoinsView coinsDummy; | CCoinsView coinsDummy; | ||||
CCoinsViewCache coins(&coinsDummy); | CCoinsViewCache coins(&coinsDummy); | ||||
auto key = CKey::MakeCompressedKey(); | auto key = CKey::MakeCompressedKey(); | ||||
const CPubKey pubkey = key.GetPubKey(); | const CPubKey pubkey = key.GetPubKey(); | ||||
const Amount value = 12345 * COIN; | const Amount value = 12345 * COIN; | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |