Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixes add funds dialog #12154

Merged
merged 2 commits into from
Dec 5, 2017
Merged

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Dec 1, 2017

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Resolves #12078

Auditors:

also added unit test for it

Test Plan:

steps based on comment: #12078 (comment)

  1. Clean profile
  2. start browser with staging server
LEDGER_ENVIRONMENT=staging npm run start
  1. Enable payments
  2. Visit some sites so that you have a few ledger entries showing on the Payments tab
  3. Fund wallet (ex: claim UGP grant)
  4. Close Brave
  5. Update reconcileStamp in ledger-state.json to the epoch for now (or a time in the past). (This site is handy for conversions)
  6. Launch Brave again using
LEDGER_NO_FUZZING=true LEDGER_VERBOSE=true LEDGER_ENVIRONMENT=staging npm run start
  1. Wait for contribution to be made
  2. "Needs deposit" notice should NOT show

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@NejcZdovc NejcZdovc self-assigned this Dec 1, 2017
@NejcZdovc NejcZdovc requested a review from bsclifton December 1, 2017 07:54
@codecov-io
Copy link

codecov-io commented Dec 1, 2017

Codecov Report

Merging #12154 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master   #12154      +/-   ##
==========================================
- Coverage      55%   54.99%   -0.01%     
==========================================
  Files         275      275              
  Lines       26569    26563       -6     
  Branches     4273     4277       +4     
==========================================
- Hits        14613    14608       -5     
+ Misses      11956    11955       -1
Flag Coverage Δ
#unittest 54.99% <100%> (-0.01%) ⬇️
Impacted Files Coverage Δ
app/browser/api/ledgerNotifications.js 74.56% <100%> (+1.63%) ⬆️
app/common/lib/ledgerUtil.js 97.1% <100%> (+2.76%) ⬆️
js/stores/appStoreRenderer.js 91.17% <0%> (-8.83%) ⬇️
app/renderer/components/reduxComponent.js 84.37% <0%> (-6.25%) ⬇️
js/stores/windowStore.js 26.71% <0%> (-0.3%) ⬇️

@NejcZdovc NejcZdovc force-pushed the hotfix/#12078-funds branch 2 times, most recently from 02fd0e6 to 5d306aa Compare December 1, 2017 08:26
@bsclifton bsclifton changed the title Fixes add founds dialog Fixes add funds dialog Dec 1, 2017
const bat = ledgerState.getInfoProp(state, 'bat')
return bat && (balance + unconfirmed > 0.9 * Number(bat))
const budget = parseInt(getSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT), 10) || 25
return balance + unconfirmed >= budget
Copy link
Member

Choose a reason for hiding this comment

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

The prior code that does getInfoProp(state, 'bat')... but I'm not seeing anything which sets this. I think the field name must have been updated from bat to converted at some point.

Why this is important: because ledgerUtil does something similar (in fact, maybe this code can be moved to ledgerUtil?):

if (pendingFunds + Number(ledgerData.get('balance') || 0) <
0.9 * Number(ledgerData.get('bat') || 0)) {
status.id = 'insufficientFundsStatus'

The code in ledgerUtil may have a problem too if nothing is setting this value

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 need to fix this line as well, we don't have bat anymore

Copy link
Member

Choose a reason for hiding this comment

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

@NejcZdovc OK great- did you want to do that here also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah will fix it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, @bsclifton please re-review

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

comment left - tests all look good; just want to make sure similar code in ledgerUtil is handled the same

NejcZdovc and others added 2 commits December 4, 2017 23:47
Resolves brave#12078

Auditors:

Test Plan:
…le testing)

Manually tested (and updated test plan in PR). Works great! :)

Auditors: @NejcZdovc
@bsclifton bsclifton force-pushed the hotfix/#12078-funds branch from 10f4d8d to c1ea5ba Compare December 5, 2017 06:48
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Thanks for updating the 2nd case! I just finished manually testing and it works great 😄 👍

Please note: I did bump the version of bat-client so that we can use the new LEDGER_NO_FUZZING parameter for testing.

@bsclifton bsclifton merged commit 8c3ef5e into brave:master Dec 5, 2017
bsclifton added a commit that referenced this pull request Dec 5, 2017
bsclifton added a commit that referenced this pull request Dec 5, 2017
bsclifton added a commit that referenced this pull request Dec 5, 2017
@bsclifton
Copy link
Member

master 8c3ef5e
0.21.x 9a3ced4
0.20.x 893bfa4
0.19.x 7394478

@srirambv
Copy link
Collaborator

srirambv commented Dec 5, 2017

Works on Windows. No Waiting for a deposit notification shown.

@bsclifton bsclifton modified the milestones: 0.19.x Hotfix 7 (Release channel), 0.19.x + C63 (Release Channel) Dec 7, 2017
@bsclifton bsclifton modified the milestones: 0.19.x + C63 (Release Channel), 0.19.x Private Search Dec 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants