diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_bad_map_type_definition.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_bad_map_type_definition.snap new file mode 100644 index 0000000000..24563ee479 --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_bad_map_type_definition.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "4cca742df63dfae2a6082353ebd9528d316f13ae99fb29442bb8e53cc7342565", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: bad-map-type-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: invalid map definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "20140d78c081fb88aa6389b2a11c24b3f98e14832df47562e52210c5145d91cb", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: bad-map-type-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: invalid map definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "00c123e8a822408dad4879b7e9d4158887a1d2750862ed15d3b34cc4cd7cc70b", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: bad-map-type-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: invalid map definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "6feebdbc00848565df5f577460dcf3937f5518e4eb91d228d73d5ed09d3cb8b6", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: bad-map-type-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: invalid map definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1372, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_constructed_list_too_large.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_constructed_list_too_large.snap new file mode 100644 index 0000000000..db55afb0ff --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_constructed_list_too_large.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "4865d7980ca587867066c6e012ef04e079a89b2e97ef78d3a2248b34c38e3f41", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: constructed-list-large-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: reached limit of elements in a sequence) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7437, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7437, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "69fae186776e92cf6946ed6a4a83c28d0024e0390278df6e68a69e09482d16e7", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: constructed-list-large-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: reached limit of elements in a sequence) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7436, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7436, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "535d3cb64b5043bc386984fce0b0e71ad7c2f703b2f4a91bac5865227642b788", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: constructed-list-large-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: reached limit of elements in a sequence) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7436, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7436, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "7b61f5697e66a568a248c80b83cae3df329c6ef279c3076d441c5d833b71c898", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: constructed-list-large-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: reached limit of elements in a sequence) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7436, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 29, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7436, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_could_not_determine_serialization_type.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_could_not_determine_serialization_type.snap new file mode 100644 index 0000000000..83c2fecb9f --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_could_not_determine_serialization_type.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "b3b9782ccbe1bf3a66f1c34fe50c83c418fd9d6265761b0a82ffe9950dc8e30f", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: serialization-type-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: use of unresolved function \'to-consensus-buff?\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 7374, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 7374, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "32e8a7c15c537c7cbffb74e28705816f8c607bd37d5b2fe9db78f24c697d506f", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: serialization-type-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: could not determine the input type for the serialization function) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 41, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7759, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 41, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7759, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "a9b3550d29aff9a7a271ee1cb981e4bb3e1948d49026511cc8183fbe2aaeb8af", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: serialization-type-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: could not determine the input type for the serialization function) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 41, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7759, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 41, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7759, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "a390adec582f30b5d9b8cb0dec54acb082db7823cd7d55a11992fda3f5f96479", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: serialization-type-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: could not determine the input type for the serialization function) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 41, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7759, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 41, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 7759, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_could_not_determine_type.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_could_not_determine_type.snap new file mode 100644 index 0000000000..b30859a1ae --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_could_not_determine_type.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "a1ba1c6711af9225754f4503aaa15ea11c8b043513b5630c32582be50ebf43a3", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: could-not-determine-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: type of expression cannot be determined) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1136, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1136, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "756733812c29ccf1a323bbe30003922119266675e389190d536ded2c2a35dea6", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: could-not-determine-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: type of expression cannot be determined) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1124, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1124, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "ad3121ac68bbe2571d9714023de241967c72ea8e6819c85634f807ff3eba80a4", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: could-not-determine-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: type of expression cannot be determined) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1124, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1124, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "44823046ccdb67c2ebfc133360d382729ae79a9bca0e108208f86fcfab950cbb", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: could-not-determine-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: type of expression cannot be determined) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1124, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1124, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_define_variable_bad_signature.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_define_variable_bad_signature.snap new file mode 100644 index 0000000000..2061c96003 --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_define_variable_bad_signature.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "3986d2b49c834d730e91c37a0749894acbf15729a49fa0212b9972a2c44bbea2", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: define-variable-bad-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: expecting 3 arguments, got 2) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "c7bdfb39ef7286728ae1e059a341ba8c1d35c19e3ef052df10f616e01a1294d5", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: define-variable-bad-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: expecting 3 arguments, got 2) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "a147afd28647fc80fbea08e3e4e2f66421a443be6497f7db0acbeb8c313360e7", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: define-variable-bad-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: expecting 3 arguments, got 2) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "006d8e80572233b24cead3478544649b58318c4beb72a4f598827f5b92e5c5cc", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: define-variable-bad-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: expecting 3 arguments, got 2) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 936, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_expected_sequence.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_expected_sequence.snap new file mode 100644 index 0000000000..050d7077c8 --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_expected_sequence.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "68e84be6abc605f8b749ffddc651ac1638855423b92fafc696e2838da89dcf88", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: expected-sequence-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: expecting expression of type \'list\', \'buff\', \'string-ascii\' or \'string-utf8\' - found \'int\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "fffbc8001d406da6c9d701e076029c33b44baaaceca50dc6f5d8bb717cad04ea", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: expected-sequence-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: expecting expression of type \'list\', \'buff\', \'string-ascii\' or \'string-utf8\' - found \'int\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "f956aea7606dc0bd69e1cd3ec9be3e528469b8335752f1635d722c707857b2d3", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: expected-sequence-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: expecting expression of type \'list\', \'buff\', \'string-ascii\' or \'string-utf8\' - found \'int\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "3eff9b43bb6fa8209b9ef1fa31f4539c5026ef47296a836e26bcfddb329059e1", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: expected-sequence-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: expecting expression of type \'list\', \'buff\', \'string-ascii\' or \'string-utf8\' - found \'int\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 5, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 713, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_invalid_type_description.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_invalid_type_description.snap new file mode 100644 index 0000000000..8b9de5a3bd --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_invalid_type_description.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "8d956af6b22c472853f432445276d339d3b57589470915f8cc1fad0bd18c925a", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: invalid-type-desc-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: invalid variable definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "50c6da88adec86d434a6cca0862f53e7b6122afa51c4cdc0475e61996f20f6bd", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: invalid-type-desc-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: invalid variable definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "9b7277c6c51eba3c77c38cda1c6ea16384121617cd587609a00b79e08565fbdd", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: invalid-type-desc-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: invalid variable definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "d21e9ecd5b113dcb0023aad628c58fd4f5e02382ea8c023dae664462cbf0addf", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: invalid-type-desc-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: invalid variable definition) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1175, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_name_already_used.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_name_already_used.snap new file mode 100644 index 0000000000..f347796dac --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_name_already_used.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "ef8ca5e533b17f2746804c4ead9de18b1a04cb18dabe4c1c8d309a19628912e4", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: name-already-used-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: defining \'foo\' conflicts with previous value) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "d77984d1398e5f4200b6a21aa2758aa3d8f0b75c1d965349a72066db1608f6cb", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: name-already-used-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: defining \'foo\' conflicts with previous value) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "e43f00aff1cbcbd51997927e276c050713caf919ad177650df2b40205c5019fa", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: name-already-used-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: defining \'foo\' conflicts with previous value) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "1f82cfdc4fbbf5a4f08cb2b39eb2e499e392a167a4f07ca15b0102b1d4ac0a12", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: name-already-used-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: defining \'foo\' conflicts with previous value) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 9, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2187, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_return_types_must_match.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_return_types_must_match.snap new file mode 100644 index 0000000000..3661e1a834 --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_return_types_must_match.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "7f0d4415c43fb0e25c9e4c06d9b3ba65180e232e1988fccb85c978d138b89f72", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: return-types-must-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: detected two execution paths, returning two different expression types (got \'(response UnknownType int)\' and \'(response UnknownType bool)\')) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "2437107153b4aa494ce6dc95a9d1d63dbf2c52e4b2a26633859fe634cb4ab17b", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: return-types-must-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: detected two execution paths, returning two different expression types (got \'(response UnknownType int)\' and \'(response UnknownType bool)\')) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "1d324958dccc3217e0ab81c63a043b7195ec9bc9e7c41dab31adef097e28351f", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: return-types-must-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: detected two execution paths, returning two different expression types (got \'(response UnknownType int)\' and \'(response UnknownType bool)\')) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "39c2be546aa7b90c1a95055f6dca367ff2465422aeb0b10e8c9c2fbcb144ba1d", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: return-types-must-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: detected two execution paths, returning two different expression types (got \'(response UnknownType int)\' and \'(response UnknownType bool)\')) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 42, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 9463, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_supertype_too_large.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_supertype_too_large.snap new file mode 100644 index 0000000000..9824d0e21c --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_supertype_too_large.snap @@ -0,0 +1,22 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Failure(ExpectedFailureOutput( + evaluated_epoch: Epoch33, + error: "Invalid Stacks block 0d9a22b0addac68110e11145d19a57186b7e6b7ea42f2ed8027edc9ef93f5a86: ClarityError(StaticCheck(StaticCheckError { err: SupertypeTooLarge, expressions: Some([SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"append\")), id: 41 }, SymbolicExpression { expr: Atom(ClarityName(\"initial\")), id: 42 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"tuple\")), id: 44 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"a\")), id: 46 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 48 }, SymbolicExpression { expr: Atom(ClarityName(\"small\")), id: 49 }]), id: 47 }]), id: 45 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"b\")), id: 51 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 53 }, SymbolicExpression { expr: Atom(ClarityName(\"big\")), id: 54 }]), id: 52 }]), id: 50 }]), id: 43 }]), id: 40 }]), diagnostic: Diagnostic { level: Error, message: \"supertype of two types is too large\", spans: [Span { start_line: 0, start_column: 0, end_line: 0, end_column: 0 }], suggestion: None } }))", + )), + Failure(ExpectedFailureOutput( + evaluated_epoch: Epoch33, + error: "Invalid Stacks block df41e1ebe0ce7009fb04a926c36f91d2fed2f08df5ce309f42ac948d97051d18: ClarityError(StaticCheck(StaticCheckError { err: SupertypeTooLarge, expressions: Some([SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"append\")), id: 41 }, SymbolicExpression { expr: Atom(ClarityName(\"initial\")), id: 42 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"tuple\")), id: 44 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"a\")), id: 46 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 48 }, SymbolicExpression { expr: Atom(ClarityName(\"small\")), id: 49 }]), id: 47 }]), id: 45 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"b\")), id: 51 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 53 }, SymbolicExpression { expr: Atom(ClarityName(\"big\")), id: 54 }]), id: 52 }]), id: 50 }]), id: 43 }]), id: 40 }]), diagnostic: Diagnostic { level: Error, message: \"supertype of two types is too large\", spans: [Span { start_line: 0, start_column: 0, end_line: 0, end_column: 0 }], suggestion: None } }))", + )), + Failure(ExpectedFailureOutput( + evaluated_epoch: Epoch33, + error: "Invalid Stacks block cd532364f7eab92dad8d01e3f9f414b41deb8d0c6166b164f2ce12f0bbd76436: ClarityError(StaticCheck(StaticCheckError { err: SupertypeTooLarge, expressions: Some([SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"append\")), id: 41 }, SymbolicExpression { expr: Atom(ClarityName(\"initial\")), id: 42 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"tuple\")), id: 44 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"a\")), id: 46 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 48 }, SymbolicExpression { expr: Atom(ClarityName(\"small\")), id: 49 }]), id: 47 }]), id: 45 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"b\")), id: 51 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 53 }, SymbolicExpression { expr: Atom(ClarityName(\"big\")), id: 54 }]), id: 52 }]), id: 50 }]), id: 43 }]), id: 40 }]), diagnostic: Diagnostic { level: Error, message: \"supertype of two types is too large\", spans: [Span { start_line: 0, start_column: 0, end_line: 0, end_column: 0 }], suggestion: None } }))", + )), + Failure(ExpectedFailureOutput( + evaluated_epoch: Epoch33, + error: "Invalid Stacks block fedb5abccb1d54e207251e441644ae6a460eb8f159e90204d76a71758179b20e: ClarityError(StaticCheck(StaticCheckError { err: SupertypeTooLarge, expressions: Some([SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"append\")), id: 41 }, SymbolicExpression { expr: Atom(ClarityName(\"initial\")), id: 42 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"tuple\")), id: 44 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"a\")), id: 46 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 48 }, SymbolicExpression { expr: Atom(ClarityName(\"small\")), id: 49 }]), id: 47 }]), id: 45 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"b\")), id: 51 }, SymbolicExpression { expr: List([SymbolicExpression { expr: Atom(ClarityName(\"var-get\")), id: 53 }, SymbolicExpression { expr: Atom(ClarityName(\"big\")), id: 54 }]), id: 52 }]), id: 50 }]), id: 43 }]), id: 40 }]), diagnostic: Diagnostic { level: Error, message: \"supertype of two types is too large\", spans: [Span { start_line: 0, start_column: 0, end_line: 0, end_column: 0 }], suggestion: None } }))", + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_type_error.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_type_error.snap new file mode 100644 index 0000000000..6456cb107f --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_type_error.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "649dbc0fcb271409512009fd37644542578f70d371499e7e9ba1139a37bea3f4", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: type-error-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: expecting expression of type \'int\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1288, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1288, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "9e0346bac690a5ab54480ba4b21a444ff77e70268a3a6838277cae6d41e58dbc", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: type-error-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: expecting expression of type \'int\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1277, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1277, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "2fd93f350a09578a2a9b13e9e71fa7f477468488139f024ed736c6add75e141b", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: type-error-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: expecting expression of type \'int\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1277, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1277, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "aa2415bf06af8e35464b356fd883fac1de6f723df6010e3fb29dc7df5028d201", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: type-error-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: expecting expression of type \'int\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1277, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1277, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_type_signature_too_deep.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_type_signature_too_deep.snap new file mode 100644 index 0000000000..7e29d6e19c --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_type_signature_too_deep.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "21cdf140aba22fc6bcef7daa80b07ae37626be01cdd3f01b97ae853e01fdbeae", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: signature-too-deep-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: created a type which was deeper than maximum allowed type depth) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "e7db8eca76b5504c7b85c6411dcdd610fcf3c32eb06380bf2cf037e94c887d54", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: signature-too-deep-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: created a type which was deeper than maximum allowed type depth) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "bf06432ec317866df4959ebd47b128cd073bb1239bb84199c8a127d79f79ca97", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: signature-too-deep-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: created a type which was deeper than maximum allowed type depth) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "ee8b2687c1a225f00b4cc5d0d0f1bbea3bec7efca2508469044dce9b1913e420", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: signature-too-deep-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: created a type which was deeper than maximum allowed type depth) [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 77, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 12036, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_undefined_variable.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_undefined_variable.snap new file mode 100644 index 0000000000..3a4878fdbd --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_undefined_variable.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "9a7b61f181ef8592a441f9ecc91bbc12f9a1793cfbec3513e4721f18d67d759c", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: undefined-variable-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: use of unresolved variable \'x\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "f4b0a03b9ae73d9bd1e1ec77670fbcdd90191aaad5b777c134aa496698278c82", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: undefined-variable-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: use of unresolved variable \'x\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "2686a862c339bc8baea4ad14b9ef33ea86ab206d25181f612337e3c5ef52e934", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: undefined-variable-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: use of unresolved variable \'x\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "623998e0fa8cec8ce015897237e9e27614819494755a4cb86254e7db04f78c73", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: undefined-variable-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: use of unresolved variable \'x\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 6, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 517, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_union_type_error.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_union_type_error.snap new file mode 100644 index 0000000000..6cd1e52128 --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_union_type_error.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "080e462a7a4181ec7a8eeecef8d0902641c1d9e71e8c70416c7dd1816231d41f", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: union-type-error-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: expecting expression of type \'int\' or \'uint\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "e864ba8c401b6e6c98eddae56e8358d3fa7eac664522d575b455803a69f0dc71", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: union-type-error-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: expecting expression of type \'int\' or \'uint\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "a5c6e2ca93557a4e7a5654c5516f7adca43040a41cb1adf6e7b3b578cda1f0a7", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: union-type-error-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: expecting expression of type \'int\' or \'uint\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "8fedf9ed13bbc6ea39b40cdff9277bcf17d942aeed400fee09cfb49067ebe23e", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: union-type-error-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: expecting expression of type \'int\' or \'uint\', found \'bool\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 10, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 1532, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_unknown_type_name.snap b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_unknown_type_name.snap new file mode 100644 index 0000000000..1b07f47cf1 --- /dev/null +++ b/stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_unknown_type_name.snap @@ -0,0 +1,126 @@ +--- +source: stackslib/src/chainstate/tests/static_analysis_tests.rs +expression: result +--- +[ + Success(ExpectedBlockOutput( + marf_hash: "8d004a3557c0396f4fc38d9ce6bf700be2d07f6afab03f03ff4e97ab98fe0f01", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: unknown-type-name-Epoch3_3-Clarity1, code_body: [..], clarity_version: Some(Clarity1))", + vm_error: "Some(:0:0: use of unresolved function \'from-consensus-buff?\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 2394, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 0, + write_count: 0, + read_length: 0, + read_count: 0, + runtime: 2394, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "eb4d4eb367b43b2b4bc7d93341c6bca0a24204c2a0a30706a8a18b5dcaf146e3", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: unknown-type-name-Epoch3_3-Clarity2, code_body: [..], clarity_version: Some(Clarity2))", + vm_error: "Some(:0:0: failed to parse type: \'foo\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 11, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2519, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 11, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2519, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "e34776337382364c9cad419d37cd265c7c9c62c36e404641a942ee13f6566562", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: unknown-type-name-Epoch3_3-Clarity3, code_body: [..], clarity_version: Some(Clarity3))", + vm_error: "Some(:0:0: failed to parse type: \'foo\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 11, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2519, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 11, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2519, + ), + )), + Success(ExpectedBlockOutput( + marf_hash: "33484e3c68f4d42586a392be72eaf557996936ebd7cd002151817474bd409aee", + evaluated_epoch: Epoch33, + transactions: [ + ExpectedTransactionOutput( + tx: "SmartContract(name: unknown-type-name-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", + vm_error: "Some(:0:0: failed to parse type: \'foo\') [NON-CONSENSUS BREAKING]", + return_type: Response(ResponseData( + committed: false, + data: Optional(OptionalData( + data: None, + )), + )), + cost: ExecutionCost( + write_length: 11, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2519, + ), + ), + ], + total_block_cost: ExecutionCost( + write_length: 11, + write_count: 1, + read_length: 1, + read_count: 1, + runtime: 2519, + ), + )), +] diff --git a/stackslib/src/chainstate/tests/static_analysis_tests.rs b/stackslib/src/chainstate/tests/static_analysis_tests.rs index c08b09d37e..f12c556d30 100644 --- a/stackslib/src/chainstate/tests/static_analysis_tests.rs +++ b/stackslib/src/chainstate/tests/static_analysis_tests.rs @@ -17,6 +17,7 @@ #[allow(unused_imports)] use clarity::vm::analysis::CheckErrorKind; +use clarity::vm::types::MAX_TYPE_DEPTH; use crate::chainstate::tests::consensus::contract_deploy_consensus_test; use crate::core::BLOCK_LIMIT_MAINNET_21; @@ -140,7 +141,7 @@ fn static_check_error_match_arms_must_match() { } /// CheckErrorKind: [`CheckErrorKind::BadMatchOptionSyntax`] -/// Caused by: option `match` expecting 4 arguments, got 3 +/// Caused by: option `match` expecting 4 arguments, got 3. /// Outcome: block accepted. #[test] fn static_check_error_bad_match_option_syntax() { @@ -204,3 +205,211 @@ fn static_check_error_expected_optional_type() { contract_code: "(default-to 3 5)", ); } + +/// CheckErrorKind: [`CheckErrorKind::NameAlreadyUsed`] +/// Caused by: redefining constant `foo` a second time. +/// Outcome: block accepted. +#[test] +fn static_check_error_name_already_used() { + contract_deploy_consensus_test!( + contract_name: "name-already-used", + contract_code: " + (define-constant foo 10) + (define-constant foo 20)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::ReturnTypesMustMatch`] +/// Caused by: `unwrap!` default returns `err 1` while the function returns `err false`, so response types diverge. +/// Outcome: block accepted. +#[test] +fn static_check_error_return_types_must_match() { + contract_deploy_consensus_test!( + contract_name: "return-types-must", + contract_code: " + (define-map tokens { id: int } { balance: int }) + (define-private (my-get-token-balance) + (let ((balance (unwrap! + (get balance (map-get? tokens (tuple (id 0)))) + (err 1)))) + (err false)))", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::TypeError`] +/// Caused by: initializing `define-data-var cursor int` with the boolean `true`. +/// Outcome: block accepted. +#[test] +fn static_check_error_type_error() { + contract_deploy_consensus_test!( + contract_name: "type-error", + contract_code: "(define-data-var cursor int true)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::DefineVariableBadSignature`] +/// Caused by: `define-data-var` is provided only a name and value, missing the required type. +/// Outcome: block accepted. +#[test] +fn static_check_error_define_variable_bad_signature() { + contract_deploy_consensus_test!( + contract_name: "define-variable-bad", + contract_code: "(define-data-var cursor 0x00)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::InvalidTypeDescription`] +/// Caused by: `define-data-var` uses `0x00` where a valid type description is required. +/// Outcome: block accepted. +#[test] +fn static_check_error_invalid_type_description() { + contract_deploy_consensus_test!( + contract_name: "invalid-type-desc", + contract_code: "(define-data-var cursor 0x00 true)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::TypeSignatureTooDeep`] +/// Caused by: parameter type nests `optional` wrappers deeper than [`MAX_TYPE_DEPTH`]. +/// Outcome: block accepted. +#[test] +fn static_check_error_type_signature_too_deep() { + contract_deploy_consensus_test!( + contract_name: "signature-too-deep", + contract_code: &{ + let depth: usize = MAX_TYPE_DEPTH as usize + 1; + let mut s = String::from("(define-public (f (x "); + for _ in 0..depth { + s.push_str("(optional "); + } + s.push_str("uint"); + for _ in 0..depth { + s.push_str(") "); + } + s.push_str(")) (ok x))"); + s + }, + ); +} + +/// CheckErrorKind: [`CheckErrorKind::SupertypeTooLarge`] +/// Caused by: combining tuples with `buff 600000` and `buff 10` forces a supertype beyond the size limit. +/// Outcome: block rejected. +#[test] +fn static_check_error_supertype_too_large() { + contract_deploy_consensus_test!( + contract_name: "supertype-too-large", + contract_code: " + (define-data-var big (buff 600000) 0x00) + (define-data-var small (buff 10) 0x00) + (define-public (trigger) + (let ((initial (list (tuple (a (var-get big)) (b (var-get small)))))) + (ok (append initial (tuple (a (var-get small)) (b (var-get big)))))))", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::ConstructedListTooLarge`] +/// Caused by: mapping `sha512` over a list capped at 65,535 elements constructs a list past [`MAX_VALUE_SIZE`]. +/// Outcome: block accepted. +#[test] +fn static_check_error_constructed_list_too_large() { + contract_deploy_consensus_test!( + contract_name: "constructed-list-large", + contract_code: " + (define-data-var ints (list 65535 int) (list 0)) + (define-public (trigger) + (let ((mapped (map sha512 (var-get ints)))) + (ok mapped) + ) + )", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::UnknownTypeName`] +/// Caused by: `from-consensus-buff?` references an undefined type named `foo`. +/// Outcome: block accepted. +/// Note: during analysis, this error can only be triggered by `from-consensus-buff?` +/// which is only available in Clarity 2 and later. So Clarity 1 will not trigger +/// this error. +#[test] +fn static_check_error_unknown_type_name() { + contract_deploy_consensus_test!( + contract_name: "unknown-type-name", + contract_code: " + (define-public (trigger) + (ok (from-consensus-buff? foo 0x00)))", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::UnionTypeError`] +/// Caused by: `map` applies subtraction to booleans. +/// Outcome: block accepted. +#[test] +fn static_check_error_union_type_error() { + contract_deploy_consensus_test!( + contract_name: "union-type-error", + contract_code: "(map - (list true false true false))", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::UndefinedVariable`] +/// Caused by: `x`, `y`, and `z` are referenced without being defined. +/// Outcome: block accepted. +#[test] +fn static_check_error_undefined_variable() { + contract_deploy_consensus_test!( + contract_name: "undefined-variable", + contract_code: "(+ x y z)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::BadMapTypeDefinition`] +/// Caused by: Invalid map type definition in a `(define-map ...)` expression. +/// Outcome: block accepted. +#[test] +fn static_check_error_bad_map_type_definition() { + contract_deploy_consensus_test!( + contract_name: "bad-map-type", + contract_code: "(define-map lists { name: int } contents)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::CouldNotDetermineType`] +/// Caused by: `(index-of (list) none)` supplies no concrete element types. +/// Outcome: block accepted. +#[test] +fn static_check_error_could_not_determine_type() { + contract_deploy_consensus_test!( + contract_name: "could-not-determine", + contract_code: "(index-of (list) none)", + ); +} + +/// CheckErrorKind: [`CheckErrorKind::ExpectedSequence`] +/// Caused by: passing integer `3` as the sequence argument to `index-of` instead of a list or string. +/// Outcome: block accepted. +#[test] +fn static_check_error_expected_sequence() { + contract_deploy_consensus_test!( + contract_name: "expected-sequence", + contract_code: r#"(index-of 3 "a")"#, + ); +} + +/// CheckErrorKind: [`CheckErrorKind::CouldNotDetermineSerializationType`] +/// Caused by: `to-consensus-buff?` over a list of trait references lacks a serialization type. +/// Outcome: block accepted. +/// Note: during analysis, this error can only be triggered by `from-consensus-buff?` +/// which is only available in Clarity 2 and later. So Clarity 1 will not trigger +/// this error. +#[test] +fn static_check_error_could_not_determine_serialization_type() { + contract_deploy_consensus_test!( + contract_name: "serialization-type", + contract_code: " + (define-trait trait-a ((ping () (response bool bool)))) + (define-trait trait-b ((pong () (response bool bool)))) + (define-public (trigger (first ) (second )) + (ok (to-consensus-buff? (list first second))))", + ); +}