Add cost logging to CLVM tests as fixture (#14444)

This commit is contained in:
Matt Hauff 2023-02-10 14:13:45 -07:00 committed by GitHub
parent 6e70868888
commit 59e389968e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 165 additions and 72 deletions

View File

@ -1,5 +1,6 @@
from __future__ import annotations
import json
import random
from contextlib import asynccontextmanager
from dataclasses import dataclass
@ -13,9 +14,10 @@ from chia.consensus.cost_calculator import NPCResult
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.full_node.bundle_tools import simple_solution_generator
from chia.full_node.coin_store import CoinStore
from chia.full_node.mempool_check_conditions import get_puzzle_and_solution_for_coin
from chia.full_node.mempool_check_conditions import get_name_puzzle_conditions, get_puzzle_and_solution_for_coin
from chia.full_node.mempool_manager import MempoolManager
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import INFINITE_COST
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.coin_record import CoinRecord
from chia.types.coin_spend import CoinSpend
@ -54,6 +56,31 @@ async def sim_and_client(
await sim.close()
class CostLogger:
def __init__(self) -> None:
self.cost_dict: Dict[str, int] = {}
self.cost_dict_no_puzs: Dict[str, int] = {}
def add_cost(self, descriptor: str, spend_bundle: SpendBundle) -> SpendBundle:
program: BlockGenerator = simple_solution_generator(spend_bundle)
npc_result: NPCResult = get_name_puzzle_conditions(
program, INFINITE_COST, cost_per_byte=DEFAULT_CONSTANTS.COST_PER_BYTE, mempool_mode=True
)
self.cost_dict[descriptor] = npc_result.cost
cost_to_subtract: int = 0
for cs in spend_bundle.coin_spends:
cost_to_subtract += len(bytes(cs.puzzle_reveal)) * DEFAULT_CONSTANTS.COST_PER_BYTE
self.cost_dict_no_puzs[descriptor] = npc_result.cost - cost_to_subtract
return spend_bundle
def log_cost_statistics(self) -> str:
merged_dict = {
"standard cost": self.cost_dict,
"no puzzle reveals": self.cost_dict_no_puzs,
}
return json.dumps(merged_dict, indent=4)
@streamable
@dataclass(frozen=True)
class SimFullBlock(Streamable):

View File

@ -5,7 +5,7 @@ from typing import List, Optional, Tuple
import pytest
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia.clvm.spend_sim import SimClient, SpendSim, sim_and_client
from chia.clvm.spend_sim import CostLogger, SimClient, SpendSim, sim_and_client
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program
@ -59,12 +59,16 @@ class TestSingleton:
coinsols: List[CoinSpend],
ex_error: Optional[Err] = None,
fail_msg: str = "",
cost_logger: Optional[CostLogger] = None,
cost_log_msg: str = "",
):
signature: G2Element = self.sign_delegated_puz(delegated_puzzle, coin)
spend_bundle = SpendBundle(
coinsols,
signature,
)
if cost_logger is not None:
spend_bundle = cost_logger.add_cost(cost_log_msg, spend_bundle)
try:
result, error = await sim_client.push_tx(spend_bundle)
@ -79,7 +83,7 @@ class TestSingleton:
@pytest.mark.asyncio
@pytest.mark.parametrize("version", [0, 1])
async def test_singleton_top_layer(self, version):
async def test_singleton_top_layer(self, version, cost_logger):
async with sim_and_client() as (sim, sim_client):
# START TESTS
# Generate starting info
@ -133,6 +137,8 @@ class TestSingleton:
starting_coin,
delegated_puzzle,
[starting_coinsol, launcher_coinsol],
cost_logger=cost_logger,
cost_log_msg="Singleton Launch + Standard TX",
)
# EVE
@ -180,6 +186,8 @@ class TestSingleton:
singleton_eve,
delegated_puzzle,
[singleton_eve_coinsol],
cost_logger=cost_logger,
cost_log_msg="Singleton Eve Spend w/ Standard TX",
)
# POST-EVE
@ -205,6 +213,8 @@ class TestSingleton:
singleton,
delegated_puzzle,
[singleton_coinsol],
cost_logger=cost_logger,
cost_log_msg="Singleton Spend + Standard TX",
)
# CLAIM A P2_SINGLETON
@ -247,7 +257,13 @@ class TestSingleton:
)
await self.make_and_spend_bundle(
sim, sim_client, singleton_child, delegated_puzzle, [singleton_claim_coinsol, claim_coinsol]
sim,
sim_client,
singleton_child,
delegated_puzzle,
[singleton_claim_coinsol, claim_coinsol],
cost_logger=cost_logger,
cost_log_msg="Singleton w/ Standard TX claim p2_singleton",
)
# CLAIM A P2_SINGLETON_OR_DELAYED
@ -303,7 +319,13 @@ class TestSingleton:
sim.get_height()
) # The last coin solution before this point is singleton_claim_coinsol
await self.make_and_spend_bundle(
sim, sim_client, singleton_child, delegated_puzzle, [delay_claim_coinsol, claim_coinsol]
sim,
sim_client,
singleton_child,
delegated_puzzle,
[delay_claim_coinsol, claim_coinsol],
cost_logger=cost_logger,
cost_log_msg="Singleton w/ Standard TX claim p2_singleton_or_delayed",
)
# TRY TO SPEND AWAY TOO SOON (Negative Test)
@ -513,6 +535,8 @@ class TestSingleton:
singleton_child,
delegated_puzzle,
[melt_coinsol],
cost_logger=cost_logger,
cost_log_msg="Singleton w/ Standard TX melt",
)
melted_coin: Coin = (await sim.all_non_reward_coins())[0]

