Skip to content

Commit 42faabe

Browse files
authored
Merge pull request #6163 from hstove/feat/signer-test-snapshots
feat: add snapshotting to SignerTest to improve boot time
2 parents fe86198 + cef9fd4 commit 42faabe

File tree

7 files changed

+339
-30
lines changed

7 files changed

+339
-30
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testnet/stacks-node/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ serial_test = "3.2.0"
5454
pinny = { git = "https://github.com/BitcoinL2-Labs/pinny-rs.git", rev = "54ba9d533a7b84525a5e65a3eae1a3ae76b9ea49" } #v0.0.2
5555
madhouse = { git = "https://github.com/stacks-network/madhouse-rs.git", rev = "fc651ddcbaf85e888b06d4a87aa788c4b7ba9309" }
5656
proptest = { git = "https://github.com/proptest-rs/proptest.git", rev = "c9bdf18c232665b2b740c667c81866b598d06dc7" }
57+
stdext = "0.3.1"
5758

5859
[[bin]]
5960
name = "stacks-node"
@@ -70,5 +71,5 @@ prod-genesis-chainstate = []
7071
default = []
7172
testing = []
7273

73-
[package.metadata.pinny]
74+
[package.metadata.pinny]
7475
allowed = ["bitcoind", "flaky", "slow"]

testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,17 @@ impl BitcoinRPCRequest {
28222822
Ok(())
28232823
}
28242824

2825+
pub fn stop_bitcoind(config: &Config) -> RPCResult<serde_json::Value> {
2826+
let payload = BitcoinRPCRequest {
2827+
method: "stop".to_string(),
2828+
params: vec![],
2829+
id: "stacks".to_string(),
2830+
jsonrpc: "2.0".to_string(),
2831+
};
2832+
2833+
BitcoinRPCRequest::send(config, payload)
2834+
}
2835+
28252836
pub fn send(config: &Config, payload: BitcoinRPCRequest) -> RPCResult<serde_json::Value> {
28262837
let request = BitcoinRPCRequest::build_rpc_request(config, &payload);
28272838
let timeout = Duration::from_secs(u64::from(config.burnchain.timeout));

testnet/stacks-node/src/tests/bitcoin_regtest.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type BitcoinResult<T> = Result<T, BitcoinCoreError>;
2929

3030
pub struct BitcoinCoreController {
3131
bitcoind_process: Option<Child>,
32-
config: Config,
32+
pub config: Config,
3333
}
3434

3535
impl BitcoinCoreController {
@@ -63,6 +63,8 @@ impl BitcoinCoreController {
6363
.arg("-nodebug")
6464
.arg("-nodebuglogfile")
6565
.arg("-rest")
66+
.arg("-persistmempool=1")
67+
.arg("-dbcache=100")
6668
.arg("-txindex=1")
6769
.arg("-server=1")
6870
.arg("-listenonion=0")
@@ -101,26 +103,23 @@ impl BitcoinCoreController {
101103
}
102104

103105
pub fn stop_bitcoind(&mut self) -> Result<(), BitcoinCoreError> {
104-
if self.bitcoind_process.take().is_some() {
105-
let payload = BitcoinRPCRequest {
106-
method: "stop".to_string(),
107-
params: vec![],
108-
id: "stacks".to_string(),
109-
jsonrpc: "2.0".to_string(),
110-
};
111-
112-
let res = BitcoinRPCRequest::send(&self.config, payload)
106+
if let Some(mut bitcoind_process) = self.bitcoind_process.take() {
107+
let res = BitcoinRPCRequest::stop_bitcoind(&self.config)
113108
.map_err(|e| BitcoinCoreError::StopFailed(format!("{e:?}")))?;
114109

115110
if let Some(err) = res.get("error") {
116111
if !err.is_null() {
117112
return Err(BitcoinCoreError::StopFailed(format!("{err}")));
118113
}
114+
} else if let Some(_result) = res.get("result") {
115+
// Expected, continue
119116
} else {
120117
return Err(BitcoinCoreError::StopFailed(format!(
121118
"Invalid response: {res:?}"
122119
)));
123120
}
121+
122+
bitcoind_process.wait().unwrap();
124123
}
125124
Ok(())
126125
}

testnet/stacks-node/src/tests/neon_integrations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9221,7 +9221,7 @@ fn filter_txs_by_origin() {
92219221
}
92229222

92239223
// https://stackoverflow.com/questions/26958489/how-to-copy-a-folder-recursively-in-rust
9224-
fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
9224+
pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
92259225
fs::create_dir_all(&dst)?;
92269226
for entry in fs::read_dir(src)? {
92279227
let entry = entry?;

0 commit comments

Comments
 (0)