-
Notifications
You must be signed in to change notification settings - Fork 220
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
Undelegate with existing rewards #3119
Undelegate with existing rewards #3119
Conversation
4cef1e8
to
9ec842c
Compare
what about adding :
to both StakePools and TransactionNew tests? |
Currently fails with: src/Test/Integration/Scenario/API/Shelley/StakePools.hs:537:15: 1) API Specifications, SHELLEY_STAKE_POOLS, STAKE_POOLS_QUIT_xx - Can quit with rewards expected: Status {statusCode = 202, statusMessage = "Accepted"} but got: Status {statusCode = 403, statusMessage = "Forbidden"} from the following response: Left (DecodeFailure "Error in $: parsing Cardano.Wallet.Api.Types.ApiTransaction(ApiTransaction) failed, key \"id\" not found: Response {responseStatus = Status {statusCode = 403, statusMessage = \"Forbidden\"}, responseVersion = HTTP/1.1, responseHeaders = [(\"Transfer-Encoding\",\"chunked\"),(\"Date\",\"Fri, 06 Aug 2021 13:21:52 GMT\"),(\"Server\",\"Warp/3.3.17\"),(\"Content-Type\",\"application/json;charset=utf-8\")], responseBody = \"{\\\"code\\\":\\\"non_null_rewards\\\",\\\"message\\\":\\\"It seems that you're trying to retire from delegation although you've unspoiled rewards in your rewards account! Make sure to withdraw your 1000000000000 lovelace first.\\\"}\", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}") While verifying value: ( Status { statusCode = 403 , statusMessage = "Forbidden" } , Left ( DecodeFailure "Error in $: parsing Cardano.Wallet.Api.Types.ApiTransaction(ApiTransaction) failed, key "id" not found: Response {responseStatus = Status {statusCode = 403, statusMessage = "Forbidden"}, responseVersion = HTTP/1.1, responseHeaders = [("Transfer-Encoding","chunked"),("Date","Fri, 06 Aug 2021 13:21:52 GMT"),("Server","Warp/3.3.17"),("Content-Type","application/json;charset=utf-8")], responseBody = "{\"code\":\"non_null_rewards\",\"message\":\"It seems that you're trying to retire from delegation although you've unspoiled rewards in your rewards account! Make sure to withdraw your 1000000000000 lovelace first.\"}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}" ))
9ec842c
to
c1aa000
Compare
@paweljakubas Done, and I found something interesting:
I pushed a fix to the |
WithdrawalSelf {} -> return () | ||
_ | ||
| rewards == Coin 0 -> return () | ||
| otherwise -> Left $ ErrNonNullRewards rewards |
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.
👍
let unsignedTx2 = getFromResponse #transaction rUnsignedTx2 | ||
verify rUnsignedTx2 | ||
[ expectField (#coinSelection . #depositsReturned) | ||
(`shouldBe` [Quantity 1000000]) |
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.
👍
ctx (Link.listStakePools arbitraryStake) Empty | ||
joinStakePool @n ctx pool (w, fixturePassphrase) >>= flip verify | ||
[ expectResponseCode HTTP.status202 | ||
, expectField #depositTaken (`shouldBe` (Quantity 0)) |
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.
hmm, shouldn't this be Quantity depositAmt
?
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 the fixture rewardWallet
s which already have registered stake keys. Added a comment to the other test, but can add one here as well.
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.
aha, ok. so this is shelley wallet with gathered some rewards 👍 (---> rewardWallet
rather than fixtureWallet
). And we do it in order not to wait. Then here we are really rejoining.
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, I was expecting the flow more like in suite STAKE_POOLS_JOIN_04 - Rewards accumulate
BTW. you need to correct there :
652 -- Can't quite if unspoiled rewards.
653 quitStakePool @n ctx (w, fixturePassphrase) >>= flip verify
654 [ expectResponseCode HTTP.status403
655 , expectErrorMessage errMsg403NonNullReward
656 ]
No anymore valid after your change.
depositValue | ||
else | ||
0 | ||
| otherwise = 0 | ||
|
||
totalInWithoutFee :: Natural |
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.
indeed, this was redundant if we take into account withdrawals 👍 And the name was misleading
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.
now thinking about this. we want to detect quitting and receiving deposit back. Shouldn't we have instead totalIn
totalInWithoutWdrl
= sum (txOutValue <$> mapMaybe snd (tx ^. #txInputs))
in the end? We are not after detecting direction here
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.
all test passes, so you are right 😅
@@ -459,8 +462,12 @@ prop_guardQuitJoin (NonEmpty knownPoolsList) dlg rewards = | |||
knownPools dlg (last knownPoolsList) noRetirementPlanned | |||
=== Right () | |||
Left W.ErrNonNullRewards{} -> | |||
label "ErrNonNullRewards" | |||
(property $ rewards /= 0) | |||
label "ErrNonNullRewards" $ |
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.
💯
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.
LGTM, except https://github.com/input-output-hk/cardano-wallet/pull/3119/files#r804961464
It is not forbidden anymore. I was expecting the flow more like in STAKE_POOLS_JOIN_04 - Rewards accumulate
but you used rewardWallet
. Kinda surprised here. I understand we have wallet with rewards, but still at first I thought when joining I will see depositTaken > 0. Of course, we cannot deregister stake credential without taking rewards home, so when we have rewards to be taken it implies we are staking ...
I checked locally
stack test --ta '-m "TRANS_NEW"' cardano-wallet:integration OK
stack test --ta '-m "STAKE_POOLS"' cardano-wallet:integration only STAKE_POOLS_JOIN_04 - Rewards accumulate fails for the obvious reason
bors try |
tryBuild succeeded: |
Old workflow:
New workflow (constructTransaction):
ErrNonNullRewards
if"withdrawal": "self"
is set when quittingComments
cabal v2-test cardano-wallet:integration --test-option=-j --test-option="10" --test-option="--match" --test-option "quit with rewards"
Before fix
After fixes:
Issue Number
ADP-1067