Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Mutants next/test stackslib with 5 shards 2/source #38

Open
wants to merge 17 commits into
base: mutants-next/test-stackslib-with-5-shards-2/base
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: mockamoto config must pass config assertions
kantai committed Dec 13, 2023
commit 52a5cd353cbe191f0c002a6a4e3c7da0b35dce6a
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@ use async_h1::client;
use async_std::io::ReadExt;
use async_std::net::TcpStream;
use base64::encode;
#[cfg(test)]
use clarity::vm::types::PrincipalData;
use http_types::{Method, Request, Url};
use serde::Serialize;
use serde_json::json;
@@ -52,8 +50,6 @@ use stacks_common::deps_common::bitcoin::network::serialize::deserialize as btc_
use stacks_common::deps_common::bitcoin::network::serialize::RawEncoder;
use stacks_common::deps_common::bitcoin::util::hash::Sha256dHash;
use stacks_common::types::chainstate::BurnchainHeaderHash;
#[cfg(test)]
use stacks_common::types::chainstate::StacksAddress;
use stacks_common::util::hash::{hex_bytes, Hash160};
use stacks_common::util::secp256k1::Secp256k1PublicKey;
use stacks_common::util::sleep_ms;
2 changes: 1 addition & 1 deletion testnet/stacks-node/src/config.rs
Original file line number Diff line number Diff line change
@@ -316,7 +316,7 @@ impl ConfigFile {
password: Some("blockstacksystem".into()),
magic_bytes: Some("M3".into()),
epochs: Some(epochs),
pox_prepare_length: Some(2),
pox_prepare_length: Some(3),
pox_reward_length: Some(36),
..BurnchainConfigFile::default()
};
21 changes: 17 additions & 4 deletions testnet/stacks-node/src/mockamoto/tests.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ use stacks::chainstate::nakamoto::NakamotoChainState;
use stacks::chainstate::stacks::db::StacksChainState;
use stacks_common::types::chainstate::{StacksAddress, StacksPrivateKey};
use stacks_common::types::StacksEpochId;
use stacks_common::util::get_epoch_time_secs;
use stacks_common::util::hash::to_hex;

use super::MockamotoNode;
@@ -18,15 +19,21 @@ use crate::{Config, ConfigFile};
#[test]
fn observe_100_blocks() {
let mut conf = Config::from_config_file(ConfigFile::mockamoto()).unwrap();
conf.node.working_dir = format!(
"/tmp/stacks-node-tests/mock_observe_100_blocks-{}",
get_epoch_time_secs()
);
conf.node.rpc_bind = "127.0.0.1:19343".into();
conf.node.p2p_bind = "127.0.0.1:19344".into();
conf.node.mockamoto_time_ms = 10;

let submitter_sk = StacksPrivateKey::from_seed(&[1]);
let submitter_addr = to_addr(&submitter_sk);
conf.add_initial_balance(submitter_addr.to_string(), 1_000_000);
let recipient_addr = StacksAddress::burn_address(false).into();

test_observer::spawn();
let observer_port = test_observer::EVENT_OBSERVER_PORT;
let observer_port = 19300;
test_observer::spawn_at(observer_port);
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{observer_port}"),
events_keys: vec![EventKeyType::AnyEvent],
@@ -129,15 +136,21 @@ fn observe_100_blocks() {
#[test]
fn mempool_rpc_submit() {
let mut conf = Config::from_config_file(ConfigFile::mockamoto()).unwrap();
conf.node.working_dir = format!(
"/tmp/stacks-node-tests/mempool_rpc_submit-{}",
get_epoch_time_secs()
);
conf.node.rpc_bind = "127.0.0.1:19743".into();
conf.node.p2p_bind = "127.0.0.1:19744".into();
conf.node.mockamoto_time_ms = 10;

let submitter_sk = StacksPrivateKey::from_seed(&[1]);
let submitter_addr = to_addr(&submitter_sk);
conf.add_initial_balance(submitter_addr.to_string(), 1_000);
let recipient_addr = StacksAddress::burn_address(false).into();

test_observer::spawn();
let observer_port = test_observer::EVENT_OBSERVER_PORT;
let observer_port = 19800;
test_observer::spawn_at(observer_port);
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{observer_port}"),
events_keys: vec![EventKeyType::AnyEvent],
18 changes: 12 additions & 6 deletions testnet/stacks-node/src/tests/neon_integrations.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use std::{cmp, env, fs, thread};
use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER;
use clarity::vm::ast::ASTRules;
use clarity::vm::costs::ExecutionCost;
use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier, StandardPrincipalData};
use clarity::vm::types::PrincipalData;
use clarity::vm::{ClarityName, ClarityVersion, ContractName, Value, MAX_CALL_STACK_DEPTH};
use rand::Rng;
use rusqlite::types::ToSql;
@@ -24,7 +24,6 @@ use stacks::chainstate::burn::operations::{
};
use stacks::chainstate::burn::ConsensusHash;
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
use stacks::chainstate::stacks::address::PoxAddress;
use stacks::chainstate::stacks::db::StacksChainState;
use stacks::chainstate::stacks::miner::{
signal_mining_blocked, signal_mining_ready, TransactionErrorEvent, TransactionEvent,
@@ -55,7 +54,6 @@ use stacks::net::atlas::{
};
use stacks::util_lib::boot::boot_code_id;
use stacks::util_lib::db::{query_row_columns, query_rows, u64_to_sql};
use stacks_common::address::C32_ADDRESS_VERSION_TESTNET_SINGLESIG;
use stacks_common::codec::StacksMessageCodec;
use stacks_common::types::chainstate::{
BlockHeaderHash, BurnchainHeaderHash, StacksAddress, StacksBlockId,
@@ -403,7 +401,7 @@ pub mod test_observer {
}

/// each path here should correspond to one of the paths listed in `event_dispatcher.rs`
async fn serve() {
async fn serve(port: u16) {
let new_blocks = warp::path!("new_block")
.and(warp::post())
.and(warp::body::json())
@@ -458,15 +456,23 @@ pub mod test_observer {
.or(mined_nakamoto_blocks)
.or(new_stackerdb_chunks),
)
.run(([127, 0, 0, 1], EVENT_OBSERVER_PORT))
.run(([127, 0, 0, 1], port))
.await
}

pub fn spawn() {
clear();
thread::spawn(|| {
let rt = tokio::runtime::Runtime::new().expect("Failed to initialize tokio");
rt.block_on(serve());
rt.block_on(serve(EVENT_OBSERVER_PORT));
});
}

pub fn spawn_at(port: u16) {
clear();
thread::spawn(move || {
let rt = tokio::runtime::Runtime::new().expect("Failed to initialize tokio");
rt.block_on(serve(port));
});
}