{"id":28172922,"url":"https://github.com/archethic-foundation/ae-contract-test","last_synced_at":"2026-03-09T06:32:39.007Z","repository":{"id":266853105,"uuid":"862219783","full_name":"archethic-foundation/ae-contract-test","owner":"archethic-foundation","description":"Test framework for the Archethic Public Blockchain Smart Contracts ","archived":false,"fork":false,"pushed_at":"2025-04-17T13:26:07.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-26T20:46:13.941Z","etag":null,"topics":["archethic","testing","wasm"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/archethic-foundation.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}},"created_at":"2024-09-24T08:35:14.000Z","updated_at":"2025-04-17T13:26:11.000Z","dependencies_parsed_at":"2024-12-06T15:25:34.362Z","dependency_job_id":"acbb1455-b165-4019-9550-ff9f37f46ea9","html_url":"https://github.com/archethic-foundation/ae-contract-test","commit_stats":null,"previous_names":["archethic-foundation/ae-contract-test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/archethic-foundation/ae-contract-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archethic-foundation%2Fae-contract-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archethic-foundation%2Fae-contract-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archethic-foundation%2Fae-contract-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archethic-foundation%2Fae-contract-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archethic-foundation","download_url":"https://codeload.github.com/archethic-foundation/ae-contract-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archethic-foundation%2Fae-contract-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30284776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: 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":["archethic","testing","wasm"],"created_at":"2025-05-15T20:11:24.625Z","updated_at":"2026-03-09T06:32:38.986Z","avatar_url":"https://github.com/archethic-foundation.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ae-contract-test\n\nTesting suite for WebAssembly smart contract for Archethic Public Blockchain.\n\nThe framework simplifies the WASM execution environement by simulating the interaction in/out between WASM and the host application.\n\n## Features\n\n- **Call abstraction**: call WASM method as Javascript function call\n- **Ease of mocking**: Simplify I/O mock function call (i.e Chain request, HTTP, etc.)\n- **Lifecycle abstraction**: Simulate contract deployment and upgrade\n- **Account mangement**: Direct interaction with wallet \u0026 network to ease testing \u0026 deployment   \n\n## Getting Started\n\n## Prerequisites\n- Node.js\n- npm\n\n## Installation\n\n```bash\nnpm install @archethicjs/ae-contract-test\n```\n\n## Usage\n\n1. Configure the environement\n\nCreate `archethic.config.js` file to define configuration for account \u0026 network interaction:\n```js\n{\n   endpoint: 'https://testnet.archethic.net',\n   seed: 'PRIVATE_SEED',\n   upgradeAddress: 'Address allowed to make code upgrade'\n}\n```\n\n2. Write a test\n\nCreate a file in `tests/index.spec.ts`\n\n```js\nimport { readFileSync } from \"fs\";\nimport { getContract } from \"@archethic/contract-testing\";\nimport { Balance } from \"@archethic/as-contract-sdk\";\nimport { Address, Result, Transaction, TransactionType } from \"@archethic/contract-testing/types\";\n\ndescribe(\"init\", () =\u003e {\n  it(\"should deploy the contract and initialize the state\", async () =\u003e {\n    const wasmBuffer = readFileSync(\"./dist/contract.wasm\");\n\n    const contract = await getContract(wasmBuffer, {\n      transaction: {\n        data: {\n          content: \"5\",\n        },\n      } as Transaction\n    });\n    expect(contract.state).toStrictEqual({ counter: 25 });\n  });\n});\n\ndescribe(\"onUpgrade\", () =\u003e {\n  it(\"should mutate the contract's state with new contract logic\", async () =\u003e {\n    const wasmBuffer = readFileSync(\"./dist/contract.wasm\");\n    const contract = await getContract(wasmBuffer);\n    expect(contract.state.counter).toBe(0);\n    const newContract = await contract.upgrade(wasmBuffer);\n    expect(newContract.state.counter).toBe(10);\n  });\n});\n\ndescribe(\"inc\", () =\u003e {\n  it(\"should increment without state\", async () =\u003e {\n    const wasmBuffer = readFileSync(\"./dist/contract.wasm\");\n    const contract = await getContract(wasmBuffer);\n    const result = contract.inc({ value: 2 });\n    expect(result?.state.counter).toBe(2);\n  });\n\n  it(\"should increment with state\", async () =\u003e {\n    const wasmBuffer = readFileSync(\"./dist/contract.wasm\");\n    const contract = await getContract(wasmBuffer);\n\n    const result = contract.inc({ state: { counter: 2 } });\n    expect(result?.state.counter).toBe(3);\n  });\n\n  it(\"should raise an error when the state is negative\", async () =\u003e {\n    const wasmBuffer = readFileSync(\"./dist/contract.wasm\");\n    const contract = await getContract(wasmBuffer);\n    expect(() =\u003e {\n      contract.inc({ state: { counter: -2 } });\n    }).toThrow(\"state cannot be negative\");\n  });\n});\n```\n\n## Development\n\nThe test framework used several modules:\n- **accounts**: Manage accounts and interaction with wallet\n- **config**: Manage test configuration\n- **connection**: Manage blockchain connection\n- **contract_factory**: Abstract WASM contract instance \u0026 function calls\n\n## **Contribution**\n\nThank you for considering to help out with the source code. We welcome contributions from anyone and are grateful for even the smallest of improvement.\n\nPlease to follow this workflow:\n\n1. Fork it!\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create new Pull Request\n\n## **Licence**\n\nAGPL\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchethic-foundation%2Fae-contract-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchethic-foundation%2Fae-contract-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchethic-foundation%2Fae-contract-test/lists"}