### Setup and Start PostgreSQL for Cardano DB-Sync Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/testnets_bootstrap_template/README.md This snippet shows how to start and set up a PostgreSQL database for Cardano DB-Sync. It includes commands for both clean setups and using existing synchronized data. Ensure the CARDANO_NODE_SOCKET_PATH environment variable is set before running these commands. ```shell /path/to/cardano-node-tests-repo/scripts/postgres-start.sh ~/tmp/postgres-for-testnet/ -k ./postgres-setup.sh ``` ```shell /path/to/cardano-node-tests-repo/scripts/postgres-start.sh ~/tmp/postgres-for-testnet/ ``` -------------------------------- ### Build and Run SMASH Server Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Builds the cardano-smash-server using cabal, copies the executable to the PATH, prepares an admins.txt file, and starts the SMASH server with specified configuration and port. Requires a config directory with mainnet-config.yaml and an admins.txt file. ```shell cabal build cardano-smash-server cp $(find . -name cardano-smash-server -executable -type f) ~/.local/bin PGPASSFILE=config/pgpass-mainnet cardano-smash-server \ --config config/mainnet-config.yaml \ --port 3100 \ --admins admins.txt ``` -------------------------------- ### Set Up Python Environment for Test Authors Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Installs project dependencies using `make install`. Assumes Nix and Poetry are already installed. This is a prerequisite for local development. ```sh make install ``` -------------------------------- ### Start Cardano Node Development Cluster Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Initializes and starts a local development cluster for testing. This involves navigating to the cardano-node directory, checking out a specific tag, entering a Nix development shell, activating a poetry virtual environment, setting environment variables for socket paths and cluster status, creating necessary directories, preparing cluster scripts, and finally starting the cluster. ```sh cd ../cardano-node git checkout nix develop .#devops /bin/bash --login # fresh shell needed cd ../cardano-node-tests source "$(poetry env info --path)"/bin/activate export PYTHONPATH="$(echo $VIRTUAL_ENV/lib/python3*/site-packages):$PYTHONPATH" export CARDANO_NODE_SOCKET_PATH="$PWD/dev_workdir/state-cluster0/bft1.socket" DEV_CLUSTER_RUNNING=1 mkdir -p "${CARDANO_NODE_SOCKET_PATH%/*}" prepare-cluster-scripts -c -d dev_workdir/conway_fast -t conway_fast ./dev_workdir/conway_fast/start-cluster ``` -------------------------------- ### Install Git Hooks for Development Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Installs pre-commit Git hooks to enforce code style and quality checks automatically before commits. ```sh pre-commit install ``` -------------------------------- ### Whitelisting and Delisting Pools Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Endpoints for querying, delisting, and whitelisting Cardano pools. Includes request and response examples. ```APIDOC ## GET /api/v1/metadata/{poolId}/{stakeId} ### Description Queries information about a specific Cardano pool. ### Method GET ### Endpoint `/api/v1/metadata/{poolId}/{stakeId}` ### Parameters #### Path Parameters - **poolId** (string) - Required - The unique identifier of the pool. - **stakeId** (string) - Required - The stake identifier associated with the pool. ### Request Example ```sh curl -X GET -v http://localhost:3100/api/v1/metadata/81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27/8e123d238a44a91bab56ebd631020bede5a381d8487a46d1f2ebbdc52e3b3eba | jq . ``` ### Response #### Success Response (200) - **name** (string) - The name of the pool. - **ticker** (string) - The ticker symbol of the pool. - **homepage** (string) - The homepage URL of the pool. - **description** (string) - A description of the pool. #### Response Example ```json { "name": "OZZIE", "ticker": "OZZIE", "homepage": "https://ozzieoffsec.github.io/pool", "description": "We love Turtles" } ``` ## PATCH /api/v1/delist ### Description Delists a specified Cardano pool. ### Method PATCH ### Endpoint `/api/v1/delist` ### Parameters #### Request Body - **poolId** (string) - Required - The unique identifier of the pool to delist. ### Request Example ```sh curl --verbose -u username:password --header "Content-Type: application/json" --request PATCH --data '{"poolId":"81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27"}' http://localhost:3100/api/v1/delist ``` ### Request Body Example ```json { "poolId":"81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27" } ``` ### Response #### Success Response (200) - **poolId** (string) - The identifier of the delisted pool. #### Response Example ```json {"poolId":"81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27"} ``` ## PATCH /api/v1/enlist ### Description Whitelists a specified Cardano pool. ### Method PATCH ### Endpoint `/api/v1/enlist` ### Parameters #### Request Body - **poolId** (string) - Required - The unique identifier of the pool to whitelist. ### Request Example ```sh curl -u username:password -X PATCH -v http://localhost:3100/api/v1/enlist -H 'content-type: application/json' -d '{"poolId": "81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27"}' ``` ### Request Body Example ```json { "poolId": "81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27" } ``` ### Response #### Success Response (200) - **poolId** (string) - The identifier of the whitelisted pool. #### Response Example ```json {"poolId":"81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27"} ``` ``` -------------------------------- ### Use cardano-clusterlib in Development Mode Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Installs the `cardano-clusterlib` Python package in editable mode for development. This involves activating the poetry environment, uninstalling the package, navigating to the `cardano-clusterlib-py` directory, installing it in editable mode, and then verifying the installation by printing the package's file path. ```sh source "$(poetry env info --path)"/bin/activate make install pip uninstall cardano-clusterlib cd ../cardano-clusterlib-py pip install -e . --config-settings editable_mode=compat cd - python -c 'from cardano_clusterlib import clusterlib_klass; print(clusterlib_klass.__file__)' ``` -------------------------------- ### Check SMASH Server Status Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Uses curl to send a GET request to the SMASH server's /api/v1/status endpoint to retrieve its operational status and version. Expects a JSON response with 'status' and 'version' fields. ```shell curl --verbose --header "Content-Type: application/json" --request GET http://localhost:3100/api/v1/status ``` -------------------------------- ### Compare SMASH Reply with Database State Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md This section demonstrates comparing the number of delisted pools obtained from a SMASH service (stored in a JSON file) with the count from a SQL database. It uses 'jq' to get the length of the 'delistedPools' array from the JSON and a SQL query to select all entries from the 'delisted_pool' table. ```sh cat smash_imported_policies.json | jq -r '.delistedPools | length' ``` ```sql select * from delisted_pool; ``` -------------------------------- ### Start Persistent Local Cluster Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Launches a persistent local cluster environment using Nix for repeated testing. This involves updating Nix flakes, entering a Nix develop shell, sourcing environment preparation scripts, and starting the cluster service. The cluster can then be interacted with or tested against. ```shell # Update Nix flakes and enter develop shell nix flake update --accept-flake-config --override-input cardano-node github:IntersectMBO/cardano-node/master nix develop --accept-flake-config # Prepare test environment for Conway era source ./prepare_test_env.sh conway # Launch the cluster ./dev_workdir/conway_fast/start-cluster ``` -------------------------------- ### Fetch Metadata from SMASH Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Uses curl to send a GET request to the SMASH server's /api/v1/metadata/{poolHash}/{metadataHash} endpoint to retrieve details of a specific metadata. Requires the pool's raw hash and the metadata hash. Returns a JSON object with metadata information. ```shell curl --verbose --header "Content-Type: application/json" --request GET http://localhost:3100/api/v1/metadata/a5a3ce765f5162548181a44d1ff8c8f8c50018cca59acc0b70a85a41/d98a03b8aa962d80511d62566df2af415afd9bd03d53cbb0ad457a53d3491f74 ``` -------------------------------- ### Shell: Run Pytest with Specific Test Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/stake_credential_history_tool.md This command executes a specific pytest test case within the cardano-node-tests project. It requires pytest to be installed and the test file `test_mir_certs.py` to exist. The command targets the `test_pay_stake_addr_from_both` test. ```sh pytest -sv cardano_node_tests/tests/test_mir_certs.py -k 'test_pay_stake_addr_from_both' ``` -------------------------------- ### SMASH Server Log Snippet Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Example log output from the SMASH server, indicating it is listening on a port and a warning message for a 'TickerAlreadyReserved' error. Useful for debugging. ```text [smash-server:Info:6] [2021-11-23 12:06:29.94 UTC] SMASH listening on port 3100 [smash-server:Warning:27] [2021-11-23 12:59:18.14 UTC] TickerAlreadyReserved (TickerName "ART") ``` -------------------------------- ### Setup Persistent Local Cardano Cluster with Nix Source: https://context7.com/intersectmbo/cardano-node-tests/llms.txt Prepare and launch a persistent local Cardano cluster for development using Nix. Includes environment preparation for specific eras (e.g., Conway), starting/stopping the cluster, and running individual tests. ```bash # Start Nix development environment nix flake update --accept-flake-config \ --override-input cardano-node github:IntersectMBO/cardano-node/master nix develop --accept-flake-config # Prepare test environment for Conway era source ./prepare_test_env.sh conway # Launch cluster ./dev_workdir/conway_fast/start-cluster # Run individual tests pytest -s -k test_minting_one_token cardano_node_tests/tests/tests_plutus pytest -s --log-level=debug -k test_transfer_funds cardano_node_tests/tests # Stop cluster when done ./dev_workdir/conway_fast/stop-cluster # Reuse environment in another shell source ./dev_workdir/.source ``` -------------------------------- ### Get Unregistered Pools (Shell) Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Retrieves a list of pools that have been unregistered. This `curl` command sends a GET request to the `/retired` endpoint, and `jq` is used to pretty-print the resulting JSON array, which contains the `poolId` for each unregistered pool. ```sh curl --header "Content-Type: application/json" http://localhost:3100/api/v1/retired | jq . ``` -------------------------------- ### Python: Set IPython Breakpoint Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/stake_credential_history_tool.md This snippet shows how to insert an IPython breakpoint in a Python test file. It requires the IPython library to be installed. When executed, it pauses the test execution, allowing for interactive debugging. ```python from IPython import embed; embed() ``` -------------------------------- ### Fetch Metadata API Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Fetches metadata for a specific stake pool using its IDs. ```APIDOC ## GET /api/v1/metadata/{poolId}/{hash} ### Description Retrieves metadata associated with a given pool ID and hash. ### Method GET ### Endpoint /api/v1/metadata/{poolId}/{hash} ### Parameters #### Path Parameters - **poolId** (string) - Required - The ID of the pool. - **hash** (string) - Required - The hash of the pool. #### Query Parameters None #### Request Body None ### Request Example ```sh curl --verbose --header "Content-Type: application/json" --request GET http://localhost:3100/api/v1/metadata/a5a3ce765f5162548181a44d1ff8c8f8c50018cca59acc0b70a85a41/d98a03b8aa962d80511d62566df2af415afd9bd03d53cbb0ad457a53d3491f74 ``` ### Response #### Success Response (200) - **name** (string) - The name of the stake pool. - **ticker** (string) - The ticker symbol for the stake pool. - **homepage** (string) - The homepage URL of the stake pool. - **description** (string) - A description of the stake pool. #### Response Example ```json { "name": "MKS Stake Pool", "ticker": "MKS", "homepage": "http://23.234.197.69", "description": "testnet stake pool" } ``` ``` -------------------------------- ### Prepare Cardano Cluster Scripts for Conway Fast Variant Source: https://context7.com/intersectmbo/cardano-node-tests/llms.txt This script prepares the necessary files and startup/stop scripts for a Cardano cluster using the 'conway_fast' testnet variant. It creates a destination directory, generates the scripts, and provides feedback on their location. The script also includes code to immediately start the prepared cluster. ```python from cardano_node_tests import prepare_cluster_scripts dest_dir = pl.Path("./my_cluster") dest_dir.mkdir(exist_ok=True) startup_files = prepare_cluster_scripts.prepare_scripts_files( destdir=dest_dir, testnet_variant="conway_fast", instance_num=0, ) print(f"Cluster scripts prepared in: {dest_dir}") print(f"Start script: {startup_files.start_script}") print(f"Stop script: {startup_files.stop_script}") # Start the cluster import subprocess subprocess.run([str(startup_files.start_script)], check=True) print("Cluster started successfully") ``` -------------------------------- ### Query SMASH Metadata with cURL Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md This snippet demonstrates how to query the SMASH API for specific pool metadata using its hash. It utilizes cURL to send a GET request to the SMASH server endpoint. The response indicates if the metadata is found or missing from the database. ```shell curl --verbose --header "Content-Type: application/json" --request GET http://localhost:3100/api/v1/metadata/be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853/f2b553839dee1ad1d16127179d4378a0c06a1fddce83409ad4b6f10b65bad395 ``` -------------------------------- ### Query Cardano Stake Distribution Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Utilizes the 'cardano-cli' to query the stake distribution on a testnet network for a specific pool. This command helps verify if the pool is recognized by the network and has any associated stake. ```sh cardano-cli query stake-distribution --testnet-magic 1097911063 | grep pool1hcefh0cwur6n6x0nk2qgvythnfyu0h6r7vc2sq67h8u9x8z2cla ``` -------------------------------- ### SMASH Status API Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Retrieves the current status and version of the SMASH server. ```APIDOC ## GET /api/v1/status ### Description Checks the operational status and version of the SMASH server. ### Method GET ### Endpoint /api/v1/status ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```sh curl --verbose --header "Content-Type: application/json" --request GET http://localhost:3100/api/v1/status ``` ### Response #### Success Response (200) - **status** (string) - The current status of the SMASH server (e.g., "OK"). - **version** (string) - The version of the SMASH server. #### Response Example ```json { "status": "OK", "version": "12.0.0" } ``` ``` -------------------------------- ### Fetch SMASH Policies using cURL Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md This command fetches delisted pool policies from a specified SMASH URL using cURL. It requires authentication credentials and sends a POST request with the SMASH service URL in the JSON payload. The output is then formatted using 'jq'. ```sh curl -u username:password --verbose --header "Content-Type: application/json" --request POST --data '{"smashURL": "https://smash.cardano-mainnet.iohk.io"}' http://localhost:3100/api/v1/policies | jq . ``` -------------------------------- ### Check Pool Rejection Errors Response (JSON) Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Example JSON response from querying pool rejection errors. It provides details for each error event, including timestamp, pool ID, retry count, the cause of the error, and the associated pool hash. ```json [ { "utcTime":"1635334386.697757s", "poolId":"be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853", "retryCount":2, "cause":"URL parse error from for pool1hcefh0cwur6n6x0nk2qgvythnfyu0h6r7vc2sq67h8u9x8z2cla resulted in : InvalidUrlException \"pool1hcefh0cwur6n6x0nk2qgvythnfyu0h6r7vc2sq67h8u9x8z2cla\" \"Invalid URL"", "poolHash":"f2b553839dee1ad1d16127179d4378a0c06a1fddce83409ad4b6f10b65bad395", "time":"27.10.2021. 11:33:06" }, { "utcTime":"1635334094.642995s", "poolId":"be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853", "retryCount":0, "cause":"HTTP Response from for https://LLCJ.com resulted in : 509", "poolHash":"4001829c25b4af556d1a473dec4874a621899cf6a84c60156ec2411727f1a169", "time":"27.10.2021. 11:28:14" } ] ``` -------------------------------- ### Query Pool Metadata (Shell) Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Retrieves metadata for a specific Cardano pool using its ID. This command uses `curl` to send a GET request to the API endpoint and `jq` to format the JSON response. It's useful for verifying pool details before or after modification. ```sh curl -X GET -v http://localhost:3100/api/v1/metadata/81e84003f3d2f65315b479dc3cdbe4aa8c8595a3d76818e284b29f27/8e123d238a44a91bab56ebd631020bede5a381d8487a46d1f2ebbdc52e3b3eba | jq . ``` -------------------------------- ### Shell: Pytest Execution Log and Output Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/stake_credential_history_tool.md This is a sample output from running a pytest command to execute a specific test case. It includes environment information, test collection details, and the interactive output from a Python breakpoint, showing the stake address information retrieved. ```sh [nix-shell:~/Playground/test_framework/cardano-node-tests]$ pytest -sv cardano_node_tests/tests/test_mir_certs.py -k 'test_pay_stake_addr_from_both' ==================================================================================================================================== test session starts ==================================================================================================================================== platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/artur/Playground/test_framework/cardano-node-tests/.env/bin/python3 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/artur/Playground/test_framework/cardano-node-tests/.hypothesis/examples') metadata: {'Python': '3.8.10', 'Platform': 'Linux-5.4.0-91-generic-x86_64-with-glibc2.29', 'Packages': {'pytest': '6.2.5', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'hypothesis': '6.31.6', 'xdist': '2.5.0', 'forked': '1.4.0', 'allure-pytest': '2.9.45', 'html': '3.1.1', 'order': '1.0.0', 'metadata': '1.11.0'}, 'cardano-node': '1.31.0', 'cardano-node rev': '2cbe363874d0261bc62f52185cf23ed492cf4859', 'ghc': 'ghc-8.10', 'cardano-node-tests rev': '950bcf9c5417388cc50aeff09b5cb078c8dd1df7', 'cardano-node-tests url': 'https://github.com/IntersectMBO/cardano-node-tests/tree/950bcf9c5417388cc50aeff09b5cb078c8dd1df7', 'CARDANO_NODE_SOCKET_PATH': '/home/artur/Playground/test_framework/cardano-node/state-cluster0/bft1.socket', 'cardano-cli exe': '/nix/store/k07rnxyzyka72678qjjpnnng9z0hwcak-cardano-cli-exe-cardano-cli-1.31.0/bin/cardano-cli', 'HAS_DBSYNC': 'True', 'db-sync': '12.0.0', 'db-sync rev': '9d0180571482ee4c6acb6fbc6bf55b5a4e2ee833', 'db-sync ghc': 'ghc-8.10', 'db-sync exe': '/nix/store/ykfw353myymhmv8v70x61kb37n5pm4ps-cardano-db-sync-exe-cardano-db-sync-12.0.0/bin/cardano-db-sync'} rootdir: /home/artur/Playground/test_framework/cardano-node-tests, configfile: pytest.ini plugins: hypothesis-6.31.6, xdist-2.5.0, forked-1.4.0, allure-pytest-2.9.45, html-3.1.1, order-1.0.0, metadata-1.11.0 collected 16 items / 15 deselected / 1 selected cardano_node_tests/tests/test_mir_certs.py::TestMIRCerts::test_pay_stake_addr_from_both -------------------------------------------------------------------------------------------------------------------------------------- live log setup --------------------------------------------------------------------------------------------------------------------------------------- INFO cardano_node_tests.tests.conftest:conftest.py:136 Changed CWD to '/run/user/1000/pytest-of-artur/pytest-0'. --------------------------------------------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------------------------------------------- INFO cardano_clusterlib.clusterlib:clusterlib.py:3291 Waiting for 18.40 sec for slot no 7005. INFO cardano_node_tests.tests.test_mir_certs:test_mir_certs.py:659 Submitting MIR cert for tranferring funds from treasury to 'stake_test1uzkhjy8tnvx5n9exsh0j63aq83laylzl7c8gq2kmf4t9hyqg2thkv' in epoch 7 on cluster instance 0 INFO cardano_node_tests.tests.test_mir_certs:test_mir_certs.py:672 Submitting MIR cert for tranferring funds from reserves to 'stake_test1uzkhjy8tnvx5n9exsh0j63aq83laylzl7c8gq2kmf4t9hyqg2thkv' in epoch 7 on cluster instance 0 INFO cardano_clusterlib.clusterlib:clusterlib.py:3291 Waiting for 184.20 sec for slot no 8005. Python 3.8.10 (default, Nov 26 2021, 20:14:08) Type 'copyright', 'credits' or 'license' for more information IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: cluster.g_query.get_stake_addr_info(registered_user.stake.address) Out[1]: StakeAddrInfo(address='stake_test1uzkhjy8tnvx5n9exsh0j63aq83laylzl7c8gq2kmf4t9hyqg2thkv', delegation='', reward_account_balance=100000000) In [2]: exit ``` -------------------------------- ### Query Reserved Pool Tickers Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md SQL query to select all entries from the 'reserved_pool_ticker' table, showing the id, name, and pool hash of reserved tickers. This is used to verify ticker reservation operations. ```sql select * from reserved_pool_ticker; ``` -------------------------------- ### Fetch Cardano Pool Metadata References Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Retrieves metadata reference information for a specific pool ID from the 'pool_metadata_ref' table. This includes the URL, hash, and the transaction ID used for registration of the metadata. ```sql select * from pool_metadata_ref where pool_id=103; ``` -------------------------------- ### Unregistered Pools List (JSON) Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Example JSON response showing a list of unregistered Cardano pools. Each object in the array contains the `poolId` of a pool that has been retired or delisted from the network. ```json [ { "poolId": "002c501d063cf552144e58ea9a85c8d156b3d7c7a498e52a50cf546c" }, { "poolId": "00cd5fd9cbf0b9535f804f59da4666859afa38e5ca7729a3172efe36" }, { "poolId": "0192e6835f8613b1a47084d800ee3d2a0931a334e5e63dd80c447c15" }, { "poolId": "01c2103a18e1dc55be3e83f7291266bba53a5b76c6c42f1969ee5193" }, { "poolId": "other pools listed ..." } ] ``` -------------------------------- ### Query and Delist Non-existent Pool via API Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_faq.md Demonstrates how to query for a pool using cURL that does not exist and subsequently delist it. This process involves an initial GET request to check for the pool's metadata and a PATCH request to delist it. The database is then checked to confirm the delisting entry. ```sh curl -X GET -v http://localhost:3101/api/v1/metadata/8517fa7042cb9494818861c53c87780b4975c0bd402e3ed85168aa66/4b2221a0ac0b0197308323080ba97e3e453f8625393d30f96eebe0fca4cb7335 | jq . curl --verbose -u username:password --header "Content-Type: application/json" --request PATCH --data '{"poolId":"8517fa7042cb9494818861c53c87780b4975c0bd402e3ed85168aa66"}' http://localhost:3101/api/v1/delist ``` -------------------------------- ### SMASH Metadata Response (JSON) Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md This is a sample JSON response from the SMASH API when querying for pool metadata. It includes a 'code' and 'description' field, indicating the status of the metadata lookup. In this case, the metadata is reported as missing from the database. ```json {"code":"DbLookupPoolMetadataHash","description":"The metadata with hash PoolMetadataHash \"f2b553839dee1ad1d16127179d4378a0c06a1fddce83409ad4b6f10b65bad395\" for pool PoolId \"be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853\" is missing from the DB."} ``` -------------------------------- ### Pool Unregistrations Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Retrieves a list of pools that have unregistered. ```APIDOC ## GET /api/v1/retired ### Description Retrieves a list of pools that have unregistered. ### Method GET ### Endpoint `/api/v1/retired` ### Parameters None ### Request Example ```sh curl --header "Content-Type: application/json" http://localhost:3100/api/v1/retired | jq . ``` ### Response #### Success Response (200) - **poolId** (string) - The unique identifier of the unregistered pool. #### Response Example ```json [ { "poolId": "002c501d063cf552144e58ea9a85c8d156b3d7c7a498e52a50cf546c" }, { "poolId": "00cd5fd9cbf0b9535f804f59da4666859afa38e5ca7729a3172efe36" }, { "poolId": "0192e6835f8613b1a47084d800ee3d2a0931a334e5e63dd80c447c15" }, { "poolId": "01c2103a18e1dc55be3e83f7291266bba53a5b76c6c42f1969ee5193" }, { "poolId": "other pools listed ..." } ] ``` ``` -------------------------------- ### Reserve Ticker API Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Reserves a ticker symbol for a stake pool. If the ticker is already reserved, an error is returned. ```APIDOC ## POST /api/v1/tickers/{tickerName} ### Description Reserves a ticker symbol for a given pool. Requires authentication. ### Method POST ### Endpoint /api/v1/tickers/{tickerName} ### Parameters #### Path Parameters - **tickerName** (string) - Required - The ticker symbol to reserve. #### Query Parameters None #### Request Body - **poolId** (string) - Required - The ID of the pool to associate with the ticker. ### Request Example ```sh curl --verbose -u username:password --header "Content-Type: application/json" --request POST --data '{"poolId":"1c443cd9c14c85e6b541be0c2bd98c9f11be25185a15636c33c4cd8f"}' http://localhost:3100/api/v1/tickers/ART ``` ### Response #### Success Response (200) - **name** (string) - The name of the reserved ticker. #### Response Example ```json { "name": "ART" } ``` #### Error Response (e.g., 400) - **code** (string) - Error code (e.g., "TickerAlreadyReserved"). - **description** (string) - Description of the error (e.g., "Ticker name ART is already reserved"). #### Error Response Example ```json { "code": "TickerAlreadyReserved", "description": "Ticker name ART is already reserved" } ``` ``` -------------------------------- ### Checking Pool Rejection Errors Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Retrieves information about pool rejection errors within a specified date range. ```APIDOC ## GET /api/v1/errors/{poolId} ### Description Retrieves a list of rejection errors for a given pool ID, optionally filtered by date. ### Method GET ### Endpoint `/api/v1/errors/{poolId}` ### Parameters #### Path Parameters - **poolId** (string) - Required - The unique identifier of the pool to check for errors. #### Query Parameters - **fromDate** (string) - Optional - The starting date to filter errors (format: DD.MM.YYYY). ### Request Example ```sh curl http://localhost:3100/api/v1/errors/be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853?fromDate=13.10.2020 ``` ### Response #### Success Response (200) - **utcTime** (string) - The UTC timestamp of the error. - **poolId** (string) - The identifier of the pool. - **retryCount** (integer) - The number of retries for this error. - **cause** (string) - The reason for the pool rejection. - **poolHash** (string) - The hash of the pool. - **time** (string) - The time the error occurred. #### Response Example ```json [ { "utcTime":"1635334386.697757s", "poolId":"be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853", "retryCount":2, "cause":"URL parse error from for pool1hcefh0cwur6n6x0nk2qgvythnfyu0h6r7vc2sq67h8u9x8z2cla resulted in : InvalidUrlException \"pool1hcefh0cwur6n6x0nk2qgvythnfyu0h6r7vc2sq67h8u9x8z2cla\" \"Invalid URL\"", "poolHash":"f2b553839dee1ad1d16127179d4378a0c06a1fddce83409ad4b6f10b65bad395", "time":"27.10.2021. 11:33:06" }, { "utcTime":"1635334094.642995s", "poolId":"be329bbf0ee0f53d19f3b2808611779a49c7df43f330a8035eb9f853", "retryCount":0, "cause":"HTTP Response from for https://LLCJ.com resulted in : 509", "poolHash":"4001829c25b4af556d1a473dec4874a621899cf6a84c60156ec2411727f1a169", "time":"27.10.2021. 11:28:14" } ] ``` ``` -------------------------------- ### Run Cardano Node Regression Tests Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/testnets_bootstrap_template/README.md This command executes the regression tests for the Cardano node. It requires specifying the node revision and the bootstrap directory. The testing framework automatically manages the node and db-sync processes, utilizing synced states if available. ```shell NODE_REV=10.4.1 BOOTSTRAP_DIR=~/path/to/preview_bootstrap ./.github/regression.sh ``` -------------------------------- ### Query Delisted Pools (SQL) Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Selects all entries from the `delisted_pool` table to check which pools have been delisted. This SQL query is used to verify the state of delisted pools in the database. ```sql select * from delisted_pool; ``` -------------------------------- ### Analyze Stake Credential History using CLI Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/stake_credential_history_tool.md This command-line interface usage demonstrates how to query the stake credential history for a given stake address. It requires configuration and socket paths for the Cardano node, along with the stake address in Bech32 format. The output shows various events like new eras, registrations, MIRs, and balances. ```bash ./tools/stake-credential-history -c ../cardano-node/state-cluster0/config-bft1.json -s ../cardano-node/state-cluster0/bft1.socket --stake-address-bech32 stake_test1uzkhjy8tnvx5n9exsh0j63aq83laylzl7c8gq2kmf4t9hyqg2thkv NEW-ERA ----------- EpochNo 1, SlotNo 1000, shelley NEW-ERA ----------- EpochNo 2, SlotNo 2000, allegra NEW-ERA ----------- EpochNo 3, SlotNo 3013, mary NEW-ERA ----------- EpochNo 4, SlotNo 4010, alonzo REGISTRATION ------ EpochNo 6, SlotNo 6885 BALANCE ----------- EpochNo 7, SlotNo 7017, balance: Lovelace 0 MIR --------------- EpochNo 7, SlotNo 7031, TreasuryMIR, Lovelace 50000000 MIR --------------- EpochNo 7, SlotNo 7080, ReservesMIR, Lovelace 50000000 BALANCE ----------- EpochNo 8, SlotNo 8014, balance: Lovelace 100000000 BALANCE ----------- EpochNo 9, SlotNo 9000, balance: Lovelace 100000000 BALANCE ----------- EpochNo 10, SlotNo 10003, balance: Lovelace 100000000 BALANCE ----------- EpochNo 11, SlotNo 11006, balance: Lovelace 100000000 BALANCE ----------- EpochNo 12, SlotNo 12000, balance: Lovelace 100000000 BALANCE ----------- EpochNo 13, SlotNo 13014, balance: Lovelace 100000000 BALANCE ----------- EpochNo 14, SlotNo 14001, balance: Lovelace 100000000 BALANCE ----------- EpochNo 15, SlotNo 15012, balance: Lovelace 100000000 BALANCE ----------- EpochNo 16, SlotNo 16010, balance: Lovelace 100000000 BALANCE ----------- EpochNo 17, SlotNo 17070, balance: Lovelace 100000000 ``` ```bash ./tools/stake-credential-history -c ../cardano-node/state-cluster0/config-bft1.json -s ../cardano-node/state-cluster0/bft1.socket --stake-address-bech32 stake_test1upfgrjq2wpd2k9lgw5744d3dlh0c88m7vev9qng5m7khtag5l8cmw NEW-ERA ----------- EpochNo 1, SlotNo 1000, shelley NEW-ERA ----------- EpochNo 2, SlotNo 2000, allegra NEW-ERA ----------- EpochNo 3, SlotNo 3013, mary NEW-ERA ----------- EpochNo 4, SlotNo 4010, alonzo REGISTRATION ------ EpochNo 10, SlotNo 10022 MIR --------------- EpochNo 10, SlotNo 10046, ReservesMIR, Lovelace 50000000000000 WDRL -------------- EpochNo 10, SlotNo 10069, Lovelace 0 DE-REGISTRATION --- EpochNo 10, SlotNo 10086 MIR --------------- EpochNo 12, SlotNo 12027, ReservesMIR, Lovelace 50000000000000 ``` -------------------------------- ### Generate Stake Pool Metadata Hash Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Shell command to calculate the metadata hash of a downloaded stake pool metadata file using the 'cardano-cli'. This is crucial for verifying hash integrity and identifying mismatches. ```sh wget https://git.io/JTUAD cardano-cli stake-pool metadata-hash --pool-metadata-file JTUAD ``` -------------------------------- ### Retrieve Cardano Pool Updates Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Fetches all update records for a given pool ID from the 'pool_update' table. This includes details like VRF keys, pledge, reward address, active epoch, metadata ID, margin, fixed cost, and registration transaction ID. ```sql select * from pool_update where hash_id=103; ``` -------------------------------- ### Reserve Ticker via SMASH API Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md Uses curl to send a POST request to the SMASH server's /api/v1/tickers/{tickerName} endpoint to reserve a ticker for a pool. Requires authentication and a JSON payload with the poolId. Returns the reserved ticker name on success or an error if the ticker is already reserved. ```shell curl --verbose -u username:password --header "Content-Type: application/json" --request POST --data '{"poolId":"1c443cd9c14c85e6b541be0c2bd98c9f11be25185a15636c33c4cd8f"}' http://localhost:3100/api/v1/tickers/ART ``` -------------------------------- ### Mint Native Tokens with Policy Scripts Source: https://context7.com/intersectmbo/cardano-node-tests/llms.txt Sets up the initial conditions for minting native tokens using policy scripts. It involves creating a `ClusterLib` instance and generating a payment address that will act as the token issuer. This is the first step in a multi-step process that would typically involve defining minting policies and constructing minting transactions. ```python from cardano_clusterlib import clusterlib from cardano_node_tests.utils import clusterlib_utils import pathlib as pl cluster = clusterlib.ClusterLib(state_dir="./dev_workdir/state-cluster0") # Create issuer address issuer_addr = cluster.g_address.gen_payment_addr_and_keys(name="token_issuer") ``` -------------------------------- ### Retrieve Pool Error Logs with cURL Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/smash/smash_tests_and_debugging_examples.md This command shows how to retrieve error logs associated with a specific Cardano stake pool. It uses cURL to make a GET request to the SMASH server's error endpoint, providing the pool's address. ```shell curl http://localhost:3100/api/v1/errors/pool1hcefh0cwur6n6x0nk2qgvythnfyu0h6r7vc2sq67h8u9x8z2cla ``` -------------------------------- ### Build Project Documentation Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Generates the project's documentation using a make target. This is typically used for reviewing or deploying documentation. ```sh make doc ``` -------------------------------- ### Python: Get Stake Address Information Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/doc/stake_credential_history_tool.md This Python code snippet, intended to be run within an active IPython session after a breakpoint, retrieves stake address information. It uses the `cluster.g_query.get_stake_addr_info` method, passing the registered user's stake address as an argument. ```python cluster.g_query.get_stake_addr_info(registered_user.stake.address) ``` -------------------------------- ### Build and Submit Cardano Transactions with clusterlib Source: https://context7.com/intersectmbo/cardano-node-tests/llms.txt Demonstrates building and submitting simple payment transactions using the `cardano-clusterlib` Python library. Includes initializing the cluster, generating addresses, funding an address, and verifying transaction submission and fund transfer. ```python from cardano_clusterlib import clusterlib from cardano_node_tests.utils import clusterlib_utils from cardano_node_tests.utils import submit_utils # Initialize cluster connection cluster = clusterlib.ClusterLib(state_dir="./dev_workdir/state-cluster0") # Create payment addresses src_addr = cluster.g_address.gen_payment_addr_and_keys(name="src_payment") dst_addr = cluster.g_address.gen_payment_addr_and_keys(name="dst_payment") # Fund source address (in real scenario, use faucet) clusterlib_utils.fund_from_faucet( src_addr, cluster_obj=cluster, amount=100_000_000, ) # Get source UTxOs src_utxos = cluster.g_query.get_utxo(address=src_addr.address) # Build and submit simple payment transaction using 'build' method tx_output = clusterlib_utils.build_and_submit_tx( cluster_obj=cluster, name_template="payment_tx", src_address=src_addr.address, txins=src_utxos, txouts=[clusterlib.TxOut(address=dst_addr.address, amount=2_000_000)], tx_files=clusterlib.TxFiles(signing_key_files=[src_addr.skey_file]), build_method=clusterlib_utils.BuildMethods.BUILD, submit_method=submit_utils.SubmitMethods.CLI, ) # Transaction successfully submitted assert tx_output.txid, "Transaction ID should be present" print(f"Transaction submitted: {tx_output.txid}") # Wait for transaction to appear on chain cluster.wait_for_new_block() # Verify destination address received funds dst_utxos = cluster.g_query.get_utxo(address=dst_addr.address) assert sum(u.amount for u in dst_utxos) >= 2_000_000 ``` -------------------------------- ### Run Project Linters Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Activates the poetry virtual environment and runs the project's linters to check code quality and style. ```sh source "$(poetry env info --path)"/bin/activate make lint ``` -------------------------------- ### Build Raw Cardano Transactions Manually Source: https://context7.com/intersectmbo/cardano-node-tests/llms.txt This snippet demonstrates the initialization of `ClusterLib` for building raw Cardano transactions, which requires manual fee calculation. Further steps would involve defining transaction inputs, outputs, and minting/burning policies if applicable. ```python from cardano_clusterlib import clusterlib from cardano_node_tests.utils import clusterlib_utils cluster = clusterlib.ClusterLib(state_dir="./dev_workdir/state-cluster0") ``` -------------------------------- ### Run Individual Tests with Custom Binaries Source: https://github.com/intersectmbo/cardano-node-tests/blob/master/README.md Execute specific tests by placing custom cardano-node and cardano-cli binaries in the `.bin` directory and then running the regression script with appropriate `PYTEST_ARGS`. This allows for testing against specific versions or modified builds of the node software. ```shell TEST_THREADS=0 CLUSTERS_COUNT=1 PYTEST_ARGS="-k 'test_minting_and_burning_sign[asset_name-build_raw-submit_cli]'" ./.github/regression.sh ```