Skip to content

Commit

Permalink
integration tests 1
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Apr 25, 2024
1 parent 98be543 commit 42958ba
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Cardano.Wallet.Api.Types
, ApiConstructTransaction (..)
, ApiDecodedTransaction
, ApiDeregisterPool (..)
, ApiEncryptMetadata (..)
, ApiEra (..)
, ApiExternalCertificate (..)
, ApiNetworkInformation
Expand Down Expand Up @@ -114,6 +115,10 @@ import Cardano.Wallet.Api.Types.Error
( ApiErrorInfo (..)
, ApiErrorTxOutputLovelaceInsufficient (ApiErrorTxOutputLovelaceInsufficient)
)
import Cardano.Wallet.Api.Types.SchemaMetadata
( TxMetadataSchema (..)
, TxMetadataWithSchema (..)
)
import Cardano.Wallet.Api.Types.Transaction
( ApiAddress (..)
, ApiValidityIntervalExplicit (..)
Expand All @@ -137,6 +142,9 @@ import Cardano.Wallet.Pools
import Cardano.Wallet.Primitive.NetworkId
( HasSNetworkId
)
import Cardano.Wallet.Primitive.Passphrase
( Passphrase (..)
)
import Cardano.Wallet.Primitive.Types
( EpochNo (..)
, NonWalletCertificate (..)
Expand Down Expand Up @@ -538,6 +546,30 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
(`shouldBe` (fromIntegral oneMillionAda - expectedFee))
]

it "TRANS_NEW_CREATE_02c - Incorrect metadata structure to be encrypted" $
\ctx -> runResourceT $ do
let metadataRaw =
TxMetadata (Map.fromList
[ (0,TxMetaText "hello")
, (1,TxMetaMap [(TxMetaText "hello", TxMetaText "world")])
, (50, TxMetaNumber 1245)
])
wa <- fixtureWallet ctx
let metadataToBeEncrypted =
TxMetadataWithSchema TxMetadataNoSchema metadataRaw
let encryptMetadata =
ApiEncryptMetadata (ApiT $ Passphrase "metadata-secret") Nothing
let payload = Json [json|{
"encrypt_metadata": #{toJSON encryptMetadata},
"metadata": #{toJSON metadataToBeEncrypted}
}|]
rTx <- request @(ApiConstructTransaction n) ctx
(Link.createUnsignedTransaction @'Shelley wa) Default payload
verify rTx
[ expectResponseCode HTTP.status403
]
decodeErrorInfo rTx `shouldBe` InvalidMetadataEncryption

it "TRANS_NEW_CREATE_03a - Withdrawal from self, 0 rewards" $ \ctx -> runResourceT $ do
wa <- fixtureWallet ctx
let initialBalance = wa ^. #balance . #available . #toNatural
Expand Down

0 comments on commit 42958ba

Please sign in to comment.