-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SC-655 Remove illegal reference to extract() in V4 (#3197)
- Loading branch information
Showing
5 changed files
with
101 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...it/src/test/scala/com/wavesplatform/it/sync/smartcontract/InvokeSmartAssetFailSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.wavesplatform.it.sync.smartcontract | ||
import com.wavesplatform.common.state.ByteStr | ||
import com.wavesplatform.common.utils.EitherExt2 | ||
import com.wavesplatform.it.api.SyncHttpApi._ | ||
import com.wavesplatform.it.sync.{setScriptFee, _} | ||
import com.wavesplatform.it.transactions.BaseTransactionSuite | ||
import com.wavesplatform.lang.v1.compiler.Terms.CONST_BOOLEAN | ||
import com.wavesplatform.lang.v1.estimator.v3.ScriptEstimatorV3 | ||
import com.wavesplatform.state.BinaryDataEntry | ||
import com.wavesplatform.transaction.TxVersion | ||
import com.wavesplatform.transaction.smart.script.ScriptCompiler | ||
|
||
// because of SC-655 bug | ||
class InvokeSmartAssetFailSuite extends BaseTransactionSuite { | ||
private val caller = firstAddress | ||
private val dApp = secondAddress | ||
|
||
val dAppText = | ||
""" | ||
|{-# STDLIB_VERSION 4 #-} | ||
|{-# CONTENT_TYPE DAPP #-} | ||
|{-# SCRIPT_TYPE ACCOUNT #-} | ||
| | ||
|let bob = addressFromPublicKey(base58'BzFTfc4TB9s25d8b3sfhptj4STZafEM2FNkR5kQ8mJeA') | ||
| | ||
|@Callable(i) | ||
|func some(fail: Boolean) = { | ||
| let issue = Issue("asset", "test asset", 500, 2, true) | ||
| let assetId = if fail then this.getBinaryValue("assetId") else issue.calculateAssetId() | ||
| | ||
| let result = [ | ||
| BinaryEntry("bin", i.transactionId), | ||
| BooleanEntry("bool", true), | ||
| IntegerEntry("int", i.fee), | ||
| StringEntry("str", i.caller.toString()), | ||
| DeleteEntry("remove") | ||
| ] | ||
| | ||
| if fail then { | ||
| result ++ [ | ||
| Reissue(assetId, 10, false) | ||
| ] | ||
| } else { | ||
| result ++ [ | ||
| issue, | ||
| Reissue(assetId, 10, false), | ||
| Burn(assetId, 5), | ||
| SponsorFee(assetId, 2), | ||
| ScriptTransfer(bob, 7, assetId) | ||
| ] | ||
| } | ||
| | ||
|} | ||
""".stripMargin | ||
|
||
test("extracted funcs") { | ||
val assetId = ByteStr.decodeBase58(sender.issue(caller, waitForTx = true).id).get | ||
val data = List(BinaryDataEntry("assetId", assetId)) | ||
val dataFee = calcDataFee(data, TxVersion.V2) | ||
sender.putData(dApp, data, fee = dataFee, waitForTx = true) | ||
|
||
val script = ScriptCompiler.compile(dAppText, ScriptEstimatorV3).explicitGet()._1.bytes().base64 | ||
sender.setScript(dApp, Some(script), setScriptFee, waitForTx = true) | ||
|
||
val tx = sender.invokeScript(caller, dApp, Some("some"), List(CONST_BOOLEAN(true)), waitForTx = true) | ||
sender.debugStateChanges(tx._1.id).stateChanges.get.error.get.text shouldBe "Asset was issued by other address" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters