tests: (in)valid unit test vectors against IsTriviallyValid() evo calls (#4660)

* evo: resolve suggestions given in dash#4696

* evo: add known-good mainnet vectors for IsTriviallyValid()

* evo: add artificially malformed vectors for IsTriviallyValid()

* evo: add IsTriviallyValid() tests

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

* Make sure we deserialize the right type of a special tx in GetTxPayload, and debug assert

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
Kittywhiskers Van Gogh 2022-03-06 12:24:26 +05:30 committed by GitHub
parent f7159d8520
commit 80777646d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 350 additions and 3 deletions

View File

@ -69,6 +69,8 @@ JSON_TEST_FILES = \
test/data/proposals_invalid.json \ test/data/proposals_invalid.json \
test/data/script_tests.json \ test/data/script_tests.json \
test/data/sighash.json \ test/data/sighash.json \
test/data/trivially_invalid.json \
test/data/trivially_valid.json \
test/data/tx_invalid.json \ test/data/tx_invalid.json \
test/data/tx_valid.json test/data/tx_valid.json
@ -144,6 +146,7 @@ BITCOIN_TESTS =\
test/dynamic_activation_thresholds_tests.cpp \ test/dynamic_activation_thresholds_tests.cpp \
test/evo_deterministicmns_tests.cpp \ test/evo_deterministicmns_tests.cpp \
test/evo_simplifiedmns_tests.cpp \ test/evo_simplifiedmns_tests.cpp \
test/evo_trivialvalidation.cpp \
test/flatfile_tests.cpp \ test/flatfile_tests.cpp \
test/fs_tests.cpp \ test/fs_tests.cpp \
test/getarg_tests.cpp \ test/getarg_tests.cpp \

View File

@ -17,6 +17,7 @@ class CValidationState;
class CCbTx class CCbTx
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_COINBASE;
static constexpr uint16_t CURRENT_VERSION = 2; static constexpr uint16_t CURRENT_VERSION = 2;
uint16_t nVersion{CURRENT_VERSION}; uint16_t nVersion{CURRENT_VERSION};

View File

@ -1190,7 +1190,6 @@ bool CDeterministicMNManager::UpgradeDBIfNeeded()
return true; return true;
} }
// Seperate into new file?
template <typename ProTx> template <typename ProTx>
static bool CheckService(const ProTx& proTx, CValidationState& state) static bool CheckService(const ProTx& proTx, CValidationState& state)
{ {

View File

@ -1,3 +1,7 @@
// Copyright (c) 2018-2021 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <evo/dmnstate.h> #include <evo/dmnstate.h>
#include <evo/simplifiedmns.h> #include <evo/simplifiedmns.h>
#include <evo/providertx.h> #include <evo/providertx.h>

View File

@ -48,6 +48,7 @@ public:
class MNHFTxPayload class MNHFTxPayload
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_MNHF_SIGNAL;
static constexpr uint16_t CURRENT_VERSION = 1; static constexpr uint16_t CURRENT_VERSION = 1;
uint16_t nVersion{CURRENT_VERSION}; uint16_t nVersion{CURRENT_VERSION};

View File

@ -30,6 +30,7 @@ struct maybe_error{
class CProRegTx class CProRegTx
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_REGISTER;
static constexpr uint16_t CURRENT_VERSION = 1; static constexpr uint16_t CURRENT_VERSION = 1;
uint16_t nVersion{CURRENT_VERSION}; // message version uint16_t nVersion{CURRENT_VERSION}; // message version
@ -98,6 +99,7 @@ public:
class CProUpServTx class CProUpServTx
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_SERVICE;
static constexpr uint16_t CURRENT_VERSION = 1; static constexpr uint16_t CURRENT_VERSION = 1;
uint16_t nVersion{CURRENT_VERSION}; // message version uint16_t nVersion{CURRENT_VERSION}; // message version
@ -137,6 +139,7 @@ public:
class CProUpRegTx class CProUpRegTx
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_REGISTRAR;
static constexpr uint16_t CURRENT_VERSION = 1; static constexpr uint16_t CURRENT_VERSION = 1;
uint16_t nVersion{CURRENT_VERSION}; // message version uint16_t nVersion{CURRENT_VERSION}; // message version
@ -187,6 +190,7 @@ public:
class CProUpRevTx class CProUpRevTx
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_REVOKE;
static constexpr uint16_t CURRENT_VERSION = 1; static constexpr uint16_t CURRENT_VERSION = 1;
// these are just informational and do not have any effect on the revocation // these are just informational and do not have any effect on the revocation

View File

@ -27,12 +27,14 @@ inline bool GetTxPayload(const std::vector<unsigned char>& payload, T& obj)
template <typename T> template <typename T>
inline bool GetTxPayload(const CMutableTransaction& tx, T& obj) inline bool GetTxPayload(const CMutableTransaction& tx, T& obj)
{ {
return GetTxPayload(tx.vExtraPayload, obj); ASSERT_IF_DEBUG(tx.nType == obj.SPECIALTX_TYPE);
return tx.nType == obj.SPECIALTX_TYPE && GetTxPayload(tx.vExtraPayload, obj);
} }
template <typename T> template <typename T>
inline bool GetTxPayload(const CTransaction& tx, T& obj) inline bool GetTxPayload(const CTransaction& tx, T& obj)
{ {
return GetTxPayload(tx.vExtraPayload, obj); ASSERT_IF_DEBUG(tx.nType == obj.SPECIALTX_TYPE);
return tx.nType == obj.SPECIALTX_TYPE && GetTxPayload(tx.vExtraPayload, obj);
} }
template <typename T> template <typename T>

View File

@ -106,6 +106,7 @@ using CFinalCommitmentPtr = std::unique_ptr<CFinalCommitment>;
class CFinalCommitmentTxPayload class CFinalCommitmentTxPayload
{ {
public: public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_QUORUM_COMMITMENT;
static constexpr uint16_t CURRENT_VERSION = 1; static constexpr uint16_t CURRENT_VERSION = 1;
public: public:

View File

@ -0,0 +1,57 @@
[
["Transaction Hash,Transaction Type,Transaction Data,Notes"],
[
"34689d74e8b6dcf794e399f034dc124751d2d14c70be05ea3f1524d24fa97d41",
"proregtx",
"03000100010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000fd1201010000000000a118920655e3b87bea5b066e45ad5a02e55ff9eee970eaad9097371579d35f020000000000000000000000000000ffff0363a5fc270f85b0c1edc20ec4437ab5f936a7e1691498dd0a73819b06c0c3b7b7f48373244aff72171ec3fa982cd5b8c8f57e411cc1e6463ba260280cbe4d3e3a31d4c6d24be6d4f58406e8e188526a5ba38bcafc6fdd191ccff20b9dc100001976a91485b0c1edc20ec4437ab5f936a7e1691498dd0a7388ac9dcd2d150b6e2348a6c13c99b2e9d761feb0c4db1670e990e2da81c8b0d24bcd416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Transaction with keyIDOwner and scriptPayout using the same address"
],
[
"7e8ae3e4f97691ff8966bafabf4aad72c6de53f943683db295ac386ed731be6d",
"proregtx",
"03000100010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000fd12010100000000000b89a4a2c40bc0992a71fe5cb62fe361cade298efcc7016db1c825128f7b89250100000000000000000000000000ffff58630b1f270fffb6ea3b32fd801dbe11597d221c5d20f22e26b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001976a9149cb70b0143c834ac6cd1c6598eeb9756e786ca5088ac8ee3de540f3808bd3a9493032865d3058acae9237e608e952fbc6831d413fe35416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Transaction with valid keyIDOwner and invalid keyIDVoting, pubKeyOperator"
],
[
"2686f47dd694aab6abe53c1eeb2e3af427527c47bcbbb642a7681f5f830759fd",
"proregtx",
"03000100010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000fa010000000000f8f78f64327dd795e13b9104557507202a2ce4c863f37792accd07c7d73cc8a50100000000000000000000000000ffffae22e9cb270fbe28fa180835be8c4ecb6068d22d1cc4ce83eac988b4342a1c9996f56589cf46fdb7372b37a0dcb56252acca3c56e17b87eb21d6d2bffb3a27fc641bc98f2574762f6bf409c7deb3962b8df8f61961747570589b9a4b56ae0000016ad399091458f5b3764889c16e3ea191f9409c1feb78520a68af4918bd2c3aa0b3416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Transaction with scriptPayout neither a P2SH nor a P2PK"
],
[
"4edaeceb793b22b40ef6cd609d6e96edea523fee7f02a23609656d4b0a894798",
"proregtx",
"03000100010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000fd120101000000000037834e505aa17140ce446c4f2e6d9af0a4d97322d811b548de5121069c87acd00100000000000000000000000000ffffb009d205270f48ecfbd2b4447d51a4cb25e7e7cf42b307b7fa79018cdbd7e89a3b0f51a72c418b11ff31552fd5aca89bb5832085bfc6f8f46632297b0721eb206c508be82793697756467bdb5f1ddf0324078619d07c7312af05fdac5a8bffff1976a91452e222a92dadbd15031f1b1ca1a74d14e165bbad88ac8e4145c64752863d1fadcc2c073038d234c15b480b3992585e844ef491112299416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Transaction with operator reward set to uint16_t numerical limit"
],
[
"9827a1ccbf225f9e4faf4db78d2529ee611d133e9cd2974446b0a38a409aa957",
"proupregtx",
"03000100010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000fd12010100000000003c55913dfbc2dc0fcbf97f992550685a39980a6f0de715352ee05af52b466b330100000000000000000000000000ffff05bd9f5e270f03e6d2bd33e88835e8995fc6d570f30bd24e20dd0074a43322d7c92ca3523b14f4eedc97f1b083977ac21d7483d9b34f32782e76b3e3bfe2bd089794f927d6443796d05d03e6d2bd33e88835e8995fc6d570f30bd24e20dd00001976a914f95848adc4ae65097342682646d98a1469e8597488ac41cf0fbc60088337c47157528fff425645879561f6628c9c095bde959bef3abc416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Valid proregtx transaction mislabeled as proupregtx"
],
[
"299767699266aa16f38176037c393e093f03dbfa5429e76ad4f756f70b22ff5b",
"proupregtx",
"03000300010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000e40100b2d3e8dea42b9c8331472962bb36dea7b684b0f6dc8f5869c80fc24936199a040000934e4e541c310c2d17df7b48040d6ae9446fab9530abcbebdd1b46d847a5b4f8898057060143436dc7003e1e6fd9bf4500000000000000000000000000000000000000001976a914b9a701d799b3d96b91a4d0311fb39c29ebad98ed88ac280b34567afd60136868e50b86db2c7e35510ed9072fe34439b9e665f9cc6492416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Transaction with invalid keyIDVoting"
],
[
"95cb5e1af901021c776b9dc43147924502e05301ba9aa9e32e9eb0abc1daa910",
"proupregtx",
"03000300010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000e40000bfd280d22a21574ea9f568f7a729b370f4051b89eab6df3d0d74b65fde1bdb7900000a6a7fb814db71eb6ef12341749d81b5fd326eb4b9445a3be65668da9856910b378ec6427fe18fc81c39499e7c7060647618f8ec94404051e4a7ab68f1b017fd9e7f94761976a914c18e0b18e0d992e7471d8a4d4da428e8e191328788ac959ca83b61eeb3f5543973253da6da8e9ac23f9e7844453ac5543b51d0177799416666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666",
"Transaction with version set to null"
],
[
"943d178782e22b573897d8d1835ac388d80d2ca5d6efcc72b32d7d83940a3c5d",
"proupregtx",
"03000400010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000a40100886e39ad019694721b7ab5b5523b5f6374cc7c322410681c7f897ab9bc4098be00000c5d4e38678fee4f0e2386609f31f40a41390a9fdc65bfa8e54157c84123eede9308be92875d1c8f52f9b28215dbc95b3006f0cc8e2f410ced1ed1d6722287978ecbab0a19ab84d6025dfb6dfaa27d2a0dc0180833577674621930a3ea6fd44e3f461dd9b5b6f79c786958d3e6045c2d9eb57629c2c2daf5403690b61ccdfe94",
"Valid prouprevtx transaction mislabeled as proupregtx"
],
[
"e0aef1c6faa5d1f640355c2a9b41b72a4969bb8227f09c4900271ee1c9ef49a3",
"prouprevtx",
"03000400010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff0100f2052a01000000016a00000000a401005f6d5e103c0f35f091201d9b7f26bc8a81ec870b2b1167021b08fc32dbd192aeffff81a667e71154308cc67481aa7da40f3cbfa48dca9075832e5c5977ab56c193c51286f9b11119a67e8c85eb57843f29655a97d41012c030204d09c6032006b8e49efd6c449580f8e49f553a22dba78d3306bcf18015a4eced33c19e43d1932522655e1f70e0f4409e7cf836a1f8ca609952c4b459f75e93f6aeb2a094e5485617",
"Transaction with reason set to uint16_t numerical limit"
]
]

View File

@ -0,0 +1,123 @@
[
["Block Height,Transaction Hash,Transaction Type,Transaction Data"],
[
1594740,
"f28601f92fbf3800b2d81d22718eb11d307cfe60f313e0b63f832d000af3788a",
"proregtx",
"030001000134689bc96274e335273043923ff6d3942ed1be84c673e7efc5295fd167dcb6eb000000006b4830450221008f174b6e420574f9afa990be19bfb1660a81c290b1e9e2815341ea923030d0340220388fae928978aa138f108618fca73ac00d36c21fa2b04b6cc5bc8b83683f0cdd0121023f7cb709dff357f8db3d49a370ee3995982b1968f73ac283df627fe20c67cfa4feffffff011aec0c00000000001976a9141d19c43cd1e46597d5241b452397bae3924d6a4b88ac00000000fd1201010000000000a118920655e3b87bea5b066e45ad5a02e55ff9eee970eaad9097371579d35f020000000000000000000000000000ffff0363a5fc270f22f092f9e8362d961f235d7efcf87bdb88266722819b06c0c3b7b7f48373244aff72171ec3fa982cd5b8c8f57e411cc1e6463ba260280cbe4d3e3a31d4c6d24be6d4f58406e8e188526a5ba38bcafc6fdd191ccff20b9dc100001976a91436d200f8160d3c882746c8771f3c7efdbf2889b488ac9dcd2d150b6e2348a6c13c99b2e9d761feb0c4db1670e990e2da81c8b0d24bcd4120e52d81fdc98e13835d9cdc395a6f7d8ec91c15b1d3ce1e5ccb1dc990199abe3e154856fc7157f024d2b791b8d0c6657c0e766e43d8834ebc571ba2283077a8f7"
],
[
1594090,
"797eca1df452270e9de965b010a1ac25c2421c46a0aea56fa55efb1e98668aca",
"proregtx",
"030001000171095fff940615dbdc2589307b13b1bf56a72ca0980bbbbdc8c8a18d5ff9bdc7000000006a4730440220652d5910a827ab1f8b8fa096b48cee2ed2e3ac3b0cd1ef522879ad9204c5587602203a6d143d331738e4ef32767f723a75b22a3b8667bd106ca6e120ed89de2fecd3012103281ee4cd3353e42cfaa91542a350c8fafc5d6dddffcd96d736b655467d6fe496feffffff01460a0d00000000001976a914ccb5def83a3208faad1b9a416cf2d7ba1a9f9a3f88ac00000000fd12010100000000000b89a4a2c40bc0992a71fe5cb62fe361cade298efcc7016db1c825128f7b89250100000000000000000000000000ffff58630b1f270fffb6ea3b32fd801dbe11597d221c5d20f22e26b692058ad273ac46e18e4f43a20b5bcfbabdcded712d80387eeabaf190d4351f45749db9a9d1bf4e13e4ae946a03ed4015fdeccf6fc878479f1f26f2ab8de502cef4a789f700001976a9149cb70b0143c834ac6cd1c6598eeb9756e786ca5088ac8ee3de540f3808bd3a9493032865d3058acae9237e608e952fbc6831d413fe35411ffe93d28939a313ee30419344dc5dc2818bcdd02b4ac73848f560b15be06de4d44cb10ad33c45f40feb77eafed8d8bddf195f2ffbb8f14c20052d4dfa22b346cc"
],
[
1594440,
"c63a1caa6e08b9658f960542f525d15fbab5304f11c96a501dd8c512926f5cd3",
"proregtx",
"0300010001ac2466d77c8816bb2611e041c8814aaa7e9f21937471d84df906e2bcef0f030d000000006a4730440220020b61d3d596f7e897f853c28bbe3c4409070b030b28f8540d9a557fa692beae0220337b15ab5876d1cf7b8fbf8cc314bad8a71e76d312d74cfb240d2cf356de209a012103cbf002bface3fda70e49a6a7e40dd1cf6de6a73a456be34a0d4031ed891cbe0bfeffffff018d1c0100000000001976a914be28fa180835be8c4ecb6068d22d1cc4ce83eac988ac00000000fd1201010000000000f8f78f64327dd795e13b9104557507202a2ce4c863f37792accd07c7d73cc8a50100000000000000000000000000ffffae22e9cb270fbe28fa180835be8c4ecb6068d22d1cc4ce83eac988b4342a1c9996f56589cf46fdb7372b37a0dcb56252acca3c56e17b87eb21d6d2bffb3a27fc641bc98f2574762f6bf409c7deb3962b8df8f61961747570589b9a4b56ae00001976a914b0d133665df60bd2bc70ae25ffa732e999e6008c88acd399091458f5b3764889c16e3ea191f9409c1feb78520a68af4918bd2c3aa0b3411f2e6da088ab945de27c3ff3a0614f6d842b25f4b06a50879af1bfd3b9098b511914d7e34fc73123e704551d4a4279972fb1b84e71e8c0758394707d5f4432a5a3"
],
[
1591360,
"cbafe0ff324859af375eae0d6eb62c8a6cb5d546c6afdbd1f4b5024d4691293c",
"proregtx",
"0300010001642dc0e287a716990134e899137b9e9774db7da7792045522346c0925c4c0570000000006b483045022100df59edbae25af070936d6ac94da410a4688d4932def9a143e45190e66a16715b02205af22c1158303390e82d09fb66e873cfd37c49b579c94ef1d9caec64456d991b0121035ffbab73725c430b2904c10563007c5047257aae6caefcda4b47ed70c03b2f6efeffffff0157d58300000000001976a914b734da3d63094c95589fcf9252cd8d9c46eebafa88ac00000000fd120101000000000037834e505aa17140ce446c4f2e6d9af0a4d97322d811b548de5121069c87acd00100000000000000000000000000ffffb009d205270f48ecfbd2b4447d51a4cb25e7e7cf42b307b7fa79018cdbd7e89a3b0f51a72c418b11ff31552fd5aca89bb5832085bfc6f8f46632297b0721eb206c508be82793697756467bdb5f1ddf0324078619d07c7312af05fdac5a8b00001976a91452e222a92dadbd15031f1b1ca1a74d14e165bbad88ac8e4145c64752863d1fadcc2c073038d234c15b480b3992585e844ef491112299412029e7808bac94bea561404fc48007eaa098b72f753e40550d898748e4e335204b5c4dc400afcaf183399bec293ca24cd630738ee71a1e5aaed73424f88aaae7a2"
],
[
1588250,
"51ff7ae8dcaf2bf44df94fc52509e4ac9836f5055e8d6872296e22d31825a1ff",
"proregtx",
"03000100016da331eb9a8cf1bab5ba71c5ff7151f3de4d3fd8c95864eeef887923729c2188000000006b48304502210092859658447910a192d40bfad5110d1b80c5d6457b9fa355a8f5bd343a7b4f530220042f60c3c5e831c800988c1020358ddafb1e67e017ed71107df53d313170e80b01210387990236f115c2b247eaa72471553d361e2fec355f26562eb03ba377024a7647feffffff01636da20a000000001976a914c533c9f87daf84c5c0e71aaa43478c82f68d7d6c88ac00000000fd12010100000000003c55913dfbc2dc0fcbf97f992550685a39980a6f0de715352ee05af52b466b330100000000000000000000000000ffff05bd9f5e270f03e6d2bd33e88835e8995fc6d570f30bd24e20dd0074a43322d7c92ca3523b14f4eedc97f1b083977ac21d7483d9b34f32782e76b3e3bfe2bd089794f927d6443796d05d03e6d2bd33e88835e8995fc6d570f30bd24e20dd00001976a914f95848adc4ae65097342682646d98a1469e8597488ac41cf0fbc60088337c47157528fff425645879561f6628c9c095bde959bef3abc4120acfb864b3799182573ab608a01626fd91e615e6a2407e2d7f6a5ec764ce070b648cb78fa7da671d41363e35863e5ae28171d5737e74bf7db89c1fa81712f83d3"
],
[
1593105,
"b964ca0256d6ff8f8d4d1f0a54540e4d6d14f93eba1b0d5cd9e819a8d37b99ab",
"proupregtx",
"0300030001aa70bc819c1acddd527aadc37fd749e139aa686289517a2e543adc8bfd302428000000006b483045022100ab2262a3dee26453db6affbfd76a3350a89e2fd1b226ecc67d992a2818da768c02201e9d3abbcf50041dc3dea81c6068da649f639d10589e9bb0655a452edc07ed16012103a70c4fcb542b8487831e87647a380b4ce1d6313fafb96ea84e98c632e4d8e0a9feffffff01ef260f00000000001976a9143c5ef681be10b283c0f5ed32ddd40a6ee66e01a688ac00000000e40100b2d3e8dea42b9c8331472962bb36dea7b684b0f6dc8f5869c80fc24936199a040000934e4e541c310c2d17df7b48040d6ae9446fab9530abcbebdd1b46d847a5b4f8898057060143436dc7003e1e6fd9bf45b2603eb918241134ab0e867f2875349218ce2d761976a914b9a701d799b3d96b91a4d0311fb39c29ebad98ed88ac280b34567afd60136868e50b86db2c7e35510ed9072fe34439b9e665f9cc6492411fa38ef65a72aeae489356fa0dcf2600804d892084389f9cde69d2a1c8c53d4e490e4ddad15448f27b8360b116e322b1c6abd7ba1113845fea69e55d77b6ac83b4"
],
[
1592060,
"cb8915031154c2b4057ddda5539b73556ae60f690e7bf11592ef10b9cc39722f",
"proupregtx",
"030003000116e0d92f7312b986e599e2d1ae666919abdb56d27ff64e28c7133ebe887d35b6000000006b483045022100ca9f9d549e2fb92d8e8b7948b8a6164ee7d1c068552c6c2e48669888de82d24d022036e70a6e80f4242bb242977ebc1b47076614b37c58f4ac981e7bad76e075aae2012102e2f8099a84f13f9e8e5d784567d49df919ec63764966738df83371c66ff534f6feffffff019f6a9800000000001976a914bcc00fdff28f1b7b85ec5135b7a2d8c800a5c01888ac00000000e40100454bce26dde61cce5a8190928ed2af0f95c5bc053c88170b1a653028b36a29a3000004c4952bba25bc5f87212d46254c5988194252157d921bbf0c771c6afa1e45219f20fa5c7de1f62edf43e232d3d4971ac99a89fcafd3a4729860b2f9cd2ba4a7d965e9271976a914ff95da123f7ee853f9ebd2b4a119026eeee5697688ac78bc35cc2794f77e2ea7441dc7573da1c83070cd776cda6f512964b4d278b7bb411f3e08fda0f04bcb8e8aeab2ffbf11d511ae78625c07bb0fd1b1260d64eb609b3e31ed44c8a4ee7b6fdd641f060d4bb8ebbe9de97403f38136a3b25046611279a8"
],
[
1576600,
"0d1db128f08aef93aa10df7fa9d2dd76dab2b6afbe1c3721a804d56e58e0be0c",
"proupregtx",
"0300030001a583e1c377f5c91ba7b46e246eef97a50eca48b7bf7664f486d263d6e0c22d1a010000006a47304402200a27f192ee0cdf2a3197127e450561661f3cea1292de01997ad95dcee8a94ce802204fc31ea24d2dbeebf18ad3882016b8d916109f6c2f02bee8533aa93b89959a9a012102090776325cdf1716f74a905c5e0c31ce810ea8cf9dca498a69aa5ec969a4b1a3feffffff015818a208000000001976a9147cb8d12b3eb59e4a73d6ae11c585570f0801e6da88ac00000000e4010051233f57404f07f850a13b469779462ac67b38dd4c9991d06729faaa30e099280000036382e6ceed79b7c8389090696ffba5e3f179aed1b7194679c9f3b9995d50eff2dbc022b464b7596a0a2c83d62f0c684e5bc32f03ad77caaeb67f17e7cf23ddd1a0934f1976a91482a70bc6686460da2adac79853b0c6b6a95d3b0088aca2f6bd516974b885731efc9292186bd53c2fa157f431c6dd81c0e6c44f3c4dbf411f407829c1399588041178bc6bcbacb67fd85d512a5d54c214be4dd66596556ba474a18c48219ea53f8405e54ea942eb65f456486bc3c9fd9cb05a8a718603cdda"
],
[
1571555,
"5137ab4754585dba7251f8fb27f268898110c912d3d9e6986022233ed88ab7d7",
"proupregtx",
"0300030001e73c9bdecd42c8e0d0e26f502e828dd833c67a0951fb1ca598e5319d61952ecb000000006b483045022100b6fae24eff9eb3af19f37fd569ece07aa9f0156b8ca60d49490476c31991fd5e022035ef72bd3412f5227008625df70fc1ab97bd0e802f60654a64777959372a9aec012103f4e143e0ad58b3b710d867acc58c5e2c44a1c378cd959c363808dbc222bb20fafeffffff0125f30800000000001976a9145a9a1dd769f834237d287a363d32407bf4b10a0288ac00000000e40100bfd280d22a21574ea9f568f7a729b370f4051b89eab6df3d0d74b65fde1bdb7900000a6a7fb814db71eb6ef12341749d81b5fd326eb4b9445a3be65668da9856910b378ec6427fe18fc81c39499e7c7060647618f8ec94404051e4a7ab68f1b017fd9e7f94761976a914c18e0b18e0d992e7471d8a4d4da428e8e191328788ac959ca83b61eeb3f5543973253da6da8e9ac23f9e7844453ac5543b51d0177799411fab7445ec7a7e22075d975b8c901ec4646e97a93094d045538cf102c0505e877344cc7b89256cfa985a90fa32f591955b8a66921ce56edd0776a7b3cde4b92d00"
],
[
1569500,
"f62dcef6bbef99a860efe2ca80cfc2bec7e152e1f42f447fe92910db218f8c74",
"proupregtx",
"030003000197c3ae1f005cd251e1789c3e1437efbcc2489bd495c04d115e38f1fa6b199124000000006b483045022100efcd65f687bab7b523d95b40d616c686a9e87449c8920b745fcc31b3468846f9022078644ba47f00096bfe6773dbaf092411cc73e3d5d11add73b370935ac08bf78e012102cd8a6648c4a8760cfc53748211329d025aa326179ee53d19449e74f4c309bfc9feffffff01683c0f00000000001976a9144904383953418cc9323616a0d77be9584c7aa41288ac00000000e401009e3e0020383204408a8a0c36232ea12c7a84ca6de444e1ef7be059bf1298cfa300008b4c95d9668b052c0931cf5f2bf5847701faab6db85953a947eea8695b0a7f452b149cd95a1c813ca5af75b1208199e336f0f27a6801a540ccd448fd6f210211cfe775271976a9144904383953418cc9323616a0d77be9584c7aa41288ac56c53ba577c2d59cb29b5a8ee0622e0c903dbad674dafedb6d5d36d0a16de86041202f2d8ff3beb1ccf3ac07958fa9b52b5e62012a4b193312773cf033e251d5bccf157d1b8cd65aa1b63cc864c091c82477202826ab78285db42155322a71e99612"
],
[
1540480,
"ee024cb04f8fe6b14cf167a27fd27b9dae0e3366f7e0036e288decb4950b1273",
"prouprevtx",
"0300040001cbe759110b0d274b88036e8b8af6dfcb1c1f5a0a5fabfcc5caa7f81312000a0c000000006b483045022100aaf64ea5f6facf79b554e6a2fa3c8cfb7598bb4382ba5aba459e37de0fc535c1022044cd82041153069d8ab4be6f29039c22b24c85fc4add580163ed3b04da32e18a012103fad50b85a93404d09202e335d213662c615ba901f77d34f53b3dfdadbf691b04feffffff01376f0a00000000001976a914bccdc47c9e264e51861f8625909ffd388314b2af88ac00000000a401009b2cce50aca32c5d65d4524fe69552df2610a7b98adf5975edd974fa7c16b0120100db7e5f113b3ac3204a149c75f939144d19c1890bc050f7871b103f6ab371ad9b09f6d212f005b212780fd9333b38c60a836740909d362ff4fdf95d84e34ce32df7b14b9784a652d77c4bc14ec456b556178e4b84cda2939d9806f0393898a282829dcae0e66c21ee0109b8e2f8e84444774cfd8cc352836c6fd32a47887261f5"
],
[
1451970,
"8c4b2d36a85d07e05be6a347f1988bd3f71792669844034805b8f6dc16e7d596",
"prouprevtx",
"03000400012c47562af46af6c7b9497aa54e7f8ad2d1af8ec0d874556627ad5bda2c14cb96000000006a47304402205b73e0925fcbc2e800c1843d59d5e3fc3ef439e0e8280611b83cf931cd77f0ba022019fced5a08ca43fe6e1ed970b742fcdb0b6e3dd131afc9be8b883713e4eb888001210345a3b3b6baabb3825b21cf37835eb20f5f5f38d77bbbb0b5e10a8b5beeb1db2dfeffffff0122d90d00000000001976a9148e5eedfa911f6ab9810eee0c1fb5141556adb60988ac00000000a40100886e39ad019694721b7ab5b5523b5f6374cc7c322410681c7f897ab9bc4098be00000c5d4e38678fee4f0e2386609f31f40a41390a9fdc65bfa8e54157c84123eede9308be92875d1c8f52f9b28215dbc95b3006f0cc8e2f410ced1ed1d6722287978ecbab0a19ab84d6025dfb6dfaa27d2a0dc0180833577674621930a3ea6fd44e3f461dd9b5b6f79c786958d3e6045c2d9eb57629c2c2daf5403690b61ccdfe94"
],
[
1414570,
"d88a40a66f6f86dc9000ab1da86cbedb7e04c0b6005cf804d6067d1f588c6d87",
"prouprevtx",
"03000400011dd4f548292ede5d321894766b86de12cfec95d7889c9069c2f711fc33d2fd80000000006b483045022100e493087fb89e2ba6b8a05e8de5dbf7b7d15dbf9a4f4490c27ca9e2fc5f6d6c2e022067277379b2481c7d005a3749d6e934d42f0d1fccc81d07f1a8f4107f8fd25b1b012102e5ee0d3a180a769d0d711407098047a1b7b66160c6174576ed5b970e72774e6efeffffff01db430800000000001976a914a440fd010c5cba8de70f88f99f3de14027ed5f9e88ac00000000a401005f6d5e103c0f35f091201d9b7f26bc8a81ec870b2b1167021b08fc32dbd192ae010081a667e71154308cc67481aa7da40f3cbfa48dca9075832e5c5977ab56c193c51286f9b11119a67e8c85eb57843f29655a97d41012c030204d09c6032006b8e49efd6c449580f8e49f553a22dba78d3306bcf18015a4eced33c19e43d1932522655e1f70e0f4409e7cf836a1f8ca609952c4b459f75e93f6aeb2a094e5485617"
],
[
1367845,
"ef8e71d71aa47d4e5db736b98e048e98125ab4af5ff69f6476b347b777866c80",
"prouprevtx",
"0300040001a8388cf36b85d508657a618c559f3dfc69a299790ea2b65518786fd9032ab24f000000006b483045022100af673336f4eece9e875c770b06097511b73e88b99fb3392d18a8bc235b1bd29e02205e4388ed67837448634802940cfa28029e7a7ce562a61d09fa650d69a40f7c16012102e5ee0d3a180a769d0d711407098047a1b7b66160c6174576ed5b970e72774e6efeffffff011f700b00000000001976a914a440fd010c5cba8de70f88f99f3de14027ed5f9e88ac00000000a40100c012075c6ccf5d1b22d1c879de2fd117f7262d0c0b84aeb0b92805bd790c277b0100c7c030bcebe02d9d9e4f76bc34af09fdb29b8389a8c8d0165b68e81b3b8c59ce08d74782e2208b28db011f0ea94fc970b7a2a141f46a04ccc5f16454f02d81ee15ff859b2ab0a940a41141251ccc9e13196cfe26bd856da7df83d43c014e9afe3a5454430271e0c6847e6adadd1e569ac335ec8301a7c6a2559b26c93f376244"
],
[
1235005,
"cf4887cf5d42a0635096ea4932d0c58551e2d3e10467fc7e9d879d0c1597cc83",
"prouprevtx",
"0300040001bec7ff3e4ea5d60f71806d493139e11a56ba011f9d29800282a1fd2943e61d77020000006b483045022100a41ffd729fd6ea218f0a099add8da7462ef9211e06ea5d4c5db5c550c45621f502202cd72905f1d523deb01c261cc3e737c33dd3f4d772f2c81e49a5253cb3a7442e012103baf97c26d6ed28efbb997b92dd3adeb94d3b386b07307942a50881e98e9edaf5feffffff0131850100000000001976a91467a94ff45092cc8297f05bfa57f535725342fa0088ac00000000a401008a0fc0e730bf5736fd853c0799daac344b1f6ce113b04135c842026aa1a96b2b0000896aec23666d93179a6b3d4f95f37afc90eae6acfec1775f59977c5ff2509bce8e2cc7c30f56a65e3559085d643467477f9ee8dc94d39a9acff03e0bb23b861204879d32016730fc8bf983588281910a019575d222078bfc9c72f5fcbfa6191c4e28de14e73e3e13b7f271c583a30417b4bfef46e0898e5f166a787e5e0fd8aa"
],
[
1594350,
"b763514fa4d5a11e320bcc9b800c8a28f6338ac5272de3af23982520c4420350",
"proupservtx",
"0300020001bc60a344a9d5c202323684e42bde6647fbea17620aa761a5ab3d11053997350d000000006a473044022048ec9d4b066d584503abb0c063a87a804e0ea80b755a2d1a2913ba5c13286d1e02200a27fea919b37f52ea23535501355631b3ccf2e346f911da1d450e0e240b83ab012102f9d0264897554d9302279c805c0e0e862aab7bf80d27a87e8669a564d79a4c6dfeffffff01db7e2d00000000001976a91456f3e3927c874fc63baa54106f2afea8a7a0abb788ac00000000ce01004283b756bbe5e4148ad51bebec76450eff9c6cda3d84599685f9eb113369bcfb00000000000000000000ffff8491915b270f1976a914a88b1eab808c8341fb2cbe2af192c76cab7a6d4b88acae805a26e7878dd04d743cd04ec90f1a63f83342a9300b2408859ec9a4ce32c6974dd6dd11fc0ee9db59e2af8cf44f8dd0196a6f0357f459bf3a8f406b2066d5d5116a1acb8a4ca3fc755a1b5a642bb617323c67c588b0fd081b41db625b40089115695bad58a6320e91d9f7cf425912c98cef06cff73a3ed8c8e825a4a17028"
],
[
1592165,
"559b9cb9b3a6077c2bc6e8c982b1ff1d28b7af411275ae6fad4cdb0571441986",
"proupservtx",
"0300020001d35829da56865bc49a93f38de7a1be3a4edd0f27705d7e59b996a781ffeaafbb000000006a47304402201aad8fdbe0d092d4db81828cb67eabf75fe6645cbd70a4740fc8ff6885ca0b92022069c1d728972038b186eaeb79b036b7e1449e61ede05fe7071546f1571760273e012102f9d0264897554d9302279c805c0e0e862aab7bf80d27a87e8669a564d79a4c6dfeffffff01a38b2d00000000001976a91456f3e3927c874fc63baa54106f2afea8a7a0abb788ac00000000ce01004283b756bbe5e4148ad51bebec76450eff9c6cda3d84599685f9eb113369bcfb00000000000000000000ffff8491915b270f1976a914a88b1eab808c8341fb2cbe2af192c76cab7a6d4b88ac50a5dbfd397df56cbad2ce36b76bbd9b4a31bf601118e6da4a64d6e01661211b1441beb88ca9940a651be27225c29f05312fc240224683f6b88589483e35a9beb99e73e3768e54f5af2543b4e3b8448d18e8fe0832abfc7bdab369fb8121bf157d7ed282ed6471455792af50184173cbe6186d821d812452a0ae31d5d6a2cf57"
],
[
1589905,
"9a42f395efdfe31c9e9699491e58fd20bb6e2396b44a00432ea224245b172e14",
"proupservtx",
"0300020001ea434166d1e624bb0f6790ef3dc2ef92da09e8d159e6347eb928a5e7d4657eeb000000006a473044022030587e28346d393fef9e30b5325cf9d8dd66140459dbffd76badffed24b2491a0220560949c3ef69acb75289a40ecaf4511ea404edcc0a47c21940408766ce37c48d012102d7a915fc25a21438b6f3ef4e56730439eba20c6084ac36fe5e7709e74ea97316feffffff01f233a008000000001976a914b914f5e3e98ae594ae1c5bc9d7b833e5656976d888ac00000000b501008afd3cd80083e5e5ca9f1be502e706394cd46fdbd69a66b64d39f657cd6f62e800000000000000000000ffffd8bd96fe270f0000d1163e2bbe1fb11518d158ddf64c658105cfdf1b2a7ced9b8bdb5d748b1ac818dc7d61b27d0695b911d7a0cefb56017fc366522a121310ef8db176f2f47055b5ce9d05a9b24caddbee8bb06fd81d600b1416908bed396c4d385f2642556c447e95123185ff285d9f98515de5867e39c0e99e658aa4825398630ad9f537bdf4"
],
[
1589620,
"77953234d195675fccae45d023a328417d1c87b03cd7639e1a352bd33bbee11e",
"proupservtx",
"0300020001f59efa115de05dd0d945445f6930b7bec473def4b34140d8b075d7bd72014446000000006b483045022100c930ed67df6c807d3bc2d6025e2bce23eceb2a038b35fc77b8a37151b92c732402202cd27d79baebe0718264ccb3ea8366bfebcf038ca0c21696f94cb8149a0d102701210347bc02fc1d3cd5db36f5513979b276b7d017863552a49ebd0b214df02fd7f187feffffff0117eb9908000000001976a914719a30ba1fcc1aa7183919b5a8a913476c9d660388ac00000000b50100c08eb53b66ba197a02b6f9f3e4c3abdb13aa014f8087559c2bc84adf65e0fe2900000000000000000000ffffb23eab10270f0075abfa7c3654b11242a922e6bdaa5946183662f6f75e49bb13da87d7ab932f2e07c3e60be6285a4461a961b7bbe52f9de93e8a91c1215515e2c68d74dee3607c0bfe761a5477113ffa74c8325f54f26b007d7a1d85f8922cf6da94b18c9e8eb3d186ec8863361b132025194d49dde56ded5af486cc27ebbc89f7554d6ea4378d"
],
[
1588000,
"dd03a15840b33e39c186d8f53d4eb8e54f9c75ff71139bbbc231d7cb8d1cc7e7",
"proupservtx",
"0300020001fb8d43439173f49572100530bab58ae1bfc6f5a1d0f0f7d6f014a3e5649fabe2000000006a47304402206e87e2221e6a469edd6868b4a665528913ce2783c0405572d13a524241682b97022020710be7c84d1d518e8bbcc1433b6bfc583db144d595fe709553b4bab1859593012102a5e9d9f3b6cb02b64c5d39135c445f24466f469c8bc70bbec3bc44316384adc2feffffff0121850100000000001976a9141751bcc51a5d213e2198fcd269293437346d3e0188ac00000000b50100e0e45d58d6e540d174a63e772f1954d2a2b7b529e211fab355c67c4434b26bfe00000000000000000000ffff55d1f204270f00b306665ec86710f0799b71ecf6f6f60b7683dd7a771f4b94396fe79aaf44db8106c3ef32d21edd405c92e749536431bcc993918d301c01949a31c5df2237f07d9ce69aa49f1feda08da627f75c98bb450d83dca7f032835397b7cada992b59ec1b8f20e9935ef31184d8341c264cf7e9184e730a48c7183e28527ad0bca36756"
]
]

View File

@ -0,0 +1,152 @@
// Copyright (c) 2021 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/util/setup_common.h>
#include <test/data/trivially_invalid.json.h>
#include <test/data/trivially_valid.json.h>
#include <evo/providertx.h>
#include <primitives/transaction.h>
#include <boost/test/unit_test.hpp>
#include <univalue.h>
extern UniValue read_json(const std::string& jsondata);
BOOST_FIXTURE_TEST_SUITE(evo_trivialvalidation, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(trivialvalidation_valid)
{
UniValue vectors = read_json(
std::string(json_tests::trivially_valid, json_tests::trivially_valid + sizeof(json_tests::trivially_valid))
);
for (uint8_t idx = 1; idx < vectors.size(); idx++) {
UniValue test = vectors[idx];
uint32_t txHeight;
uint256 txHash;
std::string txType;
CMutableTransaction tx;
try {
// Additional data
txHeight = test[0].get_int();
txHash = uint256S(test[1].get_str());
txType = test[2].get_str();
// Raw transaction
CDataStream stream(ParseHex(test[3].get_str()), SER_NETWORK, PROTOCOL_VERSION);
stream >> tx;
// Sanity check
BOOST_CHECK_EQUAL(tx.nVersion, 3);
BOOST_CHECK_EQUAL(tx.GetHash(), txHash);
// Deserialization based on transaction nType
switch (tx.nType) {
case TRANSACTION_PROVIDER_REGISTER: {
BOOST_CHECK_EQUAL(txType, "proregtx");
CProRegTx ptx;
BOOST_CHECK(GetTxPayload(tx, ptx));
BOOST_CHECK(!ptx.IsTriviallyValid().did_err);
break;
}
case TRANSACTION_PROVIDER_UPDATE_SERVICE: {
BOOST_CHECK_EQUAL(txType, "proupservtx");
CProUpServTx ptx;
BOOST_CHECK(GetTxPayload(tx, ptx));
BOOST_CHECK(!ptx.IsTriviallyValid().did_err);
break;
}
case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: {
BOOST_CHECK_EQUAL(txType, "proupregtx");
CProUpRegTx ptx;
BOOST_CHECK(GetTxPayload(tx, ptx));
BOOST_CHECK(!ptx.IsTriviallyValid().did_err);
break;
}
case TRANSACTION_PROVIDER_UPDATE_REVOKE: {
BOOST_CHECK_EQUAL(txType, "prouprevtx");
CProUpRevTx ptx;
BOOST_CHECK(GetTxPayload(tx, ptx));
BOOST_CHECK(!ptx.IsTriviallyValid().did_err);
break;
}
default:
// TRANSACTION_COINBASE and TRANSACTION_NORMAL
// are not subject to trivial validation checks
BOOST_CHECK(false);
}
} catch (...) {
BOOST_ERROR("Bad test, couldn't deserialize data: " << test.write());
continue;
}
}
}
BOOST_AUTO_TEST_CASE(trivialvalidation_invalid)
{
UniValue vectors = read_json(
std::string(json_tests::trivially_invalid, json_tests::trivially_invalid + sizeof(json_tests::trivially_invalid))
);
for (uint8_t idx = 1; idx < vectors.size(); idx++) {
UniValue test = vectors[idx];
uint256 txHash;
std::string txType;
CMutableTransaction tx;
try {
// Additional data
txHash = uint256S(test[0].get_str());
txType = test[1].get_str();
// Raw transaction
CDataStream stream(ParseHex(test[2].get_str()), SER_NETWORK, PROTOCOL_VERSION);
stream >> tx;
// Sanity check
BOOST_CHECK_EQUAL(tx.nVersion, 3);
BOOST_CHECK_EQUAL(tx.GetHash(), txHash);
// Deserialization based on transaction nType
if (txType == "proregtx") {
CProRegTx ptx;
if (GetTxPayload(tx, ptx)) {
BOOST_CHECK(ptx.IsTriviallyValid().did_err);
} else {
BOOST_CHECK(tx.nType != TRANSACTION_PROVIDER_REGISTER);
}
}
else if (txType == "proupservtx") {
CProUpServTx ptx;
if (GetTxPayload(tx, ptx)) {
BOOST_CHECK(ptx.IsTriviallyValid().did_err);
} else {
BOOST_CHECK(tx.nType != TRANSACTION_PROVIDER_UPDATE_SERVICE);
}
}
else if (txType == "proupregtx") {
CProUpRegTx ptx;
if (GetTxPayload(tx, ptx)) {
BOOST_CHECK(ptx.IsTriviallyValid().did_err);
}
else {
BOOST_CHECK(tx.nType != TRANSACTION_PROVIDER_UPDATE_REGISTRAR);
}
}
else if (txType == "prouprevtx") {
CProUpRevTx ptx;
if (GetTxPayload(tx, ptx)) {
BOOST_CHECK(ptx.IsTriviallyValid().did_err);
} else {
BOOST_CHECK(tx.nType != TRANSACTION_PROVIDER_UPDATE_REVOKE);
}
}
else {
// TRANSACTION_COINBASE and TRANSACTION_NORMAL
// are not subject to trivial validation checks
BOOST_CHECK(false);
}
} catch (...) {
BOOST_ERROR("Bad test, couldn't deserialize data: " << test.write());
continue;
}
}
}
BOOST_AUTO_TEST_SUITE_END()