Skip to content

Commit 6f588fa

Browse files
author
Matthias Zimmermann
committed
chore: minor cleanups/test additions
1 parent e3740d4 commit 6f588fa

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ RUN apt-get update && apt-get install -y \
1818
# Install uv and add it to PATH
1919
ADD https://astral.sh/uv/install.sh /uv-installer.sh
2020
RUN sh /uv-installer.sh && rm /uv-installer.sh
21-
2221
ENV PATH="/root/.local/bin/:$PATH"
2322

2423
# Suppress UV hardlink warnings in dev containers

tests/test_async_query_iterator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from arkiv import AsyncArkiv
88
from arkiv.types import ATTRIBUTES, KEY, Attributes, CreateOp, Operations, QueryOptions
99

10-
BTL = 100
10+
EXPIRES_IN = 100
1111
CONTENT_TYPE = "text/plain"
1212

1313

@@ -36,7 +36,7 @@ async def create_test_entities(client: AsyncArkiv, n: int) -> tuple[str, list[st
3636
payload=payload,
3737
content_type=CONTENT_TYPE,
3838
attributes=attributes,
39-
expires_in=BTL,
39+
expires_in=EXPIRES_IN,
4040
)
4141
create_ops.append(create_op)
4242

tests/test_entity_delete.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import pytest
66

7+
from arkiv.account import NamedAccount
78
from arkiv.client import Arkiv
89
from arkiv.types import Attributes, CreateOp, DeleteOp, Operations
910

@@ -203,3 +204,43 @@ def test_delete_entity_twice(self, arkiv_client_http: Arkiv) -> None:
203204
logger.info(
204205
f"Second delete of same entity correctly raised {type(exc_info.value).__name__}"
205206
)
207+
208+
def test_delete_entity_after_owner_change(
209+
self, arkiv_client_http: Arkiv, account_2: NamedAccount
210+
) -> None:
211+
"""Test that deleting the same entity twice raises an exception."""
212+
213+
# Create an entity
214+
entity_key, _ = arkiv_client_http.arkiv.create_entity(
215+
payload=b"Entity to delete after owner change", expires_in=100
216+
)
217+
218+
entity_before = arkiv_client_http.arkiv.get_entity(entity_key)
219+
assert entity_before.owner == arkiv_client_http.eth.default_account, (
220+
"Unexpected initial owner"
221+
)
222+
assert entity_before.owner != account_2.address, (
223+
"Account 2 address does not differ from client address"
224+
)
225+
226+
change_owner_receipt = arkiv_client_http.arkiv.change_owner(
227+
entity_key, account_2.address
228+
)
229+
logger.info(f"Change owner receipt: {change_owner_receipt}")
230+
231+
# Check owner change
232+
entity_after = arkiv_client_http.arkiv.get_entity(entity_key)
233+
assert entity_after.owner == account_2.address, "Unexpected owner after change"
234+
235+
# Add account 2 to act with right private key
236+
arkiv_client_http.accounts[account_2.name] = account_2
237+
arkiv_client_http.switch_to(account_2.name)
238+
239+
# First deletion
240+
delete_tx_hash_1 = arkiv_client_http.arkiv.delete_entity(entity_key)
241+
check_tx_hash("delete_after_owner_chnage", delete_tx_hash_1)
242+
243+
# Verify it's deleted
244+
assert not arkiv_client_http.arkiv.entity_exists(entity_key), (
245+
"Entity should be deleted after first deletion"
246+
)

tests/test_query_iterator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from arkiv import Arkiv
66
from arkiv.types import ATTRIBUTES, KEY, Attributes, CreateOp, Operations, QueryOptions
77

8-
BTL = 100
8+
EXPIRES_IN = 100
99
CONTENT_TYPE = "text/plain"
1010

1111

@@ -34,7 +34,7 @@ def create_test_entities(client: Arkiv, n: int) -> tuple[str, list[str]]:
3434
payload=payload,
3535
content_type=CONTENT_TYPE,
3636
attributes=attributes,
37-
expires_in=BTL,
37+
expires_in=EXPIRES_IN,
3838
)
3939
create_ops.append(create_op)
4040

0 commit comments

Comments
 (0)