Skip to content
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

Connection manager replacement #573

Merged

Conversation

manuelwedler
Copy link
Contributor

@manuelwedler manuelwedler commented Nov 19, 2020

closes #547, closes #252

@codecov
Copy link

codecov bot commented Nov 19, 2020

Codecov Report

Merging #573 (9589332) into master (c0831bb) will decrease coverage by 0.11%.
The diff coverage is 96.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #573      +/-   ##
==========================================
- Coverage   95.87%   95.76%   -0.12%     
==========================================
  Files          87       88       +1     
  Lines        1988     2196     +208     
  Branches      276      305      +29     
==========================================
+ Hits         1906     2103     +197     
- Misses         45       51       +6     
- Partials       37       42       +5     
Impacted Files Coverage Δ
src/app/app.component.ts 96.10% <ø> (ø)
.../components/channel-list/channel-list.component.ts 95.52% <ø> (-0.07%) ⬇️
src/app/components/channel/channel.component.ts 100.00% <ø> (ø)
.../components/contact-list/contact-list.component.ts 95.18% <ø> (ø)
...ntact/contact-actions/contact-actions.component.ts 95.83% <ø> (-0.09%) ⬇️
src/app/components/header/header.component.ts 100.00% <ø> (ø)
.../material-components/material-components.module.ts 100.00% <ø> (ø)
...rc/app/modules/raiden-icons/raiden-icons.module.ts 100.00% <ø> (ø)
src/app/utils/network-info.ts 100.00% <ø> (ø)
...pp/components/open-dialog/open-dialog.component.ts 91.66% <71.42%> (-8.34%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c0831bb...f2ff5f9. Read the comment docs.

ngOnInit() {}
ngOnInit() {
this.form.controls.token.valueChanges
.pipe(takeUntil(this.ngUnsubscribe))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: this takeUntil(subject) is a little bit weird, if the subject is created only for cleanup. A more streamlined way would be to save subscriptions, and then .add multiple if needed and .unsubscribe() at the end. If you do that because you need complete callbacks for cleanup, check the finalize operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had some problem in tests with the old add() - unsubscribe() pattern. I don't remember the exact reason, but was something about the mocked observables. That's why I moved to the takeUntil() approach. Seems also to be recommended for Angular: https://stackoverflow.com/questions/38008334/angular-rxjs-when-should-i-unsubscribe-from-subscription

}

ngOnInit(): void {
this.subscribeToSuggestions();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: private methods with internal, explicit subscriptions aren't usually the recommended way to do that in Angular. Maybe you could just initialize private cold observables, possibly shared, and then use | async on template, which does handle subscriptions automatically. Declarative is usually better than imperative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes totally sense! I like it your way better. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't make it because there were too many changes needed in the tests. Not worth the effort.

@@ -1,7 +1,7 @@
import BigNumber from 'bignumber.js';

export function losslessParse(json: string): any {
const numberRegex = /^\d+$/;
const numberRegex = /^\d+(\.\d+)?$/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This losslessParse may work only if the BNs are stringified on the JSONs (since this revive function from JSON.parse is called only after the number already got parsed as such), while it seems the current PFS implementation encodes the capacity and other BNs as JSON number. This may only be working now if the numbers on your test were small (i.e. < 2^53).
We had this issue on the LC, and ended up using json-bigint lib to parse these JSONs. Check here for our implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice you need to use a proper decoder/schema validator if you go the way we did, since it'll ensure these values are kept as strings, or use it with your reviver function after using the lib to ensure the BNs are kept as strings or bigint or whatever.. We already had the schemas in place, so went with it, but you can use the reviver as well if you don't care that much with the typesafety there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we don't use the numbers from the PFS API, I won't fix it now. I have put it into this issue: #578
Thanks for finding this!

let notificationIdentifier: number;
let errorCount = 0;

return of(null).pipe(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: you could replace of(constant)+tap with a defer call, if it's just to ensure a function is called at subscription time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I didn't know about it.

Copy link
Contributor

@andrevmatos andrevmatos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some nitpicks here and there, but this is just too big to review line-by-line. Anyway, seems solid to me, UX on specific edge cases like the slider distributor may only be possible to be tested manually, but if it's good for you, it LGTM. Thank you for this, huge but important feature done.

@manuelwedler manuelwedler merged commit 354d975 into raiden-network:master Dec 2, 2020
@manuelwedler manuelwedler deleted the connection-manager-replacement branch December 2, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add simple replacement for connection manager Quick connect inform user and avoid timeout
2 participants