@@ -3151,3 +3151,53 @@ def test_get_items_by_coin_ids(coin_ids: list[bytes32]) -> list[MempoolItem]:
3151
3151
assert err == expected_err
3152
3152
assert len (conflicts ) == len (expected_conflicts )
3153
3153
assert set (conflicts ) == set (expected_conflicts )
3154
+
3155
+
3156
+ @pytest .mark .anyio
3157
+ async def test_new_peak_deferred_ff_items () -> None :
3158
+ """
3159
+ Covers the case where we update lineage info for multiple fast forward
3160
+ singletons at new peak.
3161
+ """
3162
+ singleton_spend1 = make_singleton_spend (bytes32 ([1 ] * 32 ))
3163
+ singleton1_id = singleton_spend1 .coin .name ()
3164
+ singleton_spend2 = make_singleton_spend (bytes32 ([2 ] * 32 ))
3165
+ singleton2_id = singleton_spend2 .coin .name ()
3166
+ coins = TestCoins (
3167
+ [singleton_spend1 .coin , singleton_spend2 .coin , TEST_COIN , TEST_COIN2 ],
3168
+ {
3169
+ singleton_spend1 .coin .puzzle_hash : singleton_spend1 .coin ,
3170
+ singleton_spend2 .coin .puzzle_hash : singleton_spend2 .coin ,
3171
+ },
3172
+ )
3173
+ mempool_manager = await setup_mempool (coins )
3174
+ # Let's submit the two singletons transactions to the mempool
3175
+ sb_names = []
3176
+ for singleton_spend , regular_coin in [(singleton_spend1 , TEST_COIN ), (singleton_spend2 , TEST_COIN2 )]:
3177
+ sb = SpendBundle ([singleton_spend , mk_coin_spend (regular_coin )], G2Element ())
3178
+ sb_name = sb .name ()
3179
+ await mempool_manager .add_spend_bundle (
3180
+ sb ,
3181
+ make_test_conds (spend_ids = [(singleton_spend .coin , ELIGIBLE_FOR_FF ), (regular_coin , 0 )], cost = 1337 ),
3182
+ sb_name ,
3183
+ uint32 (1 ),
3184
+ )
3185
+ assert mempool_manager .get_mempool_item (sb_name ) is not None
3186
+ sb_names .append (sb_name )
3187
+ # Let's advance the mempool by spending these singletons into new lineages
3188
+ singleton1_new_latest = Coin (singleton1_id , singleton_spend1 .coin .puzzle_hash , singleton_spend1 .coin .amount )
3189
+ coins .update_lineage (singleton_spend1 .coin .puzzle_hash , singleton1_new_latest )
3190
+ singleton2_new_latest = Coin (singleton2_id , singleton_spend2 .coin .puzzle_hash , singleton_spend2 .coin .amount )
3191
+ coins .update_lineage (singleton_spend2 .coin .puzzle_hash , singleton2_new_latest )
3192
+ await advance_mempool (mempool_manager , [singleton1_id , singleton2_id ], use_optimization = True )
3193
+ # Both items should get updated with their related latest lineages
3194
+ mi1 = mempool_manager .get_mempool_item (sb_names [0 ])
3195
+ assert mi1 is not None
3196
+ latest_singleton_lineage1 = mi1 .bundle_coin_spends [singleton1_id ].latest_singleton_lineage
3197
+ assert latest_singleton_lineage1 is not None
3198
+ assert latest_singleton_lineage1 .coin_id == singleton1_new_latest .name ()
3199
+ mi2 = mempool_manager .get_mempool_item (sb_names [1 ])
3200
+ assert mi2 is not None
3201
+ latest_singleton_lineage2 = mi2 .bundle_coin_spends [singleton2_id ].latest_singleton_lineage
3202
+ assert latest_singleton_lineage2 is not None
3203
+ assert latest_singleton_lineage2 .coin_id == singleton2_new_latest .name ()
0 commit comments