View File

@ -16,6 +16,7 @@ import pytest_asyncio
from _pytest.fixtures import SubRequest
# Set spawn after stdlib imports, but before other imports
from chia.clvm.spend_sim import CostLogger
from chia.full_node.full_node import FullNode
from chia.full_node.full_node_api import FullNodeAPI
from chia.protocols import full_node_protocol
@ -746,3 +747,12 @@ def chia_root_fixture(tmp_path: Path, scripts_path: Path) -> ChiaRoot:
root.run(args=["configure", "--set-log-level", "INFO"])
return root
@pytest.fixture(name="cost_logger", scope="session")
def cost_logger_fixture() -> Iterator[CostLogger]:
cost_logger = CostLogger()
yield cost_logger
print()
print()
print(cost_logger.log_cost_statistics())

View File

@ -1,12 +1,12 @@
from __future__ import annotations
from typing import Dict, List, Optional, Tuple
from typing import List, Optional, Tuple
import pytest
from blspy import AugSchemeMPL, G2Element, PrivateKey
from clvm.casts import int_to_bytes
from chia.clvm.spend_sim import SimClient, SpendSim, sim_and_client
from chia.clvm.spend_sim import CostLogger, SimClient, SpendSim, sim_and_client
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.sized_bytes import bytes32
@ -44,6 +44,8 @@ async def do_spend(
extra_deltas: Optional[List[int]] = None,
additional_spends: List[SpendBundle] = [],
limitations_solutions: Optional[List[Program]] = None,
cost_logger: Optional[CostLogger] = None,
cost_log_msg: str = "",
) -> int:
if limitations_solutions is None:
limitations_solutions = [Program.to([])] * len(coins)
@ -72,15 +74,16 @@ async def do_spend(
spendable_cat_list,
)
agg_sig = AugSchemeMPL.aggregate(signatures)
result = await sim_client.push_tx(
SpendBundle.aggregate(
[
*additional_spends,
spend_bundle,
SpendBundle([], agg_sig), # "Signing" the spend bundle
]
)
final_bundle = SpendBundle.aggregate(
[
*additional_spends,
spend_bundle,
SpendBundle([], agg_sig), # "Signing" the spend bundle
]
)
if cost_logger is not None:
final_bundle = cost_logger.add_cost(cost_log_msg, final_bundle)
result = await sim_client.push_tx(final_bundle)
assert result == expected_result
cost = cost_of_spend_bundle(spend_bundle)
await sim.farm_block()
@ -88,10 +91,8 @@ async def do_spend(
class TestCATLifecycle:
cost: Dict[str, int] = {}
@pytest.mark.asyncio()
async def test_cat_mod(self):
async def test_cat_mod(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
tail = Program.to([])
checker_solution = Program.to([])
@ -101,7 +102,7 @@ class TestCATLifecycle:
starting_coin: Coin = (await sim_client.get_coin_records_by_puzzle_hash(cat_ph))[0].coin
# Testing the eve spend
self.cost["Eve Spend"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -119,6 +120,8 @@ class TestCATLifecycle:
],
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution],
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend + create three children (TAIL: ())",
)
# There's 4 total coins at this point. A farming reward and the three children of the spend above.
@ -129,7 +132,7 @@ class TestCATLifecycle:
for record in (await sim_client.get_coin_records_by_puzzle_hash(cat_ph, include_spent_coins=False))
]
coins = [coins[0], coins[1]]
self.cost["Two CATs"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -146,6 +149,8 @@ class TestCATLifecycle:
],
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution] * 2,
cost_logger=cost_logger,
cost_log_msg="Cat Spend x2 + create one child (TAIL: ())",
)
# Testing a combination of three
@ -154,7 +159,7 @@ class TestCATLifecycle:
for record in (await sim_client.get_coin_records_by_puzzle_hash(cat_ph, include_spent_coins=False))
]
total_amount: uint64 = uint64(sum([c.amount for c in coins]))
self.cost["Three CATs"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -172,6 +177,8 @@ class TestCATLifecycle:
],
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution] * 3,
cost_logger=cost_logger,
cost_log_msg="Cat Spend x3 + create one child (TAIL: ())",
)
# Spend with a standard lineage proof
@ -179,7 +186,7 @@ class TestCATLifecycle:
_, curried_args = cat_puzzle.uncurry()
_, _, innerpuzzle = curried_args.as_iter()
lineage_proof = LineageProof(parent_coin.parent_coin_info, innerpuzzle.get_tree_hash(), parent_coin.amount)
self.cost["Standard Lineage Check"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -188,10 +195,12 @@ class TestCATLifecycle:
[Program.to([[51, acs.get_tree_hash(), total_amount]])],
(MempoolInclusionStatus.SUCCESS, None),
reveal_limitations_program=False,
cost_logger=cost_logger,
cost_log_msg="Cat Spend + create one child",
)
# Melt some value
self.cost["Melting Value"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -208,6 +217,8 @@ class TestCATLifecycle:
(MempoolInclusionStatus.SUCCESS, None),
extra_deltas=[-1],
limitations_solutions=[checker_solution],
cost_logger=cost_logger,
cost_log_msg="Cat Spend (Melt) + create one child (TAIL: ())",
)
# Mint some value
@ -227,7 +238,7 @@ class TestCATLifecycle:
],
G2Element(),
)
self.cost["Mint Value"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -245,10 +256,12 @@ class TestCATLifecycle:
extra_deltas=[1],
additional_spends=[acs_bundle],
limitations_solutions=[checker_solution],
cost_logger=cost_logger,
cost_log_msg="ACS burn + Cat Spend (Mint) + create one child (TAIL: ())",
)
@pytest.mark.asyncio()
async def test_complex_spend(self):
async def test_complex_spend(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
tail = Program.to([])
checker_solution = Program.to([])
@ -264,7 +277,7 @@ class TestCATLifecycle:
eve_to_melt = cat_records[3].coin
# Spend two of them to make them non-eve
self.cost["Spend two eves"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -286,6 +299,8 @@ class TestCATLifecycle:
],
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution] * 2,
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend x2 + create one child each (TAIL: ())",
)
# Make the lineage proofs for the non-eves
@ -300,7 +315,7 @@ class TestCATLifecycle:
# Do the complex spend
# We have both and eve and non-eve doing both minting and melting
self.cost["Complex Spend"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -335,10 +350,12 @@ class TestCATLifecycle:
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution] * 4,
extra_deltas=[13, -21, 21, -13],
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend x2 (mint & melt) + Cat Spend x2 (mint & melt) - one child each (TAIL: ())",
)
@pytest.mark.asyncio()
async def test_genesis_by_id(self):
async def test_genesis_by_id(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
standard_acs = Program.to(1)
standard_acs_ph: bytes32 = standard_acs.get_tree_hash()
@ -358,7 +375,7 @@ class TestCATLifecycle:
)
await sim.farm_block()
self.cost["Genesis by ID"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -374,10 +391,12 @@ class TestCATLifecycle:
],
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution],
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend - create one child (TAIL: genesis_by_id)",
)
@pytest.mark.asyncio()
async def test_genesis_by_puzhash(self):
async def test_genesis_by_puzhash(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
standard_acs = Program.to(1)
standard_acs_ph: bytes32 = standard_acs.get_tree_hash()
@ -397,7 +416,7 @@ class TestCATLifecycle:
)
await sim.farm_block()
self.cost["Genesis by Puzhash"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -413,10 +432,12 @@ class TestCATLifecycle:
],
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution],
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend - create one child (TAIL: genesis_by_puzhash)",
)
@pytest.mark.asyncio()
async def test_everything_with_signature(self):
async def test_everything_with_signature(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
sk = PrivateKey.from_bytes(secret_exponent_for_index(1).to_bytes(32, "big"))
tail: Program = EverythingWithSig.construct([Program.to(sk.get_g1())])
@ -432,7 +453,7 @@ class TestCATLifecycle:
sk, (starting_coin.name() + sim.defaults.AGG_SIG_ME_ADDITIONAL_DATA)
)
self.cost["Signature Issuance"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -449,6 +470,8 @@ class TestCATLifecycle:
(MempoolInclusionStatus.SUCCESS, None),
limitations_solutions=[checker_solution],
signatures=[signature],
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend - create one child (TAIL: everything_with_signature)",
)
# Test melting value
@ -457,7 +480,7 @@ class TestCATLifecycle:
sk, (int_to_bytes(-1) + coin.name() + sim.defaults.AGG_SIG_ME_ADDITIONAL_DATA)
)
self.cost["Signature Melt"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -475,6 +498,8 @@ class TestCATLifecycle:
extra_deltas=[-1],
limitations_solutions=[checker_solution],
signatures=[signature],
cost_logger=cost_logger,
cost_log_msg="Cat Spend (Melt) - create one child (TAIL: everything_with_signature)",
)
# Test minting value
@ -499,7 +524,7 @@ class TestCATLifecycle:
G2Element(),
)
self.cost["Signature Mint"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -518,10 +543,12 @@ class TestCATLifecycle:
limitations_solutions=[checker_solution],
signatures=[signature],
additional_spends=[acs_bundle],
cost_logger=cost_logger,
cost_log_msg="ACS Burn + Cat Spend (Mint) - create one child (TAIL: everything_with_signature)",
)
@pytest.mark.asyncio()
async def test_delegated_tail(self):
async def test_delegated_tail(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
standard_acs = Program.to(1)
standard_acs_ph: bytes32 = standard_acs.get_tree_hash()
@ -556,7 +583,7 @@ class TestCATLifecycle:
)
signature: G2Element = AugSchemeMPL.sign(sk, new_tail.get_tree_hash())
self.cost["Delegated Genesis"] = await do_spend(
await do_spend(
sim,
sim_client,
tail,
@ -573,11 +600,6 @@ class TestCATLifecycle:
(MempoolInclusionStatus.SUCCESS, None),
signatures=[signature],
limitations_solutions=[checker_solution],
cost_logger=cost_logger,
cost_log_msg="Cat Eve Spend - create one child (TAIL: delegated_tail - genesis_by_id)",
)
def test_cost(self):
import json
import logging
log = logging.getLogger(__name__)
log.warning(json.dumps(self.cost))

View File

@ -25,7 +25,6 @@ from chia.wallet.payment import Payment
from chia.wallet.puzzle_drivers import PuzzleInfo
from chia.wallet.puzzles.cat_loader import CAT_MOD
from chia.wallet.trading.offer import OFFER_MOD, NotarizedPayment, Offer
from tests.clvm.benchmark_costs import cost_of_spend_bundle
acs = Program.to(1)
acs_ph = acs.get_tree_hash()
@ -167,10 +166,8 @@ def generate_secure_bundle(
class TestOfferLifecycle:
cost: Dict[str, int] = {}
@pytest.mark.asyncio()
async def test_complex_offer(self):
async def test_complex_offer(self, cost_logger):
async with sim_and_client() as (sim, sim_client):
coins_needed: Dict[Optional[str], List[int]] = {
None: [500, 400, 300],
@ -333,14 +330,6 @@ class TestOfferLifecycle:
arbitrage_ph: bytes32 = Program.to([3, [], [], 1]).get_tree_hash()
offer_bundle: SpendBundle = new_offer.to_valid_spend(arbitrage_ph)
result = await sim_client.push_tx(offer_bundle)
result = await sim_client.push_tx(cost_logger.add_cost("Complex Offer", offer_bundle))
assert result == (MempoolInclusionStatus.SUCCESS, None)
self.cost["complex offer"] = cost_of_spend_bundle(offer_bundle)
await sim.farm_block()
def test_cost(self):
import json
import logging
log = logging.getLogger(__name__)
log.warning(json.dumps(self.cost))

View File

@ -5,7 +5,7 @@ from typing import Dict, List, Tuple
import pytest
from blspy import G2Element
from chia.clvm.spend_sim import sim_and_client
from chia.clvm.spend_sim import CostLogger, sim_and_client
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.sized_bytes import bytes32
@ -39,7 +39,7 @@ NIL_PH = Program.to(None).get_tree_hash()
@pytest.mark.asyncio
async def test_graftroot() -> None:
async def test_graftroot(cost_logger: CostLogger) -> None:
async with sim_and_client() as (sim, sim_client):
# Create the coin we're testing
all_values: List[bytes32] = [bytes32([x] * 32) for x in range(0, 100)]
@ -117,6 +117,10 @@ async def test_graftroot() -> None:
# If this is the satisfactory merkle tree
if filtered_values == all_values:
cost_logger.add_cost(
"DL Graftroot - fake singleton w/ announce + prove two rows in a DL merkle tree + create one child",
final_bundle,
)
assert result == (MempoolInclusionStatus.SUCCESS, None)
# clear the mempool
same_height = sim.block_height

View File

@ -6,7 +6,7 @@ from typing import List
import pytest
from blspy import G2Element
from chia.clvm.spend_sim import sim_and_client
from chia.clvm.spend_sim import CostLogger, sim_and_client
from chia.types.announcement import Announcement
from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.sized_bytes import bytes32
@ -28,7 +28,7 @@ ACS_PH = ACS.get_tree_hash()
@pytest.mark.asyncio()
@pytest.mark.parametrize("metadata_updater", ["default"])
async def test_state_layer(metadata_updater: str) -> None:
async def test_state_layer(cost_logger: CostLogger, metadata_updater: str) -> None:
async with sim_and_client() as (sim, sim_client):
if metadata_updater == "default":
METADATA: Program = metadata_to_program(
@ -59,7 +59,9 @@ async def test_state_layer(metadata_updater: str) -> None:
state_layer_puzzle,
Program.to([[[51, ACS_PH, 1]]]),
)
generic_bundle = SpendBundle([generic_spend], G2Element())
generic_bundle = cost_logger.add_cost(
"State layer only coin - one child created", SpendBundle([generic_spend], G2Element())
)
result = await sim_client.push_tx(generic_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
@ -125,7 +127,9 @@ async def test_state_layer(metadata_updater: str) -> None:
]
),
)
update_bundle = SpendBundle([update_spend], G2Element())
update_bundle = cost_logger.add_cost(
"State layer only coin (metadata update) - one child created", SpendBundle([update_spend], G2Element())
)
result = await sim_client.push_tx(update_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
await sim.farm_block()
@ -133,7 +137,7 @@ async def test_state_layer(metadata_updater: str) -> None:
@pytest.mark.asyncio()
async def test_ownership_layer() -> None:
async def test_ownership_layer(cost_logger: CostLogger) -> None:
async with sim_and_client() as (sim, sim_client):
TARGET_OWNER = bytes32([0] * 32)
TARGET_TP = Program.to([8]) # (x)
@ -157,7 +161,9 @@ async def test_ownership_layer() -> None:
ownership_puzzle,
Program.to([[[51, ACS_PH, 1], [-10, [], []]]]),
)
generic_bundle = SpendBundle([generic_spend], G2Element())
generic_bundle = cost_logger.add_cost(
"Ownership only coin - one child created", SpendBundle([generic_spend], G2Element())
)
result = await sim_client.push_tx(generic_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
await sim.farm_block()
@ -222,7 +228,10 @@ async def test_ownership_layer() -> None:
]
),
)
update_everything_bundle = SpendBundle([update_everything_spend], G2Element())
update_everything_bundle = cost_logger.add_cost(
"Ownership only coin (update owner and TP) - one child + 3 announcements created",
SpendBundle([update_everything_spend], G2Element()),
)
result = await sim_client.push_tx(update_everything_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
await sim.farm_block()
@ -236,7 +245,7 @@ async def test_ownership_layer() -> None:
@pytest.mark.asyncio()
async def test_default_transfer_program() -> None:
async def test_default_transfer_program(cost_logger: CostLogger) -> None:
async with sim_and_client() as (sim, sim_client):
# Now make the ownership coin
FAKE_SINGLETON_MOD = Program.to([2, 5, 11]) # (a 5 11) | (mod (_ INNER_PUZ inner_sol) (a INNER_PUZ inner_sol))
@ -273,7 +282,9 @@ async def test_default_transfer_program() -> None:
ownership_puzzle,
Program.to([[[51, ACS_PH, 1]]]),
)
generic_bundle = SpendBundle([generic_spend], G2Element())
generic_bundle = cost_logger.add_cost(
"Ownership only coin (default NFT1 TP) - one child created", SpendBundle([generic_spend], G2Element())
)
result = await sim_client.push_tx(generic_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
await sim.farm_block()
@ -317,7 +328,7 @@ async def test_default_transfer_program() -> None:
cat_announcement_spend = CoinSpend(cat_coin, FAKE_CAT, Program.to([[[62, expected_announcement_data]]]))
# Make sure every combo except all of them work
# Make sure every combo except all of them fail
for i in range(1, 3):
for announcement_combo in itertools.combinations(
[did_announcement_spend, xch_announcement_spend, cat_announcement_spend], i
@ -326,8 +337,11 @@ async def test_default_transfer_program() -> None:
assert result == (MempoolInclusionStatus.FAILED, Err.ASSERT_ANNOUNCE_CONSUMED_FAILED)
# Make sure all of them together pass
full_bundle = SpendBundle(
[ownership_spend, did_announcement_spend, xch_announcement_spend, cat_announcement_spend], G2Element()
full_bundle = cost_logger.add_cost(
"Ownership only coin (default NFT1 TP) - one child created + update DID + offer CATs + offer XCH",
SpendBundle(
[ownership_spend, did_announcement_spend, xch_announcement_spend, cat_announcement_spend], G2Element()
),
)
result = await sim_client.push_tx(full_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
@ -349,7 +363,10 @@ async def test_default_transfer_program() -> None:
new_ownership_puzzle,
Program.to([[[51, ACS_PH, 1], [-10, [], [], []]]]),
)
empty_bundle = SpendBundle([empty_spend], G2Element())
empty_bundle = cost_logger.add_cost(
"Ownership only coin (default NFT1 TP) - one child created + clear DID",
SpendBundle([empty_spend], G2Element()),
)
result = await sim_client.push_tx(empty_bundle)
assert result == (MempoolInclusionStatus.SUCCESS, None)
await sim.farm_block()