Skip to content

Commit

Permalink
refactor: add test_observer::register
Browse files Browse the repository at this point in the history
  • Loading branch information
obycode committed Oct 9, 2024
1 parent 2975fe0 commit 1c3302a
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 454 deletions.
27 changes: 7 additions & 20 deletions testnet/stacks-node/src/tests/epoch_205.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ fn test_exact_block_costs() {
.collect();

test_observer::spawn();
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent, EventKeyType::MinedBlocks],
timeout_ms: 1000,
});
test_observer::register(
&mut conf,
&[EventKeyType::AnyEvent, EventKeyType::MinedBlocks],
);

let mut btcd_controller = BitcoinCoreController::new(conf.clone());
btcd_controller
Expand Down Expand Up @@ -336,11 +335,7 @@ fn test_dynamic_db_method_costs() {
};

test_observer::spawn();
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

let mut btcd_controller = BitcoinCoreController::new(conf.clone());
btcd_controller
Expand Down Expand Up @@ -774,11 +769,7 @@ fn test_cost_limit_switch_version205() {
});

test_observer::spawn();
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

let mut btcd_controller = BitcoinCoreController::new(conf.clone());
btcd_controller
Expand Down Expand Up @@ -1032,11 +1023,7 @@ fn bigger_microblock_streams_in_2_05() {
conf.burnchain.pox_2_activation = Some(10_003);

test_observer::spawn();
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

let mut btcd_controller = BitcoinCoreController::new(conf.clone());
btcd_controller
Expand Down
47 changes: 7 additions & 40 deletions testnet/stacks-node/src/tests/epoch_21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ fn advance_to_2_1(
conf.burnchain.peer_host = "localhost".to_string();
conf.initial_balances.append(&mut initial_balances);
conf.miner.block_reward_recipient = block_reward_recipient;

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
epochs[1].end_height = epoch_2_05;
Expand Down Expand Up @@ -577,11 +572,7 @@ fn transition_fixes_bitcoin_rigidity() {
];

conf.initial_balances.append(&mut initial_balances);
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
epochs[1].end_height = epoch_2_05;
Expand Down Expand Up @@ -1474,12 +1465,7 @@ fn transition_removes_pox_sunset() {
let (mut conf, miner_account) = neon_integration_test_conf();

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

conf.initial_balances.push(InitialBalance {
address: spender_addr.clone(),
Expand Down Expand Up @@ -1790,12 +1776,7 @@ fn transition_empty_blocks() {
conf.burnchain.epochs = Some(epochs);

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);

let keychain = Keychain::default(conf.node.seed.clone());
let http_origin = format!("http://{}", &conf.node.rpc_bind);
Expand Down Expand Up @@ -4741,11 +4722,7 @@ fn trait_invocation_cross_epoch() {
amount: 200_000_000,
}];
conf.initial_balances.append(&mut initial_balances);
conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
epochs[1].end_height = epoch_2_05;
epochs[2].start_height = epoch_2_05;
Expand Down Expand Up @@ -4987,12 +4964,7 @@ fn test_v1_unlock_height_with_current_stackers() {
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down Expand Up @@ -5253,12 +5225,7 @@ fn test_v1_unlock_height_with_delay_and_current_stackers() {
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down
7 changes: 1 addition & 6 deletions testnet/stacks-node/src/tests/epoch_22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@ fn disable_pox() {
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down
7 changes: 1 addition & 6 deletions testnet/stacks-node/src/tests/epoch_23.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ fn trait_invocation_behavior() {
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down
14 changes: 2 additions & 12 deletions testnet/stacks-node/src/tests/epoch_24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,7 @@ fn fix_to_pox_contract() {
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down Expand Up @@ -792,12 +787,7 @@ fn verify_auto_unlock_behavior() {
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down
7 changes: 1 addition & 6 deletions testnet/stacks-node/src/tests/epoch_25.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ fn microblocks_disabled() {
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;

test_observer::spawn();

conf.events_observers.insert(EventObserverConfig {
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
events_keys: vec![EventKeyType::AnyEvent],
timeout_ms: 1000,
});
test_observer::register_any(&mut conf);
conf.initial_balances.append(&mut initial_balances);

let mut epochs = core::STACKS_EPOCHS_REGTEST.to_vec();
Expand Down
Loading

0 comments on commit 1c3302a

Please sign in to comment.