Skip to content

Commit afcf58d

Browse files
committed
Add comment and field checks to test
1 parent 8e4fee3 commit afcf58d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

client/src/client_sync/v17/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,10 @@ pub enum SetBanCommand {
252252
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
253253
pub struct ImportMultiRequest {
254254
/// Descriptor to import. If using descriptor, donot also provide address/scriptPubKey, scripts, or pubkeys.
255+
#[serde(default, skip_serializing_if = "Option::is_none")]
255256
pub desc: Option<String>,
256257
/// Type of scriptPubKey (string for script, json for address). Should not be provided if using descriptor.
257-
#[serde(rename = "scriptPubKey")]
258+
#[serde(rename = "scriptPubKey", skip_serializing_if = "Option::is_none")]
258259
pub script_pub_key: Option<ImportMultiScriptPubKey>,
259260
/// Creation time of the key expressed in UNIX epoch time, or the string "now" to substitute the current synced blockchain time.
260261
pub timestamp: ImportMultiTimestamp,

integration_test/tests/wallet.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,14 @@ fn wallet__import_multi() {
360360
let addr = node.client.new_address().expect("newaddress");
361361
let dummy_desc = "pkh(02c6047f9441ed7d6d3045406e95c07cd85a2a0e5c1e507a7a7e3d2f0d6c3d8ef8)#tp9h0863";
362362

363+
// req1: returns success, no warnings nor error.
363364
let req1 = ImportMultiRequest {
364365
script_pub_key: Some(ImportMultiScriptPubKey::Script(dummy_script_hex.to_string())),
365366
timestamp: ImportMultiTimestamp::Now("now".to_string()),
366367
..Default::default()
367368
};
368369

370+
// req2: returns failure, no warnings, but json-rpc error.
369371
let req2 = ImportMultiRequest {
370372
script_pub_key: Some(ImportMultiScriptPubKey::Address {
371373
address: addr.to_string(),
@@ -374,13 +376,18 @@ fn wallet__import_multi() {
374376
..Default::default()
375377
};
376378

379+
// req3: returns success, with warnings, no error.
377380
let req3 = ImportMultiRequest {
378381
desc: Some(dummy_desc.to_string()),
379382
timestamp: ImportMultiTimestamp::Time(1_700_000_000),
380383
..Default::default()
381384
};
382385

383-
let _: ImportMulti = node.client.import_multi(&[req1, req2, req3]).expect("importmulti");
386+
let json: ImportMulti = node.client.import_multi(&[req1, req2, req3]).expect("importmulti");
387+
388+
// checks(result): req2 contain error & req3 contain warnings
389+
assert!(json.0[1].error.is_some());
390+
assert!(json.0[2].warnings.is_some());
384391
}
385392

386393
#[test]

0 commit comments

Comments
 (0)