mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
Do not run functions with necessary side-effects in assert()
This commit is contained in:
@ -31,12 +31,15 @@ static void CHACHA20_POLY1305_AEAD(benchmark::Bench& bench, size_t buffersize, b
|
|||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
bench.batch(buffersize).unit("byte").run([&] {
|
bench.batch(buffersize).unit("byte").run([&] {
|
||||||
// encrypt or decrypt the buffer with a static key
|
// encrypt or decrypt the buffer with a static key
|
||||||
assert(aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true));
|
const bool crypt_ok_1 = aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true);
|
||||||
|
assert(crypt_ok_1);
|
||||||
|
|
||||||
if (include_decryption) {
|
if (include_decryption) {
|
||||||
// if we decrypt, include the GetLength
|
// if we decrypt, include the GetLength
|
||||||
assert(aead.GetLength(&len, seqnr_aad, aad_pos, in.data()));
|
const bool get_length_ok = aead.GetLength(&len, seqnr_aad, aad_pos, in.data());
|
||||||
assert(aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true));
|
assert(get_length_ok);
|
||||||
|
const bool crypt_ok_2 = aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true);
|
||||||
|
assert(crypt_ok_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// increase main sequence number
|
// increase main sequence number
|
||||||
|
@ -64,7 +64,8 @@ static void add_coin(CWallet& wallet, const CAmount& nValue, int nAge = 6*24, bo
|
|||||||
if (spendable) {
|
if (spendable) {
|
||||||
CTxDestination dest;
|
CTxDestination dest;
|
||||||
std::string error;
|
std::string error;
|
||||||
assert(wallet.GetNewDestination(OutputType::BECH32, "", dest, error));
|
const bool destination_ok = wallet.GetNewDestination(OutputType::BECH32, "", dest, error);
|
||||||
|
assert(destination_ok);
|
||||||
tx.vout[nInput].scriptPubKey = GetScriptForDestination(dest);
|
tx.vout[nInput].scriptPubKey = GetScriptForDestination(dest);
|
||||||
}
|
}
|
||||||
if (fIsFromMe) {
|
if (fIsFromMe) {
|
||||||
|
Reference in New Issue
Block a user