Skip to content

Commit

Permalink
bytes(\d+)\(b"0" \* \1\)
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Sep 20, 2024
1 parent 668e0fc commit e02d3c7
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion chia/_tests/blockchain/test_blockchain_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from chia.util.ints import uint32, uint64
from chia.wallet.conditions import AssertCoinAnnouncement, AssertPuzzleAnnouncement

BURN_PUZZLE_HASH = bytes32(b"0" * 32)
BURN_PUZZLE_HASH = bytes32.zeros

WALLET_A = WalletTool(test_constants)
WALLET_A_PUZZLE_HASHES = [WALLET_A.get_new_puzzlehash() for _ in range(5)]
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ async def test_get_ancestors_optimized(data_store: DataStore, store_id: bytes32)
if not deleted_all:
while node_count > 0:
node_count -= 1
seed = bytes32(b"0" * 32)
seed = bytes32.zeros
node_hash = await data_store.get_terminal_node_for_seed(store_id, seed)
assert node_hash is not None
node = await data_store.get_node(node_hash)
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/stores/test_coin_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def height_of(coin_state: CoinState) -> int:
@pytest.mark.parametrize("cut_off_middle", [True, False])
async def test_batch_many_coin_states(db_version: int, cut_off_middle: bool) -> None:
async with DBConnection(db_version) as db_wrapper:
ph = bytes32(b"0" * 32)
ph = bytes32.zeros

# Generate coin records.
coin_records: List[CoinRecord] = []
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
HINT_PUZZLE = Program.to(3)
HINT_PUZZLE_HASH = HINT_PUZZLE.get_tree_hash()

IDENTITY_COIN = Coin(bytes32(b"0" * 32), IDENTITY_PUZZLE_HASH, uint64(1000))
IDENTITY_COIN = Coin(bytes32.zeros, IDENTITY_PUZZLE_HASH, uint64(1000))
OTHER_COIN = Coin(bytes32(b"3" * 32), OTHER_PUZZLE_HASH, uint64(1000))

EMPTY_SIGNATURE = AugSchemeMPL.aggregate([])
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/mempool/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
from chia.util.recursive_replace import recursive_replace
from chia.wallet.conditions import AssertCoinAnnouncement, AssertPuzzleAnnouncement

BURN_PUZZLE_HASH = bytes32(b"0" * 32)
BURN_PUZZLE_HASH = bytes32.zeros
BURN_PUZZLE_HASH_2 = bytes32(b"1" * 32)

log = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/core/mempool/test_mempool_item_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
OTHER_PUZZLE = Program.to(2)
OTHER_PUZZLE_HASH = OTHER_PUZZLE.get_tree_hash()

IDENTITY_COIN_1 = Coin(bytes32(b"0" * 32), IDENTITY_PUZZLE_HASH, uint64(1000))
IDENTITY_COIN_1 = Coin(bytes32.zeros, IDENTITY_PUZZLE_HASH, uint64(1000))
IDENTITY_COIN_2 = Coin(bytes32(b"1" * 32), IDENTITY_PUZZLE_HASH, uint64(1000))
IDENTITY_COIN_3 = Coin(bytes32(b"2" * 32), IDENTITY_PUZZLE_HASH, uint64(1000))

Expand Down Expand Up @@ -136,7 +136,7 @@ def test_by_spend_puzzle_hashes() -> None:
]

# And an unrelated puzzle hash.
assert mempool.items_with_puzzle_hashes({bytes32(b"0" * 32)}, False) == []
assert mempool.items_with_puzzle_hashes({bytes32.zeros}, False) == []


def test_by_created_coin_id() -> None:
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/test_cost_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from .make_block_generator import make_block_generator

BURN_PUZZLE_HASH = bytes32(b"0" * 32)
BURN_PUZZLE_HASH = bytes32.zeros
SMALL_BLOCK_GENERATOR = make_block_generator(1)

log = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/fee_estimation/test_fee_estimation_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ async def test_tx(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi],
client, full_node_rpc_api = setup_node_and_rpc
wallet_a: WalletTool = bt.get_pool_wallet_tool()
my_puzzle_hash = wallet_a.get_new_puzzlehash()
recevier_puzzle_hash = bytes32(b"0" * 32)
coin_to_spend = Coin(bytes32(b"0" * 32), my_puzzle_hash, uint64(1750000000000))
recevier_puzzle_hash = bytes32.zeros
coin_to_spend = Coin(bytes32.zeros, my_puzzle_hash, uint64(1750000000000))
spend_bundle = wallet_a.generate_signed_transaction(
uint64(coin_to_spend.amount), recevier_puzzle_hash, coin_to_spend
)
Expand All @@ -207,8 +207,8 @@ async def test_multiple(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpc
def get_test_spendbundle(bt: BlockTools) -> SpendBundle:
wallet_a: WalletTool = bt.get_pool_wallet_tool()
my_puzzle_hash = wallet_a.get_new_puzzlehash()
recevier_puzzle_hash = bytes32(b"0" * 32)
coin_to_spend = Coin(bytes32(b"0" * 32), my_puzzle_hash, uint64(1750000000000))
recevier_puzzle_hash = bytes32.zeros
coin_to_spend = Coin(bytes32.zeros, my_puzzle_hash, uint64(1750000000000))
return wallet_a.generate_signed_transaction(uint64(coin_to_spend.amount), recevier_puzzle_hash, coin_to_spend)


Expand Down
24 changes: 12 additions & 12 deletions chia/_tests/util/test_trusted_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@
"host,node_id,trusted_peers,trusted_cidrs,testing,result",
[
# IPv6 localhost testing
("::1", bytes32(b"0" * 32), {}, [], False, True),
("::1", bytes32.zeros, {}, [], False, True),
# IPv6 localhost testing with mismatched node_id (still True)
("::1", bytes32(b"d" * 32), {bytes32(b"a" * 32).hex(): "0"}, [], False, True),
# IPv6 localhost testing with testing flag True
("::1", bytes32(b"0" * 32), {}, [], True, False),
("::1", bytes32.zeros, {}, [], True, False),
("::1", bytes32(b"d" * 32), {bytes32(b"a" * 32).hex(): "0"}, [], True, False),
# IPv6 localhost long form
("0:0:0:0:0:0:0:1", bytes32(b"0" * 32), {}, [], False, True),
("0:0:0:0:0:0:0:1", bytes32(b"0" * 32), {}, [], True, False),
("0:0:0:0:0:0:0:1", bytes32.zeros, {}, [], False, True),
("0:0:0:0:0:0:0:1", bytes32.zeros, {}, [], True, False),
# IPv4 localhost testing
("127.0.0.1", bytes32(b"0" * 32), {}, [], False, True),
("localhost", bytes32(b"0" * 32), {}, [], False, True),
("127.0.0.1", bytes32(b"0" * 32), {}, [], True, False),
("localhost", bytes32(b"0" * 32), {}, [], True, False),
("127.0.0.1", bytes32.zeros, {}, [], False, True),
("localhost", bytes32.zeros, {}, [], False, True),
("127.0.0.1", bytes32.zeros, {}, [], True, False),
("localhost", bytes32.zeros, {}, [], True, False),
# localhost testing with testing True but with matching node_id
("127.0.0.1", bytes32(b"0" * 32), {bytes32(b"0" * 32).hex(): "0"}, [], True, True),
("127.0.0.1", bytes32.zeros, {bytes32.zeros.hex(): "0"}, [], True, True),
# misc
("2000:1000::1234:abcd", bytes32(b"0" * 32), {}, [], True, False),
("2000:1000::1234:abcd", bytes32.zeros, {}, [], True, False),
("10.11.12.13", bytes32(b"d" * 32), {bytes32(b"a" * 32).hex(): "0"}, [], False, False),
("10.11.12.13", bytes32(b"d" * 32), {bytes32(b"d" * 32).hex(): "0"}, [], False, True),
("10.11.12.13", bytes32(b"d" * 32), {}, [], False, False),
# CIDR Allowlist
("2000:1000::1234:abcd", bytes32(b"0" * 32), {}, ["2000:1000::/64"], False, True),
("2000:1000::1234:abcd", bytes32(b"0" * 32), {}, [], False, False),
("2000:1000::1234:abcd", bytes32.zeros, {}, ["2000:1000::/64"], False, True),
("2000:1000::1234:abcd", bytes32.zeros, {}, [], False, False),
("10.11.12.13", bytes32(b"d" * 32), {bytes32(b"a" * 32).hex(): "0"}, ["10.0.0.0/8"], False, True),
("10.11.12.13", bytes32(b"d" * 32), {bytes32(b"a" * 32).hex(): "0"}, [], False, False),
],
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/wallet/test_nft_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ async def test_nft_insert(self) -> None:
assert nft == (await db.get_nft_by_coin_id(nft.coin.name()))
assert await db.exists(nft.coin.name())
# negative tests
assert (await db.get_nft_by_coin_id(bytes32(b"0" * 32))) is None
assert not await db.exists(bytes32(b"0" * 32))
assert (await db.get_nft_by_coin_id(bytes32.zeros)) is None
assert not await db.exists(bytes32.zeros)

@pytest.mark.anyio
async def test_nft_remove(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/wallet/test_wallet_state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def test_get_private_key(simulator_and_wallet: OldSimulatorsAndWallets, ha
expected_private_key = conversion_method(wallet_state_manager.get_master_private_key(), derivation_index)
record = DerivationRecord(
derivation_index,
bytes32(b"0" * 32),
bytes32.zeros,
expected_private_key.get_g1(),
WalletType.STANDARD_WALLET,
uint32(1),
Expand Down
2 changes: 1 addition & 1 deletion chia/clvm/spend_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async def generate_transaction_generator(self, bundle: Optional[SpendBundle]) ->

async def farm_block(
self,
puzzle_hash: bytes32 = bytes32(b"0" * 32),
puzzle_hash: bytes32 = bytes32.zeros,
item_inclusion_filter: Optional[Callable[[bytes32], bool]] = None,
) -> Tuple[List[Coin], List[Coin]]:
# Fees get calculated
Expand Down
2 changes: 1 addition & 1 deletion chia/data_layer/util/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def generate_datastore(num_nodes: int, slow_mode: bool) -> None:

async with DataStore.managed(database=db_path) as data_store:

store_id = bytes32(b"0" * 32)
store_id = bytes32.zeros
await data_store.create_tree(store_id)

insert_time = 0.0
Expand Down

0 comments on commit e02d3c7

Please sign in to comment.