Skip to content

Commit 5198bea

Browse files
committed
Remove some useless tests in functional_tests and reject huge chans
In general we shouldn't have tests lying around that are useless as its not genuinely testing anything and may break due to harmless protocol changes. Here, we drop a few useless tests. Specifically, * We drop a test that the channel_reserve is greater than the dust_limit on a random specific channel value - of *course* the channel reserve (1% of the channel - 1000 sats) happens to be greater than the dust limit (~300 sats). * We drop a test that we don't set any bits in `channel_flags` aside from 1 which is fairly useless, but more importantly its actually just testing that we don't change code, not that we are doing some specific behavior correctly. * We also drop a test that public keys are valid - `PublicKey`s are always valid per the `secp256k1` API, so should be tested by `secp256k1`, not us. Further, we remove a test that channels of 2^24 (ie 26) sats fail to open, which was intended to test pre-WUMBO channel rejection, but actually tested too-small channels (and we have other tests for WUMBO channels).
1 parent 3031db9 commit 5198bea

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4667,27 +4667,15 @@ pub fn bolt2_open_channel_sending_node_checks_part2() {
46674667

46684668
let node_b_id = nodes[1].node.get_our_node_id();
46694669

4670-
// BOLT #2 spec: Sending node must set funding_satoshis to less than 2^24 satoshis
4671-
let channel_value_satoshis=2^24;
4672-
let push_msat=10001;
4673-
assert!(nodes[0].node.create_channel(node_b_id, channel_value_satoshis, push_msat, 42, None, None).is_err());
4674-
46754670
// BOLT #2 spec: Sending node must set push_msat to equal or less than 1000 * funding_satoshis
46764671
let channel_value_satoshis=10000;
46774672
// Test when push_msat is equal to 1000 * funding_satoshis.
46784673
let push_msat=1000*channel_value_satoshis+1;
46794674
assert!(nodes[0].node.create_channel(node_b_id, channel_value_satoshis, push_msat, 42, None, None).is_err());
46804675

4681-
// BOLT #2 spec: Sending node must set set channel_reserve_satoshis greater than or equal to dust_limit_satoshis
4682-
let channel_value_satoshis=10000;
4683-
let push_msat=10001;
4684-
assert!(nodes[0].node.create_channel(node_b_id, channel_value_satoshis, push_msat, 42, None, None).is_ok()); //Create a valid channel
4685-
let node0_to_1_send_open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
4686-
assert!(node0_to_1_send_open_channel.channel_reserve_satoshis>=node0_to_1_send_open_channel.common_fields.dust_limit_satoshis);
4676+
nodes[0].node.create_channel(node_b_id, 100_000, 0, 42, None, None).unwrap();
46874677

4688-
// BOLT #2 spec: Sending node must set undefined bits in channel_flags to 0
4689-
// Only the least-significant bit of channel_flags is currently defined resulting in channel_flags only having one of two possible states 0 or 1
4690-
assert!(node0_to_1_send_open_channel.common_fields.channel_flags<=1);
4678+
let node0_to_1_send_open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, node_b_id);
46914679

46924680
// BOLT #2 spec: Sending node should set to_self_delay sufficient to ensure the sender can irreversibly spend a commitment transaction output, in case of misbehaviour by the receiver.
46934681
assert!(BREAKDOWN_TIMEOUT>0);
@@ -4696,13 +4684,6 @@ pub fn bolt2_open_channel_sending_node_checks_part2() {
46964684
// BOLT #2 spec: Sending node must ensure the chain_hash value identifies the chain it wishes to open the channel within.
46974685
let chain_hash = ChainHash::using_genesis_block(Network::Testnet);
46984686
assert_eq!(node0_to_1_send_open_channel.common_fields.chain_hash, chain_hash);
4699-
4700-
// BOLT #2 spec: Sending node must set funding_pubkey, revocation_basepoint, htlc_basepoint, payment_basepoint, and delayed_payment_basepoint to valid DER-encoded, compressed, secp256k1 pubkeys.
4701-
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.common_fields.funding_pubkey.serialize()).is_ok());
4702-
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.common_fields.revocation_basepoint.serialize()).is_ok());
4703-
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.common_fields.htlc_basepoint.serialize()).is_ok());
4704-
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.common_fields.payment_basepoint.serialize()).is_ok());
4705-
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.common_fields.delayed_payment_basepoint.serialize()).is_ok());
47064687
}
47074688

47084689
#[xtest(feature = "_externalize_tests")]

0 commit comments

Comments
 (0)