diff --git a/CHANGELOG.md b/CHANGELOG.md index 3434afe53..57e1a67e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +#### [2.0.0](https://github.com/hirosystems/clarinet/compare/v1.8.0...v2.0.0) (2023-10-26) + +##### New Features + +* Introduce global ~/.clarinet/clarinetrc.toml (#1208) (bbe26ccf) +* Update clarinet generated template to use the sdk (#1209) (27f9bce0) +* Create clarinet-sdk testing boilerplate (#1158) (6f2e990d) +* Deployment apply -use-on-disk-deployment-plan (2cba2335) +* Allow stacks-network to be run as standalone chain coordinator (#1064) (55b03bbb) + +##### Bug Fixes + +* Detect trait dependencies in composite types (#1236) (2b385454) +* Detect dependencies defined in const (#1205) (6e8b69ab) +* Replace . with _ for contract names (#1202) (165bfb93) +* Avoid pulling undesired dependencies in stacks-rpc crate (#1115) (17d20584) +* Project manifest (de)serialization tag (#1150) (ce0881c9) +* Clarinet-deployments wasm build (#1144) (1ab57028) +* Command splits once and picks everything after as the expression to get costs from (#1112) (6b35ed75) + +##### Refactors + +* Clippy (#1223) (faa5a3eb) + +##### Chores + +* Use clarinet sdk in examples (#1204) (f88be03c) +* Remove deno (#1186) (dd905708) +* Update service names for k8s devnet assets (#1161) (e03b9416) + +##### Documentation Changes + +* Udpate hints (#1227) (763b4b64) +* Deprecation warnings for clarinet test and clarinet run (#1157) (edf98aa3) + #### [1.8.0](https://github.com/hirosystems/clarinet/compare/v1.7.1...v1.8.0) (2023-09-12) ##### Continuous Integration diff --git a/Cargo.lock b/Cargo.lock index 9075a352c..59878afdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -645,7 +645,7 @@ checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "clarinet-cli" -version = "1.8.0" +version = "2.0.0" dependencies = [ "ansi_term", "atty", @@ -658,7 +658,7 @@ dependencies = [ "clarinet-files", "clarinet-utils 1.0.0", "clarity-lsp", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "crossbeam-channel", "crossterm 0.22.1", "ctrlc", @@ -714,7 +714,7 @@ dependencies = [ "bitcoincore-rpc-json", "clarinet-files", "clarinet-utils 1.0.0", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "colored 2.0.4", "libsecp256k1 0.7.1", "reqwest", @@ -734,7 +734,7 @@ dependencies = [ "bitcoin", "chainhook-types", "clarinet-utils 1.0.0", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "js-sys", "libsecp256k1 0.7.1", "serde", @@ -754,7 +754,7 @@ version = "1.0.7" dependencies = [ "clarinet-deployments", "clarinet-files", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "console_error_panic_hook", "gloo-utils", "js-sys", @@ -793,7 +793,7 @@ version = "1.0.0" dependencies = [ "clap 3.2.23", "clarinet-files", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "serde", "serde_derive", "serde_json", @@ -805,7 +805,7 @@ name = "clarity-jupyter-kernel" version = "1.0.0" dependencies = [ "chrono", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "colored 1.9.3", "dirs", "failure", @@ -827,7 +827,7 @@ version = "1.0.0" dependencies = [ "clarinet-deployments", "clarinet-files", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "console_error_panic_hook", "js-sys", "lazy_static", @@ -878,7 +878,7 @@ dependencies = [ [[package]] name = "clarity-repl" -version = "1.8.0" +version = "2.0.0" dependencies = [ "ansi_term", "atty", @@ -4066,7 +4066,7 @@ dependencies = [ [[package]] name = "stacks-devnet-js" -version = "1.8.0" +version = "2.0.0" dependencies = [ "clarinet-deployments", "clarinet-files", @@ -4082,7 +4082,7 @@ dependencies = [ [[package]] name = "stacks-network" -version = "1.8.0" +version = "2.0.0" dependencies = [ "ansi_term", "atty", @@ -4097,7 +4097,7 @@ dependencies = [ "clarinet-deployments", "clarinet-files", "clarinet-utils 1.0.0", - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "crossbeam-channel", "crossterm 0.22.1", "ctrlc", @@ -4120,7 +4120,7 @@ dependencies = [ name = "stacks-rpc-client" version = "1.0.10" dependencies = [ - "clarity-repl 1.8.0", + "clarity-repl 2.0.0", "hmac 0.12.1", "libsecp256k1 0.7.1", "pbkdf2", diff --git a/README.md b/README.md index 0abd53675..1fa18be29 100644 --- a/README.md +++ b/README.md @@ -348,59 +348,8 @@ This annotation tells the check-checker to consider the specified variables to b ### Execute a test suite -> Warning: `clarinet test` will soon be deprecated in favor of a new way of testing smart contracts. The new documentation is under construction. In the meantime, learn more [in the clarinet-sdk Readme](https://github.com/hirosystems/clarinet/blob/01da3550670f321a2f19fd3b0f8df0fb4b769b08/components/clarinet-sdk/README.md). +> Warning: `clarinet test` has been be deprecated in Clarinet 2 in favor of a new way of testing smart contracts Learn more in the [announcement blog post](https://www.hiro.so/blog/announcing-the-clarinet-sdk-a-javascript-programming-model-for-easy-smart-contract-testing) or [in the clarinet-sdk Readme](https://github.com/hirosystems/clarinet/blob/01da3550670f321a2f19fd3b0f8df0fb4b769b08/components/clarinet-sdk/README.md). -Clarinet provides a testing harness based on Deno that can enable you to create automated unit tests or pseudo-integration tests using Typescript. - -```bash -clarinet test -``` - -For more information on how to create unit tests using Typescript, see the [Writing Unit Tests Using Typescript](https://www.youtube.com/watch?v=Z4YEHUxHWuE&list=PL5Ujm489LoJaAz9kUJm8lYUWdGJ2AnQTb&index=7) YouTube video. - -When you use the `clarinet contract new foo` command to create a new contract, Clarinet will automatically create a unit test file for this new contract, `tests/foo_test.ts`. Other files under the `tests/_ directory` following the Deno test naming convention will also be included: - -- named test.{ts, tsx, mts, js, mjs, jsx, cjs, cts}, -- or ending with .test.{ts, tsx, mts, js, mjs, jsx, cjs, cts}, -- or ending with \_test.{ts, tsx, mts, js, mjs, jsx, cjs, cts} - -Within these tests, you can simulate mining a block containing transactions using your contract, and then examine the results of those transactions as well as the events generated by them. - -See the [billboard example](examples/billboard/tests/billboard_test.ts) for sample unit tests. - -**Note:** If you see an error in VS Code on the imports in the generated test file(s), that says, "An import path cannot end with a '.ts' extension" (an example is shown below), installing the [Deno extension](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno) will resolve this error. - -![VS Code deno error](docs/images/deno-error.png) - -#### Measure and increase code coverage - -To help maximize a smart contract's test coverage, Clarinet can produce a `lcov` report, using the following option: - -```bash -clarinet test --coverage -``` - -From there, you can use the `lcov` tooling suite to produce HTML reports: - -```bash -brew install lcov -genhtml --branch-coverage -o coverage coverage.lcov -open coverage/index.html -``` - -![lcov](docs/images/lcov.png) - -### Cost optimizations - -Clarinet can also be used to optimize costs. When executing a test suite, Clarinet will keep track of all the costs being computed when executing the `contract-call`, and display the most expensive ones in a table: - -```bash -clarinet test --costs -``` - -The `--costs` option can be used in conjunction with `--watch` and filters to maximize productivity, as illustrated here: - -![costs](docs/images/costs.gif) ### Load contracts in a console diff --git a/components/clarinet-cli/Cargo.toml b/components/clarinet-cli/Cargo.toml index b6fb734f2..34a410ee9 100644 --- a/components/clarinet-cli/Cargo.toml +++ b/components/clarinet-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clarinet-cli" -version = "1.8.0" +version = "2.0.0" authors = ["Ludo Galabru ", "Brice Dobry "] edition = "2021" description = "Clarinet is a simple, modern and opinionated runtime for testing, integrating and deploying Clarity smart contracts." diff --git a/components/clarinet-cli/examples/.vscode/settings.json b/components/clarinet-cli/examples/.vscode/settings.json deleted file mode 100644 index cbac5697b..000000000 --- a/components/clarinet-cli/examples/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "deno.enable": true -} diff --git a/components/clarinet-cli/examples/counter/tests/counter_test.ts b/components/clarinet-cli/examples/counter/tests/counter_test.ts deleted file mode 100644 index 8a717558b..000000000 --- a/components/clarinet-cli/examples/counter/tests/counter_test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Clarinet, Tx, Chain, Account, types } from "https://deno.land/x/clarinet@v1.7.1/index.ts"; -import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; - -Clarinet.test({ - name: "Ensure that counter can be incremented multiples per block, accross multiple blocks", - fn(chain: Chain, accounts: Map) { - const wallet_1 = accounts.get("wallet_1")!; - const wallet_2 = accounts.get("wallet_2")!; - - let block = chain.mineBlock([ - Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address), - Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address), - Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address), - ]); - assertEquals(block.height, 3); - block.receipts[0].result.expectOk().expectUint(2); - block.receipts[1].result.expectOk().expectUint(6); - block.receipts[2].result.expectOk().expectUint(16); - - block = chain.mineBlock([ - Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address), - Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address), - Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address), - Tx.transferSTX(1, wallet_2.address, wallet_1.address), - ]); - - assertEquals(block.height, 4); - block.receipts[0].result.expectOk().expectUint(17); - block.receipts[1].result.expectOk().expectUint(21); - block.receipts[2].result.expectOk().expectUint(31); - - const result = chain.getAssetsMaps(); - assertEquals(result.assets["STX"][wallet_1.address], 99999999999999); - - const call = chain.callReadOnlyFn("counter", "read-counter", [], wallet_1.address); - call.result.expectOk().expectUint(31); - - "0x0001020304".expectBuff(new Uint8Array([0, 1, 2, 3, 4])); - "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.plaid-token".expectPrincipal( - "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.plaid-token" - ); - }, -}); - -Clarinet.test({ - name: "Test with pre-setup", - preDeployment: (chain: Chain) => { - chain.mineEmptyBlock(100); - }, - fn(chain: Chain, accounts: Map) { - const wallet_1 = accounts.get("wallet_1")!; - - const block = chain.mineBlock([ - Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address), - Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address), - Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address), - ]); - assertEquals(block.height, 103); - block.receipts[0].result.expectOk().expectUint(2); - block.receipts[1].result.expectOk().expectUint(6); - block.receipts[2].result.expectOk().expectUint(16); - }, -}); diff --git a/components/clarinet-files/Cargo.toml b/components/clarinet-files/Cargo.toml index 79e67a2b3..08fac6eb1 100644 --- a/components/clarinet-files/Cargo.toml +++ b/components/clarinet-files/Cargo.toml @@ -10,8 +10,6 @@ serde = "1" serde_derive = "1" chainhook-types = "=1.1.0" # chainhook-types = { version = "=1.1.0", path = "../../../chainhook/components/chainhook-types-rs" } -clarinet-utils = { version = "1", path = "../clarinet-utils" } -clarity-repl = { version = "1", path = "../clarity-repl", default-features = false, optional = true } bip39 = { version = "1.0.1", default-features = false } libsecp256k1 = "0.7.0" toml = { version = "0.5.6", features = ["preserve_order"] } @@ -19,6 +17,9 @@ url = { version = "2.2.2", features = ["serde"] } tiny-hderive = "0.3.0" bitcoin = { version = "0.29.2", optional = true } +clarinet-utils = { version = "1", path = "../clarinet-utils" } +clarity-repl = { version = "2", path = "../clarity-repl", default-features = false, optional = true } + # wasm js-sys = { version = "0.3", optional = true } serde-wasm-bindgen = { version = "0.6.0", optional = true } diff --git a/components/clarity-repl/Cargo.toml b/components/clarity-repl/Cargo.toml index 52688da1a..854371648 100644 --- a/components/clarity-repl/Cargo.toml +++ b/components/clarity-repl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clarity-repl" -version = "1.8.0" +version = "2.0.0" description = "Clarity REPL" authors = [ "Ludo Galabru ", diff --git a/components/stacks-devnet-js/Cargo.toml b/components/stacks-devnet-js/Cargo.toml index 78b91d786..eadce3e50 100644 --- a/components/stacks-devnet-js/Cargo.toml +++ b/components/stacks-devnet-js/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stacks-devnet-js" -version = "1.8.0" +version = "2.0.0" license = "ISC" edition = "2018" exclude = ["index.node"] diff --git a/components/stacks-devnet-js/package.json b/components/stacks-devnet-js/package.json index 19f7e2a43..c4d431620 100644 --- a/components/stacks-devnet-js/package.json +++ b/components/stacks-devnet-js/package.json @@ -1,6 +1,6 @@ { "name": "@hirosystems/stacks-devnet-js", - "version": "1.8.0", + "version": "2.0.0", "description": "stacks-devnet-js is a library for writing end to end tests for protocols interacting with the Stacks blockchain and the Bitcoin blockchain.", "author": "Ludo Galabru", "repository": "https://github.com/hirosystems/clarinet/tree/main/components/stacks-devnet-js", diff --git a/components/stacks-network/Cargo.toml b/components/stacks-network/Cargo.toml index 15df3f9f3..eb11c405e 100644 --- a/components/stacks-network/Cargo.toml +++ b/components/stacks-network/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stacks-network" -version = "1.8.0" +version = "2.0.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/components/stacks-rpc-client/Cargo.toml b/components/stacks-rpc-client/Cargo.toml index 44846b8d3..920e784e8 100644 --- a/components/stacks-rpc-client/Cargo.toml +++ b/components/stacks-rpc-client/Cargo.toml @@ -9,7 +9,6 @@ edition = "2021" serde = "1" serde_json = "1" serde_derive = "1" -clarity_repl = { version = "1", package = "clarity-repl", path = "../clarity-repl", default-features = false, features = ["sdk"] } reqwest = { version = "0.11", default-features = false, features = [ "blocking", "json", @@ -20,3 +19,7 @@ pbkdf2 = { version = "0.11.0", features = ["simple"], default-features = false } sha2 = "0.10.0" tiny-hderive = { version = "0.3.0" } libsecp256k1 = { version = "0.7.0" } + +clarity_repl = { version = "2", package = "clarity-repl", path = "../clarity-repl", default-features = false, features = [ + "sdk", +] }