-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add network change events #1336
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
3b4a484
to
5f810be
Compare
e9fec1b
to
27b0eab
Compare
5f810be
to
38afc7c
Compare
821d791
to
afb95de
Compare
38afc7c
to
c579b1a
Compare
e8fed4e
to
7553660
Compare
c579b1a
to
3126c92
Compare
caf4790
to
afe64b2
Compare
I did originally intend for this PR to include the same coverage as the extension (in that we would ensure the |
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, just had a few minor notes.
const networkWillChange = await waitForPublishedEvents({ | ||
messenger, | ||
eventType: 'NetworkController:networkWillChange', | ||
operation: () => { | ||
// Intentionally not awaited because we're capturing an event | ||
// emitted partway through the operation | ||
controller.rollbackToPreviousProvider(); | ||
}, | ||
}); | ||
|
||
expect(networkWillChange).toStrictEqual([[]]); |
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.
Nit: In a previous commit I added a toBeFulfilled
matcher to make some of the existing tests in this repo more clear. Since the payload of the published event doesn't matter, I wonder if that matcher would be useful here too?
const networkWillChange = await waitForPublishedEvents({ | |
messenger, | |
eventType: 'NetworkController:networkWillChange', | |
operation: () => { | |
// Intentionally not awaited because we're capturing an event | |
// emitted partway through the operation | |
controller.rollbackToPreviousProvider(); | |
}, | |
}); | |
expect(networkWillChange).toStrictEqual([[]]); | |
const promiseForNetworkWillChange = waitForPublishedEvents({ | |
messenger, | |
eventType: 'NetworkController:networkWillChange', | |
operation: () => { | |
// Intentionally not awaited because we're capturing an event | |
// emitted partway through the operation | |
controller.rollbackToPreviousProvider(); | |
}, | |
}); | |
expect(promiseForNetworkWillChange).toBeFulfilled(); |
Similar for the other tests.
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 idea! I might handle this in a follow-up PR though, since it applies to a lot of tests not covered in this PR
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.
Done here: #1347
The network controller now emits the events `networkWillChange` and `networkDidChange` when the network is being refreshed. The event `networkWillChange` is emitted before the switch begins (before the network status is cleared), and the `networkDidChange` event is emitted after the new provider is setup (but before it has finished initializing). Closes #1210
afe64b2
to
5ed561a
Compare
The `toBeFulfilled` matcher is now used for any network controller test where we want to ensure a promise is resolved, but we don't care about the value. This is a follow-up to a suggestion made in #1336
The `toBeFulfilled` matcher is now used for any network controller test where we want to ensure a promise is resolved, but we don't care about the value. This is a follow-up to a suggestion made in #1336
The `toBeFulfilled` matcher is now used for any network controller test where we want to ensure a promise is resolved, but we don't care about the value. This is a follow-up to a suggestion made in #1336
The network controller now emits the events `networkWillChange` and `networkDidChange` when the network is being refreshed. The event `networkWillChange` is emitted before the switch begins (before the network status is cleared), and the `networkDidChange` event is emitted after the new provider is setup (but before it has finished initializing). Closes #1210
The `toBeFulfilled` matcher is now used for any network controller test where we want to ensure a promise is resolved, but we don't care about the value. This is a follow-up to a suggestion made in #1336
The network controller now emits the events `networkWillChange` and `networkDidChange` when the network is being refreshed. The event `networkWillChange` is emitted before the switch begins (before the network status is cleared), and the `networkDidChange` event is emitted after the new provider is setup (but before it has finished initializing). Closes #1210
The `toBeFulfilled` matcher is now used for any network controller test where we want to ensure a promise is resolved, but we don't care about the value. This is a follow-up to a suggestion made in #1336
Description
The network controller now emits the events
networkWillChange
andnetworkDidChange
when the network is being refreshed. The eventnetworkWillChange
is emitted before the switch begins (before the network status is cleared), and thenetworkDidChange
event is emitted after the new provider is setup (but before it has finished initializing).Changes
networkWillChange
andnetworkDidChange
are emitted duringsetProviderType
,setActiveNetwork
,resetConnection
, androllbackToPreviousProvider
networkWillChange
event is emitted before the network is switched (before the network status is cleared),networkDidChange
event is emitted after the new provider is setup (but before it has finished initializing).References
Closes #1210
Checklist