Skip to content

Commit 9c94664

Browse files
Merge pull request #6686 from Jiloc/chore/static-analysis-error-tests-1
test: first set of consensus tests for `CheckErrorKind` during contract analysis
2 parents 2662a10 + 66772cf commit 9c94664

File tree

17 files changed

+1981
-0
lines changed

17 files changed

+1981
-0
lines changed

stackslib/src/chainstate/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
pub mod consensus;
1616
mod parse_tests;
17+
mod static_analysis_tests;
1718

1819
use std::fs;
1920

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
source: stackslib/src/chainstate/tests/static_analysis_tests.rs
3+
expression: result
4+
---
5+
[
6+
Success(ExpectedBlockOutput(
7+
marf_hash: "0263830e8d5e8a47c31382256d9608d41fb6d53b95ef85e3da06d70dc2cf5095",
8+
evaluated_epoch: Epoch33,
9+
transactions: [
10+
ExpectedTransactionOutput(
11+
tx: "SmartContract(name: bad-match-input-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))",
12+
vm_error: "Some(:0:0: match requires an input of either a response or optional, found input: \'int\') [NON-CONSENSUS BREAKING]",
13+
return_type: Response(ResponseData(
14+
committed: false,
15+
data: Optional(OptionalData(
16+
data: None,
17+
)),
18+
)),
19+
cost: ExecutionCost(
20+
write_length: 14,
21+
write_count: 1,
22+
read_length: 1,
23+
read_count: 1,
24+
runtime: 1662,
25+
),
26+
),
27+
],
28+
total_block_cost: ExecutionCost(
29+
write_length: 14,
30+
write_count: 1,
31+
read_length: 1,
32+
read_count: 1,
33+
runtime: 1662,
34+
),
35+
)),
36+
Success(ExpectedBlockOutput(
37+
marf_hash: "4b39ac7225cca66a1fb2df3e471a3178d9fa54063fa3957bb40b84199f4af98d",
38+
evaluated_epoch: Epoch33,
39+
transactions: [
40+
ExpectedTransactionOutput(
41+
tx: "SmartContract(name: bad-match-input-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))",
42+
vm_error: "Some(:0:0: match requires an input of either a response or optional, found input: \'int\') [NON-CONSENSUS BREAKING]",
43+
return_type: Response(ResponseData(
44+
committed: false,
45+
data: Optional(OptionalData(
46+
data: None,
47+
)),
48+
)),
49+
cost: ExecutionCost(
50+
write_length: 14,
51+
write_count: 1,
52+
read_length: 1,
53+
read_count: 1,
54+
runtime: 1662,
55+
),
56+
),
57+
],
58+
total_block_cost: ExecutionCost(
59+
write_length: 14,
60+
write_count: 1,
61+
read_length: 1,
62+
read_count: 1,
63+
runtime: 1662,
64+
),
65+
)),
66+
Success(ExpectedBlockOutput(
67+
marf_hash: "b936b54305cae864335b0b489fa4d6afb0001e7fed2f82df339bd1beca72af2a",
68+
evaluated_epoch: Epoch33,
69+
transactions: [
70+
ExpectedTransactionOutput(
71+
tx: "SmartContract(name: bad-match-input-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))",
72+
vm_error: "Some(:0:0: match requires an input of either a response or optional, found input: \'int\') [NON-CONSENSUS BREAKING]",
73+
return_type: Response(ResponseData(
74+
committed: false,
75+
data: Optional(OptionalData(
76+
data: None,
77+
)),
78+
)),
79+
cost: ExecutionCost(
80+
write_length: 14,
81+
write_count: 1,
82+
read_length: 1,
83+
read_count: 1,
84+
runtime: 1662,
85+
),
86+
),
87+
],
88+
total_block_cost: ExecutionCost(
89+
write_length: 14,
90+
write_count: 1,
91+
read_length: 1,
92+
read_count: 1,
93+
runtime: 1662,
94+
),
95+
)),
96+
Success(ExpectedBlockOutput(
97+
marf_hash: "016e673aebdbb7cc7370029c118a8f5216574b7d2d8b4310f172be7666811262",
98+
evaluated_epoch: Epoch33,
99+
transactions: [
100+
ExpectedTransactionOutput(
101+
tx: "SmartContract(name: bad-match-input-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))",
102+
vm_error: "Some(:0:0: match requires an input of either a response or optional, found input: \'int\') [NON-CONSENSUS BREAKING]",
103+
return_type: Response(ResponseData(
104+
committed: false,
105+
data: Optional(OptionalData(
106+
data: None,
107+
)),
108+
)),
109+
cost: ExecutionCost(
110+
write_length: 14,
111+
write_count: 1,
112+
read_length: 1,
113+
read_count: 1,
114+
runtime: 1662,
115+
),
116+
),
117+
],
118+
total_block_cost: ExecutionCost(
119+
write_length: 14,
120+
write_count: 1,
121+
read_length: 1,
122+
read_count: 1,
123+
runtime: 1662,
124+
),
125+
)),
126+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
source: stackslib/src/chainstate/tests/static_analysis_tests.rs
3+
expression: result
4+
---
5+
[
6+
Success(ExpectedBlockOutput(
7+
marf_hash: "97bdd398cc2e587a4a544054de83f26b716c28ba576ce0b73baf59227bf34f95",
8+
evaluated_epoch: Epoch33,
9+
transactions: [
10+
ExpectedTransactionOutput(
11+
tx: "SmartContract(name: bad-match-option-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))",
12+
vm_error: "Some(:0:0: match on a optional type uses the following syntax: (match input some-name if-some-expression if-none-expression). Caused by: expecting 4 arguments, got 3) [NON-CONSENSUS BREAKING]",
13+
return_type: Response(ResponseData(
14+
committed: false,
15+
data: Optional(OptionalData(
16+
data: None,
17+
)),
18+
)),
19+
cost: ExecutionCost(
20+
write_length: 11,
21+
write_count: 1,
22+
read_length: 1,
23+
read_count: 1,
24+
runtime: 1538,
25+
),
26+
),
27+
],
28+
total_block_cost: ExecutionCost(
29+
write_length: 11,
30+
write_count: 1,
31+
read_length: 1,
32+
read_count: 1,
33+
runtime: 1538,
34+
),
35+
)),
36+
Success(ExpectedBlockOutput(
37+
marf_hash: "c534c204ed354f05c2959377e96d25477fdfff0dc8133c8fc2425af464f46f5c",
38+
evaluated_epoch: Epoch33,
39+
transactions: [
40+
ExpectedTransactionOutput(
41+
tx: "SmartContract(name: bad-match-option-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))",
42+
vm_error: "Some(:0:0: match on a optional type uses the following syntax: (match input some-name if-some-expression if-none-expression). Caused by: expecting 4 arguments, got 3) [NON-CONSENSUS BREAKING]",
43+
return_type: Response(ResponseData(
44+
committed: false,
45+
data: Optional(OptionalData(
46+
data: None,
47+
)),
48+
)),
49+
cost: ExecutionCost(
50+
write_length: 11,
51+
write_count: 1,
52+
read_length: 1,
53+
read_count: 1,
54+
runtime: 1538,
55+
),
56+
),
57+
],
58+
total_block_cost: ExecutionCost(
59+
write_length: 11,
60+
write_count: 1,
61+
read_length: 1,
62+
read_count: 1,
63+
runtime: 1538,
64+
),
65+
)),
66+
Success(ExpectedBlockOutput(
67+
marf_hash: "769e0f2174f193dcae9cdbb5e80e0d8c8162a618f95a8be0ce98430ddf55e935",
68+
evaluated_epoch: Epoch33,
69+
transactions: [
70+
ExpectedTransactionOutput(
71+
tx: "SmartContract(name: bad-match-option-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))",
72+
vm_error: "Some(:0:0: match on a optional type uses the following syntax: (match input some-name if-some-expression if-none-expression). Caused by: expecting 4 arguments, got 3) [NON-CONSENSUS BREAKING]",
73+
return_type: Response(ResponseData(
74+
committed: false,
75+
data: Optional(OptionalData(
76+
data: None,
77+
)),
78+
)),
79+
cost: ExecutionCost(
80+
write_length: 11,
81+
write_count: 1,
82+
read_length: 1,
83+
read_count: 1,
84+
runtime: 1538,
85+
),
86+
),
87+
],
88+
total_block_cost: ExecutionCost(
89+
write_length: 11,
90+
write_count: 1,
91+
read_length: 1,
92+
read_count: 1,
93+
runtime: 1538,
94+
),
95+
)),
96+
Success(ExpectedBlockOutput(
97+
marf_hash: "8650a9ad98ee134b8ccdbabab4742e07f7a0fb64e7bfadb8eddbbcb597367b4e",
98+
evaluated_epoch: Epoch33,
99+
transactions: [
100+
ExpectedTransactionOutput(
101+
tx: "SmartContract(name: bad-match-option-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))",
102+
vm_error: "Some(:0:0: match on a optional type uses the following syntax: (match input some-name if-some-expression if-none-expression). Caused by: expecting 4 arguments, got 3) [NON-CONSENSUS BREAKING]",
103+
return_type: Response(ResponseData(
104+
committed: false,
105+
data: Optional(OptionalData(
106+
data: None,
107+
)),
108+
)),
109+
cost: ExecutionCost(
110+
write_length: 11,
111+
write_count: 1,
112+
read_length: 1,
113+
read_count: 1,
114+
runtime: 1538,
115+
),
116+
),
117+
],
118+
total_block_cost: ExecutionCost(
119+
write_length: 11,
120+
write_count: 1,
121+
read_length: 1,
122+
read_count: 1,
123+
runtime: 1538,
124+
),
125+
)),
126+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
source: stackslib/src/chainstate/tests/static_analysis_tests.rs
3+
expression: result
4+
---
5+
[
6+
Success(ExpectedBlockOutput(
7+
marf_hash: "5a73aac7831befd63163ac6f9a6ad5a0be69013687380f767e21afd1f0cac873",
8+
evaluated_epoch: Epoch33,
9+
transactions: [
10+
ExpectedTransactionOutput(
11+
tx: "SmartContract(name: bad-match-response-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))",
12+
vm_error: "Some(:0:0: match on a result type uses the following syntax: (match input ok-name if-ok-expression err-name if-err-expression). Caused by: expecting 5 arguments, got 3) [NON-CONSENSUS BREAKING]",
13+
return_type: Response(ResponseData(
14+
committed: false,
15+
data: Optional(OptionalData(
16+
data: None,
17+
)),
18+
)),
19+
cost: ExecutionCost(
20+
write_length: 11,
21+
write_count: 1,
22+
read_length: 1,
23+
read_count: 1,
24+
runtime: 1485,
25+
),
26+
),
27+
],
28+
total_block_cost: ExecutionCost(
29+
write_length: 11,
30+
write_count: 1,
31+
read_length: 1,
32+
read_count: 1,
33+
runtime: 1485,
34+
),
35+
)),
36+
Success(ExpectedBlockOutput(
37+
marf_hash: "aaa3ebe5b7074a85bd68dc9bc9bb7d64bfeb8ea43916c35caecfa6804969c169",
38+
evaluated_epoch: Epoch33,
39+
transactions: [
40+
ExpectedTransactionOutput(
41+
tx: "SmartContract(name: bad-match-response-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))",
42+
vm_error: "Some(:0:0: match on a result type uses the following syntax: (match input ok-name if-ok-expression err-name if-err-expression). Caused by: expecting 5 arguments, got 3) [NON-CONSENSUS BREAKING]",
43+
return_type: Response(ResponseData(
44+
committed: false,
45+
data: Optional(OptionalData(
46+
data: None,
47+
)),
48+
)),
49+
cost: ExecutionCost(
50+
write_length: 11,
51+
write_count: 1,
52+
read_length: 1,
53+
read_count: 1,
54+
runtime: 1485,
55+
),
56+
),
57+
],
58+
total_block_cost: ExecutionCost(
59+
write_length: 11,
60+
write_count: 1,
61+
read_length: 1,
62+
read_count: 1,
63+
runtime: 1485,
64+
),
65+
)),
66+
Success(ExpectedBlockOutput(
67+
marf_hash: "37e6347d1073a867b149d6dbb2093f29796d87d0a170762a261ca829248c6c4a",
68+
evaluated_epoch: Epoch33,
69+
transactions: [
70+
ExpectedTransactionOutput(
71+
tx: "SmartContract(name: bad-match-response-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))",
72+
vm_error: "Some(:0:0: match on a result type uses the following syntax: (match input ok-name if-ok-expression err-name if-err-expression). Caused by: expecting 5 arguments, got 3) [NON-CONSENSUS BREAKING]",
73+
return_type: Response(ResponseData(
74+
committed: false,
75+
data: Optional(OptionalData(
76+
data: None,
77+
)),
78+
)),
79+
cost: ExecutionCost(
80+
write_length: 11,
81+
write_count: 1,
82+
read_length: 1,
83+
read_count: 1,
84+
runtime: 1485,
85+
),
86+
),
87+
],
88+
total_block_cost: ExecutionCost(
89+
write_length: 11,
90+
write_count: 1,
91+
read_length: 1,
92+
read_count: 1,
93+
runtime: 1485,
94+
),
95+
)),
96+
Success(ExpectedBlockOutput(
97+
marf_hash: "42b191d1207c0aa4a43f35887fbd7625df62f017bce9c016e74e5cad481b6971",
98+
evaluated_epoch: Epoch33,
99+
transactions: [
100+
ExpectedTransactionOutput(
101+
tx: "SmartContract(name: bad-match-response-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))",
102+
vm_error: "Some(:0:0: match on a result type uses the following syntax: (match input ok-name if-ok-expression err-name if-err-expression). Caused by: expecting 5 arguments, got 3) [NON-CONSENSUS BREAKING]",
103+
return_type: Response(ResponseData(
104+
committed: false,
105+
data: Optional(OptionalData(
106+
data: None,
107+
)),
108+
)),
109+
cost: ExecutionCost(
110+
write_length: 11,
111+
write_count: 1,
112+
read_length: 1,
113+
read_count: 1,
114+
runtime: 1485,
115+
),
116+
),
117+
],
118+
total_block_cost: ExecutionCost(
119+
write_length: 11,
120+
write_count: 1,
121+
read_length: 1,
122+
read_count: 1,
123+
runtime: 1485,
124+
),
125+
)),
126+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: stackslib/src/chainstate/tests/static_analysis_tests.rs
3+
expression: result
4+
---
5+
[
6+
Failure("Invalid Stacks block a58fcb42e51e055d3c11754df7c62976f69a02e9e4ffd7c83033fa7f670f229b: CostOverflowError(ExecutionCost { write_length: 0, write_count: 0, read_length: 0, read_count: 0, runtime: 0 }, ExecutionCost { write_length: 75013, write_count: 1, read_length: 1020001, read_count: 15001, runtime: 135183501 }, ExecutionCost { write_length: 15000000, write_count: 15000, read_length: 100000000, read_count: 15000, runtime: 5000000000 })"),
7+
Failure("Invalid Stacks block 0b0d94606ac3b7adb14e1ae8dd5efb49504774555b3984eced1ab733da004fac: CostOverflowError(ExecutionCost { write_length: 0, write_count: 0, read_length: 0, read_count: 0, runtime: 0 }, ExecutionCost { write_length: 75013, write_count: 1, read_length: 1020001, read_count: 15001, runtime: 135168502 }, ExecutionCost { write_length: 15000000, write_count: 15000, read_length: 100000000, read_count: 15000, runtime: 5000000000 })"),
8+
Failure("Invalid Stacks block 99c326760a910f67d9695673b15cce43602a161b31362d9e2ef388ab444306e2: CostOverflowError(ExecutionCost { write_length: 0, write_count: 0, read_length: 0, read_count: 0, runtime: 0 }, ExecutionCost { write_length: 75013, write_count: 1, read_length: 1020001, read_count: 15001, runtime: 135168502 }, ExecutionCost { write_length: 15000000, write_count: 15000, read_length: 100000000, read_count: 15000, runtime: 5000000000 })"),
9+
Failure("Invalid Stacks block 92bd5f026210bd6c018ac4761cd4fb3d3968dec0fbda129673338933512b78bc: CostOverflowError(ExecutionCost { write_length: 0, write_count: 0, read_length: 0, read_count: 0, runtime: 0 }, ExecutionCost { write_length: 75013, write_count: 1, read_length: 1020001, read_count: 15001, runtime: 135168502 }, ExecutionCost { write_length: 15000000, write_count: 15000, read_length: 100000000, read_count: 15000, runtime: 5000000000 })"),
10+
]

0 commit comments

Comments
 (0)