Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 35ea437

Browse files
committed
Integration: mine empty block
1 parent 7109a87 commit 35ea437

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

romeo/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ tracing-subscriber.workspace = true
2323
tracing.workspace = true
2424
url.workspace = true
2525
rs_merkle.workspace = true
26+
27+
[dev-dependencies]
28+
reqwest = { workspace = true, features = ["json", "blocking"] }
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use std::env;
2+
3+
use reqwest::blocking::Client;
4+
use serde_json::json;
5+
use url::Url;
6+
7+
pub fn bitcoin_url() -> Url {
8+
let base = env::var("PROJECT_NAME").unwrap();
9+
Url::parse(&format!("http://{base}-bitcoin-1")).unwrap()
10+
}
11+
12+
pub fn generate_blocks(blocks: u64, ctx: Client) {
13+
let endpoint = {
14+
let mut endpoint = bitcoin_url();
15+
endpoint.set_port(Some(18443)).unwrap();
16+
endpoint
17+
};
18+
let user = "devnet";
19+
let password = "devnet";
20+
let body = json!({
21+
"jsonrpc": "1.0",
22+
"id": "1",
23+
"method": "generatetoaddress",
24+
//developer's
25+
"params": [blocks,"mqVnk6NPRdhntvfm4hh9vvjiRkFDUuSYsH"]
26+
});
27+
28+
let response_json: serde_json::Value = ctx
29+
.post(endpoint)
30+
.basic_auth(user, Some(password))
31+
.header(reqwest::header::CONTENT_TYPE, "application/json")
32+
.json(&body)
33+
.send()
34+
.unwrap()
35+
.json()
36+
.unwrap();
37+
38+
assert_eq!(response_json["error"], serde_json::Value::Null);
39+
}
40+
41+
#[test]
42+
fn mine_empty_block() {
43+
let client = Client::new();
44+
generate_blocks(10, client);
45+
}

0 commit comments

Comments
 (0)