-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gatewayd integration test suite proposal #1702
Conversation
a4cced0
to
3d5984b
Compare
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #1702 +/- ##
==========================================
- Coverage 62.95% 62.84% -0.12%
==========================================
Files 137 137
Lines 26517 26518 +1
==========================================
- Hits 16694 16664 -30
- Misses 9823 9854 +31
... and 10 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Why would the real tests and mock tests be separated if we can hide the implementation behind an interface? I think similar to how we do in |
Spinning up a real federation with bitcoind and other integration artifacts might too heavy for the gateway test suite. However, we may want to:
integrationtest would have simpler tests for the gateway, but might ochestrate its real gateway with various implementations of lightning |
Not true! After #1717 , I see how we can move all gateway integration tests to this framework. We'd just need to share he fixture for spinning up real bitcoind, lightning, and federations |
182d3da
to
b8fbf6d
Compare
e98cd4a
to
914e09e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some comments; I know it's WIP, but just wanted to know what's going on.
I probably need to have a closer look at the gateway API myself to get some context.
) | ||
.await? | ||
.status(), | ||
401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that a copy paste error? the returned status should not be 401, right?
edit: I see, it's a asser_ne
. maybe change this to an assert_eq
and expect the status code 200
that is returned when the call was successful (I assume).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_eq(200)
tests for success on authentication, AND success in whatever authenticated api we are currently checking. Since we cannot be sure that our API succeeds after successful auth, we did not assert a 200
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same discussion, months apart :) #1023 (comment)
// assert cannot withdraw amount greater than the available balance | ||
let outcome = parse_response::<TransactionId>( | ||
rpc_ref | ||
.withdraw( | ||
gw_password.clone(), | ||
WithdrawPayload { | ||
federation_id: fid.clone(), | ||
amount: bitcoin::Amount::from_sat(amount_sats.clone() + 1), | ||
address: bitcoin.get_new_address().await, | ||
}, | ||
) | ||
.await | ||
.map_err(|e| anyhow::anyhow!(e)) | ||
.unwrap(), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
assert_eq!(outcome.0, 200); | ||
assert!(outcome.1.is_some()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I would expect that we get some error or similar that the amount we want to withdrawal is too big?
Basically, these assert make sure that the call to withdraw
was successful and then we ensure below by calling get_balance
that nothing was withdrawn, right?
I'm not sure if we can design the API slightly different, so that the call to withdraw
already lets us know that it's not possible to withdraw that amount (I'm missing a bit of context here. didn't dig into it).
edit: ok, I think I fundamentally do not understand something. We do a withdraw
that is too large here and we get back a Some(TransactionId)
in outcome.1
. In line 367 we withdraw a permitted amount (everything that the gateway has) and we assert that outcome.1.is_none()
, so no TransactionId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revisiting these proposals.
In order to give the best attention to each test case, I will first propose the test suite and then fill in the test cases one-by-one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so I deferred the test implementation themselves. Following up with those. With consideration for the review above
What is our strategy for merging this? Perhaps it would be best to just move the existing tests to the new crate, and then add new tests in follow-up commits? |
How about the reverse strategy: add new non-overlapping tests so we have more coverage, and then move the existing tests over? IMO this is preferable because the existing tests don't exercise the public API surface of gatewayd. Moving them over will include a considerable rewrite. |
Works for me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good as a first step. I'd aim for an optional mock / real mode like with our existing tests.
Often you find bugs in real mode you wouldn't with mocks, but you don't want to run it while developing.
Proposes an integration test suite for gatewayd.
To start with, tests are only run with mocks of dependencies like
ILnRpcClient
andIFederationApi
.In it's full extent, this proposal would involve sharing the following from fedimint-testing crate:
Gateway would then own it's own integration tests where it uses real or fake fixtures in validating it's functionality in serving one or more federations
towards #742