|
4 | 4 | [](https://pypi.org/project/cardano-clusterlib/)
|
5 | 5 | [](https://github.com/ambv/black)
|
6 | 6 |
|
7 |
| -Python wrapper for cardano-cli for working with cardano cluster. |
| 7 | +Python wrapper for cardano-cli for working with cardano cluster. It supports all cardano-cli commands (except parts of `genesis` and `governance`). |
| 8 | + |
| 9 | +The library is used for development of [cardano-node system tests](https://github.com/input-output-hk/cardano-node-tests). |
8 | 10 |
|
9 | 11 | ## Installation
|
10 | 12 |
|
11 | 13 | ```sh
|
12 | 14 | # create and activate virtual env
|
13 | 15 | $ python3 -m venv .env
|
14 | 16 | $ . .env/bin/activate
|
15 |
| -# install it from PyPI |
| 17 | +# install cardano-clusterlib from PyPI |
16 | 18 | $ pip install cardano-clusterlib
|
17 |
| -# - OR - install it in develop mode together with dev requirements |
| 19 | +# - OR - install cardano-clusterlib in development mode together with dev requirements |
18 | 20 | $ make install
|
19 | 21 | ```
|
20 | 22 |
|
21 | 23 | ## Usage
|
22 | 24 |
|
23 |
| -Needs working `cardano-cli` (the command is available on `PATH`, `cardano-node` is running, `CARDANO_NODE_SOCKET_PATH` is set). In `state_dir` it expects "shelley/genesis.json". |
| 25 | +The library needs working `cardano-cli` (the command is available on `PATH`, `cardano-node` is running, `CARDANO_NODE_SOCKET_PATH` is set). In `state_dir` it expects "shelley/genesis.json". |
| 26 | + |
| 27 | +```python |
| 28 | +# instantiate `ClusterLib` |
| 29 | +cluster = clusterlib.ClusterLib(state_dir="path/to/cluster/state_dir") |
| 30 | +``` |
| 31 | + |
| 32 | +On custom testnets that were started in Byron era, you might need to specify a slots offset between Byron epochs and Shelley epochs. |
| 33 | +The "slots_offset" is a difference between number of slots in Byron epochs and in the same number of Shelley epochs. |
| 34 | + |
| 35 | +E.g. for a testnet with parameters |
| 36 | + |
| 37 | +* 100 slots per epoch in Byron era |
| 38 | +* 1000 slots per epoch in Shelley era |
| 39 | +* two epochs in Byron era before forking to Shelley |
| 40 | + |
| 41 | +The offset will be `2 * (1000 - 100) = 1800`. |
| 42 | + |
| 43 | +```python |
| 44 | +cluster = clusterlib.ClusterLib(state_dir="path/to/cluster/state_dir", slots_offset=1800) |
| 45 | +``` |
24 | 46 |
|
25 | 47 | ### Transfer funds
|
26 | 48 |
|
@@ -151,7 +173,7 @@ cluster.g_transaction.submit_tx(tx_file=tx_signed_redeem, txins=tx_output_fund.t
|
151 | 173 |
|
152 | 174 | ### More examples
|
153 | 175 |
|
154 |
| -See [cardano-node-tests](https://github.com/input-output-hk/cardano-node-tests) for more examples, e.g. [minting new tokens](https://github.com/input-output-hk/cardano-node-tests/blob/90aa4a2e9fe4019a89e6f4cdec7cb092732e6f2a/cardano_node_tests/utils/clusterlib_utils.py#L567-L602) or [minting new tokens with Plutus](https://github.com/input-output-hk/cardano-node-tests/blob/d688a9bcf00a30f9881c52aab9311dd1a0cb3077/cardano_node_tests/tests/test_plutus_mint_build.py#L173-L217) |
| 176 | +See [cardano-node-tests](https://github.com/input-output-hk/cardano-node-tests) for more examples, e.g. [minting new tokens](https://github.com/input-output-hk/cardano-node-tests/blob/4b50e8069f5294aaba14140ef0509e2857bec35d/cardano_node_tests/utils/clusterlib_utils.py#L491) or [minting new tokens with Plutus](https://github.com/input-output-hk/cardano-node-tests/blob/4b50e8069f5294aaba14140ef0509e2857bec35d/cardano_node_tests/tests/tests_plutus/test_mint_build.py#L151-L195) |
155 | 177 |
|
156 | 178 |
|
157 | 179 | ## Source Documentation
|
|
0 commit comments