@@ -3201,3 +3201,61 @@ async def test_new_peak_deferred_ff_items() -> None:
3201
3201
latest_singleton_lineage2 = mi2 .bundle_coin_spends [singleton2_id ].latest_singleton_lineage
3202
3202
assert latest_singleton_lineage2 is not None
3203
3203
assert latest_singleton_lineage2 .coin_id == singleton2_new_latest .name ()
3204
+
3205
+
3206
+ @pytest .mark .anyio
3207
+ async def test_different_ff_versions () -> None :
3208
+ """
3209
+ Covers the case where we send an item with an older ff singleton version
3210
+ while the mempool is aware of a newer lineage.
3211
+ """
3212
+ launcher_id = bytes32 ([1 ] * 32 )
3213
+ singleton_spend1 = make_singleton_spend (launcher_id , bytes32 ([2 ] * 32 ))
3214
+ version1_id = singleton_spend1 .coin .name ()
3215
+ singleton_spend2 = make_singleton_spend (launcher_id , bytes32 ([3 ] * 32 ))
3216
+ version2_id = singleton_spend2 .coin .name ()
3217
+ singleton_ph = singleton_spend2 .coin .puzzle_hash
3218
+ coins = TestCoins (
3219
+ [singleton_spend1 .coin , singleton_spend2 .coin , TEST_COIN , TEST_COIN2 ], {singleton_ph : singleton_spend2 .coin }
3220
+ )
3221
+ mempool_manager = await setup_mempool (coins )
3222
+ mempool_items : list [MempoolItem ] = []
3223
+ for singleton_spend , regular_coin in [(singleton_spend1 , TEST_COIN ), (singleton_spend2 , TEST_COIN2 )]:
3224
+ sb = SpendBundle ([singleton_spend , mk_coin_spend (regular_coin )], G2Element ())
3225
+ sb_name = sb .name ()
3226
+ await mempool_manager .add_spend_bundle (
3227
+ sb ,
3228
+ make_test_conds (spend_ids = [(singleton_spend .coin , ELIGIBLE_FOR_FF ), (regular_coin , 0 )], cost = 1337 ),
3229
+ sb_name ,
3230
+ uint32 (1 ),
3231
+ )
3232
+ mi = mempool_manager .get_mempool_item (sb_name )
3233
+ assert mi is not None
3234
+ mempool_items .append (mi )
3235
+ [mi1 , mi2 ] = mempool_items
3236
+ latest_lineage_id = version2_id
3237
+ assert latest_lineage_id != version1_id
3238
+ # Bundle coin spends key points to version 1 but the lineage is latest (v2)
3239
+ latest_singleton_lineage1 = mi1 .bundle_coin_spends [version1_id ].latest_singleton_lineage
3240
+ assert latest_singleton_lineage1 is not None
3241
+ assert latest_singleton_lineage1 .coin_id == latest_lineage_id
3242
+ # Both the bundle coin spends key and the lineage point to latest (v2)
3243
+ latest_singleton_lineage2 = mi2 .bundle_coin_spends [version2_id ].latest_singleton_lineage
3244
+ assert latest_singleton_lineage2 is not None
3245
+ assert latest_singleton_lineage2 .coin_id == latest_lineage_id
3246
+ # Let's update the lineage with a new version of the singleton
3247
+ new_latest_lineage = Coin (version2_id , singleton_ph , singleton_spend2 .coin .amount )
3248
+ new_latest_lineage_id = new_latest_lineage .name ()
3249
+ coins .update_lineage (singleton_ph , new_latest_lineage )
3250
+ await advance_mempool (mempool_manager , [version1_id , version2_id ], use_optimization = True )
3251
+ # Both items should get updated with the latest lineage
3252
+ new_mi1 = mempool_manager .get_mempool_item (mi1 .spend_bundle_name )
3253
+ assert new_mi1 is not None
3254
+ latest_singleton_lineage1 = new_mi1 .bundle_coin_spends [version1_id ].latest_singleton_lineage
3255
+ assert latest_singleton_lineage1 is not None
3256
+ assert latest_singleton_lineage1 .coin_id == new_latest_lineage_id
3257
+ new_mi2 = mempool_manager .get_mempool_item (mi2 .spend_bundle_name )
3258
+ assert new_mi2 is not None
3259
+ latest_singleton_lineage2 = new_mi2 .bundle_coin_spends [version2_id ].latest_singleton_lineage
3260
+ assert latest_singleton_lineage2 is not None
3261
+ assert latest_singleton_lineage2 .coin_id == new_latest_lineage_id
0 commit comments