@@ -420,7 +420,7 @@ TEST(TestPendingTxsPool, TxsPrioritizationMoreThanMaxTxs)
420420 pendingTxsPool.deinit ();
421421}
422422
423- TEST (TestPendingTxsPool, TxsPrioritizationDuplicateTxs )
423+ TEST (TestPendingTxsPool, RejectDuplicateTxs )
424424{
425425 TestPendingTxsPool pendingTxsPool;
426426 unsigned long long seed = 9532 ;
@@ -436,26 +436,26 @@ TEST(TestPendingTxsPool, TxsPrioritizationDuplicateTxs)
436436
437437 pendingTxsPool.beginEpoch (firstEpochTick0);
438438
439- // add duplicate transactions: same dest, src, and amount
439+ // try to add duplicate transactions: same dest, src, amount, tick, input size/type
440440 m256i dest{ 562 , 789 , 234 , 121 };
441441 m256i src{ 0 , 0 , 0 , NUM_INITIALIZED_ENTITIES / 3 };
442442 long long amount = 1 ;
443- for (unsigned int t = 0 ; t < numTxs; ++t)
444- EXPECT_TRUE (pendingTxsPool.addTransaction (firstEpochTick0, amount, /* inputSize=*/ 0 , &dest, & src));
445443
446- EXPECT_EQ (pendingTxsPool.getTotalNumberOfPendingTxs (firstEpochTick0 - 1 ), numTxs);
447- EXPECT_EQ (pendingTxsPool.getNumberOfPendingTickTxs (firstEpochTick0), numTxs);
448-
449- for (unsigned int t = 0 ; t < numTxs; ++t)
450- {
451- Transaction* tx = pendingTxsPool.getTx (firstEpochTick0, t);
452- EXPECT_TRUE (tx->checkValidity ());
453- EXPECT_EQ (tx->amount , amount);
454- EXPECT_EQ (tx->tick , firstEpochTick0);
455- EXPECT_EQ (static_cast <unsigned int >(tx->inputSize ), 0U );
456- EXPECT_TRUE (tx->destinationPublicKey == dest);
457- EXPECT_TRUE (tx->sourcePublicKey == src);
458- }
444+ // first add should succeed, all others should fail
445+ EXPECT_TRUE (pendingTxsPool.addTransaction (firstEpochTick0, amount, /* inputSize=*/ 0 , &dest, &src));
446+ for (unsigned int t = 1 ; t < numTxs; ++t)
447+ EXPECT_FALSE (pendingTxsPool.addTransaction (firstEpochTick0, amount, /* inputSize=*/ 0 , &dest, &src));
448+
449+ EXPECT_EQ (pendingTxsPool.getTotalNumberOfPendingTxs (firstEpochTick0 - 1 ), 1 );
450+ EXPECT_EQ (pendingTxsPool.getNumberOfPendingTickTxs (firstEpochTick0), 1 );
451+
452+ Transaction* tx = pendingTxsPool.getTx (firstEpochTick0, 0 );
453+ EXPECT_TRUE (tx->checkValidity ());
454+ EXPECT_EQ (tx->amount , amount);
455+ EXPECT_EQ (tx->tick , firstEpochTick0);
456+ EXPECT_EQ (static_cast <unsigned int >(tx->inputSize ), 0U );
457+ EXPECT_TRUE (tx->destinationPublicKey == dest);
458+ EXPECT_TRUE (tx->sourcePublicKey == src);
459459
460460 pendingTxsPool.deinit ();
461461}
0 commit comments