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