Repository navigation
Fix four AccountService bugs found in bug hunt (each with a failing test) - #383
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…n-user exception in AccountService Co-Authored-By: Grace Juan <grace.juan@cognition.ai>
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug hunt on
bug-hunt-demo. Each bug is proven by a test in the newAccountServiceTest(Mockito unit tests). All 9 tests fail on the base branch and pass with this change../mvnw clean testpasses: 10 tests, 0 failures.hasSufficientFundsusedcompareTo(amount) > 0, but its doc says "at least". Withdrawing or transferring the exact balance failed with "Insufficient funds".hasSufficientFundsIsTrueWhenBalanceEqualsAmount,withdrawingTheFullBalanceSucceeds,transferringTheFullBalanceSucceeds> 0→>= 0getTransactionHistory(account, from, to)usedend = to.atStartOfDay()with an exclusive bound, but the doc says "both days inclusive". Thetoday was dropped, so a single-day range always returned[].dateRangeHistoryIncludesTransactionsOnTheEndDay,singleDayRangeReturnsThatDaysTransactionsend = to.plusDays(1).atStartOfDay()withdraw(-50)increased the balance,transferAmount(..., -200)took money from the recipient, anddeposit(-50)reduced the balance.negativeWithdrawalIsRejectedAndDoesNotIncreaseBalance,negativeTransferIsRejectedAndDoesNotTakeRecipientFunds,negativeDepositIsRejectedAndDoesNotDecreaseBalancerequireNonNegative(amount)guard in all three methods./depositnow catches the error and shows it on the dashboard, the same way/withdrawand/transferalready do (before, it would have returned a 500).loadUserByUsernamethrew a plainRuntimeExceptionfor unknown users, but theUserDetailsServicecontract requiresUsernameNotFoundException. Theaccount == nullcheck never ran.loadUserByUsernameThrowsUsernameNotFoundForUnknownUserfindByUsername(...).orElseThrow(() -> new UsernameNotFoundException(...))Dropped suspect: a self-transfer creating money. With Spring's open-in-view on, both sides of the transfer are the same entity during a web request, so I could not show it as a real bug.
Note: zero amounts are still allowed. No test covered them, so their behavior is unchanged.
Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/76f92a851e5b4ac1b58b539be0350cf5
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/76f92a851e5b4ac1b58b539be0350cf5?variant=devin
Requested by: @gracejuan-star
Note
Devin errored when opening this Pull Request as gracejuan-star.
As a fallback, Devin opened this PR as itself.