| 36 | } |
| 37 | |
| 38 | BOOST_FIXTURE_TEST_CASE(package_sanitization_tests, TestChain100Setup) |
| 39 | { |
| 40 | // Packages can't have more than 25 transactions. |
| 41 | Package package_too_many; |
| 42 | package_too_many.reserve(MAX_PACKAGE_COUNT + 1); |
| 43 | for (size_t i{0}; i < MAX_PACKAGE_COUNT + 1; ++i) { |
| 44 | package_too_many.emplace_back(create_placeholder_tx(1, 1)); |
| 45 | } |
| 46 | PackageValidationState state_too_many; |
| 47 | BOOST_CHECK(!CheckPackage(package_too_many, state_too_many)); |
| 48 | BOOST_CHECK_EQUAL(state_too_many.GetResult(), PackageValidationResult::PCKG_POLICY); |
| 49 | BOOST_CHECK_EQUAL(state_too_many.GetRejectReason(), "package-too-many-transactions"); |
| 50 | |
| 51 | // Packages can't have a total size of more than 101KvB. |
| 52 | CTransactionRef large_ptx = create_placeholder_tx(150, 150); |
| 53 | Package package_too_large; |
| 54 | auto size_large = GetVirtualTransactionSize(*large_ptx); |
| 55 | size_t total_size{0}; |
| 56 | while (total_size <= MAX_PACKAGE_SIZE * 1000) { |
| 57 | package_too_large.push_back(large_ptx); |
| 58 | total_size += size_large; |
| 59 | } |
| 60 | BOOST_CHECK(package_too_large.size() <= MAX_PACKAGE_COUNT); |
| 61 | PackageValidationState state_too_large; |
| 62 | BOOST_CHECK(!CheckPackage(package_too_large, state_too_large)); |
| 63 | BOOST_CHECK_EQUAL(state_too_large.GetResult(), PackageValidationResult::PCKG_POLICY); |
| 64 | BOOST_CHECK_EQUAL(state_too_large.GetRejectReason(), "package-too-large"); |
| 65 | } |
| 66 | |
| 67 | BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup) |
| 68 | { |
nothing calls this directly
no test coverage detected