Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHIA-945 Remove no longer needed TestWalletKeyValStore class #18327

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions chia/_tests/wallet/test_wallet_key_val_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,32 @@
from chia.wallet.key_val_store import KeyValStore


class TestWalletKeyValStore:
@pytest.mark.anyio
@pytest.mark.standard_block_tools
async def test_store(self, bt):
async with DBConnection(1) as db_wrapper:
store = await KeyValStore.create(db_wrapper)
blocks = bt.get_consecutive_blocks(20)
block: FullBlock = blocks[0]
block_2: FullBlock = blocks[1]
@pytest.mark.anyio
@pytest.mark.standard_block_tools
async def test_store(bt):
async with DBConnection(1) as db_wrapper:
store = await KeyValStore.create(db_wrapper)
blocks = bt.get_consecutive_blocks(20)
block: FullBlock = blocks[0]
block_2: FullBlock = blocks[1]

assert (await store.get_object("a", FullBlock)) is None
await store.set_object("a", block)
assert await store.get_object("a", FullBlock) == block
await store.set_object("a", block)
assert await store.get_object("a", FullBlock) == block
await store.set_object("a", block_2)
await store.set_object("a", block_2)
assert await store.get_object("a", FullBlock) == block_2
await store.remove_object("a")
assert (await store.get_object("a", FullBlock)) is None
assert (await store.get_object("a", FullBlock)) is None
await store.set_object("a", block)
assert await store.get_object("a", FullBlock) == block
await store.set_object("a", block)
assert await store.get_object("a", FullBlock) == block
await store.set_object("a", block_2)
await store.set_object("a", block_2)
assert await store.get_object("a", FullBlock) == block_2
await store.remove_object("a")
assert (await store.get_object("a", FullBlock)) is None

for block in blocks:
assert (await store.get_object(block.header_hash.hex(), FullBlock)) is None
await store.set_object(block.header_hash.hex(), block)
assert (await store.get_object(block.header_hash.hex(), FullBlock)) == block
for block in blocks:
assert (await store.get_object(block.header_hash.hex(), FullBlock)) is None
await store.set_object(block.header_hash.hex(), block)
assert (await store.get_object(block.header_hash.hex(), FullBlock)) == block

# Wrong type
await store.set_object("a", block_2)
with pytest.raises(Exception):
await store.get_object("a", HeaderBlock)
# Wrong type
await store.set_object("a", block_2)
with pytest.raises(Exception):
await store.get_object("a", HeaderBlock)
Loading