Skip to content

Commit

Permalink
change integration scenario to always allow redeeming from self
Browse files Browse the repository at this point in the history
  This makes it a lot easier for clients to deal with rewards. One can always give 'self' and simply let the backend decides whether or not rewards should be redeemed. For external wallets however, it could be quite counter-intuitive to succeed in the case there are no rewards in the target wallet so we still error in that case.
  • Loading branch information
KtorZ committed Aug 4, 2020
1 parent 204a59b commit 728ab75
Showing 1 changed file with 23 additions and 3 deletions.
Expand Up @@ -1323,7 +1323,7 @@ spec = do
(.> (wSelf ^. #balance . #getApiT . #available))
]

it "SHELLEY_TX_REDEEM_03 - Can't redeem rewards if none left" $ \ctx -> do
it "SHELLEY_TX_REDEEM_03 - Can't redeem rewards from other if none left" $ \ctx -> do
(wOther, mw) <- rewardWallet ctx
wSelf <- fixtureWallet ctx
addr:_ <- fmap (view #id) <$> listAddresses @n ctx wSelf
Expand Down Expand Up @@ -1356,7 +1356,27 @@ spec = do
, expectErrorMessage errMsg403WithdrawalNotWorth
]

it "SHELLEY_TX_REDEEM_04 - Can't redeem rewards from unknown key" $ \ctx -> do
it "SHELLEY_TX_REDEEM_04 - Can always ask for self redemption" $ \ctx -> do
wSelf <- fixtureWallet ctx
addr:_ <- fmap (view #id) <$> listAddresses @n ctx wSelf

let payload = Json [json|{
"withdrawal": "self",
"payments": [{
"address": #{addr},
"amount": { "quantity": 1, "unit": "lovelace" }
}],
"passphrase": #{fixturePassphrase}
}|]

rTx <- request @(ApiTransaction n) ctx
(Link.createTransaction @'Shelley wSelf) Default payload
verify rTx
[ expectResponseCode HTTP.status202
, expectField #withdrawals (`shouldSatisfy` null)
]

it "SHELLEY_TX_REDEEM_05 - Can't redeem rewards from unknown key" $ \ctx -> do
wSelf <- fixtureWallet ctx
addr:_ <- fmap (view #id) <$> listAddresses @n ctx wSelf

Expand All @@ -1377,7 +1397,7 @@ spec = do
, expectErrorMessage errMsg403WithdrawalNotWorth
]

it "SHELLEY_TX_REDEEM_05 - Can't redeem rewards using byron wallet" $ \ctx -> do
it "SHELLEY_TX_REDEEM_06 - Can't redeem rewards using byron wallet" $ \ctx -> do
(wSelf, addrs) <- fixtureIcarusWalletAddrs @n ctx
let addr = encodeAddress @n (head addrs)

Expand Down

0 comments on commit 728ab75

Please sign in to comment.