Skip to content

Commit

Permalink
feat: Integration test with signer reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
netrome committed Mar 25, 2024
1 parent f9e9791 commit ea0766e
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 139 deletions.
115 changes: 2 additions & 113 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ rand_core = "0.6"
rand = "0.8"
rand_chacha = "0.3.1"
tikv-jemallocator = "0.5.4"
# wsts = { version = "8.1", default-features = false }
wsts = { git = "https://github.com/stacks-network/wsts.git", branch = "feat/public-sign-ids" }
wsts = { git = "https://github.com/stacks-network/wsts.git", default-features = false, rev = "af2b907" }

# Use a bit more than default optimization for
# dev builds to speed up test execution
Expand Down
29 changes: 17 additions & 12 deletions stacks-signer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,23 @@ pub fn build_signer_config_tomls(
timeout: Option<Duration>,
network: &Network,
password: &str,
mut port_start: usize,
) -> Vec<String> {
let mut signer_config_tomls = vec![];

let mut port = 30000;
let run_stamp = rand::random::<u16>();
let db_dir = format!(
"/tmp/stacks-node-tests/integrations-signers/{:#X}",
run_stamp,
);
fs::create_dir_all(&db_dir).unwrap();
for (ix, stacks_private_key) in stacks_private_keys.iter().enumerate() {
let endpoint = format!("localhost:{}", port);
port += 1;
for stacks_private_key in stacks_private_keys {
let endpoint = format!("localhost:{}", port_start);
port_start += 1;

let stacks_public_key = StacksPublicKey::from_private(stacks_private_key).to_hex();
let db_dir = std::env::temp_dir().join(format!(
"stacks-node-tests/integrations-signers/signer_{stacks_public_key}"
));
let db_path = db_dir.join("signerdb.sqlite");
let db_path = db_path.display();

fs::create_dir_all(&db_dir).unwrap();

let stacks_private_key = stacks_private_key.to_hex();
let mut signer_config_toml = format!(
r#"
Expand All @@ -359,7 +363,7 @@ node_host = "{node_host}"
endpoint = "{endpoint}"
network = "{network}"
auth_password = "{password}"
db_path = "{db_dir}/{ix}.sqlite"
db_path = "{db_path}"
"#
);

Expand Down Expand Up @@ -394,7 +398,8 @@ mod tests {
let network = Network::Testnet;
let password = "melon";

let config_tomls = build_signer_config_tomls(&[pk], node_host, None, &network, password);
let config_tomls =
build_signer_config_tomls(&[pk], node_host, None, &network, password, 3000);

let config =
RawConfigFile::load_from_str(&config_tomls[0]).expect("Failed to parse config file");
Expand Down
1 change: 1 addition & 0 deletions stacks-signer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ fn handle_generate_files(args: GenerateFilesArgs) {
args.timeout.map(Duration::from_millis),
&args.network,
&args.password,
3000,
);
debug!("Built {:?} signer config tomls.", signer_config_tomls.len());
for (i, file_contents) in signer_config_tomls.iter().enumerate() {
Expand Down
Loading

0 comments on commit ea0766e

Please sign in to comment.