File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -378,6 +378,32 @@ BOOST_AUTO_TEST_CASE(tx_no_inputs)
378
378
BOOST_CHECK (state.GetRejectReason () == " bad-txns-vin-empty" );
379
379
}
380
380
381
+ BOOST_AUTO_TEST_CASE (tx_oversized)
382
+ {
383
+ auto createTransaction =[](size_t payloadSize) {
384
+ CMutableTransaction tx;
385
+ tx.vin .resize (1 );
386
+ tx.vout .emplace_back (1 , CScript () << OP_RETURN << std::vector<unsigned char >(payloadSize));
387
+ return CTransaction (tx);
388
+ };
389
+ const auto maxTransactionSize = MAX_BLOCK_WEIGHT / WITNESS_SCALE_FACTOR;
390
+ const auto oversizedTransactionBaseSize = ::GetSerializeSize (TX_NO_WITNESS (createTransaction (maxTransactionSize))) - maxTransactionSize;
391
+
392
+ auto maxPayloadSize = maxTransactionSize - oversizedTransactionBaseSize;
393
+ {
394
+ TxValidationState state;
395
+ CheckTransaction (createTransaction (maxPayloadSize), state);
396
+ BOOST_CHECK (state.GetRejectReason () != " bad-txns-oversize" );
397
+ }
398
+
399
+ maxPayloadSize += 1 ;
400
+ {
401
+ TxValidationState state;
402
+ BOOST_CHECK_MESSAGE (!CheckTransaction (createTransaction (maxPayloadSize), state), " Oversized transaction should be invalid" );
403
+ BOOST_CHECK (state.GetRejectReason () == " bad-txns-oversize" );
404
+ }
405
+ }
406
+
381
407
BOOST_AUTO_TEST_CASE (basic_transaction_tests)
382
408
{
383
409
// Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436)
You can’t perform that action at this time.
0 commit comments