@@ -597,7 +597,7 @@ def mempool_item_from_spendbundle(spend_bundle: SpendBundle) -> MempoolItem:
597
597
)
598
598
bundle_coin_spends , fee = make_bundle_spends_map_and_fee (spend_bundle , conds )
599
599
return MempoolItem (
600
- spend_bundle = spend_bundle ,
600
+ aggregated_signature = spend_bundle . aggregated_signature ,
601
601
fee = fee ,
602
602
conds = conds ,
603
603
spend_bundle_name = spend_bundle .name (),
@@ -927,7 +927,7 @@ def mk_item(
927
927
spend_bundle = SpendBundle (coin_spends , G2Element ())
928
928
conds = make_test_conds (cost = cost , spend_ids = spend_ids )
929
929
return MempoolItem (
930
- spend_bundle = spend_bundle ,
930
+ aggregated_signature = spend_bundle . aggregated_signature ,
931
931
fee = uint64 (fee ),
932
932
conds = conds ,
933
933
spend_bundle_name = spend_bundle .name (),
@@ -3310,3 +3310,21 @@ async def test_new_peak_txs_added(condition_and_error: tuple[ConditionOpcode, Er
3310
3310
# The item gets retried successfully now
3311
3311
assert new_peak_info .spend_bundle_ids == [sb_name ]
3312
3312
assert mempool_manager .get_mempool_item (sb_name , include_pending = False ) is not None
3313
+
3314
+
3315
+ @pytest .mark .anyio
3316
+ async def test_mempool_item_to_spend_bundle () -> None :
3317
+ """
3318
+ Tests that we can properly go back to a `SpendBundle` from a `MempoolItem`.
3319
+ """
3320
+ coins = [Coin (bytes32 .random (), IDENTITY_PUZZLE_HASH , uint64 (i + 1 )) for i in range (random .randint (42 , 1337 ))]
3321
+ mempool_manager = await setup_mempool (TestCoins (coins , {}))
3322
+ random_sample = random .sample (coins , 42 )
3323
+ sb = SpendBundle ([CoinSpend (c , IDENTITY_PUZZLE , SerializedProgram .to (None )) for c in random_sample ], G2Element ())
3324
+ sb_name = sb .name ()
3325
+ await add_spendbundle (mempool_manager , sb , sb_name )
3326
+ mi = mempool_manager .get_mempool_item (sb_name )
3327
+ assert mi is not None
3328
+ result = mi .to_spend_bundle ()
3329
+ assert result == sb
3330
+ assert result .name () == sb_name
0 commit comments