Skip to content

Commit f1a9acf

Browse files
committed
fixed unit tests
1 parent 80de5d1 commit f1a9acf

File tree

1 file changed

+56
-9
lines changed
  • stackslib/src/chainstate/nakamoto/coordinator

1 file changed

+56
-9
lines changed

stackslib/src/chainstate/nakamoto/coordinator/tests.rs

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,8 @@ fn transactions_indexing() {
16051605
let mut boot_plan = NakamotoBootPlan::new(function_name!())
16061606
.with_test_stackers(test_stackers.clone())
16071607
.with_test_signers(test_signers.clone())
1608-
.with_private_key(private_key);
1608+
.with_private_key(private_key)
1609+
.with_txindex(true);
16091610
boot_plan.pox_constants = pox_constants;
16101611

16111612
let mut peer = boot_plan.boot_into_nakamoto_peer(vec![], None);
@@ -1618,14 +1619,6 @@ fn transactions_indexing() {
16181619

16191620
let tracked_block_id = tracked_block.block_id();
16201621

1621-
// generate a new block but without txindex
1622-
let (untracked_block, burn_height, ..) =
1623-
peer.single_block_tenure(&private_key, |_| {}, |_| {}, |_| false);
1624-
1625-
assert_eq!(peer.try_process_block(&untracked_block).unwrap(), true);
1626-
1627-
let untracked_block_id = untracked_block.block_id();
1628-
16291622
let chainstate = &peer.stacks_node.unwrap().chainstate;
16301623

16311624
// compare transactions to what has been tracked
@@ -1638,6 +1631,60 @@ fn transactions_indexing() {
16381631
assert_eq!(index_block_hash, tracked_block_id);
16391632
assert_eq!(tx_hex, current_tx_hex);
16401633
}
1634+
}
1635+
1636+
#[test]
1637+
// Test Transactions indexing system (not indexing)
1638+
fn transactions_not_indexing() {
1639+
let private_key = StacksPrivateKey::from_seed(&[2]);
1640+
let addr = StacksAddress::p2pkh(false, &StacksPublicKey::from_private(&private_key));
1641+
1642+
let num_stackers: u32 = 4;
1643+
let mut signing_key_seed = num_stackers.to_be_bytes().to_vec();
1644+
signing_key_seed.extend_from_slice(&[1, 1, 1, 1]);
1645+
let signing_key = StacksPrivateKey::from_seed(signing_key_seed.as_slice());
1646+
let test_stackers = (0..num_stackers)
1647+
.map(|index| TestStacker {
1648+
signer_private_key: signing_key.clone(),
1649+
stacker_private_key: StacksPrivateKey::from_seed(&index.to_be_bytes()),
1650+
amount: u64::MAX as u128 - 10000,
1651+
pox_addr: Some(PoxAddress::Standard(
1652+
StacksAddress::new(
1653+
C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
1654+
Hash160::from_data(&index.to_be_bytes()),
1655+
)
1656+
.unwrap(),
1657+
Some(AddressHashMode::SerializeP2PKH),
1658+
)),
1659+
max_amount: None,
1660+
})
1661+
.collect::<Vec<_>>();
1662+
let test_signers = TestSigners::new(vec![signing_key]);
1663+
let mut pox_constants = TestPeerConfig::default().burnchain.pox_constants;
1664+
pox_constants.reward_cycle_length = 10;
1665+
pox_constants.v2_unlock_height = 21;
1666+
pox_constants.pox_3_activation_height = 26;
1667+
pox_constants.v3_unlock_height = 27;
1668+
pox_constants.pox_4_activation_height = 28;
1669+
1670+
let mut boot_plan = NakamotoBootPlan::new(function_name!())
1671+
.with_test_stackers(test_stackers.clone())
1672+
.with_test_signers(test_signers.clone())
1673+
.with_private_key(private_key)
1674+
.with_txindex(false);
1675+
boot_plan.pox_constants = pox_constants;
1676+
1677+
let mut peer = boot_plan.boot_into_nakamoto_peer(vec![], None);
1678+
1679+
// generate a new block but without txindex
1680+
let (untracked_block, burn_height, ..) =
1681+
peer.single_block_tenure(&private_key, |_| {}, |_| {}, |_| false);
1682+
1683+
assert_eq!(peer.try_process_block(&untracked_block).unwrap(), true);
1684+
1685+
let untracked_block_id = untracked_block.block_id();
1686+
1687+
let chainstate = &peer.stacks_node.unwrap().chainstate;
16411688

16421689
// ensure untracked transactions are not recorded
16431690
for tx in untracked_block.txs {

0 commit comments

Comments
 (0)