Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pycardano/backend/blockfrost.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(
)

# Set network value to mainnet if base_url contains "mainnet".
if "mainnet" in self._base_url.value:
if "mainnet" in self._base_url:
self._network = Network.MAINNET

self.api = BlockFrostApi(project_id=self._project_id, base_url=self._base_url)
Expand Down
22 changes: 22 additions & 0 deletions test/pycardano/backend/test_blockfrost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from unittest.mock import MagicMock, patch

from blockfrost import ApiUrls

from pycardano.backend.blockfrost import BlockFrostChainContext
from pycardano.network import Network


@patch("pycardano.backend.blockfrost.BlockFrostApi")
def test_blockfrost_chain_context(mock_api):
mock_api.return_value = MagicMock()
chain_context = BlockFrostChainContext("project_id", base_url=ApiUrls.mainnet.value)
assert chain_context.network == Network.MAINNET

chain_context = BlockFrostChainContext("project_id", base_url=ApiUrls.testnet.value)
assert chain_context.network == Network.TESTNET

chain_context = BlockFrostChainContext("project_id", base_url=ApiUrls.preprod.value)
assert chain_context.network == Network.TESTNET

chain_context = BlockFrostChainContext("project_id", base_url=ApiUrls.preview.value)
assert chain_context.network == Network.TESTNET