From 1224e53b744f8338163998d06b139a3f7a006b08 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 29 Jul 2018 14:04:42 +0100 Subject: core_tests: add a test for 4-aggregated BP verification --- tests/core_tests/bulletproofs.cpp | 9 +++++++++ tests/core_tests/bulletproofs.h | 6 ++++++ tests/core_tests/chaingen_main.cpp | 1 + 3 files changed, 16 insertions(+) diff --git a/tests/core_tests/bulletproofs.cpp b/tests/core_tests/bulletproofs.cpp index aea502faa..db875d2a2 100644 --- a/tests/core_tests/bulletproofs.cpp +++ b/tests/core_tests/bulletproofs.cpp @@ -282,6 +282,15 @@ bool gen_bp_txs_invalid_2_and_8_2_and_16_16_1::generate(std::vector& events) const +{ + const size_t mixin = 10; + const uint64_t amounts_paid[] = {11111115000, 11111115000, (uint64_t)-1, 11111115000, 11111115000, 11111115001, (uint64_t)-1, 11111115000, 11111115002, (uint64_t)-1, 11111115000, 11111115000, 11111115000, 11111115003, (uint64_t)-1}; + const rct::RangeProofType range_proof_type[] = {rct::RangeProofPaddedBulletproof, rct::RangeProofPaddedBulletproof, rct::RangeProofPaddedBulletproof, rct::RangeProofPaddedBulletproof}; + const size_t bp_sizes[] = {2, (size_t)-1, 4, (size_t)-1, 2, (size_t)-1, 4, (size_t)-1}; + return generate_with(events, mixin, 4, amounts_paid, true, range_proof_type, NULL, [&](const cryptonote::transaction &tx, size_t tx_idx) { return check_bp(tx, tx_idx, bp_sizes, "gen_bp_txs_valid_2_and_3_and_2_and_4"); }); +} + bool gen_bp_tx_invalid_not_enough_proofs::generate(std::vector& events) const { DEFINE_TESTS_ERROR_CONTEXT("gen_bp_tx_invalid_not_enough_proofs"); diff --git a/tests/core_tests/bulletproofs.h b/tests/core_tests/bulletproofs.h index c3a7db2c7..e29b34690 100644 --- a/tests/core_tests/bulletproofs.h +++ b/tests/core_tests/bulletproofs.h @@ -156,6 +156,12 @@ struct gen_bp_txs_invalid_2_and_8_2_and_16_16_1 : public gen_bp_tx_validation_ba }; template<> struct get_test_options: public get_test_options {}; +struct gen_bp_txs_valid_2_and_3_and_2_and_4 : public gen_bp_tx_validation_base +{ + bool generate(std::vector& events) const; +}; +template<> struct get_test_options: public get_test_options {}; + struct gen_bp_tx_invalid_not_enough_proofs : public gen_bp_tx_validation_base { bool generate(std::vector& events) const; diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index 6f26e6532..abc412318 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -233,6 +233,7 @@ int main(int argc, char* argv[]) GENERATE_AND_PLAY(gen_bp_tx_invalid_16_16); 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_txs_valid_2_and_3_and_2_and_4); 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); -- cgit v1.2.3