Skip to content

Commit 5f1173a

Browse files
committed
test: ensure auto-generated test contract names are not too long
1 parent 863490a commit 5f1173a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

stackslib/src/net/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,7 @@ pub mod test {
16561656
use std::{fs, io, thread};
16571657

16581658
use clarity::boot_util::boot_code_id;
1659+
use clarity::vm::ast::parser::v1::CONTRACT_MAX_NAME_LENGTH;
16591660
use clarity::vm::ast::ASTRules;
16601661
use clarity::vm::costs::ExecutionCost;
16611662
use clarity::vm::database::STXBalance;
@@ -2403,7 +2404,17 @@ pub mod test {
24032404
let smart_contract = TransactionPayload::SmartContract(
24042405
TransactionSmartContract {
24052406
name: ContractName::try_from(
2406-
conf.test_name.replace("::", "-").to_string(),
2407+
conf.test_name
2408+
.replace("::", "-")
2409+
.to_string()
2410+
.chars()
2411+
// ensure auto-generated contract names are not too long
2412+
.skip(
2413+
conf.test_name
2414+
.len()
2415+
.saturating_sub(CONTRACT_MAX_NAME_LENGTH),
2416+
)
2417+
.collect::<String>(),
24072418
)
24082419
.expect("FATAL: invalid boot-code contract name"),
24092420
code_body: StacksString::from_str(&conf.setup_code)

0 commit comments

Comments
 (0)