Skip to content

Commit 730fc6d

Browse files
crc: clean contract code string literal, #6627
1 parent 2ac068b commit 730fc6d

11 files changed

+208
-228
lines changed

stackslib/src/chainstate/tests/parse_tests.rs

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ fn test_stack_depth_too_deep() {
4545
fn test_failed_parsing_int_value() {
4646
contract_deploy_consensus_test!(
4747
contract_name: "my-contract",
48-
contract_code: &{"
49-
(define-data-var my-int int 340282366920938463463374607431768211455)
50-
"},
48+
contract_code: "(define-data-var my-int int 340282366920938463463374607431768211455)",
5149
);
5250
}
5351

@@ -58,9 +56,7 @@ fn test_failed_parsing_int_value() {
5856
fn test_failed_parsing_uint_value() {
5957
contract_deploy_consensus_test!(
6058
contract_name: "my-contract",
61-
contract_code: &{"
62-
(define-data-var my-uint uint u999340282366920938463463374607431768211455)
63-
"},
59+
contract_code: "(define-data-var my-uint uint u999340282366920938463463374607431768211455)",
6460
);
6561
}
6662

@@ -71,10 +67,10 @@ fn test_failed_parsing_uint_value() {
7167
fn test_circular_reference() {
7268
contract_deploy_consensus_test!(
7369
contract_name: "my-contract",
74-
contract_code: &{"
70+
contract_code: "
7571
(define-constant my-a my-b)
7672
(define-constant my-b my-a)
77-
"},
73+
",
7874
);
7975
}
8076

@@ -85,12 +81,12 @@ fn test_circular_reference() {
8581
fn test_named_already_used() {
8682
contract_deploy_consensus_test!(
8783
contract_name: "my-contract",
88-
contract_code: &{"
84+
contract_code: "
8985
(define-trait trait-1 (
9086
(get-1 (uint) (response uint uint))))
9187
(define-trait trait-1 (
9288
(get-1 (int) (response uint uint))))
93-
"},
89+
",
9490
);
9591
}
9692

@@ -101,11 +97,11 @@ fn test_named_already_used() {
10197
fn test_trait_ref_not_allowed() {
10298
contract_deploy_consensus_test!(
10399
contract_name: "my-contract",
104-
contract_code: &{"
100+
contract_code: "
105101
(define-trait trait-1 (
106102
(get-1 (uint) (response uint uint))))
107103
(define-map kv-store { key: uint } { value: <trait-1> })
108-
"},
104+
",
109105
);
110106
}
111107

@@ -116,9 +112,7 @@ fn test_trait_ref_not_allowed() {
116112
fn test_import_trait_bad_signature() {
117113
contract_deploy_consensus_test!(
118114
contract_name: "my-contract",
119-
contract_code: &{"
120-
(use-trait)
121-
"},
115+
contract_code: "(use-trait)",
122116
);
123117
}
124118

@@ -129,9 +123,7 @@ fn test_import_trait_bad_signature() {
129123
fn test_define_trait_bad_signature() {
130124
contract_deploy_consensus_test!(
131125
contract_name: "my-contract",
132-
contract_code: &{"
133-
(define-trait)
134-
"},
126+
contract_code: "(define-trait)",
135127
);
136128
}
137129

@@ -142,9 +134,7 @@ fn test_define_trait_bad_signature() {
142134
fn test_impl_trait_bad_signature() {
143135
contract_deploy_consensus_test!(
144136
contract_name: "my-contract",
145-
contract_code: &{"
146-
(impl-trait)
147-
"},
137+
contract_code: "(impl-trait)",
148138
);
149139
}
150140

@@ -155,9 +145,7 @@ fn test_impl_trait_bad_signature() {
155145
fn test_trait_reference_unknown() {
156146
contract_deploy_consensus_test!(
157147
contract_name: "my-contract",
158-
contract_code: &{"
159-
(+ 1 <my-trait>)
160-
"},
148+
contract_code: "(+ 1 <my-trait>)",
161149
);
162150
}
163151

@@ -168,9 +156,7 @@ fn test_trait_reference_unknown() {
168156
fn test_lexer_unknown_symbol() {
169157
contract_deploy_consensus_test!(
170158
contract_name: "my-contract",
171-
contract_code: &{"
172-
(define-data-var my-uint uint _)
173-
"},
159+
contract_code: "(define-data-var my-uint uint _)",
174160
);
175161
}
176162

@@ -184,9 +170,7 @@ fn test_lexer_unknown_symbol() {
184170
fn test_contract_name_too_long() {
185171
contract_deploy_consensus_test!(
186172
contract_name: &{"n".repeat(MAX_CONTRACT_NAME_LEN + 1)},
187-
contract_code: &{"
188-
()
189-
"},
173+
contract_code: "()",
190174
);
191175
}
192176

@@ -197,9 +181,7 @@ fn test_contract_name_too_long() {
197181
fn test_expected_closing() {
198182
contract_deploy_consensus_test!(
199183
contract_name: "my-contract",
200-
contract_code: &{"
201-
(
202-
"},
184+
contract_code: "(",
203185
);
204186
}
205187

@@ -210,8 +192,6 @@ fn test_expected_closing() {
210192
fn test_note_to_match_this() {
211193
contract_deploy_consensus_test!(
212194
contract_name: "my-contract",
213-
contract_code: &{"
214-
())
215-
"},
195+
contract_code: "())",
216196
);
217197
}

stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__parse_tests__circular_reference.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ expression: result
6969
transactions: [
7070
ExpectedTransactionOutput(
7171
tx: "SmartContract(name: my-contract-Epoch3_2-Clarity3, code_body: [..], clarity_version: Some(Clarity3))",
72-
vm_error: "Some(detected interdependent functions (my-b, my-a)) [NON-CONSENSUS BREAKING]",
72+
vm_error: "Some(detected interdependent functions (my-a, my-b)) [NON-CONSENSUS BREAKING]",
7373
return_type: Response(ResponseData(
7474
committed: false,
7575
data: Optional(OptionalData(
@@ -159,7 +159,7 @@ expression: result
159159
transactions: [
160160
ExpectedTransactionOutput(
161161
tx: "SmartContract(name: my-contract-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))",
162-
vm_error: "Some(detected interdependent functions (my-b, my-a)) [NON-CONSENSUS BREAKING]",
162+
vm_error: "Some(detected interdependent functions (my-a, my-b)) [NON-CONSENSUS BREAKING]",
163163
return_type: Response(ResponseData(
164164
committed: false,
165165
data: Optional(OptionalData(
@@ -189,7 +189,7 @@ expression: result
189189
transactions: [
190190
ExpectedTransactionOutput(
191191
tx: "SmartContract(name: my-contract-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))",
192-
vm_error: "Some(detected interdependent functions (my-b, my-a)) [NON-CONSENSUS BREAKING]",
192+
vm_error: "Some(detected interdependent functions (my-a, my-b)) [NON-CONSENSUS BREAKING]",
193193
return_type: Response(ResponseData(
194194
committed: false,
195195
data: Optional(OptionalData(

stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__parse_tests__define_trait_bad_signature.snap

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ expression: result
44
---
55
[
66
Success(ExpectedBlockOutput(
7-
marf_hash: "34b362f8dadde6564274df15d3dfbeece020b820eaaf9eb7c7e6a1208f049522",
7+
marf_hash: "a3d1a1085f34e65565204169b55ed662e51e038162b8eb72b2e71bde4ef1760b",
88
evaluated_epoch: Epoch32,
99
transactions: [
1010
ExpectedTransactionOutput(
@@ -21,7 +21,7 @@ expression: result
2121
write_count: 0,
2222
read_length: 0,
2323
read_count: 0,
24-
runtime: 1125,
24+
runtime: 531,
2525
),
2626
),
2727
],
@@ -30,11 +30,11 @@ expression: result
3030
write_count: 0,
3131
read_length: 0,
3232
read_count: 0,
33-
runtime: 1125,
33+
runtime: 531,
3434
),
3535
)),
3636
Success(ExpectedBlockOutput(
37-
marf_hash: "a303708fb184f6dab99fc9129a7351d40707acad1723acb5bed17bff518261a3",
37+
marf_hash: "ab910b5c1e09eff4f3169dd918d6c1ea199345876254b15b480a0d1a2f2f85c3",
3838
evaluated_epoch: Epoch32,
3939
transactions: [
4040
ExpectedTransactionOutput(
@@ -51,7 +51,7 @@ expression: result
5151
write_count: 0,
5252
read_length: 0,
5353
read_count: 0,
54-
runtime: 1125,
54+
runtime: 531,
5555
),
5656
),
5757
],
@@ -60,11 +60,11 @@ expression: result
6060
write_count: 0,
6161
read_length: 0,
6262
read_count: 0,
63-
runtime: 1125,
63+
runtime: 531,
6464
),
6565
)),
6666
Success(ExpectedBlockOutput(
67-
marf_hash: "ef42fe0e865b95557a47138dac274236f62fd85f57caf45ecdcb72f3db6cec02",
67+
marf_hash: "6978f819c2b1e4470844fd03b83d2714fbe379bf8405fd8eaf772cd2bae2ac81",
6868
evaluated_epoch: Epoch32,
6969
transactions: [
7070
ExpectedTransactionOutput(
@@ -81,7 +81,7 @@ expression: result
8181
write_count: 0,
8282
read_length: 0,
8383
read_count: 0,
84-
runtime: 1125,
84+
runtime: 531,
8585
),
8686
),
8787
],
@@ -90,11 +90,11 @@ expression: result
9090
write_count: 0,
9191
read_length: 0,
9292
read_count: 0,
93-
runtime: 1125,
93+
runtime: 531,
9494
),
9595
)),
9696
Success(ExpectedBlockOutput(
97-
marf_hash: "b346221ab3b38fc46fbe723eaff80f0e0969e44db5f99fa01012cadb8acbeebb",
97+
marf_hash: "a0fb3f6fb695248dc400bc27e95c77c79240187c95326be8eda5ad23399ebc6f",
9898
evaluated_epoch: Epoch33,
9999
transactions: [
100100
ExpectedTransactionOutput(
@@ -111,7 +111,7 @@ expression: result
111111
write_count: 0,
112112
read_length: 0,
113113
read_count: 0,
114-
runtime: 1125,
114+
runtime: 531,
115115
),
116116
),
117117
],
@@ -120,11 +120,11 @@ expression: result
120120
write_count: 0,
121121
read_length: 0,
122122
read_count: 0,
123-
runtime: 1125,
123+
runtime: 531,
124124
),
125125
)),
126126
Success(ExpectedBlockOutput(
127-
marf_hash: "fd4c883b4c7c7716875faf16438bf52bcf6e520e58cda8dbaf1a56cc97e8f668",
127+
marf_hash: "1b5de6233dff8436d126fbbb2fb8a00ba0f2e64cb6e00a90bbe4c912a570b5ae",
128128
evaluated_epoch: Epoch33,
129129
transactions: [
130130
ExpectedTransactionOutput(
@@ -141,7 +141,7 @@ expression: result
141141
write_count: 0,
142142
read_length: 0,
143143
read_count: 0,
144-
runtime: 1125,
144+
runtime: 531,
145145
),
146146
),
147147
],
@@ -150,11 +150,11 @@ expression: result
150150
write_count: 0,
151151
read_length: 0,
152152
read_count: 0,
153-
runtime: 1125,
153+
runtime: 531,
154154
),
155155
)),
156156
Success(ExpectedBlockOutput(
157-
marf_hash: "0260023a1bc690bb7a1e025636132f84f8d757222ece925c1ef207aa67c4d028",
157+
marf_hash: "9a6aa80b153a24b20f16f58fe936781d0d8b060576a3a8af64a9f5844a404558",
158158
evaluated_epoch: Epoch33,
159159
transactions: [
160160
ExpectedTransactionOutput(
@@ -171,7 +171,7 @@ expression: result
171171
write_count: 0,
172172
read_length: 0,
173173
read_count: 0,
174-
runtime: 1125,
174+
runtime: 531,
175175
),
176176
),
177177
],
@@ -180,11 +180,11 @@ expression: result
180180
write_count: 0,
181181
read_length: 0,
182182
read_count: 0,
183-
runtime: 1125,
183+
runtime: 531,
184184
),
185185
)),
186186
Success(ExpectedBlockOutput(
187-
marf_hash: "6848b0dd731cf49041f83c01654d16b5adfb8987bf5e49d670e368449d1cdf1c",
187+
marf_hash: "5b3e7bd76dd17a978fec8b073e1895a3317869f8e0aa2fd5526ab62c8e1316a3",
188188
evaluated_epoch: Epoch33,
189189
transactions: [
190190
ExpectedTransactionOutput(
@@ -201,7 +201,7 @@ expression: result
201201
write_count: 0,
202202
read_length: 0,
203203
read_count: 0,
204-
runtime: 1125,
204+
runtime: 531,
205205
),
206206
),
207207
],
@@ -210,7 +210,7 @@ expression: result
210210
write_count: 0,
211211
read_length: 0,
212212
read_count: 0,
213-
runtime: 1125,
213+
runtime: 531,
214214
),
215215
)),
216216
]

0 commit comments

Comments
 (0)