Skip to content

Commit 3612582

Browse files
committed
Make TestPeer use TestChainstate internally
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 33d7113 commit 3612582

36 files changed

+2888
-2634
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

8-
## Unreleased
8+
## [3.2.0.0.2]
99

1010
### Added
1111

stacks-signer/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

88

9-
## Unreleased
9+
## [3.2.0.0.2.0]
1010

1111
### Added
1212

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

Lines changed: 187 additions & 135 deletions
Large diffs are not rendered by default.

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ impl NakamotoBlockHeader {
843843
.map_err(|_| ChainstateError::NoRegisteredSigners(0))?;
844844

845845
// HashMap of <PublicKey, (Signer, Index)>
846-
let signers_by_pk: HashMap<_, _> = signers
846+
let mut signers_by_pk: HashMap<_, _> = signers
847847
.iter()
848848
.enumerate()
849849
.map(|(i, signer)| (&signer.signing_key, (signer, i)))
@@ -861,7 +861,7 @@ impl NakamotoBlockHeader {
861861
let mut public_key_bytes = [0u8; 33];
862862
public_key_bytes.copy_from_slice(&public_key.to_bytes_compressed()[..]);
863863

864-
let (signer, signer_index) = signers_by_pk.get(&public_key_bytes).ok_or_else(|| {
864+
let (signer, signer_index) = signers_by_pk.remove(&public_key_bytes).ok_or_else(|| {
865865
warn!(
866866
"Found an invalid public key. Reward set has {} signers. Chain length {}. Signatures length {}",
867867
signers.len(),
@@ -876,13 +876,13 @@ impl NakamotoBlockHeader {
876876

877877
// Enforce order of signatures
878878
if let Some(index) = last_index.as_ref() {
879-
if *index >= *signer_index {
879+
if *index >= signer_index {
880880
return Err(ChainstateError::InvalidStacksBlock(
881881
"Signatures are out of order".to_string(),
882882
));
883883
}
884884
} else {
885-
last_index = Some(*signer_index);
885+
last_index = Some(signer_index);
886886
}
887887

888888
total_weight_signed = total_weight_signed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ fn test_make_miners_stackerdb_config() {
19911991
None,
19921992
);
19931993

1994-
let naka_miner_hash160 = peer.miner.nakamoto_miner_hash160();
1994+
let naka_miner_hash160 = peer.chain.miner.nakamoto_miner_hash160();
19951995
let miner_keys: Vec<_> = (0..10).map(|_| StacksPrivateKey::random()).collect();
19961996
let miner_hash160s: Vec<_> = miner_keys
19971997
.iter()
@@ -2009,8 +2009,8 @@ fn test_make_miners_stackerdb_config() {
20092009
debug!("miners = {:#?}", &miner_hash160s);
20102010

20112011
// extract chainstate, sortdb, and stackerdbs -- we don't need the peer anymore
2012-
let chainstate = &mut peer.stacks_node.as_mut().unwrap().chainstate;
2013-
let sort_db = peer.sortdb.as_mut().unwrap();
2012+
let chainstate = &mut peer.chain.stacks_node.as_mut().unwrap().chainstate;
2013+
let sort_db = peer.chain.sortdb.as_mut().unwrap();
20142014
let mut last_snapshot = SortitionDB::get_canonical_burn_chain_tip(sort_db.conn()).unwrap();
20152015
let stackerdbs = peer.network.stackerdbs;
20162016
let miners_contract_id = boot_code_id(MINERS_NAME, false);
@@ -3261,9 +3261,7 @@ pub mod nakamoto_block_signatures {
32613261

32623262
match header.verify_signer_signatures(&reward_set) {
32633263
Ok(_) => panic!("Expected duplicate signature to fail"),
3264-
Err(ChainstateError::InvalidStacksBlock(msg)) => {
3265-
assert!(msg.contains("Signatures are out of order"));
3266-
}
3264+
Err(ChainstateError::InvalidStacksBlock(_)) => {}
32673265
_ => panic!("Expected InvalidStacksBlock error"),
32683266
}
32693267
}

0 commit comments

Comments
 (0)