Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions chia/_tests/core/cmds/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def cat_name_resolver(request: CATAssetIDToName) -> CATAssetIDToNameRespon

@pytest.mark.anyio
async def test_print_offer_summary_xch(capsys: Any) -> None:
summary_dict = {"xch": 1_000_000_000_000}
summary_dict = {"xch": str(1_000_000_000_000)}

await print_offer_summary(cat_name_resolver, summary_dict)

Expand All @@ -38,7 +38,7 @@ async def test_print_offer_summary_xch(capsys: Any) -> None:
@pytest.mark.anyio
async def test_print_offer_summary_cat(capsys: Any) -> None:
summary_dict = {
TEST_DUCKSAUCE_ASSET_ID: 1_000,
TEST_DUCKSAUCE_ASSET_ID: str(1_000),
}

await print_offer_summary(cat_name_resolver, summary_dict)
Expand All @@ -51,8 +51,8 @@ async def test_print_offer_summary_cat(capsys: Any) -> None:
@pytest.mark.anyio
async def test_print_offer_summary_multiple_cats(capsys: Any) -> None:
summary_dict = {
TEST_DUCKSAUCE_ASSET_ID: 1_000,
TEST_CRUNCHBERRIES_ASSET_ID: 2_000,
TEST_DUCKSAUCE_ASSET_ID: str(1_000),
TEST_CRUNCHBERRIES_ASSET_ID: str(2_000),
}

await print_offer_summary(cat_name_resolver, summary_dict)
Expand All @@ -66,10 +66,10 @@ async def test_print_offer_summary_multiple_cats(capsys: Any) -> None:
@pytest.mark.anyio
async def test_print_offer_summary_xch_and_cats(capsys: Any) -> None:
summary_dict = {
"xch": 2_500_000_000_000,
TEST_DUCKSAUCE_ASSET_ID: 1_111,
TEST_CRUNCHBERRIES_ASSET_ID: 2_222,
TEST_UNICORNTEARS_ASSET_ID: 3_333,
"xch": str(2_500_000_000_000),
TEST_DUCKSAUCE_ASSET_ID: str(1_111),
TEST_CRUNCHBERRIES_ASSET_ID: str(2_222),
TEST_UNICORNTEARS_ASSET_ID: str(3_333),
}

await print_offer_summary(cat_name_resolver, summary_dict)
Expand All @@ -85,10 +85,10 @@ async def test_print_offer_summary_xch_and_cats(capsys: Any) -> None:
@pytest.mark.anyio
async def test_print_offer_summary_xch_and_cats_with_zero_values(capsys: Any) -> None:
summary_dict = {
"xch": 0,
TEST_DUCKSAUCE_ASSET_ID: 0,
TEST_CRUNCHBERRIES_ASSET_ID: 0,
TEST_UNICORNTEARS_ASSET_ID: 0,
"xch": str(0),
TEST_DUCKSAUCE_ASSET_ID: str(0),
TEST_CRUNCHBERRIES_ASSET_ID: str(0),
TEST_UNICORNTEARS_ASSET_ID: str(0),
}

await print_offer_summary(cat_name_resolver, summary_dict)
Expand All @@ -104,8 +104,8 @@ async def test_print_offer_summary_xch_and_cats_with_zero_values(capsys: Any) ->
@pytest.mark.anyio
async def test_print_offer_summary_cat_with_fee_and_change(capsys: Any) -> None:
summary_dict = {
TEST_DUCKSAUCE_ASSET_ID: 1_000,
"unknown": 3_456,
TEST_DUCKSAUCE_ASSET_ID: str(1_000),
"unknown": str(3_456),
}

await print_offer_summary(cat_name_resolver, summary_dict, has_fee=True)
Expand All @@ -118,7 +118,7 @@ async def test_print_offer_summary_cat_with_fee_and_change(capsys: Any) -> None:

@pytest.mark.anyio
async def test_print_offer_summary_xch_with_one_mojo(capsys: Any) -> None:
summary_dict = {"xch": 1}
summary_dict = {"xch": str(1)}

await print_offer_summary(cat_name_resolver, summary_dict)

Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def test_complex_offer(cost_logger: CostLogger) -> None:
{"type": AssetType.CAT.value, "tail": "0x" + str_to_tail_hash("blue").hex()}
),
}
driver_dict_as_infos = {key.hex(): value.info for key, value in driver_dict.items()}
driver_dict_as_summary = {key.hex(): value for key, value in driver_dict.items()}

