Skip to content

Commit

Permalink
Merge pull request #4586 from stacks-network/chore/rust-scenario-test
Browse files Browse the repository at this point in the history
Integrated/Scenario Tests In Rust
  • Loading branch information
obycode committed Apr 18, 2024
2 parents 34b97e1 + 9b51ccc commit 9cb64be
Show file tree
Hide file tree
Showing 5 changed files with 2,873 additions and 449 deletions.
1 change: 1 addition & 0 deletions stackslib/src/chainstate/nakamoto/coordinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use crate::chainstate::nakamoto::tests::get_account;
use crate::chainstate::nakamoto::tests::node::TestStacker;
use crate::chainstate::nakamoto::{NakamotoBlock, NakamotoChainState};
use crate::chainstate::stacks::address::PoxAddress;
use crate::chainstate::stacks::boot::pox_4_tests::{get_stacking_minimum, get_tip};
use crate::chainstate::stacks::boot::signers_tests::{readonly_call, readonly_call_with_sortdb};
use crate::chainstate::stacks::boot::test::{
key_to_stacks_addr, make_pox_4_lockup, make_signer_key_signature,
Expand Down
74 changes: 74 additions & 0 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ pub mod test {
use stacks_common::util::secp256k1::Secp256k1PublicKey;
use stacks_common::util::*;

use self::signers_tests::readonly_call;
use super::*;
use crate::burnchains::{Address, PublicKey};
use crate::chainstate::burn::db::sortdb::*;
Expand Down Expand Up @@ -1728,6 +1729,58 @@ pub mod test {
}
}

pub fn get_stacker_info_pox_4(
peer: &mut TestPeer,
addr: &PrincipalData,
) -> Option<(PoxAddress, u128, u128, Vec<u128>)> {
let value_opt = eval_at_tip(
peer,
"pox-4",
&format!("(get-stacker-info '{})", addr.to_string()),
);
let data = if let Some(d) = value_opt.expect_optional().unwrap() {
d
} else {
return None;
};

let data = data.expect_tuple().unwrap();
let pox_addr = tuple_to_pox_addr(
data.get("pox-addr")
.unwrap()
.to_owned()
.expect_tuple()
.unwrap(),
);
let first_reward_cycle = data
.get("first-reward-cycle")
.unwrap()
.to_owned()
.expect_u128()
.unwrap();
let lock_period = data
.get("lock-period")
.unwrap()
.to_owned()
.expect_u128()
.unwrap();
let reward_set_indices = data
.get("reward-set-indexes")
.unwrap()
.to_owned()
.expect_list()
.unwrap()
.iter()
.map(|v| v.to_owned().expect_u128().unwrap())
.collect();
Some((
pox_addr,
first_reward_cycle,
lock_period,
reward_set_indices,
))
}

pub fn get_stacker_info(
peer: &mut TestPeer,
addr: &PrincipalData,
Expand Down Expand Up @@ -1987,6 +2040,27 @@ pub mod test {
make_tx(key, nonce, 1, payload)
}

pub fn get_approved_aggregate_key(
peer: &mut TestPeer<'_>,
latest_block_id: StacksBlockId,
reward_cycle: u128,
) -> Option<Point> {
let key_opt = readonly_call(
peer,
&latest_block_id,
SIGNERS_VOTING_NAME.into(),
"get-approved-aggregate-key".into(),
vec![Value::UInt(reward_cycle)],
)
.expect_optional()
.unwrap();
key_opt.map(|key_value| {
let data = key_value.expect_buff(33).unwrap();
let compressed_data = Compressed::try_from(data.as_slice()).unwrap();
Point::try_from(&compressed_data).unwrap()
})
}

pub fn make_pox_2_increase(
key: &StacksPrivateKey,
nonce: u64,
Expand Down
Loading

0 comments on commit 9cb64be

Please sign in to comment.