Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/delegation_tests.cpp
Show All 25 Lines | static void CheckDelegation(const Delegation &dg, const ProofRef &p, | ||||
BOOST_CHECK(pubkey == expected_pubkey); | BOOST_CHECK(pubkey == expected_pubkey); | ||||
BOOST_CHECK(dg.getProofId() == p->getId()); | BOOST_CHECK(dg.getProofId() == p->getId()); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(verify_random) { | BOOST_AUTO_TEST_CASE(verify_random) { | ||||
auto key = CKey::MakeCompressedKey(); | auto key = CKey::MakeCompressedKey(); | ||||
auto p = buildRandomProof(123456, key); | auto p = buildRandomProof(123456, 1234, key); | ||||
DelegationBuilder dgb(*p); | DelegationBuilder dgb(*p); | ||||
{ | { | ||||
Delegation dg = dgb.build(); | Delegation dg = dgb.build(); | ||||
BOOST_CHECK_EQUAL(dg.getId(), p->getId()); | BOOST_CHECK_EQUAL(dg.getId(), p->getId()); | ||||
CheckDelegation(dg, p, p->getMaster()); | CheckDelegation(dg, p, p->getMaster()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | for (auto &c : testcases) { | ||||
c.result == DelegationResult::NONE); | c.result == DelegationResult::NONE); | ||||
BOOST_CHECK(state.GetResult() == c.result); | BOOST_CHECK(state.GetResult() == c.result); | ||||
BOOST_CHECK(pubkey == CPubKey(ParseHex(c.pubkey))); | BOOST_CHECK(pubkey == CPubKey(ParseHex(c.pubkey))); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(level_limit) { | BOOST_AUTO_TEST_CASE(level_limit) { | ||||
auto proofKey = CKey::MakeCompressedKey(); | auto proofKey = CKey::MakeCompressedKey(); | ||||
auto p = buildRandomProof(123456, proofKey); | auto p = buildRandomProof(123456, 1234, proofKey); | ||||
DelegationBuilder dgb(*p); | DelegationBuilder dgb(*p); | ||||
CKey delegatorKey = proofKey; | CKey delegatorKey = proofKey; | ||||
for (size_t i = 0; i < MAX_DELEGATION_LEVELS; i++) { | for (size_t i = 0; i < MAX_DELEGATION_LEVELS; i++) { | ||||
CKey delegatedKey = CKey::MakeCompressedKey(); | CKey delegatedKey = CKey::MakeCompressedKey(); | ||||
BOOST_CHECK(dgb.addLevel(delegatorKey, delegatedKey.GetPubKey())); | BOOST_CHECK(dgb.addLevel(delegatorKey, delegatedKey.GetPubKey())); | ||||
delegatorKey = delegatedKey; | delegatorKey = delegatedKey; | ||||
Show All 20 Lines |