Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/util.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | ProofRef TestProofBuilder::buildWithReversedOrderStakes(ProofBuilder &pb) { | ||||
while (!pb.stakes.empty()) { | while (!pb.stakes.empty()) { | ||||
// We need a forward iterator, so pb.stakes.rbegin() is not an | // We need a forward iterator, so pb.stakes.rbegin() is not an | ||||
// option. | // option. | ||||
auto handle = pb.stakes.extract(std::prev(pb.stakes.end())); | auto handle = pb.stakes.extract(std::prev(pb.stakes.end())); | ||||
signedStakes.push_back(handle.value().sign(commitment)); | signedStakes.push_back(handle.value().sign(commitment)); | ||||
} | } | ||||
return std::make_shared<Proof>( | return ProofRef::make(pb.sequence, pb.expirationTime, | ||||
pb.sequence, pb.expirationTime, pb.masterKey.GetPubKey(), | pb.masterKey.GetPubKey(), std::move(signedStakes), | ||||
std::move(signedStakes), pb.payoutScriptPubKey, SchnorrSig()); | pb.payoutScriptPubKey, SchnorrSig()); | ||||
} | } | ||||
ProofId TestProofBuilder::getDuplicatedStakeProofId(ProofBuilder &pb) { | ProofId TestProofBuilder::getDuplicatedStakeProofId(ProofBuilder &pb) { | ||||
CHashWriter ss(SER_GETHASH, 0); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << pb.sequence; | ss << pb.sequence; | ||||
ss << pb.expirationTime; | ss << pb.expirationTime; | ||||
WriteCompactSize(ss, 2 * pb.stakes.size()); | WriteCompactSize(ss, 2 * pb.stakes.size()); | ||||
Show All 18 Lines | ProofRef TestProofBuilder::buildDuplicatedStakes(ProofBuilder &pb) { | ||||
while (!pb.stakes.empty()) { | while (!pb.stakes.empty()) { | ||||
auto handle = pb.stakes.extract(pb.stakes.begin()); | auto handle = pb.stakes.extract(pb.stakes.begin()); | ||||
SignedStake signedStake = handle.value().sign(commitment); | SignedStake signedStake = handle.value().sign(commitment); | ||||
signedStakes.push_back(signedStake); | signedStakes.push_back(signedStake); | ||||
signedStakes.push_back(signedStake); | signedStakes.push_back(signedStake); | ||||
} | } | ||||
return std::make_shared<Proof>( | return ProofRef::make(pb.sequence, pb.expirationTime, | ||||
pb.sequence, pb.expirationTime, pb.masterKey.GetPubKey(), | pb.masterKey.GetPubKey(), std::move(signedStakes), | ||||
std::move(signedStakes), pb.payoutScriptPubKey, SchnorrSig()); | pb.payoutScriptPubKey, SchnorrSig()); | ||||
} | } | ||||
} // namespace avalanche | } // namespace avalanche |