diff --git a/content/docs/stacks/clarinet-js-sdk/guides/migrate-to-the-clarinet-sdk.mdx b/content/docs/stacks/clarinet-js-sdk/guides/migrate-to-the-clarinet-sdk.mdx deleted file mode 100644 index 73562daac..000000000 --- a/content/docs/stacks/clarinet-js-sdk/guides/migrate-to-the-clarinet-sdk.mdx +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: How to migrate to the SDK -description: Learn how to migrate your existing Clarinet projects to the Clarinet SDK. ---- - -In this guide, you will learn how to: - -1. Migrate your existing Clarinet projects to the Clarinet SDK. -2. Run your existing tests using the Clarinet SDK. - - -This guide is for projects that have been created with Clarinet v1 and do not have the v2 boilerplate code auto-generated in their projects. - - ---- - -## Executing the migration script - -Inside your Clarinet v1 project, run the following command to initialise NPM and Vitest. It will also create a sample test file. - -```terminal -$ npx @hirosystems/clarinet-sdk@latest -``` - -Follow the prompts to initialise NPM and Vitest, this can take a few seconds. - - -The file `tests/counter_test.ts` that was created by `clarinet contract new counter` can be deleted. - -You can also have a look at `tests/contract.test.ts`. It's a sample file showing how to use the SDK with Vitest. -It can safely be deleted. - - -## Unit test for counter example - -```ts tests/counter.test.ts -import { Cl } from '@stacks/transactions'; -import { describe, expect, it } from 'vitest'; - -const accounts = simnet.getAccounts(); -const address1 = accounts.get('wallet_1')!; - -describe('test `increment` public function', () => { - it('increments the count by the given value', () => { - const incrementResponse = simnet.callPublicFn('counter', 'increment', [Cl.uint(1)], address1); - console.log(Cl.prettyPrint(incrementResponse.result)); // (ok u2) - expect(incrementResponse.result).toBeOk(Cl.uint(2)); - - const count1 = simnet.getDataVar('counter', 'count'); - expect(count1).toBeUint(2); - - simnet.callPublicFn('counter', 'increment', [Cl.uint(40)], address1); - const count2 = simnet.getDataVar('counter', 'count'); - expect(count2).toBeUint(42); - }); - - it('sends a print event', () => { - const incrementResponse = simnet.callPublicFn('counter', 'increment', [Cl.uint(1)], address1); - - expect(incrementResponse.events).toHaveLength(1); - const printEvent = incrementResponse.events[0]; - expect(printEvent.event).toBe('print_event'); - expect(printEvent.data.value).toBeTuple({ - object: Cl.stringAscii('count'), - action: Cl.stringAscii('incremented'), - value: Cl.uint(2), - }); - }); -}); -``` - -To run the test, go back to your console and run the `test` command using your preferred package manager. It should display a report telling you that tests succeeded. - -```terminal -$ npm test -``` - - -The `simnet` object is available globally in the tests, and is automatically initialized before each test. You can have a look at the `vitest.config.js` file at the root of you project for more details. - - -Getting back to the tests - the first test checks that the `increment` function returns the new value and saves it to the `count` variable. -The second test checks that an `print_event` is emitted when the `increment` function is called. - ---- - -## Next steps - - - - - - \ No newline at end of file diff --git a/content/docs/stacks/clarinet-js-sdk/index.mdx b/content/docs/stacks/clarinet-js-sdk/index.mdx index 29421b19e..b6dedd216 100644 --- a/content/docs/stacks/clarinet-js-sdk/index.mdx +++ b/content/docs/stacks/clarinet-js-sdk/index.mdx @@ -26,11 +26,6 @@ Here is a non-exhaustive list of some of simnet's use-cases: title="Simulate a blockchain with Clarinet JS SDK" description="Learn how to interact with a simulated network without running a node." /> - Reach out to us on the #clarinet channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. There's also a [weekly office hours](https://www.addevent.com/event/kI22007085) call every Wednesday at 1pm ET. - \ No newline at end of file + diff --git a/content/docs/stacks/clarinet-js-sdk/meta.json b/content/docs/stacks/clarinet-js-sdk/meta.json index fd62e0662..e5d85f985 100644 --- a/content/docs/stacks/clarinet-js-sdk/meta.json +++ b/content/docs/stacks/clarinet-js-sdk/meta.json @@ -9,7 +9,6 @@ "---Guides---", "guides/unit-testing", "guides/integration-testing", - "guides/migrate-to-the-clarinet-sdk", "---Reference---", "references/simnet", "references/properties", diff --git a/content/docs/stacks/clarinet-js-sdk/quickstart.mdx b/content/docs/stacks/clarinet-js-sdk/quickstart.mdx index 6ad67b6cb..b31b04294 100644 --- a/content/docs/stacks/clarinet-js-sdk/quickstart.mdx +++ b/content/docs/stacks/clarinet-js-sdk/quickstart.mdx @@ -219,9 +219,4 @@ Check out the [methods](/stacks/clarinet-js-sdk/references/methods) page for the title="Custom matchers" description="Learn about the custom matchers that are available in the Clarinet JS SDK." /> - - \ No newline at end of file +