Skip to content

Commit f081fd6

Browse files
authored
Merge pull request #139 from stevenroose/ci-0.20
Add v0.20.0 and v0.20.1
2 parents ca9cbf0 + 897aeb4 commit f081fd6

File tree

5 files changed

+67
-13
lines changed

5 files changed

+67
-13
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
language: rust
22
rust:
33
- stable
4-
- beta
54
- nightly
65
- 1.29.0
76
env:
87
- BITCOINVERSION=0.18.0
98
- BITCOINVERSION=0.18.1
109
- BITCOINVERSION=0.19.0.1
1110
- BITCOINVERSION=0.19.1
11+
- BITCOINVERSION=0.20.0
12+
- BITCOINVERSION=0.20.1
1213

1314
script:
1415
- ./contrib/test.sh

integration_test/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ authors = ["Steven Roose <[email protected]>"]
55

66
[dependencies]
77
bitcoincore-rpc = { path = "../client" }
8-
lazy_static = "1.4.0"
98
bitcoin = { version = "0.23", features = [ "use-serde", "rand" ] }
9+
lazy_static = "1.4.0"
10+
log = "0.4"

integration_test/run.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ PID1=$!
1919
sleep 3
2020

2121
BLOCKFILTERARG=""
22-
if bitcoind -version | grep -q "0\.19"; then
22+
if bitcoind -version | grep -q "0\.19\|0\.20"; then
2323
BLOCKFILTERARG="-blockfilterindex=1"
2424
fi
2525

26-
bitcoind -regtest $BLOCKFILTERARG \
26+
FALLBACKFEEARG=""
27+
if bitcoind -version | grep -q "0\.20"; then
28+
FALLBACKFEEARG="-fallbackfee=0.00001000"
29+
fi
30+
31+
bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG \
2732
-datadir=${TESTDIR}/2 \
2833
-connect=127.0.0.1:12348 \
2934
-rpcport=12349 \
@@ -34,7 +39,10 @@ PID2=$!
3439
# Let it connect to the other node.
3540
sleep 5
3641

37-
RPC_URL=http://localhost:12349 RPC_COOKIE=${TESTDIR}/2/regtest/.cookie cargo run
42+
RPC_URL=http://localhost:12349 \
43+
RPC_COOKIE=${TESTDIR}/2/regtest/.cookie \
44+
cargo run
45+
3846
RESULT=$?
3947

4048
kill -9 $PID1 $PID2

integration_test/src/main.rs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern crate bitcoin;
1414
extern crate bitcoincore_rpc;
1515
#[macro_use]
1616
extern crate lazy_static;
17+
extern crate log;
1718

1819
use std::collections::HashMap;
1920

@@ -41,6 +42,24 @@ lazy_static! {
4142
static ref FEE: Amount = Amount::from_btc(0.001).unwrap();
4243
}
4344

45+
struct StdLogger;
46+
47+
impl log::Log for StdLogger {
48+
fn enabled(&self, metadata: &log::Metadata) -> bool {
49+
metadata.target().contains("jsonrpc") || metadata.target().contains("bitcoincore_rpc")
50+
}
51+
52+
fn log(&self, record: &log::Record) {
53+
if self.enabled(record.metadata()) {
54+
println!("[{}][{}]: {}", record.level(), record.metadata().target(), record.args());
55+
}
56+
}
57+
58+
fn flush(&self) {}
59+
}
60+
61+
static LOGGER: StdLogger = StdLogger;
62+
4463
/// Assert that the call returns a "deprecated" error.
4564
macro_rules! assert_deprecated {
4665
($call:expr) => {
@@ -91,6 +110,8 @@ fn get_auth() -> bitcoincore_rpc::Auth {
91110
}
92111

93112
fn main() {
113+
log::set_logger(&LOGGER).map(|()| log::set_max_level(log::LevelFilter::max())).unwrap();
114+
94115
let rpc_url = get_rpc_url();
95116
let auth = get_auth();
96117

@@ -282,16 +303,33 @@ fn test_get_address_info(cl: &Client) {
282303
assert!(!info.hex.unwrap().is_empty());
283304
}
284305

306+
#[allow(deprecated)]
285307
fn test_set_label(cl: &Client) {
286308
let addr = cl.get_new_address(Some("label"), None).unwrap();
287309
let info = cl.get_address_info(&addr).unwrap();
288-
assert_eq!(&info.label, "label");
289-
assert_eq!(info.labels[0].name, "label");
310+
if version() >= 0_20_00_00 {
311+
assert!(info.label.is_none());
312+
assert_eq!(info.labels[0], json::GetAddressInfoResultLabel::Simple("label".into()));
313+
} else {
314+
assert_eq!(info.label.as_ref().unwrap(), "label");
315+
assert_eq!(info.labels[0], json::GetAddressInfoResultLabel::WithPurpose {
316+
name: "label".into(),
317+
purpose: json::GetAddressInfoResultLabelPurpose::Receive,
318+
});
319+
}
290320

291321
cl.set_label(&addr, "other").unwrap();
292322
let info = cl.get_address_info(&addr).unwrap();
293-
assert_eq!(&info.label, "other");
294-
assert_eq!(info.labels[0].name, "other");
323+
if version() >= 0_20_00_00 {
324+
assert!(info.label.is_none());
325+
assert_eq!(info.labels[0], json::GetAddressInfoResultLabel::Simple("other".into()));
326+
} else {
327+
assert_eq!(info.label.as_ref().unwrap(), "other");
328+
assert_eq!(info.labels[0], json::GetAddressInfoResultLabel::WithPurpose {
329+
name: "other".into(),
330+
purpose: json::GetAddressInfoResultLabelPurpose::Receive,
331+
});
332+
}
295333
}
296334

297335
fn test_send_to_address(cl: &Client) {

json/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,13 @@ pub enum GetAddressInfoResultLabelPurpose {
646646
}
647647

648648
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
649-
pub struct GetAddressInfoResultLabel {
650-
pub name: String,
651-
pub purpose: GetAddressInfoResultLabelPurpose,
649+
#[serde(untagged)]
650+
pub enum GetAddressInfoResultLabel {
651+
Simple(String),
652+
WithPurpose {
653+
name: String,
654+
purpose: GetAddressInfoResultLabelPurpose,
655+
}
652656
}
653657

654658
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
@@ -679,13 +683,15 @@ pub struct GetAddressInfoResult {
679683
pub embedded: Option<GetAddressInfoResultEmbedded>,
680684
#[serde(rename = "is_compressed")]
681685
pub is_compressed: Option<bool>,
682-
pub label: String,
683686
pub timestamp: Option<u64>,
684687
#[serde(rename = "hdkeypath")]
685688
pub hd_key_path: Option<bip32::DerivationPath>,
686689
#[serde(rename = "hdseedid")]
687690
pub hd_seed_id: Option<bitcoin::XpubIdentifier>,
688691
pub labels: Vec<GetAddressInfoResultLabel>,
692+
/// Deprecated in v0.20.0. See `labels` field instead.
693+
#[deprecated(note = "since Core v0.20.0")]
694+
pub label: Option<String>,
689695
}
690696

691697
/// Models the result of "getblockchaininfo"

0 commit comments

Comments
 (0)