Skip to content

Commit

Permalink
make active TRANS_NEW_CREATE_04a
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Oct 12, 2021
1 parent aadf833 commit 14827b4
Showing 1 changed file with 27 additions and 4 deletions.
Expand Up @@ -375,7 +375,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do

it "TRANS_NEW_CREATE_04a - Single Output Transaction" $ \ctx -> runResourceT $ do

liftIO $ pendingWith "Missing outputs on response - to be fixed in ADP-985"
--liftIO $ pendingWith "Missing outputs on response - to be fixed in ADP-985"

let initialAmt = 3 * minUTxOValue (_mainEra ctx)
wa <- fixtureWalletWith @n ctx [initialAmt]
Expand All @@ -396,16 +396,39 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
, expectField (#coinSelection . #change) (`shouldSatisfy` (not . null))
, expectField (#fee . #getQuantity) (`shouldBe` feeMin)
]
let expectedFee = getFromResponse (#fee . #getQuantity) rTx

let filterInitialAmt =
filter (\(ApiCoinSelectionInput _ _ _ _ amt' _) -> amt' == Quantity initialAmt)
let coinSelInputs = filterInitialAmt $
getFromResponse (#coinSelection . #inputs) rTx
length coinSelInputs `shouldBe` 1

-- TODO: now we should sign it and send it in two steps
-- make sure it is delivered
-- make sure balance is updated accordingly on src and dst wallets
apiTx <- unsafeGetTx rTx

signedTx <- signTx ctx wa apiTx

void $ submitTx ctx signedTx [ expectResponseCode HTTP.status202 ]

eventually "Source wallet balance is decreased by amt + fee" $ do
rWa <- request @ApiWallet ctx
(Link.getWallet @'Shelley wa) Default Empty
verify rWa
[ expectSuccess
, expectField
(#balance . #available . #getQuantity)
(`shouldBe` initialAmt - (amt + fromIntegral expectedFee))
]

eventually "Target wallet balance is amt" $ do
rWr <- request @ApiWallet ctx
(Link.getWallet @'Shelley wb) Default Empty
verify rWr
[ expectSuccess
, expectField
(#balance . #available . #getQuantity)
(`shouldBe` amt)
]

it "TRANS_NEW_CREATE_04b - Cannot spend less than minUTxOValue" $ \ctx -> runResourceT $ do
wa <- fixtureWallet ctx
Expand Down

0 comments on commit 14827b4

Please sign in to comment.