-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Internal improvement: refactor connectOrStart #4671
Conversation
53aeb32
to
4c92148
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.
Seems basically good to me, confused about something in .eslintrc.json
though.
This PR continues to be dogged by some race condition(s) that prevents CI from logging completed steps. What a PITA. Cancelling the job forces a flush, it seems.
Ah, this PR's tests pass, but did it break another test? 🤔
|
So, wait, is this working now, or was that just luck? |
Hard to tell @haltman-at. I'm going to wait on the fix to Ganache-2185 as it seems to be relevant during my investigation. |
Yep, definitely lucky the last time. I re-ran CI and it failed unable to shut down Ganache, killing the test-runner that needed to be manually cancelled.
|
2c713aa
to
72fb420
Compare
72fb420
to
16d4633
Compare
Oh hey a quick note, the |
16d4633
to
787a595
Compare
Good catch! rebasing. |
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.
Seems mostly good to me (as best I can understand anyway); just two questions about the tests.
}); | ||
|
||
it("Environment.develop overwrites the network_id of the network", async function() { | ||
it("Environment.develop overwrites the network_id of the network", async function () { | ||
sinon.stub(Environment, "detect"); |
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.
I'm confused why this is being stubbed... what is this for?
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.
Environment.develop()
invokes Environment.detect()
as its final step, which isn't needed to validate the test's assertion. I'll add a clarifying comment and leave potential refactoring for followup work.
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.
Oh, huh, OK. Odd use and I'd suggest getting rid of it, but I guess it's OK to put that off?
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.
This is one of those things that touches TruffleConfig's side-effect behavior. There are a bunch of methods in Environment
that modify TruffleConfig
:/ . A code smell to be addressed later.
This function [1] changed and returns a promise and does not accept a callback. 1: https://github.com/trufflesuite/ganache/blob/d5c3bcbcf2198d2664bd9bfafd331d80994afc7f/src/packages/core/src/server.ts#L272
Test to validate code path to connect to an established Ganache server, or no Ganache server.
- remove catch - add messages to assertions
set instead of invoking , which forces the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to process.stdout and process.stderr.
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.
lookin good
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.
OK, looks good to me!
This PR
server.close()
method, which uses a promise instead of node's callback idiom. We should tear down Ganache properly.connectOrStart
connectOfStart
try/catch logic path.