-
Notifications
You must be signed in to change notification settings - Fork 19
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
Cleanup integration tests #757
Conversation
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.
LGTM, except oddly there is a failing test 🤔
Failing test should be fixed in e62843d. Timing between test runner ( provider.getCurrentTime() ) and nodes ( clock.now ) was sometimes off by more than 10 seconds, failing the test. I ran the test 100x, and it succeeded all the time. |
3d07bbe
to
e62843d
Compare
e62843d
to
48091c0
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.
LGTM
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.
What are your thoughts on moving some of these tests over from twonodesuite
to marketplacesuite
?
To ensure that tests involving multiple nodes do not start with out-of-sync clocks
eceb914
to
69fd071
Compare
I would say that that would be part of the work in #746, but not for this PR. |
The intermittently failing test should be fixed in 97a57a1. The test would fail when the storage request was cancelled while a proof was being generated. The async state machine would then cancel the proving state, which triggers a chronos cancellation of future that calculates the proof. But the code that calculates the proof would catch and ignore the CancelledError (by catching all CatchableErrors). This pattern of catching CatchableError and not dealing with CancelledError properly happens in more places in the codebase. I tried to fix them all. |
Right ok, this is a great catch! Just to clarify, you mean the |
No, if I remember correctly it was in the proving state. It had already filled the slot, but the other slots in the contract do not get filled, so eventually the contract is cancelled. This is also why the test was failing intermittently; the odds of it having to provide a proof at the same time that the storage contract expires is small. |
@@ -244,7 +246,8 @@ proc rpcHandler( | |||
|
|||
if payment =? SignedState.init(msg.payment): | |||
asyncSpawn b.handlePayment(peer, payment) | |||
|
|||
except CancelledError as error: |
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.
If we're going to asyncSpawn handlePayment
, there is no point in try/catch
around it. Any escaping exception is converted to a Defect
by asyncSpawn
.
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.
Good point, I have no idea why the error handling was here in the first place. I just added the extra case for CancelledError
, but in the current code everything is asyncSpawn
ed, and no errors will be raised anyway.
@@ -72,6 +74,8 @@ proc broadcast*(b: NetworkPeer, msg: Message) = | |||
proc sendAwaiter() {.async.} = | |||
try: | |||
await b.send(msg) | |||
except CancelledError as error: | |||
raise error |
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.
Don't re-raise in a proc that is asyncSpawn
it will be terminate the application because it is converted to a Defect
. Anything that is asyncSpawn
should not raise exceptions.
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.
Good catch, I misread the except
as being part of broadcast
instead of sendAwaiter
.
By the way, it seems that broadcast
is unused? Should we remove it?
@@ -90,6 +90,8 @@ proc new*( | |||
res += await stream.readOnce(addr data[res], len - res) | |||
except LPStreamEOFError as exc: | |||
trace "LPStreamChunker stream Eof", exc = exc.msg | |||
except CancelledError as error: | |||
raise error | |||
except CatchableError as exc: | |||
trace "CatchableError exception", exc = exc.msg | |||
raise newException(Defect, exc.msg) |
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.
Not sure why we're converting this to a Defect
, should maybe be simply re-raised?
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.
No idea either, I just left that part alone.
No Exceptions can occur, only Defects, because everything is asyncSpawned. Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
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.
Great catch! LGTM 👍
Moves the tests from the venerable
testIntegration.nim
into several new test modules.testrestapi.nim
: tests that exercise and test the REST APItestupdownload.nim
: tests that exercise uploading and downloading contenttestpurchasing.nim
: tests for buying storagetestsales.nim
: tests for selling storagetestmarketplace.nim
: tests that exercise a combination of buying and selling storagePart of #746