Files

98 lines
2.7 KiB
C++
Raw Permalink Normal View History

2018-12-28 12:10:28 +01:00
/*
* This file is part of the Flowee project
2021-01-20 19:21:53 +01:00
* Copyright (C) 2018-2021 Tom Zander <tom@flowee.org>
2018-12-28 12:10:28 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCRIPT_TESTS_H
#define SCRIPT_TESTS_H
2026-05-08 22:11:32 +02:00
#include <common/TestFloweeEnvPlusNet.h>
2018-12-28 12:10:28 +01:00
#include <primitives/transaction.h>
2023-11-24 18:16:32 +01:00
#include <primitives/PrivateKey.h>
2018-12-28 12:10:28 +01:00
#include <univalue.h>
#include <script/interpreter.h>
class TestBuilder
{
private:
CScript scriptPubKey;
CTransaction creditTx;
CMutableTransaction spendTx;
bool havePush;
std::vector<unsigned char> push;
QString comment;
int flags;
2021-01-20 19:21:53 +01:00
int64_t nValue;
2018-12-28 12:10:28 +01:00
void DoPush();
void DoPush(const std::vector<unsigned char>& data);
public:
2021-01-20 19:21:53 +01:00
TestBuilder(const CScript& redeemScript, const QString& comment, int flags, bool P2SH = false, int64_t nValue_ = 0);
2018-12-28 12:10:28 +01:00
TestBuilder& Add(const CScript& script);
TestBuilder& Num(int num);
TestBuilder& Push(const std::string& hex);
2022-07-06 22:12:33 +02:00
TestBuilder& PushSig(const PrivateKey& key, int nHashType = SIGHASH_ALL, unsigned int lenR = 32, unsigned int lenS = 32, int64_t amount = 0);
2018-12-28 12:10:28 +01:00
2022-07-06 21:56:34 +02:00
TestBuilder& Push(const PublicKey& pubkey);
2018-12-28 12:10:28 +01:00
TestBuilder& PushRedeem();
TestBuilder& EditPush(unsigned int pos, const std::string& hexin, const std::string& hexout);
TestBuilder& DamagePush(unsigned int pos);
TestBuilder& Test(bool expect);
UniValue GetJSON();
QString GetComment() const;
const CScript& GetScriptPubKey();
};
class TestScript : public TestFloweeEnvPlusNet
{
Q_OBJECT
public:
2022-07-06 22:12:33 +02:00
CScript sign_multisig(CScript scriptPubKey, std::vector<PrivateKey> keys, CTransaction transaction);
CScript sign_multisig(CScript scriptPubKey, const PrivateKey &key, CTransaction transaction);
2018-12-28 12:10:28 +01:00
private slots:
void script_build();
void script_valid();
void script_invalid();
void script_PushData();
void script_CHECKMULTISIG12();
void script_CHECKMULTISIG23();
void script_standard_push();
void script_IsPushOnly_on_invalid_scripts();
void script_GetScriptAsm();
void minimize_big_endian_test();
void minimalPush();
2026-05-08 22:11:32 +02:00
void bigInt();
2026-05-08 22:53:38 +02:00
void bigIntVch();
void bigIntVch_data();
2018-12-28 12:10:28 +01:00
};
#endif