@@ -3,15 +3,12 @@ package com.wavesplatform.it.sync.transactions
3
3
import com .typesafe .config .Config
4
4
import com .wavesplatform .api .http .ApiError .TransactionNotAllowedByAssetScript
5
5
import com .wavesplatform .api .http .DebugMessage
6
- import com .wavesplatform .common .state .ByteStr
7
6
import com .wavesplatform .common .utils .EitherExt2
8
7
import com .wavesplatform .it .api .SyncHttpApi .*
9
- import com .wavesplatform .it .api .{StateChanges , TransactionStatus }
10
8
import com .wavesplatform .it .sync .*
11
9
import com .wavesplatform .it .transactions .BaseTransactionSuite
12
- import com .wavesplatform .lang .v1 .compiler .Terms
13
10
import com .wavesplatform .lang .v1 .estimator .v3 .ScriptEstimatorV3
14
- import com .wavesplatform .state .{ BooleanDataEntry , StringDataEntry }
11
+ import com .wavesplatform .state .StringDataEntry
15
12
import com .wavesplatform .test .*
16
13
import com .wavesplatform .transaction .assets .exchange .AssetPair
17
14
import com .wavesplatform .transaction .smart .script .ScriptCompiler
@@ -118,52 +115,6 @@ class FailedTransactionSuite extends BaseTransactionSuite with CancelAfterFailur
118
115
sender.setScript(contract, Some (script), setScriptFee, waitForTx = true ).id
119
116
}
120
117
121
- test(" InvokeScriptTransaction: insufficient action fees propagates failed transaction" ) {
122
- val invokeFee = 0.005 .waves
123
- val setAssetScriptMinFee = setAssetScriptFee + smartFee
124
- val priorityFee = setAssetScriptMinFee + invokeFee
125
-
126
- updateAssetScript(result = true , smartAsset, contract, setAssetScriptMinFee)
127
-
128
- for (typeName <- Seq (" transfer" , " issue" , " reissue" , " burn" )) {
129
- updateTikTok(" unknown" , setAssetScriptMinFee)
130
-
131
- val prevBalance = sender.balance(caller.toAddress.toString).balance
132
- val prevAssetBalance = sender.assetBalance(contractAddress, smartAsset)
133
- val prevAssets = sender.assetsBalance(contractAddress)
134
-
135
- overflowBlock()
136
- sendTxsAndThenPriorityTx(
137
- _ => sender.invokeScript(caller, contractAddress, Some (" tikTok" ), fee = invokeFee)._1.id,
138
- () => updateTikTok(typeName, priorityFee, waitForTx = false )
139
- ) { (txs, priorityTx) =>
140
- logPriorityTx(priorityTx)
141
-
142
- val failed = assertFailedTxs(txs)
143
-
144
- sender.balance(caller.toAddress.toString).balance shouldBe prevBalance - txs.size * invokeFee
145
- sender.assetBalance(contractAddress, smartAsset) shouldBe prevAssetBalance
146
- sender.assetsBalance(contractAddress).balances should contain theSameElementsAs prevAssets.balances
147
-
148
- val (scriptInvokedInfo, issuedInfo) =
149
- if (typeName == " issue" )
150
- (" " , " with 1 assets issued" )
151
- else
152
- (" with 1 total scripts invoked" , " " )
153
-
154
- val minFee = if (typeName == " issue" ) invokeFee + issueFee else invokeFee + smartFee
155
- val text = s " Fee in WAVES for InvokeScriptTransaction ( $invokeFee in WAVES) " +
156
- s " $scriptInvokedInfo$issuedInfo does not exceed minimal value of $minFee WAVES. "
157
-
158
- failed.foreach { s =>
159
- checkStateChange(sender.stateChanges(s.id), 2 , text)
160
- }
161
-
162
- failed
163
- }
164
- }
165
- }
166
-
167
118
test(" InvokeScriptTransaction: reject transactions if account script failed" ) {
168
119
val invokeFee = 0.005 .waves
169
120
val setAssetScriptMinFee = setAssetScriptFee + smartFee
@@ -212,50 +163,6 @@ class FailedTransactionSuite extends BaseTransactionSuite with CancelAfterFailur
212
163
}
213
164
}
214
165
215
- test(" InvokeScriptTransaction: transactionHeightById returns only succeed transactions" ) {
216
- val invokeFee = 0.005 .waves + smartFee
217
- val setAssetScriptMinFee = setAssetScriptFee + smartFee
218
- val priorityFee = setAssetScriptMinFee + invokeFee
219
-
220
- updateAccountScript(None , caller, setScriptFee + smartFee)
221
- updateTikTok(" reissue" , setAssetScriptMinFee)
222
- updateAssetScript(result = true , smartAsset, contract, setAssetScriptMinFee)
223
- waitForEmptyUtx()
224
- overflowBlock()
225
-
226
- val failedTxs = sendTxsAndThenPriorityTx(
227
- _ => sender.invokeScript(caller, contractAddress, Some (" tikTok" ), fee = invokeFee)._1.id,
228
- () => updateAssetScript(result = false , smartAsset, contract, priorityFee)
229
- ) { (txs, priorityTx) =>
230
- logPriorityTx(priorityTx)
231
- assertFailedTxs(txs)
232
- }
233
-
234
- checkTransactionHeightById(failedTxs)
235
- }
236
-
237
- test(" ExchangeTransaction: transaction validates as failed when asset script fails" ) {
238
- val Precondition (amountAsset, priceAsset, buyFeeAsset, sellFeeAsset) =
239
- exchangePreconditions(
240
- Some (ScriptCompiler .compile(" true" , ScriptEstimatorV3 (fixOverflow = true , overhead = false )).explicitGet()._1.bytes().base64)
241
- )
242
-
243
- val assetPair = AssetPair .createAssetPair(amountAsset, priceAsset).get
244
- val fee = 0.003 .waves + 4 * smartFee
245
- val sellMatcherFee = fee / 100000L
246
- val buyMatcherFee = fee / 100000L
247
-
248
- val (assetScript, _) =
249
- ScriptCompiler .compile(" if true then throw(\" error\" ) else false" , ScriptEstimatorV3 (fixOverflow = true , overhead = false )).explicitGet()
250
- val scriptTx = sender.setAssetScript(priceAsset, buyerAddress, script = Some (assetScript.bytes().base64))
251
- nodes.waitForHeightAriseAndTxPresent(scriptTx.id)
252
-
253
- val tx = mkExchange(buyer, seller, matcher, assetPair, fee, buyFeeAsset, sellFeeAsset, buyMatcherFee, sellMatcherFee)
254
- val result = sender.signedValidate(tx.json())
255
- (result \ " valid" ).as[Boolean ] shouldBe false
256
- (result \ " error" ).as[String ] should include(" not allowed by script of the asset" )
257
- }
258
-
259
166
test(" ExchangeTransaction: invalid exchange tx when asset script fails on broadcast" ) {
260
167
val init = Seq (
261
168
sender.setScript(firstKeyPair, None , setScriptFee + smartFee).id,
@@ -309,38 +216,6 @@ class FailedTransactionSuite extends BaseTransactionSuite with CancelAfterFailur
309
216
private def waitForTxs (txs : Seq [String ]): Unit =
310
217
nodes.waitFor(" preconditions" , 500 .millis)(_.transactionStatus(txs).forall(_.status == " confirmed" ))(_.forall(identity))
311
218
312
- private def checkStateChange (info : StateChanges , code : Int , text : String , strict : Boolean = false ): Unit = {
313
- info.stateChanges shouldBe defined
314
- info.stateChanges.get.issues.size shouldBe 0
315
- info.stateChanges.get.reissues.size shouldBe 0
316
- info.stateChanges.get.burns.size shouldBe 0
317
- info.stateChanges.get.error shouldBe defined
318
- info.stateChanges.get.error.get.code shouldBe code
319
- if (strict)
320
- info.stateChanges.get.error.get.text shouldBe text
321
- else
322
- info.stateChanges.get.error.get.text should include(text)
323
- }
324
-
325
- private def checkTransactionHeightById (failedTxs : Seq [TransactionStatus ]): Unit = {
326
- val defineTxs = failedTxs.map { status =>
327
- sender
328
- .invokeScript(
329
- caller,
330
- contractAddress,
331
- Some (" defineTxHeight" ),
332
- List (Terms .CONST_BYTESTR (ByteStr .decodeBase58(status.id).get).explicitGet()),
333
- fee = invokeFee
334
- )
335
- ._1
336
- .id
337
- }
338
-
339
- waitForTxs(defineTxs)
340
-
341
- failedTxs.foreach(status => sender.getDataByKey(contractAddress, status.id) shouldBe BooleanDataEntry (status.id, value = false ))
342
- }
343
-
344
219
private def exchangePreconditions (initScript : Option [String ]): Precondition = {
345
220
val transfers = Seq (
346
221
sender.transfer(sender.keyPair, sellerAddress.toAddress.toString, 100 .waves).id,
0 commit comments