Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,24 @@ strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false

[contracts.all-annotations]
path = "contracts/all-annotations.clar"

[contracts.bad-annotations]
path = "contracts/bad-annotations.clar"

[contracts.bad-flow]
path = "contracts/bad-flow.clar"

[contracts.no-annotations]
path = "contracts/no-annotations.clar"

[contracts.no-flow]
path = "contracts/no-flow.clar"

[contracts.simple-annotations]
path = "contracts/simple-annotations.clar"

[contracts.simple-flow]
path = "contracts/simple-flow.clar"
5 changes: 5 additions & 0 deletions contracts/all-annotations.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(define-public (test-all-annotations-1)
(ok true))

(define-public (test-all-annotations-2)
(ok true))
2 changes: 2 additions & 0 deletions contracts/bad-annotations.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(define-public (test-bad-annotations)
(ok false))
8 changes: 8 additions & 0 deletions contracts/bad-flow.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(define-public (test-bad-flow)
(begin
(try! (my-test-function))
(ok true)))


(define-private (my-test-function)
(ok true))
3 changes: 3 additions & 0 deletions contracts/no-flow.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; A contract without any flow tests
(define-public (not-a-test)
(ok true))
2 changes: 2 additions & 0 deletions contracts/simple-annotations.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(define-public (test-simple-annotations)
(ok true))
11 changes: 11 additions & 0 deletions contracts/simple-flow.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(define-public (test-simple-flow)
(begin
(try! (my-test-function))
(try! (my-test-function2))
(ok true)))

(define-private (my-test-function)
(ok true))

(define-private (my-test-function2)
(ok true))
54 changes: 48 additions & 6 deletions deployments/default.simnet-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,57 @@ genesis:
balance: "100000000000000"
sbtc-balance: "1000000000"
contracts:
- genesis
- lockup
- bns
- cost-voting
- costs
- pox
- costs-2
- pox-2
- costs-3
- pox-3
- pox-4
- lockup
- costs-2
- costs-3
- cost-voting
- bns
- signers
- signers-voting
- costs-4
plan:
batches: []
batches:
- id: 0
transactions:
- emulated-contract-publish:
contract-name: all-annotations
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\all-annotations.clar"
clarity-version: 1
- emulated-contract-publish:
contract-name: bad-annotations
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\bad-annotations.clar"
clarity-version: 1
- emulated-contract-publish:
contract-name: bad-flow
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\bad-flow.clar"
clarity-version: 1
- emulated-contract-publish:
contract-name: no-annotations
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\no-annotations.clar"
clarity-version: 1
- emulated-contract-publish:
contract-name: no-flow
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\no-flow.clar"
clarity-version: 1
- emulated-contract-publish:
contract-name: simple-annotations
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\simple-annotations.clar"
clarity-version: 1
- emulated-contract-publish:
contract-name: simple-flow
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
path: "contracts\\simple-flow.clar"
clarity-version: 1
epoch: "2.05"
60 changes: 60 additions & 0 deletions deployments/default.testnet-plan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
id: 0
name: Testnet deployment
network: testnet
stacks-node: "https://api.testnet.hiro.so"
bitcoin-node: "http://blockstack:blockstacksystem@bitcoind.testnet.stacks.co:18332"
plan:
batches:
- id: 0
transactions:
- contract-publish:
contract-name: all-annotations
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 1110
path: "contracts\\all-annotations.clar"
anchor-block-only: true
clarity-version: 1
- contract-publish:
contract-name: bad-annotations
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 540
path: "contracts\\bad-annotations.clar"
anchor-block-only: true
clarity-version: 1
- contract-publish:
contract-name: bad-flow
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 1510
path: "contracts\\bad-flow.clar"
anchor-block-only: true
clarity-version: 1
- contract-publish:
contract-name: no-annotations
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 520
path: "contracts\\no-annotations.clar"
anchor-block-only: true
clarity-version: 1
- contract-publish:
contract-name: no-flow
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 800
path: "contracts\\no-flow.clar"
anchor-block-only: true
clarity-version: 1
- contract-publish:
contract-name: simple-annotations
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 560
path: "contracts\\simple-annotations.clar"
anchor-block-only: true
clarity-version: 1
- contract-publish:
contract-name: simple-flow
expected-sender: ST1K2XGT5RNGT42N49BH936VDF8NXWNZJY0N432CM
cost: 2370
path: "contracts\\simple-flow.clar"
anchor-block-only: true
clarity-version: 1
epoch: "2.05"
44 changes: 0 additions & 44 deletions example/tests/my-contract_flow_test.clar

This file was deleted.

27 changes: 0 additions & 27 deletions example/tests/my-contract_test.clar

This file was deleted.

2 changes: 1 addition & 1 deletion settings/Mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stacks_node_rpc_address = "https://api.hiro.so"
deployment_fee_rate = 10

[accounts.deployer]
mnemonic = "<YOUR PRIVATE MAINNET MNEMONIC HERE>"
mnemonic = ""
2 changes: 1 addition & 1 deletion settings/Testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stacks_node_rpc_address = "https://api.testnet.hiro.so"
deployment_fee_rate = 10

[accounts.deployer]
mnemonic = "<YOUR PRIVATE TESTNET MNEMONIC HERE>"
mnemonic = ""
3 changes: 3 additions & 0 deletions src/parser/clarity-parser-flow-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export function extractTestAnnotationsAndCalls(
lastFunctionName = functionName;
}
}
if (indexStart < 0) {
return [functionAnnotations, functionBodies];
}
const lastFunctionBody = contractSource.substring(indexStart + headerLength);
contractCalls = extractContractCalls(lastFunctionBody, simnet);
functionBodies[lastFunctionName] = contractCalls;
Expand Down
13 changes: 13 additions & 0 deletions tests/clarity-parser-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,17 @@ describe("verify clarity parser for flow tests", () => {
});
expect(callInfos["test-bad-flow"].length).toEqual(1);
});

it("should return empty results when no test functions exist", () => {
const [annotations, callInfos] = extractTestAnnotationsAndCalls(
fs.readFileSync(
path.join(__dirname, "./contracts/parser-tests/no-flow.clar"),
"utf8"
),
simnet
);

expect(annotations).toEqual({});
expect(callInfos).toEqual({});
});
});
13 changes: 0 additions & 13 deletions tests/contracts/parser-tests/all-annotations.clar

This file was deleted.

5 changes: 0 additions & 5 deletions tests/contracts/parser-tests/bad-annotations.clar

This file was deleted.

12 changes: 0 additions & 12 deletions tests/contracts/parser-tests/bad-flow.clar

This file was deleted.

4 changes: 0 additions & 4 deletions tests/contracts/parser-tests/simple-annotations.clar

This file was deleted.

16 changes: 0 additions & 16 deletions tests/contracts/parser-tests/simple-flow.clar

This file was deleted.