Repository: Chia-Network/chia-blockchain
File: chia/_tests/core/mempool/test_mempool_manager.py (Python)

Code before:
        _, status, error = await add_spendbundle(mempool_manager, sb, sb.name())
        assert (status, error) == (expected_status, expected_error)
    except ValidationError as e:
        assert expected_status == mis.FAILED
        assert expected_error == e.code


def test_optional_min() -> None:
    assert optional_min(uint32(100), None) == uint32(100)
    assert optional_min(None, uint32(100)) == uint32(100)
    assert optional_min(None, None) is None
    assert optional_min(uint32(123), uint32(234)) == uint32(123)


def test_optional_max() -> None:
    assert optional_max(uint32(100), None) == uint32(100)
    assert optional_max(None, uint32(100)) == uint32(100)
    assert optional_max(None, None) is None
    assert optional_max(uint32(123), uint32(234)) == uint32(234)


def mk_coin_spend(coin: Coin, solution: Optional[str] = None) -> CoinSpend:
    return make_spend(
        coin,
        SerializedProgram.to(None),
        SerializedProgram.from_bytes(bytes.fromhex(solution) if solution is not None else b"\x80"),
    )


def mk_bcs(coin_spend: CoinSpend, flags: int = 0) -> BundleCoinSpend:
    return BundleCoinSpend(
        coin_spend=coin_spend,
        eligible_for_dedup=bool(flags & ELIGIBLE_FOR_DEDUP),
        eligible_for_fast_forward=bool(flags & ELIGIBLE_FOR_FF),
        additions=[],
    )


def mk_item(
    coins: list[Coin],
    *,
    cost: int = 1,
    fee: int = 0,
    assert_height: Optional[int] = None,
    assert_before_height: Optional[int] = None,
    assert_before_seconds: Optional[int] = None,
    solution: Optional[str] = None,
    flags: list[int] = [],
) -> MempoolItem:
    # we don't actually care about the puzzle and solutions for the purpose of
    # can_replace()

Review comment (suggestion):
```suggestion
        SerializedProgram.fromhex(solution if solution is not None else "80"),
```

Code after:
        _, status, error = await add_spendbundle(mempool_manager, sb, sb.name())
        assert (status, error) == (expected_status, expected_error)
    except ValidationError as e:
        assert expected_status == mis.FAILED
        assert expected_error == e.code


def test_optional_min() -> None:
    assert optional_min(uint32(100), None) == uint32(100)
    assert optional_min(None, uint32(100)) == uint32(100)
    assert optional_min(None, None) is None
    assert optional_min(uint32(123), uint32(234)) == uint32(123)


def test_optional_max() -> None:
    assert optional_max(uint32(100), None) == uint32(100)
    assert optional_max(None, uint32(100)) == uint32(100)
    assert optional_max(None, None) is None
    assert optional_max(uint32(123), uint32(234)) == uint32(234)


def mk_coin_spend(coin: Coin, solution: Optional[str] = None) -> CoinSpend:
    return make_spend(
        coin,
        SerializedProgram.to(None),
        SerializedProgram.fromhex(solution if solution is not None else "80"),
    )


def mk_bcs(coin_spend: CoinSpend, flags: int = 0) -> BundleCoinSpend:
    return BundleCoinSpend(
        coin_spend=coin_spend,
        eligible_for_dedup=bool(flags & ELIGIBLE_FOR_DEDUP),
        eligible_for_fast_forward=bool(flags & ELIGIBLE_FOR_FF),
        additions=[],
    )


def mk_item(
    coins: list[Coin],
    *,
    cost: int = 1,
    fee: int = 0,
    assert_height: Optional[int] = None,
    assert_before_height: Optional[int] = None,
    assert_before_seconds: Optional[int] = None,
    solution: Optional[str] = None,
    flags: list[int] = [],
) -> MempoolItem:
    # we don't actually care about the puzzle and solutions for the purpose of
    # can_replace()