@@ -155,6 +155,100 @@ testExtendedTransactionP9 = do
155155 [(0 , [(0 , keypair 3 )])]
156156 Nothing
157157
158+ -- | Test that a non-sponsored transaction with an invalid payload (not deserializable) is rejected
159+ -- with the cost correctly charged to the sender and recorded as such.
160+ testNonSponsoredSerializationFailP10 :: Expectation
161+ testNonSponsoredSerializationFailP10 = do
162+ expectation <- Helpers. runTestBlockState $ do
163+ initialState <- constructInitialBlockState @ 'P10
164+ (result, finalState) <- Helpers. runScheduler Helpers. defaultTestConfig initialState transactions
165+ expAccBalances <-
166+ assertAccountBalances
167+ finalState
168+ (initialAmounts & ix 1 -~ 16200 )
169+ return $ do
170+ let resultTransactions = Helpers. srTransactions result
171+ assertEqual " Failed transactions" [] (ftFailed resultTransactions)
172+ assertEqual
173+ " Added transactions"
174+ [((toBlockItem testTransaction, Nothing ), summary)]
175+ (ftAdded resultTransactions)
176+ expAccBalances
177+ expectation
178+ where
179+ transactions = [TGAccountTransactions [(testTransaction, Nothing )]]
180+ acc = Helpers. accountAddressFromSeed
181+ keypair = Helpers. keyPairFromSeed
182+ testTransaction =
183+ fromAccountTransactionV1 0 $
184+ signAccountTransactionV1
185+ (makeHeaderV1 (acc 1 ) Nothing 1 1000 )
186+ (EncodedPayload mempty )
187+ [(0 , [(0 , keypair 1 )])]
188+ Nothing
189+ summary =
190+ TransactionSummary
191+ { tsSender = Just (acc 1 ),
192+ tsHash = getHash testTransaction,
193+ tsCost = 16200 ,
194+ tsEnergyCost = 162 ,
195+ tsType = TSTAccountTransaction Nothing ,
196+ tsResult = TxReject {vrRejectReason = SerializationFailure },
197+ tsIndex = 0 ,
198+ tsSponsorDetails = CTrue Nothing
199+ }
200+
201+ -- | Test that a sponsored transaction with an invalid payload (not deserializable) is rejected
202+ -- with the cost correctly charged to the sponsor and recorded as such.
203+ testSponsoredSerializationFailP10 :: Expectation
204+ testSponsoredSerializationFailP10 = do
205+ expectation <- Helpers. runTestBlockState $ do
206+ initialState <- constructInitialBlockState @ 'P10
207+ (result, finalState) <- Helpers. runScheduler Helpers. defaultTestConfig initialState transactions
208+ expAccBalances <-
209+ assertAccountBalances
210+ finalState
211+ (initialAmounts & ix 0 -~ 29400 )
212+ return $ do
213+ let resultTransactions = Helpers. srTransactions result
214+ assertEqual " Failed transactions" [] (ftFailed resultTransactions)
215+ assertEqual
216+ " Added transactions"
217+ [((toBlockItem testTransaction, Nothing ), summary)]
218+ (ftAdded resultTransactions)
219+ expAccBalances
220+ expectation
221+ where
222+ transactions = [TGAccountTransactions [(testTransaction, Nothing )]]
223+ acc = Helpers. accountAddressFromSeed
224+ keypair = Helpers. keyPairFromSeed
225+ testTransaction =
226+ fromAccountTransactionV1 0 $
227+ signAccountTransactionV1
228+ (makeHeaderV1 (acc 3 ) (Just (acc 0 )) 1 1000 )
229+ (EncodedPayload mempty )
230+ [(0 , [(0 , keypair 3 )])]
231+ (Just [(0 , [(0 , keypair 0 )])])
232+ summary =
233+ TransactionSummary
234+ { tsSender = Just (acc 3 ),
235+ tsHash = getHash testTransaction,
236+ tsCost = 0 ,
237+ tsEnergyCost = 294 ,
238+ tsType = TSTAccountTransaction Nothing ,
239+ tsResult = TxReject {vrRejectReason = SerializationFailure },
240+ tsIndex = 0 ,
241+ tsSponsorDetails =
242+ CTrue
243+ ( Just
244+ ( SponsorDetails
245+ { sdSponsor = acc 0 ,
246+ sdCost = 29400
247+ }
248+ )
249+ )
250+ }
251+
158252-- | Test that a sponsored transaction where the sender has insufficient balance to cover the
159253-- transfer amount is rejected (but added to the block) in P10.
160254testSponsoredTransferRejectP10 :: Expectation
@@ -824,6 +918,8 @@ tests = parallel $ do
824918 it " Sponsored transfer @P9" testSponsoredTransferP9
825919 it " Extended transaction (transfer, no sponsor) @P9" testExtendedTransactionP9
826920
921+ it " Non-sponsored transaction, garbage payload (reject) @P10" testNonSponsoredSerializationFailP10
922+ it " Sponsored transaction, garbage payload (reject) @P10" testSponsoredSerializationFailP10
827923 it " Sponsored transfer (reject) @P10" testSponsoredTransferRejectP10
828924 it " Sponsored transfer (success) @P10" testSponsoredTransferSuccessP10
829925 it " Extended transaction (transfer, no sponsor, success) @P10" testExtendedTransactionSuccessP10
0 commit comments