diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-07-26 10:21:28 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-09-11 13:38:18 +0000 |
commit | 6526d87f17a153a6a7f9f1e81a53b113c20e5f3b (patch) | |
tree | 8de15cde5ac705d8b5aa10168671aa535253b8df | |
parent | multiexp: fix maxscalar off by one (diff) | |
download | monero-6526d87f17a153a6a7f9f1e81a53b113c20e5f3b.tar.xz |
core_tests: add a test for a tx with empty bulletproof
-rw-r--r-- | tests/core_tests/bulletproofs.cpp | 13 | ||||
-rw-r--r-- | tests/core_tests/bulletproofs.h | 6 | ||||
-rw-r--r-- | tests/core_tests/chaingen_main.cpp | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/core_tests/bulletproofs.cpp b/tests/core_tests/bulletproofs.cpp index 3b3039a18..aea502faa 100644 --- a/tests/core_tests/bulletproofs.cpp +++ b/tests/core_tests/bulletproofs.cpp @@ -297,6 +297,19 @@ bool gen_bp_tx_invalid_not_enough_proofs::generate(std::vector<test_event_entry> }); } +bool gen_bp_tx_invalid_empty_proofs::generate(std::vector<test_event_entry>& events) const +{ + DEFINE_TESTS_ERROR_CONTEXT("gen_bp_tx_invalid_empty_proofs"); + const size_t mixin = 10; + const uint64_t amounts_paid[] = {50000, 50000, (uint64_t)-1}; + const rct::RangeProofType range_proof_type[] = { rct::RangeProofBulletproof }; + return generate_with(events, mixin, 1, amounts_paid, false, range_proof_type, NULL, [&](cryptonote::transaction &tx, size_t idx){ + CHECK_TEST_CONDITION(tx.rct_signatures.type == rct::RCTTypeBulletproof); + tx.rct_signatures.p.bulletproofs.clear(); + return true; + }); +} + bool gen_bp_tx_invalid_too_many_proofs::generate(std::vector<test_event_entry>& events) const { DEFINE_TESTS_ERROR_CONTEXT("gen_bp_tx_invalid_too_many_proofs"); diff --git a/tests/core_tests/bulletproofs.h b/tests/core_tests/bulletproofs.h index 13faa3493..c3a7db2c7 100644 --- a/tests/core_tests/bulletproofs.h +++ b/tests/core_tests/bulletproofs.h @@ -162,6 +162,12 @@ struct gen_bp_tx_invalid_not_enough_proofs : public gen_bp_tx_validation_base }; template<> struct get_test_options<gen_bp_tx_invalid_not_enough_proofs>: public get_test_options<gen_bp_tx_validation_base> {}; +struct gen_bp_tx_invalid_empty_proofs : public gen_bp_tx_validation_base +{ + bool generate(std::vector<test_event_entry>& events) const; +}; +template<> struct get_test_options<gen_bp_tx_invalid_empty_proofs>: public get_test_options<gen_bp_tx_validation_base> {}; + struct gen_bp_tx_invalid_too_many_proofs : public gen_bp_tx_validation_base { bool generate(std::vector<test_event_entry>& events) const; diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index 278ef81a6..6f26e6532 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -234,6 +234,7 @@ int main(int argc, char* argv[]) GENERATE_AND_PLAY(gen_bp_txs_valid_2_and_2); GENERATE_AND_PLAY(gen_bp_txs_invalid_2_and_8_2_and_16_16_1); GENERATE_AND_PLAY(gen_bp_tx_invalid_not_enough_proofs); + GENERATE_AND_PLAY(gen_bp_tx_invalid_empty_proofs); GENERATE_AND_PLAY(gen_bp_tx_invalid_too_many_proofs); GENERATE_AND_PLAY(gen_bp_tx_invalid_wrong_amount); GENERATE_AND_PLAY(gen_bp_tx_invalid_borromean_type); |