Skip to content

Commit 3ce1f47

Browse files
committed
use spend() as pyo3 doesn't support property
1 parent 333294e commit 3ce1f47

15 files changed

+39
-45
lines changed

chia/_tests/blockchain/test_blockchain.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ async def test_timelock_conditions(
20762076
if expected == AddBlockResult.NEW_PEAK:
20772077
# ensure coin was in fact spent
20782078
c = await b.coin_store.get_coin_record(coin.name())
2079-
assert c is not None and c.spent
2079+
assert c is not None and c.spent()
20802080

20812081
@pytest.mark.anyio
20822082
@pytest.mark.parametrize(
@@ -2286,10 +2286,10 @@ async def test_ephemeral_timelock(
22862286
if expected == AddBlockResult.NEW_PEAK:
22872287
# ensure coin1 was in fact spent
22882288
c = await b.coin_store.get_coin_record(coin1.name())
2289-
assert c is not None and c.spent
2289+
assert c is not None and c.spent()
22902290
# ensure coin2 was NOT spent
22912291
c = await b.coin_store.get_coin_record(coin2.name())
2292-
assert c is not None and not c.spent
2292+
assert c is not None and not c.spent()
22932293

22942294
@pytest.mark.anyio
22952295
async def test_not_tx_block_but_has_data(self, empty_blockchain: Blockchain, bt: BlockTools) -> None:
@@ -3103,9 +3103,9 @@ async def test_double_spent_in_reorg(self, empty_blockchain: Blockchain, bt: Blo
31033103

31043104
# ephemeral coin is spent
31053105
first_coin = await b.coin_store.get_coin_record(new_coin.name())
3106-
assert first_coin is not None and first_coin.spent
3106+
assert first_coin is not None and first_coin.spent()
31073107
second_coin = await b.coin_store.get_coin_record(tx_2.additions()[0].name())
3108-
assert second_coin is not None and not second_coin.spent
3108+
assert second_coin is not None and not second_coin.spent()
31093109

31103110
farmer_coin = create_farmer_coin(
31113111
blocks_reorg[-1].height,
@@ -3121,7 +3121,7 @@ async def test_double_spent_in_reorg(self, empty_blockchain: Blockchain, bt: Blo
31213121
await _validate_and_add_block(b, blocks_reorg[-1])
31223122

31233123
farmer_coin_record = await b.coin_store.get_coin_record(farmer_coin.name())
3124-
assert farmer_coin_record is not None and farmer_coin_record.spent
3124+
assert farmer_coin_record is not None and farmer_coin_record.spent()
31253125

31263126
@pytest.mark.anyio
31273127
async def test_minting_coin(self, empty_blockchain: Blockchain, bt: BlockTools) -> None:

chia/_tests/clvm/coin_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def all_coins(self) -> Iterator[Coin]:
130130

131131
def all_unspent_coins(self) -> Iterator[Coin]:
132132
for coin_entry in self._db.values():
133-
if not coin_entry.spent:
133+
if not coin_entry.spent():
134134
yield coin_entry.coin
135135

136136
def _add_coin_entry(self, coin: Coin, birthday: CoinTimestamp) -> None:

chia/_tests/core/full_node/stores/test_coin_store.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ async def test_basic_coin_store(db_version: int, softfork_height: uint32, bt: Bl
138138
# Check that the coinbase rewards are added
139139
record = await coin_store.get_coin_record(expected_coin.name())
140140
assert record is not None
141-
assert not record.spent
141+
assert not record.spent()
142142
assert record.coin == expected_coin
143143
all_records.add(record)
144144
for coin_name in tx_removals:
145145
# Check that the removed coins are set to spent
146146
record = await coin_store.get_coin_record(coin_name)
147147
assert record is not None
148-
assert record.spent
148+
assert record.spent()
149149
all_records.add(record)
150150
for coin_id, coin, _ in tx_additions:
151151
# Check that the added coins are added
152152
record = await coin_store.get_coin_record(coin_id)
153153
assert record is not None
154-
assert not record.spent
154+
assert not record.spent()
155155
assert coin == record.coin
156156
all_records.add(record)
157157

@@ -200,7 +200,7 @@ async def test_set_spent(db_version: int, bt: BlockTools) -> None:
200200
records = [await coin_store.get_coin_record(coin.name()) for coin in coins]
201201
for record in records:
202202
assert record is not None
203-
assert record.spent
203+
assert record.spent()
204204
assert record.spent_block_index == block.height
205205

206206

@@ -268,9 +268,9 @@ async def test_rollback(db_version: int, bt: BlockTools) -> None:
268268
and selected_coin.name == record.name
269269
and not selected_coin.confirmed_block_index < block.height
270270
):
271-
assert not record.spent
271+
assert not record.spent()
272272
else:
273-
assert record.spent
273+
assert record.spent()
274274
assert record.spent_block_index == block.height
275275

276276
if spend_selected_coin:
@@ -303,7 +303,7 @@ async def test_rollback(db_version: int, bt: BlockTools) -> None:
303303
if block.height <= reorg_index:
304304
for record in records:
305305
assert record is not None
306-
assert record.spent == (record.name != selected_coin.name)
306+
assert record.spent() == (record.name != selected_coin.name)
307307
else:
308308
for record in records:
309309
assert record is None
@@ -334,7 +334,7 @@ async def test_basic_reorg(tmp_dir: Path, db_version: int, bt: BlockTools) -> No
334334
records = [await coin_store.get_coin_record(coin.name()) for coin in coins]
335335
for record in records:
336336
assert record is not None
337-
assert not record.spent
337+
assert not record.spent()
338338
assert record.confirmed_block_index == block.height
339339
assert record.spent_block_index == 0
340340

@@ -359,7 +359,7 @@ async def test_basic_reorg(tmp_dir: Path, db_version: int, bt: BlockTools) -> No
359359
records = [await coin_store.get_coin_record(coin.name()) for coin in coins]
360360
for record in records:
361361
assert record is not None
362-
assert not record.spent
362+
assert not record.spent()
363363
assert record.confirmed_block_index == reorg_block.height
364364
assert record.spent_block_index == 0
365365
peak = b.get_peak()

chia/_tests/core/test_full_node_rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def test1(
198198
assert coin in compute_additions(coin_spend)
199199

200200
assert len(await client.get_coin_records_by_puzzle_hash(ph_receiver)) == 1
201-
assert len(list(filter(lambda cr: not cr.spent, (await client.get_coin_records_by_puzzle_hash(ph))))) == 3
201+
assert len(list(filter(lambda cr: not cr.spent(), (await client.get_coin_records_by_puzzle_hash(ph))))) == 3
202202
assert len(await client.get_coin_records_by_puzzle_hashes([ph_receiver, ph])) == 5
203203
assert len(await client.get_coin_records_by_puzzle_hash(ph, False)) == 3
204204
assert len(await client.get_coin_records_by_puzzle_hash(ph, True)) == 4

chia/_tests/wallet/rpc/test_wallet_rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ async def test_get_coin_records_by_names(wallet_rpc_environment: WalletRpcTestEn
14641464
# Prepare some records and parameters first
14651465
result = await store.get_coin_records()
14661466
coins = {record.coin for record in result.records}
1467-
coins_unspent = {record.coin for record in result.records if not record.spent}
1467+
coins_unspent = {record.coin for record in result.records if not record.spent()}
14681468
coin_ids = [coin.name() for coin in coins]
14691469
coin_ids_unspent = [coin.name() for coin in coins_unspent]
14701470
assert len(coin_ids) > 0

chia/_tests/wallet/test_singleton_lifecycle_fast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def create_throwaway_pubkey(seed: bytes) -> G1Element:
424424
def assert_coin_spent(coin_store: CoinStore, coin: Coin, is_spent: bool = True) -> None:
425425
coin_record = coin_store.coin_record(coin.name())
426426
assert coin_record is not None
427-
assert coin_record.spent is is_spent
427+
assert coin_record.spent() is is_spent
428428

429429

430430
def spend_coin_to_singleton(

chia/_tests/wallet/test_wallet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,11 +1885,11 @@ async def test_wallet_tx_reorg(self, wallet_environments: WalletTestFramework) -
18851885
added_1 = tx_record.additions[1]
18861886
wallet_coin_record_rem = await wsm.coin_store.get_coin_record(removed.name())
18871887
assert wallet_coin_record_rem is not None
1888-
assert wallet_coin_record_rem.spent
1888+
assert wallet_coin_record_rem.spent()
18891889

18901890
coin_record_full_node = await full_node_api.full_node.coin_store.get_coin_record(removed.name())
18911891
assert coin_record_full_node is not None
1892-
assert coin_record_full_node.spent
1892+
assert coin_record_full_node.spent()
18931893
add_1_coin_record_full_node = await full_node_api.full_node.coin_store.get_coin_record(added.name())
18941894
assert add_1_coin_record_full_node is not None
18951895
assert add_1_coin_record_full_node.confirmed_block_index > 0

chia/_tests/wallet/test_wallet_coin_store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ async def test_set_spent() -> None:
202202
store = await WalletCoinStore.create(db_wrapper)
203203
await store.add_coin_record(record_1)
204204

205-
assert not (await store.get_coin_record(coin_1.name())).spent
205+
assert not (await store.get_coin_record(coin_1.name())).spent()
206206
await store.set_spent(coin_1.name(), uint32(12))
207-
assert (await store.get_coin_record(coin_1.name())).spent
207+
assert (await store.get_coin_record(coin_1.name())).spent()
208208
assert (await store.get_coin_record(coin_1.name())).spent_block_height == 12
209209

210210

@@ -908,7 +908,7 @@ async def test_rollback_to_block() -> None:
908908
await store.rollback_to_block(6)
909909

910910
new_r5 = await store.get_coin_record(coin_5.name())
911-
assert not new_r5.spent
911+
assert not new_r5.spent()
912912
assert new_r5.spent_block_height == 0
913913
assert new_r5 != r5
914914

@@ -918,7 +918,7 @@ async def test_rollback_to_block() -> None:
918918

919919
assert await store.get_coin_record(coin_5.name()) is None
920920
new_r4 = await store.get_coin_record(coin_4.name())
921-
assert not new_r4.spent
921+
assert not new_r4.spent()
922922
assert new_r4.spent_block_height == 0
923923
assert new_r4 != r4
924924

chia/cmds/sim_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def print_coin_record(
337337
print(f"Coin 0x{coin_record.name.hex()}")
338338
print(f"Wallet Address: {coin_address}")
339339
print(f"Confirmed at block: {coin_record.confirmed_block_index}")
340-
print(f"Spent: {f'at Block {coin_record.spent_block_index}' if coin_record.spent else 'No'}")
340+
print(f"Spent: {f'at Block {coin_record.spent_block_index}' if coin_record.spent() else 'No'}")
341341
print(f"Coin Amount: {coin_record.coin.amount} {name}")
342342
print(f"Parent Coin ID: 0x{coin_record.coin.parent_coin_info.hex()}")
343343
print(f"Created at: {datetime.fromtimestamp(float(coin_record.timestamp)).strftime('%Y-%m-%d %H:%M:%S')}\n")

chia/consensus/block_body_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ async def validate_block_body(
482482
if unspent.confirmed_block_index <= fork_info.fork_height:
483483
# Spending something in the current chain, confirmed before fork
484484
# (We ignore all coins confirmed after fork)
485-
if unspent.spent == 1 and unspent.spent_block_index <= fork_info.fork_height:
485+
if unspent.spent() == 1 and unspent.spent_block_index <= fork_info.fork_height:
486486
# Check for coins spent in an ancestor block
487487
return Err.DOUBLE_SPEND
488488
removal_coin_records[unspent.name] = unspent

0 commit comments

Comments
 (0)