lightning icon indicating copy to clipboard operation
lightning copied to clipboard

Issue 5363 mkfunding unit tests

Open greggzigler opened this issue 1 year ago • 2 comments

Issue https://github.com/ElementsProject/lightning/issues/5363 suggests that we create some sanity checking tests for the mkfunding devtool. In this draft pull request, I copied the parameters from the top of mkfunding.c and used them as input into three "unit tests".

A couple obvious problems so far:

  • I mocked-out most of the interesting bitcoin/*.c functions that the devtool uses, just to get the three tests to pass; so it doesn't do any interesting work. So far, "pass" simply means it didn't abort after all the mocked functions returned successfully;
  • I don't know what use cases these three sets of parameters actually represent; I can't put a meaningful label on any of the test cases.

I'd like to create tests for specific use cases, including segfaults and crashes and error conditions as suggested in the issue. I'd be open to suggestions.

Is this PR headed in the right direction?

greggzigler avatar Sep 08 '22 21:09 greggzigler

Whoa this is a great idea. I think the easiest thing to do would be more "blackbox", so having a shell function that calls mkfunding with some parameters and verifies the output.

You could probably do these using the python test framework? SImilar to the ones we have for the hsmtool.

Here's where we test hsmtool: https://github.com/ElementsProject/lightning/blob/master/tests/test_wallet.py#L1103-L1109

niftynei avatar Sep 24 '22 19:09 niftynei

Note that there's a partial fix for mkfunding here (still has crash)

https://github.com/ElementsProject/lightning/commit/d2ea7f25fa1a5271096067fd4b666064d4054948

niftynei avatar Sep 24 '22 19:09 niftynei

agree with more blackbox approach, it has served me well in the past

instagibbs avatar Nov 01 '22 17:11 instagibbs

Issue 5363 has been fixed, so closing this pull request

greggzigler avatar Nov 10 '22 19:11 greggzigler