From 8063a13eb8e719f162fc12d52ee4b4bd9dec432d Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Tue, 22 Aug 2023 14:04:24 +0200 Subject: [PATCH] integration test - part 1 --- .../Scenario/API/Shelley/TransactionsNew.hs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index 94e82cb1632..837ae9a2bcb 100644 --- a/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -1148,6 +1148,49 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do , expectErrorMessage errMsg403NotEnoughMoney ] + it "TRANS_NEW_ASSETS_CREATE_02 - using reference script" $ \ctx -> runResourceT $ do + + let initialAmt = 3 * minUTxOValue (_mainEra ctx) + wa <- fixtureWalletWith @n ctx [initialAmt] + wb <- emptyWallet ctx + let amt = (minUTxOValue (_mainEra ctx) :: Natural) + + let policyWithHash = Link.getPolicyKey @'Shelley wa (Just True) + (_, policyKeyHashPayload) <- + unsafeRequest @ApiPolicyKey ctx policyWithHash Empty + let (Just policyKeyHash) = + keyHashFromBytes (Policy, getApiPolicyKey policyKeyHashPayload) + let _scriptUsed = RequireAllOf + [ RequireSignatureOf policyKeyHash + ] + + addrs <- listAddresses @n ctx wb + let destination = (addrs !! 1) ^. #id + let payload = Json [json|{ + "reference_policy_script_template": + { "all": [ "cosigner#0" ] }, + "payments": [{ + "address": #{destination}, + "amount": { + "quantity": #{amt}, + "unit": "lovelace" + } + }] + }|] + + let expectedCreateTx = + [ expectSuccess + , expectResponseCode HTTP.status202 + , expectField (#coinSelection . #inputs) (`shouldSatisfy` (not . null)) + , expectField (#coinSelection . #outputs) (`shouldSatisfy` (not . null)) + , expectField (#coinSelection . #change) (`shouldSatisfy` (not . null)) + , expectField (#fee . #getQuantity) (`shouldSatisfy` (> 0)) + ] + + rTx <- request @(ApiConstructTransaction n) ctx + (Link.createUnsignedTransaction @'Shelley wa) Default payload + verify rTx expectedCreateTx + it "TRANS_NEW_VALIDITY_INTERVAL_01a - \ \Validity interval with second" $ \ctx -> runResourceT $ do