Skip to content

Test to showcase high memory consumption of batch_script_get_history #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/raw_client.rs
Original file line number Diff line number Diff line change
@@ -1131,6 +1131,40 @@ mod test {
assert!(resp.confirmed >= 213091301265);
}

#[test]
fn test_batch_script_get_history() {
use std::str::FromStr;

let client = RawClient::new(get_test_server(), None).unwrap();

// Using different address does not change the behavior
// new address: 38zTM2hA9Xg354HfhLGC5kDJfwv8mSU9Gc
// old address: 1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF
let script_1 = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF")
.unwrap()
.script_pubkey();

let mut list = Vec::new();

for _ in 1..7000 {
list.push(&script_1);
}

dbg!("batch_script_get_history started");
let _histories = client.batch_script_get_history(list.clone()).unwrap();
dbg!("batch_script_get_history finished");

let awaiting_map = client.waiting_map.lock().unwrap();
dbg!(awaiting_map.len());
// If we run the batching in a loop (i.e. a periodic sync) then this capacity never goes down.
// A lot of memory is getting allocated here
dbg!(awaiting_map.capacity());

let read_buffer = client.buf_reader.lock().unwrap();
dbg!(read_buffer.capacity());

}

#[test]
fn test_script_get_history() {
use std::str::FromStr;