{"id":49911126,"url":"https://github.com/blockfrost/testgen-hs","last_synced_at":"2026-05-16T13:05:00.368Z","repository":{"id":264851923,"uuid":"894441681","full_name":"blockfrost/testgen-hs","owner":"blockfrost","description":"CBOR test case generator and deserializer for cross-checking other implementations","archived":false,"fork":false,"pushed_at":"2026-04-07T14:15:12.000Z","size":257,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-04-07T16:15:37.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blockfrost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-26T11:10:44.000Z","updated_at":"2026-04-07T14:15:21.000Z","dependencies_parsed_at":"2025-10-13T03:52:43.389Z","dependency_job_id":"34944307-35a1-4cf9-8044-5904ee4155c7","html_url":"https://github.com/blockfrost/testgen-hs","commit_stats":null,"previous_names":["input-output-hk/testgen-hs","blockfrost/testgen-hs"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/blockfrost/testgen-hs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Ftestgen-hs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Ftestgen-hs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Ftestgen-hs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Ftestgen-hs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blockfrost","download_url":"https://codeload.github.com/blockfrost/testgen-hs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Ftestgen-hs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33103971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-16T13:04:58.398Z","updated_at":"2026-05-16T13:05:00.338Z","avatar_url":"https://github.com/blockfrost.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# testgen-hs\n\nCBOR test case generator and deserializer for cross-checking other implementations.\n\n## Example 1 – how to use it\n\n```\n❯ testgen-hs --help\n\nUsage: testgen-hs COMMAND\n\n  Test case generator for cross-checking CBOR (de)serializers\n\nAvailable options:\n  -h,--help                Show this help text\n\nAvailable commands:\n  generate                 Generate random CBOR test cases\n  deserialize              Deserialize CBOR of ‘HardForkApplyTxErr’ that you got\n                           from cardano-node\n```\n\n```\n❯ testgen-hs generate --help\n\nUsage: testgen-hs generate [-s|--seed SEED] [-g|--generator-size SIZE]\n                           [-n|--number NUM] COMMAND\n\n  Generate random CBOR test cases\n\nAvailable options:\n  -s,--seed SEED           Random seed integer (UNIX timestamp by default)\n  -g,--generator-size SIZE Set the relative ‘size’ of the test cases\n  -n,--number NUM          How many test cases to generate\n  -h,--help                Show this help text\n\nAvailable commands:\n  ApplyTxErr_Byron         Generate CBOR of ApplyTxErr'Byron\n  ApplyTxErr_Shelley       Generate CBOR of ApplyTxErr'Shelley\n  ApplyTxErr_Allegra       Generate CBOR of ApplyTxErr'Allegra\n  ApplyTxErr_Mary          Generate CBOR of ApplyTxErr'Mary\n  ApplyTxErr_Alonzo        Generate CBOR of ApplyTxErr'Alonzo\n  ApplyTxErr_Babbage       Generate CBOR of ApplyTxErr'Babbage\n  ApplyTxErr_Conway        Generate CBOR of ApplyTxErr'Conway\n  GHCInteger               Generate CBOR of GHCInteger\n  DataText                 Generate CBOR of DataText\n  ExampleADT               Generate CBOR of ExampleADT\n```\n\n```\n❯ testgen-hs generate -g1 -n1 ApplyTxErr_Conway\n```\n\n```json\n{\n  \"seed\": 1731690796,\n  \"testCases\": [\n    {\n      \"cbor\": \"81820682820182018082038210581de0988807a48f6c7871bfa29d3ea70a6328c5fa35beb8c48589c676dc7b\",\n      \"haskellRepr\": \"ApplyTxError (ConwayUtxowFailure (InvalidWitnessesUTXOW []) :| [ConwayGovFailure (ProposalReturnAccountDoesNotExist (RewardAccount {raNetwork = Testnet, raCredential = KeyHashObj (KeyHash {unKeyHash = \\\"988807a48f6c7871bfa29d3ea70a6328c5fa35beb8c48589c676dc7b\\\"})}))])\",\n      \"json\": {\n        \"contents\": {\n          \"contents\": {\n            \"contents\": {\n              \"era\": \"ShelleyBasedEraConway\",\n              \"error\": [\n                \"ConwayUtxowFailure (InvalidWitnessesUTXOW [])\",\n                \"ConwayGovFailure (ProposalReturnAccountDoesNotExist (RewardAccount {raNetwork = Testnet, raCredential = KeyHashObj (KeyHash {unKeyHash = \\\"988807a48f6c7871bfa29d3ea70a6328c5fa35beb8c48589c676dc7b\\\"})}))\"\n              ],\n              \"kind\": \"ShelleyTxValidationError\"\n            },\n            \"tag\": \"TxValidationErrorInCardanoMode\"\n          },\n          \"tag\": \"TxCmdTxSubmitValidationError\"\n        },\n        \"tag\": \"TxSubmitFail\"\n      },\n      \"typeTag\": \"ApplyTxError (ConwayEra StandardCrypto)\"\n    }\n  ]\n}\n```\n\n## Example 2 – searching for a particular error\n\nWith a little of Bash, it's possible to search for a particular error:\n\n```bash\n❯ while true ; do\n    output=$(testgen-hs generate -g1 -n1 ApplyTxErr_Conway)\n    if grep -q FeeTooSmall \u003c\u003c\u003c\"$output\" ; then\n      jq . \u003c\u003c\u003c\"$output\"\n      break\n    fi\n    sleep 0.01\n  done\n```\n\n```json\n{\n  \"seed\": 1732539592414,\n  \"testCases\": [\n    {\n      \"cbor\": \"81820682830601008201820083051a000aa8a91a000291ff\",\n      \"haskellRepr\": \"ApplyTxError (ConwayTxRefScriptsSizeTooBig 1 0 :| [ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 698537) (Coin 168447)))])\",\n      \"json\": {\n        \"contents\": {\n          \"contents\": {\n            \"contents\": {\n              \"era\": \"ShelleyBasedEraConway\",\n              \"error\": [\n                \"ConwayTxRefScriptsSizeTooBig 1 0\",\n                \"ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 698537) (Coin 168447)))\"\n              ],\n              \"kind\": \"ShelleyTxValidationError\"\n            },\n            \"tag\": \"TxValidationErrorInCardanoMode\"\n          },\n          \"tag\": \"TxCmdTxSubmitValidationError\"\n        },\n        \"tag\": \"TxSubmitFail\"\n      },\n      \"typeTag\": \"ApplyTxError (ConwayEra StandardCrypto)\"\n    }\n  ]\n}\n```\n\nAnd then easily reproduce it by providing the same seed that was found:\n\n```\n❯ testgen-hs generate -s1732539592414 -g1 -n1 ApplyTxErr_Conway\n```\n\n```json\n{\n  \"seed\": 1732539592414,\n  \"testCases\": [\n    {\n      \"cbor\": \"81820682830601008201820083051a000aa8a91a000291ff\",\n      \"haskellRepr\": \"ApplyTxError (ConwayTxRefScriptsSizeTooBig 1 0 :| [ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 698537) (Coin 168447)))])\",\n      \"json\": {\n        \"contents\": {\n          \"contents\": {\n            \"contents\": {\n              \"era\": \"ShelleyBasedEraConway\",\n              \"error\": [\n                \"ConwayTxRefScriptsSizeTooBig 1 0\",\n                \"ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 698537) (Coin 168447)))\"\n              ],\n              \"kind\": \"ShelleyTxValidationError\"\n            },\n            \"tag\": \"TxValidationErrorInCardanoMode\"\n          },\n          \"tag\": \"TxCmdTxSubmitValidationError\"\n        },\n        \"tag\": \"TxSubmitFail\"\n      },\n      \"typeTag\": \"ApplyTxError (ConwayEra StandardCrypto)\"\n    }\n  ]\n}\n```\n\n## Example 3 – two small Conway errors\n\n```\n❯ testgen-hs generate -s1732187056519 -g1 -n1 ApplyTxErr_Conway\n```\n\n```json\n{\n  \"seed\": 1732187056519,\n  \"testCases\": [\n    {\n      \"cbor\": \"818206828201820083051a000151351a00074b8582076162\",\n      \"haskellRepr\": \"ApplyTxError (ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 86325) (Coin 478085))) :| [ConwayMempoolFailure \\\"b\\\"])\",\n      \"json\": {\n        \"contents\": {\n          \"contents\": {\n            \"contents\": {\n              \"era\": \"ShelleyBasedEraConway\",\n              \"error\": [\n                \"ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 86325) (Coin 478085)))\",\n                \"ConwayMempoolFailure \\\"b\\\"\"\n              ],\n              \"kind\": \"ShelleyTxValidationError\"\n            },\n            \"tag\": \"TxValidationErrorInCardanoMode\"\n          },\n          \"tag\": \"TxCmdTxSubmitValidationError\"\n        },\n        \"tag\": \"TxSubmitFail\"\n      },\n      \"typeTag\": \"ApplyTxError (ConwayEra StandardCrypto)\"\n    }\n  ]\n}\n```\n\n```\n❯ testgen-hs generate -s1732186210861 -g1 -n1 ApplyTxErr_Conway\n```\n\n```json\n{\n  \"seed\": 1732186210861,\n  \"testCases\": [\n    {\n      \"cbor\": \"818206828201820083051a000a63d11a0009580683051a0008d00a1a0001ebc4\",\n      \"haskellRepr\": \"ApplyTxError (ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 680913) (Coin 612358))) :| [ConwayTreasuryValueMismatch (Coin 577546) (Coin 125892)])\",\n      \"json\": {\n        \"contents\": {\n          \"contents\": {\n            \"contents\": {\n              \"era\": \"ShelleyBasedEraConway\",\n              \"error\": [\n                \"ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 680913) (Coin 612358)))\",\n                \"ConwayTreasuryValueMismatch (Coin 577546) (Coin 125892)\"\n              ],\n              \"kind\": \"ShelleyTxValidationError\"\n            },\n            \"tag\": \"TxValidationErrorInCardanoMode\"\n          },\n          \"tag\": \"TxCmdTxSubmitValidationError\"\n        },\n        \"tag\": \"TxSubmitFail\"\n      },\n      \"typeTag\": \"ApplyTxError (ConwayEra StandardCrypto)\"\n    }\n  ]\n}\n```\n\n## Example 4 – deserialize a CBOR\n\n```\n❯ testgen-hs deserialize 818206828201820083051a000a63d11a0009580683051a0008d00a1a0001ebc4\n```\n\n```json\n{\n  \"cbor\": \"818206828201820083051a000a63d11a0009580683051a0008d00a1a0001ebc4\",\n  \"haskellRepr\": \"ApplyTxError (ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 680913) (Coin 612358))) :| [ConwayTreasuryValueMismatch (Coin 577546) (Coin 125892)])\",\n  \"json\": {\n    \"contents\": {\n      \"contents\": {\n        \"contents\": {\n          \"era\": \"ShelleyBasedEraConway\",\n          \"error\": [\n            \"ConwayUtxowFailure (UtxoFailure (FeeTooSmallUTxO (Coin 680913) (Coin 612358)))\",\n            \"ConwayTreasuryValueMismatch (Coin 577546) (Coin 125892)\"\n          ],\n          \"kind\": \"ShelleyTxValidationError\"\n        },\n        \"tag\": \"TxValidationErrorInCardanoMode\"\n      },\n      \"tag\": \"TxCmdTxSubmitValidationError\"\n    },\n    \"tag\": \"TxSubmitFail\"\n  },\n  \"typeTag\": \"ApplyTxError (ConwayEra StandardCrypto)\"\n}\n```\n\n## Example 5 – deserialize a stream of CBORs\n\n```\n❯ ( echo 8182068182028200a0\n    echo 81820681820481581cc0231342a5c66b25d652a7116559d02cbe9515ef890fd698de38d456\n  ) | testgen-hs deserialize-stream\n```\n\n```json\n{\"cbor\":\"8182068182028200a0\",\"haskellRepr\":\"ApplyTxError (ConwayCertsFailure (WithdrawalsNotInRewardsCERTS (fromList [])) :| [])\",\"json\":{\"contents\":{\"contents\":{\"contents\":{\"era\":\"ShelleyBasedEraConway\",\"error\":[\"ConwayCertsFailure (WithdrawalsNotInRewardsCERTS (fromList []))\"],\"kind\":\"ShelleyTxValidationError\"},\"tag\":\"TxValidationErrorInCardanoMode\"},\"tag\":\"TxCmdTxSubmitValidationError\"},\"tag\":\"TxSubmitFail\"},\"typeTag\":\"ApplyTxError (ConwayEra StandardCrypto)\"}\n{\"cbor\":\"81820681820481581cc0231342a5c66b25d652a7116559d02cbe9515ef890fd698de38d456\",\"haskellRepr\":\"ApplyTxError (ConwayWdrlNotDelegatedToDRep (KeyHash {unKeyHash = \\\"c0231342a5c66b25d652a7116559d02cbe9515ef890fd698de38d456\\\"} :| []) :| [])\",\"json\":{\"contents\":{\"contents\":{\"contents\":{\"era\":\"ShelleyBasedEraConway\",\"error\":[\"ConwayWdrlNotDelegatedToDRep (KeyHash {unKeyHash = \\\"c0231342a5c66b25d652a7116559d02cbe9515ef890fd698de38d456\\\"} :| [])\"],\"kind\":\"ShelleyTxValidationError\"},\"tag\":\"TxValidationErrorInCardanoMode\"},\"tag\":\"TxCmdTxSubmitValidationError\"},\"tag\":\"TxSubmitFail\"},\"typeTag\":\"ApplyTxError (ConwayEra StandardCrypto)\"}\n```\n\n## Development – HLS setup\n\nThis project provides a Nix devshell with GHC and HLS. To get full IDE\nsupport you need [`direnv`](https://direnv.net/) with\n[`nix-direnv`](https://github.com/nix-community/nix-direnv) so that the\n`.envrc` is picked up automatically. See their official documentation for\ninstallation instructions.\n\nThe instructions below use VS Code as an example, but any editor with LSP and\n`direnv` support (Neovim, Emacs, etc.) works the same way. The devshell puts\nboth `haskell-language-server` and `haskell-language-server-wrapper` on\n`PATH`, so most editors should pick up HLS automatically.\n\n### VS Code example\n\n1. Install the extensions **Haskell** (`haskell.haskell`) and **direnv**\n   (`mkhl.direnv`).\n\n2. Tell the Haskell extension to use the HLS provided by the devshell\n   instead of managing its own. Add this to your VS Code settings:\n\n   ```json\n   { \"haskell.manageHLS\": \"PATH\" }\n   ```\n\n   Optionally, enable semantic highlighting (richer colours for types,\n   type variables, etc.):\n\n   ```json\n   { \"haskell.plugin.semanticTokens.globalOn\": true }\n   ```\n\n3. Allow direnv for this project and restart HLS:\n\n   ```\n   direnv allow\n   ```\n\n   Then in VS Code: `Ctrl+Shift+P` → _Haskell: Restart Haskell LSP Server_.\n\n\u003e **Note:** The first HLS session takes roughly 10 minutes while `hie-bios`\n\u003e builds all dependencies via `cabal v2-repl`. Subsequent loads use the\n\u003e cache at `~/.cache/hie-bios/`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockfrost%2Ftestgen-hs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblockfrost%2Ftestgen-hs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockfrost%2Ftestgen-hs/lists"}