Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed Jan 21, 2025
1 parent 6778cb9 commit 99ad073
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/base/lib/Convex/BuildTx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ payToScriptHash network script datum stakeAddress vl =
inAlonzo @era $
let val = mkTxOutValue vl
addr = C.makeShelleyAddressInEra C.shelleyBasedEra network (C.PaymentCredentialByScript script) stakeAddress
dat = C.TxOutDatumInline C.babbageBasedEra datum
dat = C.TxOutDatumHash C.alonzoBasedEra (C.hashScriptDataBytes datum)
txo = C.TxOut addr val dat C.ReferenceScriptNone
in addOutput txo

Expand Down
14 changes: 4 additions & 10 deletions src/coin-selection/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ checkResolveDatumHash = do

assertDatumPresent datum1

-- 2. resolve a datum that was provided as a "TxOutDatumInTx" (this is what 'payToScriptDatumHash' does)
let d2 = (11 :: Integer, 12 :: Integer)
datum2 = C.unsafeHashableScriptData $ C.fromPlutusData $ PV2.toData d2
_ <- tryExecBuildTxWallet Wallet.w1 (payToScriptDatumHash Defaults.networkId (plutusScript txInscript) d2 C.NoStakeAddress mempty)
assertDatumPresent datum2

-- 3. resolve a datum that was provided by a redeeming transaction
let d3 = 500 :: Integer
datum3 = C.unsafeHashableScriptData $ C.fromPlutusData $ PV2.toData d3
Expand Down Expand Up @@ -401,17 +395,17 @@ buildTxMixedInputs = mockchainSucceeds $ failOnError $ do
largeTransactionTest :: Assertion
largeTransactionTest = do
let largeDatum :: [Integer] = replicate 10_000 33
largeDatumTx = execBuildTxWallet Wallet.w1 (payToScriptDatumHash Defaults.networkId (plutusScript txInscript) largeDatum C.NoStakeAddress mempty)
largeDatumTx = execBuildTxWallet Wallet.w1 (BuildTx.payToScriptInlineDatum Defaults.networkId (C.hashScript $ plutusScript txInscript) largeDatum C.NoStakeAddress mempty)

-- tx fails with default parameters
runMockchain0IOWith Wallet.initialUTxOs Defaults.nodeParams (failOnError largeDatumTx) >>= \case
(_, view failedTransactions -> [(_, err)]) -> case err of
ApplyTxFailure (ApplyTxError (Rules.ConwayUtxowFailure (Rules.UtxoFailure (Rules.MaxTxSizeUTxO (Mismatch 20_313 16384))) :| [])) -> pure ()
ApplyTxFailure (ApplyTxError (Rules.ConwayUtxowFailure (Rules.UtxoFailure (Rules.MaxTxSizeUTxO (Mismatch 20_249 16384))) :| [])) -> pure ()
_ -> fail $ "Unexpected failure. Expected 'MaxTxSizeUTxO', found " <> show err
(_, length . view failedTransactions -> numFailed) -> fail $ "Expected one failed transaction, found " <> show numFailed

-- the tx should succeed after setting the max tx size to exactly 20313 (see the error message in the test above)
let params' = Defaults.nodeParams & ledgerProtocolParameters . protocolParameters . Ledger.ppMaxTxSizeL .~ 20_313
-- the tx should succeed after setting the max tx size to exactly 20249 (see the error message in the test above)
let params' = Defaults.nodeParams & ledgerProtocolParameters . protocolParameters . Ledger.ppMaxTxSizeL .~ 20_249
runMockchain0IOWith Wallet.initialUTxOs params' (failOnError largeDatumTx) >>= \case
(Right{}, view failedTransactions -> []) -> pure ()
(_, length . view failedTransactions -> numFailed) -> fail $ "Expected success with 0 failed transactions, found " <> show numFailed
Expand Down
2 changes: 1 addition & 1 deletion src/devnet/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ main = do

checkCardanoNode :: IO ()
checkCardanoNode = do
let expectedVersion = "10.1.1"
let expectedVersion = "10.1.4"
version <- getCardanoNodeVersion
let isExpected = expectedVersion `isInfixOf` version
unless isExpected (putStrLn version)
Expand Down

0 comments on commit 99ad073

Please sign in to comment.