mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-28 19:55:20 +08:00
chore: test coverage for both paying to contracts and standard principals
This commit is contained in:
@@ -6,7 +6,6 @@ use stacks::burnchains::Burnchain;
|
||||
use stacks::chainstate::stacks::db::StacksChainState;
|
||||
use stacks::chainstate::stacks::StacksBlockHeader;
|
||||
use stacks::types::chainstate::StacksAddress;
|
||||
use stacks::vm::types::PrincipalData;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::config::EventKeyType;
|
||||
@@ -40,7 +39,7 @@ use stacks_common::util::secp256k1::Secp256k1PublicKey;
|
||||
|
||||
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
|
||||
|
||||
use clarity::vm::types::QualifiedContractIdentifier;
|
||||
use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
|
||||
use stacks::core::BURNCHAIN_TX_SEARCH_WINDOW;
|
||||
|
||||
use crate::burnchains::bitcoin_regtest_controller::UTXO;
|
||||
@@ -50,7 +49,7 @@ use crate::Keychain;
|
||||
|
||||
fn advance_to_2_1(
|
||||
mut initial_balances: Vec<InitialBalance>,
|
||||
pay_to_contract: Option<QualifiedContractIdentifier>,
|
||||
block_reward_recipient: Option<PrincipalData>,
|
||||
) -> (
|
||||
Config,
|
||||
BitcoinCoreController,
|
||||
@@ -66,7 +65,7 @@ fn advance_to_2_1(
|
||||
let (mut conf, miner_account) = neon_integration_test_conf();
|
||||
|
||||
conf.initial_balances.append(&mut initial_balances);
|
||||
conf.miner.pay_to_contract = pay_to_contract;
|
||||
conf.miner.block_reward_recipient = block_reward_recipient;
|
||||
|
||||
conf.events_observers.push(EventObserverConfig {
|
||||
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
|
||||
@@ -478,7 +477,7 @@ fn transition_adds_burn_block_height() {
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn transition_adds_pay_to_contract() {
|
||||
fn transition_adds_pay_to_alt_recipient_contract() {
|
||||
if env::var("BITCOIND_TEST") != Ok("1".into()) {
|
||||
return;
|
||||
}
|
||||
@@ -487,7 +486,10 @@ fn transition_adds_pay_to_contract() {
|
||||
let target_contract_address =
|
||||
QualifiedContractIdentifier::parse("ST000000000000000000002AMW42H.bns").unwrap();
|
||||
let (conf, _btcd_controller, mut btc_regtest_controller, blocks_processed, coord_channel) =
|
||||
advance_to_2_1(vec![], Some(target_contract_address.clone()));
|
||||
advance_to_2_1(
|
||||
vec![],
|
||||
Some(PrincipalData::Contract(target_contract_address.clone())),
|
||||
);
|
||||
|
||||
let http_origin = format!("http://{}", &conf.node.rpc_bind);
|
||||
let contract_account_before = get_account(&http_origin, &target_contract_address);
|
||||
@@ -504,6 +506,34 @@ fn transition_adds_pay_to_contract() {
|
||||
coord_channel.stop_chains_coordinator();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn transition_adds_pay_to_alt_recipient_principal() {
|
||||
if env::var("BITCOIND_TEST") != Ok("1".into()) {
|
||||
return;
|
||||
}
|
||||
// very simple test to verify that the miner will automatically start sending block rewards to
|
||||
// an alternative principal in the config file when it mines after epoch 2.1.
|
||||
let target_principal_address =
|
||||
PrincipalData::parse("ST34CV1214XJF9S8WPT09TJNYJTM8GM4W6N7ZGKDF").unwrap();
|
||||
let (conf, _btcd_controller, mut btc_regtest_controller, blocks_processed, coord_channel) =
|
||||
advance_to_2_1(vec![], Some(target_principal_address.clone()));
|
||||
|
||||
let http_origin = format!("http://{}", &conf.node.rpc_bind);
|
||||
let alt_account_before = get_account(&http_origin, &target_principal_address);
|
||||
|
||||
for _i in 0..stacks_common::consts::MINER_REWARD_MATURITY + 1 {
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
}
|
||||
|
||||
let alt_account_after = get_account(&http_origin, &target_principal_address);
|
||||
|
||||
assert!(alt_account_before.balance < alt_account_after.balance);
|
||||
|
||||
test_observer::clear();
|
||||
coord_channel.stop_chains_coordinator();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn transition_fixes_bitcoin_rigidity() {
|
||||
@@ -677,7 +707,7 @@ fn transition_fixes_bitcoin_rigidity() {
|
||||
btc_regtest_controller.build_next_block(1);
|
||||
|
||||
// these should all succeed across the epoch 2.1 boundary
|
||||
for i in 0..3 {
|
||||
for _i in 0..3 {
|
||||
let tip_info = get_chain_info(&conf);
|
||||
|
||||
// this block is the epoch transition?
|
||||
|
||||
Reference in New Issue
Block a user