Skip to content

Conversation

@f3r10
Copy link
Collaborator

@f3r10 f3r10 commented Feb 11, 2025

fix #176

@f3r10
Copy link
Collaborator Author

f3r10 commented Feb 11, 2025

@carlaKC what do you think about my approach to creating the test?

@f3r10 f3r10 requested a review from carlaKC February 11, 2025 17:49
Copy link
Contributor

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approach looks good, just some minor comments to cut down the test a little

)));
}

if payment_flow.amount_msat.value() == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like to cut down the size of the test a bit, happy to move this to the top of the loop so that you don't have to expect the get_info calls in the test?

);
clients.insert(
node_2.pubkey,
std::sync::Arc::new(tokio::sync::Mutex::new(mock_node_2)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can import these in use statements

@f3r10 f3r10 force-pushed the do_not_allow_defined_activity_with_zero_amount branch from eac7c6c to 2be6ae5 Compare February 26, 2025 15:45
@f3r10 f3r10 marked this pull request as ready for review February 26, 2025 15:45
Copy link
Contributor

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some last nitpicks on the test, non-blocking if you'd like to merge as-is!

.clone();
node_1.features.set_keysend_optional();
let mut node_2 = test_utils::create_nodes(1, 0).first().unwrap().0.clone();
node_2.features.set_keysend_optional();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than setting keysend here, let's update create_nodes to set this feature bit? We just didn't need it in the past, which is why it's an empty vector.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, maybe it would be better to open another PR doing this? because several places call create_nodes that are not related with this PR. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it'll break any existing tests, so I think we can go ahead in this PR? I was thinking just set it inside of create_nodes so that fn signature doesn't change so it would be a small change.

But if I'm wrong (always the most likely outcome 😅 ) and it breaks a bunch of stuff then yes let's do a followup!


#[tokio::test]
async fn test_validate_zero_amount_no_valid() {
let mut node_1 = test_utils::create_nodes(1, 100_000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: create two nodes at once using create_nodes(2, 100_000)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah much better 😅

let mock_node_1 = MockLightningNode::new();
let mock_node_2 = MockLightningNode::new();
let mut clients: HashMap<
bitcoin::secp256k1::PublicKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: import with use, same for SimulationConfig below - generally have always been importing like this in the project rather than inlining

@f3r10 f3r10 force-pushed the do_not_allow_defined_activity_with_zero_amount branch 2 times, most recently from 2492a2e to 4883019 Compare March 4, 2025 22:45
@f3r10 f3r10 force-pushed the do_not_allow_defined_activity_with_zero_amount branch from 4883019 to bb4b7e4 Compare March 4, 2025 22:55
Copy link
Contributor

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK bb4b7e4!

Going to go ahead and merge this so that we don't run into conflicts with any of the incoming PRs. I would like to move keysend into test utils, but we can do that in another PR.

@carlaKC carlaKC merged commit 8366b49 into bitcoin-dev-project:main Mar 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation: Do not allow defined activity with zero amount

2 participants