Skip to content

Commit

Permalink
ci: setup ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Feb 10, 2025
1 parent 57e830b commit c6a7aa3
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 22 deletions.
Binary file added .DS_Store
Binary file not shown.
36 changes: 36 additions & 0 deletions .github/test-contract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Test get-price contract

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run test:reports

- name: Upload coverage data to codecov
if: ${{ matrix.node-version == '22.x' }}
uses: codecov/codecov-action@v4
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ epoch = 3.1

[repl.remote_data]
enabled = true
api_url = "https://api.hiro.so"
api_url = 'https://api.hiro.so'
initial_height = 522000
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"type": "module",
"private": true,
"scripts": {
"test": "vitest run",
"test": "vitest run -- --costs",
"test:report": "vitest run -- --coverage --costs",
"test:watch": "chokidar \"tests/**/*.ts\" \"contracts/**/*.clar\" -c \"npm run test:report\""
},
"engines": {
"node": ">=22.12.0"
},
"dependencies": {
"@hirosystems/clarinet-sdk": "^2.13.0-beta15",
"@hirosystems/clarinet-sdk": "^2.13.0-beta18",
"@stacks/transactions": "^6.12.0",
"chokidar-cli": "^3.0.0",
"typescript": "^5.3.3",
Expand Down
35 changes: 35 additions & 0 deletions tests/get-price.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,38 @@ describe("example tests", () => {
expect(result).toBeOk(Cl.uint(100738000));
});
});

describe("mint-sbtc demo", () => {
it("can get tx costs", () => {
const blockHeight = 1000;
const hash = simnet.callPublicFn(
"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-deposit",
"get-burn-header",
[Cl.uint(blockHeight)],
address1,
);
// @ts-ignore
const burnHash = hash.result.value.buffer;

const { result, costs: _costs } = simnet.callPublicFn(
"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-deposit",
"complete-deposit-wrapper",
[
Cl.bufferFromHex(
"3ae3dfeedc6eb99fb5e2c5d0c90697a66de969c3f4d974ebe2ef104fcea7f13b",
),
Cl.uint(1),
Cl.uint(100000000), // 1 BTC
Cl.principal(address1),
Cl.buffer(burnHash),
Cl.uint(blockHeight),
Cl.bufferFromHex(
"52500d11cabf1049ebb139a82b439d08bd3a8e867a41fb3f368dfa125e043989",
),
],
"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4",
);

expect(result).toBeOk(Cl.bool(true));
});
});
9 changes: 6 additions & 3 deletions vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ import {
- vitest run -- --coverage --costs # collect coverage and cost reports
*/

const args = getClarinetVitestsArgv();

export default defineConfig({
test: {
environment: "clarinet", // use vitest-environment-clarinet
// use vitest-environment-clarinet
environment: "clarinet",
pool: "forks",
poolOptions: {
// run in a single thread if coverage is enabled
forks: { singleFork: true },
},
setupFiles: [
Expand All @@ -34,8 +38,7 @@ export default defineConfig({
],
environmentOptions: {
clarinet: {
...getClarinetVitestsArgv(),
// add or override options
...args,
},
},
},
Expand Down

0 comments on commit c6a7aa3

Please sign in to comment.