Skip to content

Commit dc181fc

Browse files
committed
Add descriptions to test cases
1 parent 3896829 commit dc181fc

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

lightning/src/ln/interactivetxs.rs

+35-2
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ mod tests {
944944
}
945945

946946
struct TestSession {
947+
description: String,
947948
inputs_a: Vec<(TxIn, TransactionU16LenLimited)>,
948949
outputs_a: Vec<TxOut>,
949950
inputs_b: Vec<(TxIn, TransactionU16LenLimited)>,
@@ -1035,7 +1036,12 @@ mod tests {
10351036
},
10361037
_ => ErrorCulprit::NodeA,
10371038
};
1038-
assert_eq!(Some((abort_reason, error_culprit)), session.expect_error);
1039+
assert_eq!(
1040+
Some((abort_reason, error_culprit)),
1041+
session.expect_error,
1042+
"Test: {}",
1043+
session.description
1044+
);
10391045
assert!(message_send_b.is_none());
10401046
return;
10411047
},
@@ -1054,7 +1060,12 @@ mod tests {
10541060
},
10551061
_ => ErrorCulprit::NodeB,
10561062
};
1057-
assert_eq!(Some((abort_reason, error_culprit)), session.expect_error);
1063+
assert_eq!(
1064+
Some((abort_reason, error_culprit)),
1065+
session.expect_error,
1066+
"Test: {}",
1067+
session.description
1068+
);
10581069
assert!(message_send_a.is_none());
10591070
return;
10601071
},
@@ -1175,6 +1186,7 @@ mod tests {
11751186
fn test_interactive_tx_constructor() {
11761187
// No contributions.
11771188
do_test_interactive_tx_constructor(TestSession {
1189+
description: "No contributions".to_string(),
11781190
inputs_a: vec![],
11791191
outputs_a: vec![],
11801192
inputs_b: vec![],
@@ -1183,6 +1195,7 @@ mod tests {
11831195
});
11841196
// Single contribution, no initiator inputs.
11851197
do_test_interactive_tx_constructor(TestSession {
1198+
description: "Single contribution, no initiator inputs".to_string(),
11861199
inputs_a: vec![],
11871200
outputs_a: generate_outputs(&[1_000_000]),
11881201
inputs_b: vec![],
@@ -1191,6 +1204,7 @@ mod tests {
11911204
});
11921205
// Single contribution, no initiator outputs.
11931206
do_test_interactive_tx_constructor(TestSession {
1207+
description: "Single contribution, no initiator outputs".to_string(),
11941208
inputs_a: generate_inputs(&[1_000_000]),
11951209
outputs_a: vec![],
11961210
inputs_b: vec![],
@@ -1199,6 +1213,7 @@ mod tests {
11991213
});
12001214
// Single contribution, insufficient fees.
12011215
do_test_interactive_tx_constructor(TestSession {
1216+
description: "Single contribution, insufficient fees".to_string(),
12021217
inputs_a: generate_inputs(&[1_000_000]),
12031218
outputs_a: generate_outputs(&[1_000_000]),
12041219
inputs_b: vec![],
@@ -1207,6 +1222,8 @@ mod tests {
12071222
});
12081223
// Initiator contributes sufficient fees, but non-initiator does not.
12091224
do_test_interactive_tx_constructor(TestSession {
1225+
description: "Initiator contributes sufficient fees, but non-initiator does not"
1226+
.to_string(),
12101227
inputs_a: generate_inputs(&[1_000_000]),
12111228
outputs_a: vec![],
12121229
inputs_b: generate_inputs(&[100_000]),
@@ -1215,6 +1232,7 @@ mod tests {
12151232
});
12161233
// Multi-input-output contributions from both sides.
12171234
do_test_interactive_tx_constructor(TestSession {
1235+
description: "Multi-input-output contributions from both sides".to_string(),
12181236
inputs_a: generate_inputs(&[1_000_000, 1_000_000]),
12191237
outputs_a: generate_outputs(&[1_000_000, 200_000]),
12201238
inputs_b: generate_inputs(&[1_000_000, 500_000]),
@@ -1244,6 +1262,7 @@ mod tests {
12441262
..Default::default()
12451263
};
12461264
do_test_interactive_tx_constructor(TestSession {
1265+
description: "Prevout from initiator is not a witness program".to_string(),
12471266
inputs_a: vec![(non_segwit_input, non_segwit_output_tx)],
12481267
outputs_a: vec![],
12491268
inputs_b: vec![],
@@ -1258,6 +1277,7 @@ mod tests {
12581277
..Default::default()
12591278
};
12601279
do_test_interactive_tx_constructor(TestSession {
1280+
description: "Invalid input sequence from initiator".to_string(),
12611281
inputs_a: vec![(invalid_sequence_input, tx.clone())],
12621282
outputs_a: generate_outputs(&[1_000_000]),
12631283
inputs_b: vec![],
@@ -1271,6 +1291,7 @@ mod tests {
12711291
..Default::default()
12721292
};
12731293
do_test_interactive_tx_constructor(TestSession {
1294+
description: "Duplicate prevout from initiator".to_string(),
12741295
inputs_a: vec![(duplicate_input.clone(), tx.clone()), (duplicate_input, tx.clone())],
12751296
outputs_a: generate_outputs(&[1_000_000]),
12761297
inputs_b: vec![],
@@ -1284,6 +1305,7 @@ mod tests {
12841305
..Default::default()
12851306
};
12861307
do_test_interactive_tx_constructor(TestSession {
1308+
description: "Non-initiator uses same prevout as initiator".to_string(),
12871309
inputs_a: vec![(duplicate_input.clone(), tx.clone())],
12881310
outputs_a: generate_outputs(&[1_000_000]),
12891311
inputs_b: vec![(duplicate_input.clone(), tx.clone())],
@@ -1292,6 +1314,7 @@ mod tests {
12921314
});
12931315
// Initiator sends too many TxAddInputs
12941316
do_test_interactive_tx_constructor(TestSession {
1317+
description: "Initiator sends too many TxAddInputs".to_string(),
12951318
inputs_a: generate_fixed_number_of_inputs(MAX_RECEIVED_TX_ADD_INPUT_COUNT + 1),
12961319
outputs_a: vec![],
12971320
inputs_b: vec![],
@@ -1302,6 +1325,7 @@ mod tests {
13021325
// entropy source, `DuplicateEntropySource` to simulate this.
13031326
do_test_interactive_tx_constructor_with_entropy_source(
13041327
TestSession {
1328+
description: "Attempt to queue up two inputs with duplicate serial ids".to_string(),
13051329
inputs_a: generate_fixed_number_of_inputs(2),
13061330
outputs_a: vec![],
13071331
inputs_b: vec![],
@@ -1312,6 +1336,7 @@ mod tests {
13121336
);
13131337
// Initiator sends too many TxAddOutputs.
13141338
do_test_interactive_tx_constructor(TestSession {
1339+
description: "Initiator sends too many TxAddOutputs".to_string(),
13151340
inputs_a: vec![],
13161341
outputs_a: generate_fixed_number_of_outputs(MAX_RECEIVED_TX_ADD_OUTPUT_COUNT + 1),
13171342
inputs_b: vec![],
@@ -1320,6 +1345,7 @@ mod tests {
13201345
});
13211346
// Initiator sends an output below dust value.
13221347
do_test_interactive_tx_constructor(TestSession {
1348+
description: "Initiator sends an output below dust value".to_string(),
13231349
inputs_a: vec![],
13241350
outputs_a: generate_outputs(&[1]),
13251351
inputs_b: vec![],
@@ -1328,6 +1354,7 @@ mod tests {
13281354
});
13291355
// Initiator sends an output above maximum sats allowed.
13301356
do_test_interactive_tx_constructor(TestSession {
1357+
description: "Initiator sends an output above maximum sats allowed".to_string(),
13311358
inputs_a: vec![],
13321359
outputs_a: generate_outputs(&[TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1]),
13331360
inputs_b: vec![],
@@ -1336,6 +1363,7 @@ mod tests {
13361363
});
13371364
// Initiator sends an output without a witness program.
13381365
do_test_interactive_tx_constructor(TestSession {
1366+
description: "Initiator sends an output without a witness program".to_string(),
13391367
inputs_a: vec![],
13401368
outputs_a: vec![generate_non_witness_output(1_000_000)],
13411369
inputs_b: vec![],
@@ -1346,6 +1374,8 @@ mod tests {
13461374
// entropy source, `DuplicateEntropySource` to simulate this.
13471375
do_test_interactive_tx_constructor_with_entropy_source(
13481376
TestSession {
1377+
description: "Attempt to queue up two outputs with duplicate serial ids"
1378+
.to_string(),
13491379
inputs_a: vec![],
13501380
outputs_a: generate_fixed_number_of_outputs(2),
13511381
inputs_b: vec![],
@@ -1357,6 +1387,7 @@ mod tests {
13571387

13581388
// Peer contributed more output value than inputs
13591389
do_test_interactive_tx_constructor(TestSession {
1390+
description: "Peer contributed more output value than inputs".to_string(),
13601391
inputs_a: generate_inputs(&[100_000]),
13611392
outputs_a: generate_outputs(&[1_000_000]),
13621393
inputs_b: vec![],
@@ -1366,6 +1397,7 @@ mod tests {
13661397

13671398
// Peer contributed more than allowed number of inputs.
13681399
do_test_interactive_tx_constructor(TestSession {
1400+
description: "Peer contributed more than allowed number of inputs".to_string(),
13691401
inputs_a: generate_fixed_number_of_inputs(MAX_INPUTS_OUTPUTS_COUNT as u16 + 1),
13701402
outputs_a: vec![],
13711403
inputs_b: vec![],
@@ -1377,6 +1409,7 @@ mod tests {
13771409
});
13781410
// Peer contributed more than allowed number of outputs.
13791411
do_test_interactive_tx_constructor(TestSession {
1412+
description: "Peer contributed more than allowed number of outputs".to_string(),
13801413
inputs_a: generate_inputs(&[TOTAL_BITCOIN_SUPPLY_SATOSHIS]),
13811414
outputs_a: generate_fixed_number_of_outputs(MAX_INPUTS_OUTPUTS_COUNT as u16 + 1),
13821415
inputs_b: vec![],

0 commit comments

Comments
 (0)