mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-03-30 16:45:26 +08:00
@@ -667,13 +667,13 @@ impl BitcoinRegtestController {
|
||||
result_vec
|
||||
}
|
||||
|
||||
/// Checks if there is a default wallet with the name of "".
|
||||
/// If the default wallet does not exist, this function creates a wallet with name "".
|
||||
/// Checks if the config-supplied wallet exists.
|
||||
/// If it does not exist, this function creates it.
|
||||
pub fn create_wallet_if_dne(&self) -> RPCResult<()> {
|
||||
let wallets = BitcoinRPCRequest::list_wallets(&self.config)?;
|
||||
|
||||
if !wallets.contains(&("".to_string())) {
|
||||
BitcoinRPCRequest::create_wallet(&self.config, "")?;
|
||||
if !wallets.contains(&self.config.burnchain.wallet_name) {
|
||||
BitcoinRPCRequest::create_wallet(&self.config, &self.config.burnchain.wallet_name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -2138,15 +2138,15 @@ impl BitcoinRPCRequest {
|
||||
let url = {
|
||||
// some methods require a wallet ID
|
||||
let wallet_id = match payload.method.as_str() {
|
||||
"importaddress" | "listunspent" => Some("".to_string()),
|
||||
"importaddress" | "listunspent" => Some(config.burnchain.wallet_name.clone()),
|
||||
_ => None,
|
||||
};
|
||||
let url = config.burnchain.get_rpc_url(wallet_id);
|
||||
Url::parse(&url).expect(&format!("Unable to parse {} as a URL", url))
|
||||
};
|
||||
debug!(
|
||||
"BitcoinRPC builder: {:?}:{:?}@{}",
|
||||
&config.burnchain.username, &config.burnchain.password, &url
|
||||
"BitcoinRPC builder '{}': {:?}:{:?}@{}",
|
||||
&payload.method, &config.burnchain.username, &config.burnchain.password, &url
|
||||
);
|
||||
|
||||
let mut req = Request::new(Method::Post, url);
|
||||
|
||||
@@ -4711,7 +4711,7 @@ fn trait_invocation_cross_epoch() {
|
||||
|
||||
test_observer::spawn();
|
||||
|
||||
let (mut conf, _miner_account) = neon_integration_test_conf();
|
||||
let (mut conf, _) = neon_integration_test_conf();
|
||||
let mut initial_balances = vec![InitialBalance {
|
||||
address: spender_addr.clone(),
|
||||
amount: 200_000_000,
|
||||
@@ -4728,8 +4728,6 @@ fn trait_invocation_cross_epoch() {
|
||||
epochs[3].start_height = epoch_2_1;
|
||||
conf.burnchain.epochs = Some(epochs);
|
||||
|
||||
let _http_origin = format!("http://{}", &conf.node.rpc_bind);
|
||||
|
||||
let mut burnchain_config = Burnchain::regtest(&conf.get_burn_db_path());
|
||||
|
||||
let reward_cycle_len = 2000;
|
||||
|
||||
@@ -67,6 +67,7 @@ use stacks::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
burnchains::bitcoin_regtest_controller::BitcoinRPCRequest,
|
||||
burnchains::bitcoin_regtest_controller::UTXO, config::EventKeyType,
|
||||
config::EventObserverConfig, config::InitialBalance, neon, operations::BurnchainOpSigner,
|
||||
syncctl::PoxSyncWatchdogComms, BitcoinRegtestController, BurnchainController, Config,
|
||||
@@ -10195,6 +10196,70 @@ fn push_boot_receipts() {
|
||||
assert_eq!(events.len(), 26);
|
||||
}
|
||||
|
||||
/// Verify that we can operate with a custom wallet name
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn run_with_custom_wallet() {
|
||||
if env::var("BITCOIND_TEST") != Ok("1".into()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let (mut conf, _) = neon_integration_test_conf();
|
||||
conf.events_observers.push(EventObserverConfig {
|
||||
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
|
||||
events_keys: vec![EventKeyType::AnyEvent],
|
||||
});
|
||||
|
||||
// custom wallet
|
||||
conf.burnchain.wallet_name = "test_with_custom_wallet".to_string();
|
||||
|
||||
test_observer::spawn();
|
||||
|
||||
let mut btcd_controller = BitcoinCoreController::new(conf.clone());
|
||||
btcd_controller
|
||||
.start_bitcoind()
|
||||
.map_err(|_e| ())
|
||||
.expect("Failed starting bitcoind");
|
||||
|
||||
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
|
||||
|
||||
btc_regtest_controller.bootstrap_chain(201);
|
||||
|
||||
eprintln!("Chain bootstrapped...");
|
||||
|
||||
let mut run_loop = neon::RunLoop::new(conf.clone());
|
||||
let blocks_processed = run_loop.get_blocks_processed_arc();
|
||||
|
||||
thread::spawn(move || run_loop.start(None, 0));
|
||||
|
||||
// Give the run loop some time to start up!
|
||||
wait_for_runloop(&blocks_processed);
|
||||
|
||||
// First block wakes up the run loop.
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
|
||||
// Second block will hold our VRF registration.
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
|
||||
// Third block will be the first mined Stacks block.
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
|
||||
// verify that the event observer got its boot receipts.
|
||||
// If we get this far, then it also means that mining and block-production worked.
|
||||
let blocks = test_observer::get_blocks();
|
||||
assert!(blocks.len() > 1);
|
||||
|
||||
// bitcoin node knows of this wallet
|
||||
let wallets = BitcoinRPCRequest::list_wallets(&conf).unwrap();
|
||||
let mut found = false;
|
||||
for w in wallets {
|
||||
if w == conf.burnchain.wallet_name {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
assert!(found);
|
||||
}
|
||||
|
||||
/// Make a contract that takes a parameterized amount of runtime
|
||||
/// `num_index_of` is the number of times to call `index-of`
|
||||
fn make_runtime_sized_contract(num_index_of: usize, nonce: u64, addr_prefix: &str) -> String {
|
||||
|
||||
Reference in New Issue
Block a user