remove ntz tests

This commit is contained in:
Duke
2026-03-03 17:35:22 -05:00
parent c5a9aab2f9
commit 25c62c52f5
2 changed files with 0 additions and 251 deletions

View File

@@ -1,197 +0,0 @@
// Copyright (c) 2016-2024 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <gtest/gtest.h>
#include "cc/betprotocol.h"
#include "cc/eval.h"
#include "base58.h"
#include "core_io.h"
#include "key.h"
#include "main.h"
#include "script/cc.h"
#include "primitives/transaction.h"
#include "script/interpreter.h"
#include "script/serverchecker.h"
#include "testutils.h"
extern int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
namespace TestEvalNotarization {
class EvalMock : public Eval
{
public:
uint32_t nNotaries;
uint8_t notaries[64][33];
std::map<uint256, CTransaction> txs;
std::map<uint256, CBlockIndex> blocks;
int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const
{
memcpy(pubkeys, notaries, sizeof(notaries));
return nNotaries;
}
bool GetTxUnconfirmed(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) const
{
auto r = txs.find(hash);
if (r != txs.end()) {
txOut = r->second;
if (blocks.count(hash) > 0)
hashBlock = hash;
return true;
}
return false;
}
bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const
{
auto r = blocks.find(hash);
if (r == blocks.end()) return false;
blockIdx = r->second;
return true;
}
};
//static auto noop = [&](CMutableTransaction &mtx){};
static auto noop = [](CMutableTransaction &mtx){};
template<typename Modifier>
void SetupEval(EvalMock &eval, CMutableTransaction &notary, Modifier modify)
{
eval.nNotaries = hush_notaries(eval.notaries, 780060, 1522946781);
// make fake notary inputs
notary.vin.resize(11);
for (int i=0; i<notary.vin.size(); i++) {
CMutableTransaction txIn;
txIn.vout.resize(1);
txIn.vout[0].scriptPubKey << VCH(eval.notaries[i*2], 33) << OP_CHECKSIG;
notary.vin[i].prevout = COutPoint(txIn.GetHash(), 0);
eval.txs[txIn.GetHash()] = CTransaction(txIn);
}
modify(notary);
eval.txs[notary.GetHash()] = CTransaction(notary);
eval.blocks[notary.GetHash()].SetHeight(780060);
eval.blocks[notary.GetHash()].nTime = 1522946781;
}
// inputs have been dropped
static auto rawNotaryTx = "01000000000290460100000000002321020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9ac0000000000000000506a4c4dae8e0f3e6e5de498a072f5967f3c418c4faba5d56ac8ce17f472d029ef3000008f2e0100424f545300050ba773f0bc31da5839fc7cb9bd7b87f3b765ca608e5cf66785a466659b28880500000000000000";
CTransaction notaryTx;
static bool init = DecodeHexTx(notaryTx, rawNotaryTx);
static uint256 proofTxHash = uint256S("37f76551a16093fbb0a92ee635bbd45b3460da8fd00cf7d5a6b20d93e727fe4c");
static auto vMomProof = ParseHex("0303faecbdd4b3da128c2cd2701bb143820a967069375b2ec5b612f39bbfe78a8611978871c193457ab1e21b9520f4139f113b8d75892eb93ee247c18bccfd067efed7eacbfcdc8946cf22de45ad536ec0719034fb9bc825048fe6ab61fee5bd6e9aae0bb279738d46673c53d68eb2a72da6dbff215ee41a4d405a74ff7cd355805b"); // $ fiat/bots txMoMproof $proofTxHash
/*
TEST(TestEvalNotarization, testGetNotarization)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetupEval(eval, notary, noop);
NotarizationData data;
ASSERT_TRUE(eval.GetNotarizationData(notary.GetHash(), data));
EXPECT_EQ(data.height, 77455);
EXPECT_EQ(data.blockHash.GetHex(), "000030ef29d072f417cec86ad5a5ab4f8c413c7f96f572a098e45d6e3e0f8eae");
EXPECT_STREQ(data.symbol, "BOTS");
EXPECT_EQ(data.MoMDepth, 5);
EXPECT_EQ(data.MoM.GetHex(), "88289b6566a48567f65c8e60ca65b7f3877bbdb97cfc3958da31bcf073a70b05");
MoMProof proof;
E_UNMARSHAL(vMomProof, ss >> proof);
EXPECT_EQ(data.MoM, proof.branch.Exec(proofTxHash));
}
TEST(TestEvalNotarization, testInvalidNotaryPubkey)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetupEval(eval, notary, noop);
memset(eval.notaries[10], 0, 33);
NotarizationData data;
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
}
*/
TEST(TestEvalNotarization, testInvalidNotarizationBadOpReturn)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
notary.vout[1].scriptPubKey = CScript() << OP_RETURN << 0;
SetupEval(eval, notary, noop);
NotarizationData data(0);
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
}
TEST(TestEvalNotarization, testInvalidNotarizationTxNotEnoughSigs)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetupEval(eval, notary, [](CMutableTransaction &tx) {
tx.vin.resize(10);
});
NotarizationData data(0);
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
}
TEST(TestEvalNotarization, testInvalidNotarizationTxDoesntExist)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetupEval(eval, notary, noop);
NotarizationData data(0);
ASSERT_FALSE(eval.GetNotarizationData(uint256(), data));
}
TEST(TestEvalNotarization, testInvalidNotarizationDupeNotary)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetupEval(eval, notary, [](CMutableTransaction &tx) {
tx.vin[1] = tx.vin[3];
});
NotarizationData data(0);
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
}
TEST(TestEvalNotarization, testInvalidNotarizationInputNotCheckSig)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetupEval(eval, notary, [&](CMutableTransaction &tx) {
int i = 1;
CMutableTransaction txIn;
txIn.vout.resize(1);
txIn.vout[0].scriptPubKey << VCH(eval.notaries[i*2], 33) << OP_RETURN;
notary.vin[i].prevout = COutPoint(txIn.GetHash(), 0);
eval.txs[txIn.GetHash()] = CTransaction(txIn);
});
NotarizationData data(0);
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
}
} /* namespace TestEvalNotarization */

