-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add cardano-cli chain context * fix: allow instances of str to submit_tx_cbor * fix: cast to int for asset amount and check for None in get_min_utxo * test: add test for cardano-cli chain context * Black formatting * Fix some QA issues * refactor: use `--out-file /dev/stdout` to get utxo data as json * fix: remove unused offline/online mode code * fix: remove unused fraction parser method * fix: add docker configuration to use cardano-cli in a Docker container and network args method to use custom networks * test: add integration tests for cardano-cli * test: fix cardano-node container name * Add more integration tests for cardano cli context --------- Co-authored-by: Hareem Adderley <[email protected]> Co-authored-by: Niels Mündler <[email protected]> Co-authored-by: Jerry <[email protected]>
- Loading branch information
1 parent
590c49a
commit 54ec756
Showing
11 changed files
with
1,656 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from pycardano import ( | ||
CardanoCliChainContext, | ||
CardanoCliNetwork, | ||
GenesisParameters, | ||
Network, | ||
ProtocolParameters, | ||
) | ||
from pycardano.backend.cardano_cli import DockerConfig | ||
|
||
|
||
class TestCardanoCli: | ||
network_env = os.getenv("NETWORK", "local-alonzo") | ||
host_socket = os.getenv("DOCKER_HOST", None) | ||
network_magic = os.getenv("NETWORK_MAGIC", 42) | ||
|
||
configs_dir = Path(__file__).parent.parent / "configs" | ||
|
||
chain_context = CardanoCliChainContext( | ||
binary=Path("cardano-cli"), | ||
socket=Path("/ipc/node.socket"), | ||
config_file=configs_dir / network_env / "config.json", | ||
network=CardanoCliNetwork.CUSTOM, | ||
docker_config=DockerConfig( | ||
container_name="integration-test_cardano-node_1", | ||
host_socket=Path(host_socket) if host_socket else None, | ||
), | ||
network_magic_number=int(network_magic), | ||
) | ||
|
||
def test_protocol_param(self): | ||
protocol_param = self.chain_context.protocol_param | ||
|
||
assert protocol_param is not None | ||
assert isinstance(protocol_param, ProtocolParameters) | ||
|
||
cost_models = protocol_param.cost_models | ||
for _, cost_model in cost_models.items(): | ||
assert "addInteger-cpu-arguments-intercept" in cost_model | ||
assert "addInteger-cpu-arguments-slope" in cost_model | ||
|
||
def test_genesis_param(self): | ||
genesis_param = self.chain_context.genesis_param | ||
|
||
assert genesis_param is not None | ||
assert isinstance(genesis_param, GenesisParameters) | ||
|
||
def test_network(self): | ||
network = self.chain_context.network | ||
|
||
assert network is not None | ||
assert isinstance(network, Network) | ||
|
||
def test_epoch(self): | ||
epoch = self.chain_context.epoch | ||
|
||
assert epoch is not None | ||
assert isinstance(epoch, int) | ||
assert epoch > 0 | ||
|
||
def test_last_block_slot(self): | ||
last_block_slot = self.chain_context.last_block_slot | ||
|
||
assert isinstance(last_block_slot, int) | ||
assert last_block_slot > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
from .base import * | ||
from .blockfrost import * | ||
from .cardano_cli import * | ||
from .ogmios import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.