# Create an XCH Offer for RED
chia_requested_payments: dict[Optional[bytes32], list[CreateCoin]] = {
Expand Down Expand Up @@ -239,9 +239,9 @@ async def test_complex_offer(cost_logger: CostLogger) -> None:
}
assert new_offer.get_requested_amounts() == {None: 900, str_to_tail_hash("red"): 350}
assert new_offer.summary() == (
{"xch": 1000, str_to_tail_hash("red").hex(): 350, str_to_tail_hash("blue").hex(): 2000},
{"xch": 900, str_to_tail_hash("red").hex(): 350},
driver_dict_as_infos,
{"xch": "1000", str_to_tail_hash("red").hex(): "350", str_to_tail_hash("blue").hex(): "2000"},
{"xch": "900", str_to_tail_hash("red").hex(): "350"},
driver_dict_as_summary,
ConditionValidTimes(),
)
assert new_offer.get_pending_amounts() == {
Expand Down
32 changes: 16 additions & 16 deletions chia/_tests/wallet/cat_wallet/test_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from chia.wallet.puzzle_drivers import PuzzleInfo
from chia.wallet.trade_manager import TradeManager
from chia.wallet.trade_record import TradeRecord
from chia.wallet.trading.offer import Offer, OfferSummary
from chia.wallet.trading.offer import Offer, OfferSpecification
from chia.wallet.trading.trade_status import TradeStatus
from chia.wallet.transaction_record import TransactionRecord
from chia.wallet.util.transaction_type import TransactionType
Expand Down Expand Up @@ -415,29 +415,29 @@ async def test_cat_trades(
await env_maker.check_balances()

# Create the trade parameters
chia_for_cat: OfferSummary = {
chia_for_cat: OfferSpecification = {
wallet_maker.id(): -1,
bytes32.from_hexstr(new_cat_wallet_maker.get_asset_id()): 2, # This is the CAT that the taker made
}
cat_for_chia: OfferSummary = {
cat_for_chia: OfferSpecification = {
wallet_maker.id(): 3,
cat_wallet_maker.id(): -4, # The taker has no knowledge of this CAT yet
}
cat_for_cat: OfferSummary = {
cat_for_cat: OfferSpecification = {
bytes32.from_hexstr(cat_wallet_maker.get_asset_id()): -5,
new_cat_wallet_maker.id(): 6,
}
chia_for_multiple_cat: OfferSummary = {
chia_for_multiple_cat: OfferSpecification = {
wallet_maker.id(): -7,
cat_wallet_maker.id(): 8,
new_cat_wallet_maker.id(): 9,
}
multiple_cat_for_chia: OfferSummary = {
multiple_cat_for_chia: OfferSpecification = {
wallet_maker.id(): 10,
cat_wallet_maker.id(): -11,
new_cat_wallet_maker.id(): -12,
}
chia_and_cat_for_cat: OfferSummary = {
chia_and_cat_for_cat: OfferSpecification = {
wallet_maker.id(): -13,
cat_wallet_maker.id(): -14,
new_cat_wallet_maker.id(): 15,
Expand Down Expand Up @@ -1673,12 +1673,12 @@ async def test_trade_cancellation(wallet_environments: WalletTestFramework, wall
]
)

cat_for_chia: OfferSummary = {
cat_for_chia: OfferSpecification = {
env_maker.wallet_aliases["xch"]: 1,
env_maker.wallet_aliases["cat"]: -2,
}

chia_for_cat: OfferSummary = {
chia_for_cat: OfferSpecification = {
env_maker.wallet_aliases["xch"]: -3,
env_maker.wallet_aliases["cat"]: 4,
}
Expand Down Expand Up @@ -1846,7 +1846,7 @@ async def test_trade_cancellation(wallet_environments: WalletTestFramework, wall
await time_out_assert(15, get_trade_and_status, TradeStatus.CANCELLED, trade_manager_maker, trade_make)

# Now let's test the case where two coins need to be spent in order to cancel
chia_and_cat_for_something: OfferSummary = {
chia_and_cat_for_something: OfferSpecification = {
env_maker.wallet_aliases["xch"]: -5,
env_maker.wallet_aliases["cat"]: -6,
bytes32.zeros: 1, # Doesn't matter
Expand Down Expand Up @@ -1991,7 +1991,7 @@ async def test_trade_conflict(wallet_environments: WalletTestFramework, wallet_t
]
)

cat_for_chia: OfferSummary = {
cat_for_chia: OfferSpecification = {
env_maker.wallet_aliases["xch"]: 1000,
env_maker.wallet_aliases["cat"]: -4,
}
Expand Down Expand Up @@ -2182,7 +2182,7 @@ async def test_trade_bad_spend(wallet_environments: WalletTestFramework, wallet_
]
)

cat_for_chia: OfferSummary = {
cat_for_chia: OfferSpecification = {
env_maker.wallet_aliases["xch"]: 1000,
env_maker.wallet_aliases["cat"]: -4,
}
Expand Down Expand Up @@ -2304,7 +2304,7 @@ async def test_trade_high_fee(wallet_environments: WalletTestFramework, wallet_t
]
)

cat_for_chia: OfferSummary = {
cat_for_chia: OfferSpecification = {
env_maker.wallet_aliases["xch"]: 1000,
env_maker.wallet_aliases["cat"]: -4,
}
Expand Down Expand Up @@ -2449,15 +2449,15 @@ async def test_aggregated_trade_state(wallet_environments: WalletTestFramework,
]
)

cat_for_chia: OfferSummary = {
cat_for_chia: OfferSpecification = {
env_maker.wallet_aliases["xch"]: 2,
env_maker.wallet_aliases["cat"]: -2,
}
chia_for_cat: OfferSummary = {
chia_for_cat: OfferSpecification = {
env_maker.wallet_aliases["xch"]: -1,
env_maker.wallet_aliases["cat"]: 1,
}
combined_summary: OfferSummary = {
combined_summary: OfferSpecification = {
env_maker.wallet_aliases["xch"]: cat_for_chia[env_maker.wallet_aliases["xch"]]
+ chia_for_cat[env_maker.wallet_aliases["xch"]],
env_maker.wallet_aliases["cat"]: cat_for_chia[env_maker.wallet_aliases["cat"]]
Expand Down
68 changes: 34 additions & 34 deletions chia/_tests/wallet/db_wallet/test_dl_offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from chia._tests.environments.wallet import WalletStateTransition, WalletTestFramework
from chia._tests.util.time_out_assert import time_out_assert
from chia.data_layer.data_layer_wallet import DataLayerWallet
from chia.data_layer.data_layer_wallet import DataLayerSummary, DataLayerWallet, SingletonDependencies, SingletonSummary
from chia.wallet.puzzle_drivers import Solver
from chia.wallet.trade_record import TradeRecord
from chia.wallet.trading.offer import Offer
Expand Down Expand Up @@ -179,20 +179,20 @@ async def test_dl_offers(wallet_environments: WalletTestFramework) -> None:
assert success is True
assert offer_maker is not None

assert await trade_manager_taker.get_offer_summary(Offer.from_bytes(offer_maker.offer)) == {
"offered": [
{
"launcher_id": launcher_id_maker.hex(),
"new_root": maker_root.hex(),
"dependencies": [
{
"launcher_id": launcher_id_taker.hex(),
"values_to_prove": [taker_branch.hex()],
}
assert await trade_manager_taker.get_dl_offer_summary(Offer.from_bytes(offer_maker.offer)) == DataLayerSummary(
offered=[
SingletonSummary(
launcher_id=launcher_id_maker,
new_root=maker_root,
dependencies=[
SingletonDependencies(
launcher_id=launcher_id_taker,
values_to_prove=[taker_branch],
)
],
}
)
]
}
)

[_maker_offer], signing_response = await wsm_maker.sign_offers([Offer.from_bytes(offer_maker.offer)])
async with trade_manager_taker.wallet_state_manager.new_action_scope(
Expand Down Expand Up @@ -231,30 +231,30 @@ async def test_dl_offers(wallet_environments: WalletTestFramework) -> None:
)
assert offer_taker is not None

assert await trade_manager_maker.get_offer_summary(Offer.from_bytes(offer_taker.offer)) == {
"offered": [
{
"launcher_id": launcher_id_maker.hex(),
"new_root": maker_root.hex(),
"dependencies": [
{
"launcher_id": launcher_id_taker.hex(),
"values_to_prove": [taker_branch.hex()],
}
assert await trade_manager_maker.get_dl_offer_summary(Offer.from_bytes(offer_taker.offer)) == DataLayerSummary(
offered=[
SingletonSummary(
launcher_id=launcher_id_maker,
new_root=maker_root,
dependencies=[
SingletonDependencies(
launcher_id=launcher_id_taker,
values_to_prove=[taker_branch],
)
],
},
{
"launcher_id": launcher_id_taker.hex(),
"new_root": taker_root.hex(),
"dependencies": [
{
"launcher_id": launcher_id_maker.hex(),
"values_to_prove": [maker_branch.hex()],
}
),
SingletonSummary(
launcher_id=launcher_id_taker,
new_root=taker_root,
dependencies=[
SingletonDependencies(
launcher_id=launcher_id_maker,
values_to_prove=[maker_branch],
),
],
},
),
]
}
)

await wallet_environments.process_pending_states(
[
Expand Down
16 changes: 8 additions & 8 deletions chia/_tests/wallet/nft_wallet/test_nft_1_offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from chia.wallet.nft_wallet.nft_wallet import NFTWallet
from chia.wallet.outer_puzzles import create_asset_id, match_puzzle
from chia.wallet.puzzle_drivers import PuzzleInfo
from chia.wallet.trading.offer import Offer, OfferSummary
from chia.wallet.trading.offer import Offer, OfferSpecification
from chia.wallet.trading.trade_status import TradeStatus
from chia.wallet.uncurried_puzzle import uncurry_puzzle

Expand Down Expand Up @@ -163,7 +163,7 @@ async def test_nft_offer_sell_nft(wallet_environments: WalletTestFramework, zero
xch_requested = 1000
maker_fee = uint64(433)

offer_did_nft_for_xch: OfferSummary = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested}
offer_did_nft_for_xch: OfferSpecification = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested}

async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
Expand Down Expand Up @@ -395,7 +395,7 @@ async def test_nft_offer_request_nft(wallet_environments: WalletTestFramework, z
maker_fee = uint64(10)
driver_dict = {nft_to_request_asset_id: nft_to_request_info}

offer_dict: OfferSummary = {nft_to_request_asset_id: 1, wallet_maker.id(): -xch_offered}
offer_dict: OfferSpecification = {nft_to_request_asset_id: 1, wallet_maker.id(): -xch_offered}

async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
Expand Down Expand Up @@ -685,7 +685,7 @@ async def test_nft_offer_sell_did_to_did(wallet_environments: WalletTestFramewor
xch_requested = 1000
maker_fee = uint64(433)

offer_did_nft_for_xch: OfferSummary = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested}
offer_did_nft_for_xch: OfferSpecification = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested}

async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
Expand Down Expand Up @@ -990,7 +990,7 @@ async def test_nft_offer_sell_nft_for_cat(
cats_requested = 1000
maker_fee = uint64(433)

offer_did_nft_for_xch: OfferSummary = {nft_to_offer_asset_id: -1, cat_wallet_maker.id(): cats_requested}
offer_did_nft_for_xch: OfferSpecification = {nft_to_offer_asset_id: -1, cat_wallet_maker.id(): cats_requested}

async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
Expand Down Expand Up @@ -1347,7 +1347,7 @@ async def test_nft_offer_request_nft_for_cat(
maker_fee = uint64(433)
driver_dict = {nft_to_request_asset_id: nft_to_request_info}

offer_dict: OfferSummary = {nft_to_request_asset_id: 1, cat_wallet_maker.id(): -cats_requested}
offer_dict: OfferSpecification = {nft_to_request_asset_id: 1, cat_wallet_maker.id(): -cats_requested}

async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
Expand Down Expand Up @@ -1583,7 +1583,7 @@ async def test_nft_offer_sell_cancel(wallet_environments: WalletTestFramework) -
xch_requested = 1000
maker_fee = uint64(433)

offer_did_nft_for_xch: OfferSummary = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested}
offer_did_nft_for_xch: OfferSpecification = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested}

async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
Expand Down Expand Up @@ -1976,7 +1976,7 @@ async def test_complex_nft_offer(
CAT_REQUESTED = 100000
FEE = uint64(2000000000000)

complex_nft_offer: OfferSummary = {
complex_nft_offer: OfferSpecification = {
nft_to_offer_asset_id_maker: -1,
cat_wallet_maker.id(): CAT_REQUESTED * -1,
1: XCH_REQUESTED,
Expand Down
Loading
Loading