View File

@@ -1,54 +0,0 @@
// Copyright (c) 2016-2024 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <gtest/gtest.h>
#include "cc/eval.h"
#include "core_io.h"
#include "key.h"
#include "testutils.h"
namespace TestParseNotarization {
class TestParseNotarization : public ::testing::Test, public Eval {};
TEST(TestParseNotarization, test_ee2fa)
{
// ee2fa47820a31a979f9f21cb3fedbc484bf9a8957cb6c9acd0af28ced29bdfe1
std::vector<uint8_t> opret = ParseHex("c349ff90f3bce62c1b7b49d1da0423b1a3d9b733130cce825b95b9e047c729066e020d00743a06fdb95ad5775d032b30bbb3680dac2091a0f800cf54c79fd3461ce9b31d4b4d4400");
NotarizationData nd;
ASSERT_TRUE(E_UNMARSHAL(opret, ss >> nd));
}
TEST(TestParseNotarization, test__)
{
// 576e910a1f704207bcbcf724124ff9adc5237f45cb6919589cd0aa152caec424
std::vector<uint8_t> opret = ParseHex("b3ed7fbbfbc027caeeeec81e65489ec5d9cd47cda675a5cbb75b4a845e67cf0ef6330300b5a6bd8385feb833f3be961c9d8a46fcecd36dcdfa42ad81a20a892433722f0b4b4d44004125a06024eae24c11f36ea110acd707b041d5355b6e1b42de5e2614357999c6aa02000d26ad0300000000404b4c000000000005130300500d000061f22ba7d19fe29ac3baebd839af8b7127d1f90755534400");
NotarizationData nd;
// We can't parse this one
ASSERT_FALSE(E_UNMARSHAL(opret, ss >> nd));
}
TEST(TestParseNotarization, test__a)
{
// be55101e6c5a93fb3611a44bd66217ad8714d204275ea4e691cfff9d65dff85c TXSCL
std::vector<uint8_t> opret = ParseHex("fb9ea2818eec8b07f8811bab49d64379db074db478997f8114666f239bd79803cc460000d0fac4e715b7e2b917a5d79f85ece0c423d27bd3648fd39ac1dc7db8e1bd4b16545853434c00a69eab9f23d7fb63c4624973e7a9079d6ada2f327040936356d7af5e849f6d670a0003001caf7b7b9e1c9bc59d0c7a619c9683ab1dd0794b6f3ea184a19f8fda031150e700000000");
NotarizationData nd(1);
bool res = E_UNMARSHAL(opret, ss >> nd);
ASSERT_TRUE(res);
}
TEST(TestParseNotarization, test__b)
{
// 03085dafed656aaebfda25bf43ffe9d1fb72565bb1fc8b2a12a631659f28f877 TXSCL
std::vector<uint8_t> opret = ParseHex("48c71a10aa060eab1a43f52acefac3b81fb2a2ce310186b06141884c0501d403c246000052e6d49afd82d9ab3d97c996dd9b6a78a554ffa1625e8dadf0494bd1f8442e3e545853434c007cc5c07e3b67520fd14e23cd5b49f2aa022f411500fd3326ff91e6dc0544a1c90c0003008b69117bb1376ac8df960f785d8c208c599d3a36248c98728256bb6d4737e59600000000");
NotarizationData nd(1);
bool res = E_UNMARSHAL(opret, ss >> nd);
ASSERT_TRUE(res);
}
// for l in `g 'parse notarization' ~/.hush/HUSH3/debug.log | pyline 'l.split()[8]'`; do hoek decodeTx '{"hex":"'`src/hush-cli getrawtransaction "$l"`'"}' | jq '.outputs[1].script.op_return' | pyline 'import base64; print base64.b64decode(l).encode("hex")'; done
}