{"id":28746200,"url":"https://github.com/stacks-network/madhouse-rs","last_synced_at":"2025-09-09T00:37:27.880Z","repository":{"id":286607145,"uuid":"927878402","full_name":"stacks-network/madhouse-rs","owner":"stacks-network","description":"Model-based Rust state machine testing. Inspired by Hughes, Testing the Hard Stuff and Staying Sane.","archived":false,"fork":false,"pushed_at":"2025-05-12T14:25:52.000Z","size":142,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-02T11:46:27.963Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stacks-network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-02-05T17:34:39.000Z","updated_at":"2025-05-11T13:10:37.000Z","dependencies_parsed_at":"2025-04-20T12:19:26.028Z","dependency_job_id":null,"html_url":"https://github.com/stacks-network/madhouse-rs","commit_stats":null,"previous_names":["moodmosaic/madhouse","moodmosaic/madhouse-rs","stacks-network/madhouse-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stacks-network/madhouse-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fmadhouse-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fmadhouse-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fmadhouse-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fmadhouse-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacks-network","download_url":"https://codeload.github.com/stacks-network/madhouse-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fmadhouse-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231097,"owners_count":25245687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-06-16T14:30:43.262Z","updated_at":"2025-09-09T00:37:27.858Z","avatar_url":"https://github.com/stacks-network.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# madhouse-rs\n\nModel-based Rust state machine testing.\n\n## Overview\n\nTests state machines via sequences of command objects. Each command:\n1. Checks preconditions via check()\n2. Mutates state via apply()\n3. Verifies assertions\n\n### Command flow\n\n```\n                   +-------+\n                   | State |\n                   +-------+\n                       ^\n                       |\n  +---------+     +----+----+     +-----------+\n  | Command | --\u003e | check() | --\u003e |  apply()  |\n  +---------+     +---------+     | [asserts] |\n       ^                          +-----------+\n       |\n  +----------+\n  | Strategy |\n  +----------+\n```\n\n## Usage\n\n```rust\nuse madhouse::*;\nuse proptest::prelude::*;\nuse std::env;\nuse std::sync::Arc;\n\n// State + Context\n#[derive(Debug, Default)]\nstruct Counter {\n    value: u32,\n    max: u32,\n}\nimpl State for Counter {}\n\n#[derive(Debug, Clone, Default)]\nstruct Ctx {}\nimpl TestContext for Ctx {}\n\n// Commands\nstruct Inc {\n    amount: u32,\n}\nimpl Command\u003cCounter, Ctx\u003e for Inc {\n    fn check(\u0026self, s: \u0026Counter) -\u003e bool {\n        s.value + self.amount \u003c= s.max\n    }\n    fn apply(\u0026self, s: \u0026mut Counter) {\n        s.value += self.amount;\n    }\n    fn label(\u0026self) -\u003e String {\n        format!(\"INC({})\", self.amount)\n    }\n    fn build(_: Arc\u003cCtx\u003e) -\u003e impl Strategy\u003cValue = CommandWrapper\u003cCounter, Ctx\u003e\u003e {\n        (1..=5u32).prop_map(|n| CommandWrapper::new(Inc { amount: n }))\n    }\n}\n\nstruct Reset;\nimpl Command\u003cCounter, Ctx\u003e for Reset {\n    fn check(\u0026self, s: \u0026Counter) -\u003e bool {\n        s.value \u003e 0\n    }\n    fn apply(\u0026self, s: \u0026mut Counter) {\n        s.value = 0;\n    }\n    fn label(\u0026self) -\u003e String {\n        \"RESET\".to_string()\n    }\n    fn build(_: Arc\u003cCtx\u003e) -\u003e impl Strategy\u003cValue = CommandWrapper\u003cCounter, Ctx\u003e\u003e {\n        Just(CommandWrapper::new(Reset))\n    }\n}\n\nfn main() {\n    let ctx = Arc::new(Ctx::default());\n    scenario![ctx, Inc, Reset, (Inc { amount: 42 })];\n}\n```\n\n## Testing Modes\n\n- **Normal**: Commands run in specified order but proptest strategies will generate different values across runs unless using a fixed seed\n- **Random**: Commands chosen pseudorandomly (set `MADHOUSE=1`)\n- **Shrinking**: To shrink test cases, set `PROPTEST_MAX_SHRINK_ITERS`\n\n## Example\n\nRun tests:\n```bash\n# Normal mode\ncargo test\n\n# Random mode\nMADHOUSE=1 cargo test\n\n# With shrinking\nMADHOUSE=1 PROPTEST_MAX_SHRINK_ITERS=100 cargo test\n```\n\n## Features\n\n- Trait-based command design\n- Self-validating commands\n- Timing information\n- Test case shrinking\n\n## License\n\nGPL-3.0\n\nCopyright (C) 2025 Stacks Open Internet Foundation. \u003chttps://stacks.org/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacks-network%2Fmadhouse-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacks-network%2Fmadhouse-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacks-network%2Fmadhouse-rs/lists"}