Skip to content

Commit 657b637

Browse files
authored
[LABS-151] Replace NIL with Program.NIL (#20189)
Replace `NIL` with `Program.NIL`
1 parent e36d768 commit 657b637

27 files changed

+66
-69
lines changed

chia/_tests/cmds/wallet/test_did.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from chia._tests.cmds.cmd_test_utils import TestRpcClients, TestWalletRpcClient, logType, run_cli_command_and_assert
1212
from chia._tests.cmds.wallet.test_consts import FINGERPRINT_ARG, STD_TX, STD_UTX, get_bytes32
13-
from chia.types.blockchain_format.program import NIL, Program
13+
from chia.types.blockchain_format.program import Program
1414
from chia.types.signing_mode import SigningMode
1515
from chia.util.bech32m import encode_puzzle_hash
1616
from chia.wallet.conditions import Condition, ConditionValidTimes, CreateCoinAnnouncement, CreatePuzzleAnnouncement
@@ -42,7 +42,7 @@
4242
argnames=["program", "result"],
4343
argvalues=[
4444
(Program.to(NIL_TREEHASH), True),
45-
(NIL, True),
45+
(Program.NIL, True),
4646
(Program.to(bytes32([1] * 32)), False),
4747
],
4848
)

chia/_tests/wallet/cat_wallet/test_cat_wallet.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from chia._tests.util.time_out_assert import time_out_assert, time_out_assert_not_none
2020
from chia.simulator.simulator_protocol import ReorgProtocol
2121
from chia.types.blockchain_format.coin import Coin, coin_as_list
22-
from chia.types.blockchain_format.program import NIL, Program
22+
from chia.types.blockchain_format.program import Program
2323
from chia.types.coin_spend import make_spend
2424
from chia.util.bech32m import encode_puzzle_hash
2525
from chia.util.db_wrapper import DBWrapper2
@@ -82,7 +82,9 @@ async def mint_cat(
8282
1,
8383
[
8484
CreateCoin(wrapped_inner_puzzle_hash, amount, memos=[inner_puzzle_hash]).to_program(),
85-
UnknownCondition(opcode=Program.to(51), args=[NIL, Program.to(-113), tail, NIL]).to_program(),
85+
UnknownCondition(
86+
opcode=Program.to(51), args=[Program.NIL, Program.to(-113), tail, Program.NIL]
87+
).to_program(),
8688
],
8789
)
8890
)
@@ -112,7 +114,7 @@ async def mint_cat(
112114
cat_addition,
113115
tail_hash,
114116
eve_inner_puzzle,
115-
NIL,
117+
Program.NIL,
116118
)
117119
],
118120
)
@@ -1411,7 +1413,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
14111413
if wallet_type is RCATWallet:
14121414
inner_puzhash = create_revocation_layer(bytes32.zeros, inner_puzhash).get_tree_hash()
14131415
puzzlehash_unhardened = construct_cat_puzzle(
1414-
CAT_MOD, Program.to(None).get_tree_hash(), inner_puzhash
1416+
CAT_MOD, Program.NIL.get_tree_hash(), inner_puzhash
14151417
).get_tree_hash_precalc(inner_puzhash)
14161418
change_derivation = DerivationRecord(
14171419
uint32(0), puzzlehash_unhardened, pubkey_unhardened, WalletType.CAT, uint32(2), False
@@ -1422,7 +1424,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
14221424
our_puzzle = await action_scope.get_puzzle(wallet.wallet_state_manager)
14231425
cat_puzzle = construct_cat_puzzle(
14241426
CAT_MOD,
1425-
Program.to(None).get_tree_hash(),
1427+
Program.NIL.get_tree_hash(),
14261428
Program.to(1),
14271429
)
14281430
addr = encode_puzzle_hash(cat_puzzle.get_tree_hash(), "txch")
@@ -1451,7 +1453,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
14511453
cat_coin = next(c for c in spend_bundle.additions() if c.amount == cat_amount_0)
14521454
next_coin = Coin(
14531455
cat_coin.name(),
1454-
construct_cat_puzzle(CAT_MOD, Program.to(None).get_tree_hash(), our_puzzle).get_tree_hash(),
1456+
construct_cat_puzzle(CAT_MOD, Program.NIL.get_tree_hash(), our_puzzle).get_tree_hash(),
14551457
cat_amount_0,
14561458
)
14571459
eve_spend, _ = await wsm.sign_bundle(
@@ -1478,7 +1480,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
14781480
),
14791481
make_spend(
14801482
next_coin,
1481-
construct_cat_puzzle(CAT_MOD, Program.to(None).get_tree_hash(), our_puzzle),
1483+
construct_cat_puzzle(CAT_MOD, Program.NIL.get_tree_hash(), our_puzzle),
14821484
Program.to(
14831485
[
14841486
[
@@ -1660,7 +1662,7 @@ async def test_cat_melt_balance(wallet_environments: WalletTestFramework) -> Non
16601662
conditions=(
16611663
UnknownCondition(
16621664
opcode=Program.to(51),
1663-
args=[Program.to(None), Program.to(-113), Program.to(ACS_TAIL), Program.to(None)],
1665+
args=[Program.NIL, Program.to(-113), Program.to(ACS_TAIL), Program.NIL],
16641666
),
16651667
),
16661668
),

chia/_tests/wallet/db_wallet/test_db_graftroot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232
ACS_PH = ACS.get_tree_hash()
3333

34-
NIL_PH = Program.to(None).get_tree_hash()
34+
NIL_PH = Program.NIL.get_tree_hash()
3535

3636

3737
@pytest.mark.anyio

chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
def test_ownership_outer_puzzle() -> None:
1818
ACS = Program.to(1)
19-
NIL = Program.to([])
2019
owner = bytes32.zeros
2120
# (mod (current_owner conditions solution)
2221
# (list current_owner () conditions)
@@ -28,7 +27,7 @@ def test_ownership_outer_puzzle() -> None:
2827
)
2928
transfer_program_default: Program = puzzle_for_transfer_program(bytes32([1] * 32), bytes32([2] * 32), uint16(5000))
3029
ownership_puzzle: Program = puzzle_for_ownership_layer(owner, Program.to(transfer_program), ACS)
31-
ownership_puzzle_empty: Program = puzzle_for_ownership_layer(NIL, Program.to(transfer_program), ACS)
30+
ownership_puzzle_empty: Program = puzzle_for_ownership_layer(Program.NIL, Program.to(transfer_program), ACS)
3231
ownership_puzzle_default: Program = puzzle_for_ownership_layer(owner, transfer_program_default, ACS)
3332
ownership_driver: Optional[PuzzleInfo] = match_puzzle(uncurry_puzzle(ownership_puzzle))
3433
ownership_driver_empty: Optional[PuzzleInfo] = match_puzzle(uncurry_puzzle(ownership_puzzle_empty))
@@ -41,7 +40,7 @@ def test_ownership_outer_puzzle() -> None:
4140
assert transfer_program_driver is not None
4241
assert ownership_driver.type() == "ownership"
4342
assert ownership_driver["owner"] == owner
44-
assert ownership_driver_empty["owner"] == NIL
43+
assert ownership_driver_empty["owner"] == Program.NIL
4544
assert ownership_driver["transfer_program"] == transfer_program
4645
assert ownership_driver_default["transfer_program"] == transfer_program_driver
4746
assert transfer_program_driver.type() == "royalty transfer program"

chia/_tests/wallet/rpc/test_wallet_rpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3130,7 +3130,7 @@ async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironme
31303130
# Send to a CAT with an anyone can spend TAIL
31313131
async with env.wallet_1.wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
31323132
our_ph = await action_scope.get_puzzle_hash(env.wallet_1.wallet.wallet_state_manager)
3133-
cat_puzzle: Program = construct_cat_puzzle(CAT_MOD, Program.to(None).get_tree_hash(), Program.to(1))
3133+
cat_puzzle: Program = construct_cat_puzzle(CAT_MOD, Program.NIL.get_tree_hash(), Program.to(1))
31343134
addr = encode_puzzle_hash(
31353135
cat_puzzle.get_tree_hash(),
31363136
"txch",
@@ -3175,7 +3175,7 @@ async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironme
31753175
await farm_transaction(full_node_api, wallet_node, eve_spend)
31763176

31773177
# Make sure we have the CAT
3178-
res = await client.create_wallet_for_existing_cat(Program.to(None).get_tree_hash())
3178+
res = await client.create_wallet_for_existing_cat(Program.NIL.get_tree_hash())
31793179
assert res["success"]
31803180
cat_wallet_id = res["wallet_id"]
31813181
await time_out_assert(20, get_confirmed_balance, tx_amount, client, cat_wallet_id)

chia/_tests/wallet/test_conditions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ class TimelockInfo:
285285
],
286286
)
287287
def test_timelock_parsing(timelock_info: TimelockInfo) -> None:
288-
assert timelock_info.parsed_info == parse_timelock_info(
289-
[UnknownCondition(Program.to(None), []), *timelock_info.drivers]
290-
)
288+
assert timelock_info.parsed_info == parse_timelock_info([UnknownCondition(Program.NIL, []), *timelock_info.drivers])
291289
assert timelock_info.parsed_info.to_conditions() == (
292290
timelock_info.conditions_after if timelock_info.conditions_after is not None else timelock_info.drivers
293291
)

chia/_tests/wallet/test_debug_spend_bundle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_debug_spend_bundle(capsys: pytest.CaptureFixture[str]) -> None:
5050
make_spend(
5151
coin_bad_reveal,
5252
ACS,
53-
Program.to(None),
53+
Program.NIL,
5454
),
5555
make_spend(
5656
coin,
@@ -60,7 +60,7 @@ def test_debug_spend_bundle(capsys: pytest.CaptureFixture[str]) -> None:
6060
make_spend(
6161
child_coin,
6262
ACS,
63-
Program.to(None),
63+
Program.NIL,
6464
),
6565
],
6666
sig,

chia/_tests/wallet/test_signer_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def test_p2dohp_wallet_signer_protocol(wallet_environments: WalletTestFram
135135
async with wallet.wallet_state_manager.new_action_scope(wallet_environments.tx_config, push=False) as action_scope:
136136
[coin] = await wallet.select_coins(uint64(0), action_scope)
137137
puzzle: Program = await wallet.puzzle_for_puzzle_hash(coin.puzzle_hash)
138-
delegated_puzzle: Program = Program.to(None)
138+
delegated_puzzle: Program = Program.NIL
139139
delegated_puzzle_hash: bytes32 = delegated_puzzle.get_tree_hash()
140140
solution: Program = Program.to([None, None, None])
141141

chia/_tests/wallet/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_list_to_binary_tree() -> None:
106106
@pytest.mark.parametrize(
107107
"serializations",
108108
[
109-
(tuple(), Program.to(None), []),
109+
(tuple(), Program.NIL, []),
110110
((bytes32.zeros,), Program.to([bytes32.zeros]), [LineageProofField.PARENT_NAME]),
111111
(
112112
(bytes32.zeros, bytes32.zeros),
@@ -129,7 +129,7 @@ def test_lineage_proof_varargs(serializations: tuple[tuple[Any, ...], Program, l
129129
@pytest.mark.parametrize(
130130
"serializations",
131131
[
132-
({}, Program.to(None), []),
132+
({}, Program.NIL, []),
133133
({"parent_name": bytes32.zeros}, Program.to([bytes32.zeros]), [LineageProofField.PARENT_NAME]),
134134
(
135135
{"parent_name": bytes32.zeros, "inner_puzzle_hash": bytes32.zeros},

chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
def test_cat_outer_puzzle() -> None:
2424
authorized_providers: list[bytes32] = [bytes32.zeros, bytes32.zeros]
25-
proofs_checker: Program = Program.to(None)
25+
proofs_checker: Program = Program.NIL
2626
ACS: Program = Program.to(1)
2727
cr_puzzle: Program = construct_cr_layer(authorized_providers, proofs_checker, ACS)
2828
double_cr_puzzle: Program = construct_cr_layer(authorized_providers, proofs_checker, cr_puzzle)

0 commit comments

Comments
 (0)