Skip to content

Commit

Permalink
Merge pull request #1705 from wavesplatform/node-1311-no-order-in-ass…
Browse files Browse the repository at this point in the history
…et-context

NODE 1311: No order in asset context
  • Loading branch information
alexeykiselev authored Nov 28, 2018
2 parents d87f403 + baebce9 commit 1e8713c
Show file tree
Hide file tree
Showing 50 changed files with 300 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.wavesplatform.transaction.smart.script.ScriptCompiler
class CompilerBenchmark {

@Benchmark
def serialize_test(st: St, bh: Blackhole): Unit = bh.consume(ScriptCompiler(st.scriptString).explicitGet()._1)
def serialize_test(st: St, bh: Blackhole): Unit = bh.consume(ScriptCompiler(st.scriptString, isAssetScript = false).explicitGet()._1)
}

object CompilerBenchmark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object StateSyntheticBenchmark {

val textScript = "sigVerify(tx.bodyBytes,tx.proofs[0],tx.senderPk)"
val untypedScript = Parser(textScript).get.value
val typedScript = CompilerV1(compilerContext(V1), untypedScript).explicitGet()._1
val typedScript = CompilerV1(compilerContext(V1, isAssetScript = false), untypedScript).explicitGet()._1

val setScriptBlock = nextBlock(
Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Gen {
|${recString(10)} || true
""".stripMargin

val script = ScriptCompiler(s).explicitGet()
val script = ScriptCompiler(s, isAssetScript = false).explicitGet()

script._1
}
Expand Down Expand Up @@ -60,7 +60,7 @@ object Gen {
|}
""".stripMargin

val script = ScriptCompiler(src).explicitGet()
val script = ScriptCompiler(src, isAssetScript = false).explicitGet()

script._1
}
Expand Down Expand Up @@ -97,7 +97,7 @@ object Gen {
|$finalStatement
""".stripMargin

val (script, _) = ScriptCompiler(src)
val (script, _) = ScriptCompiler(src, isAssetScript = false)
.explicitGet()
log.info(s"${script.text}")
script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ trait IntegrationSuiteWithThreeAddresses
def setContract(contractText: Option[String], acc: PrivateKeyAccount): String = {
val script = contractText.map { x =>
val scriptText = x.stripMargin
ScriptCompiler(scriptText).explicitGet()._1
ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
}
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, acc, script, 0.014.waves, System.currentTimeMillis())
Expand Down
4 changes: 2 additions & 2 deletions it/src/main/scala/com/wavesplatform/it/MatcherNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ trait MatcherNode extends BeforeAndAfterAll with Nodes with ScorexLogging {

def initialScripts(): Unit = {
for (i <- List(matcherNode, aliceNode, bobNode).indices) {
val script = ScriptCompiler("true").explicitGet()._1
val script = ScriptCompiler("true", isAssetScript = false).explicitGet()._1
val pk = PrivateKeyAccount.fromSeed(nodes(i).seed(addresses(i))).right.get
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, pk, Some(script), 0.01.waves, System.currentTimeMillis())
Expand All @@ -58,7 +58,7 @@ trait MatcherNode extends BeforeAndAfterAll with Nodes with ScorexLogging {
def setContract(contractText: Option[String], acc: PrivateKeyAccount): TransactionInfo = {
val script = contractText.map { x =>
val scriptText = x.stripMargin
ScriptCompiler(scriptText).explicitGet()._1
ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
}
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, acc, script, 0.014.waves, System.currentTimeMillis())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExtraFeeTestSuite extends MatcherSuiteBase {

override protected def nodeConfigs: Seq[Config] = Configs

val trueScript = Some(ScriptCompiler("true").explicitGet()._1.bytes().base64) //TODO добавить типовые проверки в скрипт
val trueScript = Some(ScriptCompiler("true", isAssetScript = false).explicitGet()._1.bytes().base64) //TODO добавить типовые проверки в скрипт
val amount = 1L
val price = 100000000L

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ class OrdersFromScriptedAccTestSuite extends MatcherSuiteBase {

withClue("duplicate names in contracts are denied") {
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head,
bobAcc,
Some(ScriptCompiler(sDupNames).explicitGet()._1),
0.014.waves,
System.currentTimeMillis())
.selfSigned(
SetScriptTransaction.supportedVersions.head,
bobAcc,
Some(ScriptCompiler(sDupNames, isAssetScript = false).explicitGet()._1),
0.014.waves,
System.currentTimeMillis()
)
.explicitGet()

assertBadRequestAndResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ object OrdersFromScriptedAssetTestSuite {
| case other => true
|}
|""".stripMargin
ScriptCompiler(scriptText).explicitGet()._1
ScriptCompiler(scriptText, isAssetScript = true).explicitGet()._1
}

private val commonConfig = ConfigFactory.parseString(s"""
Expand Down
2 changes: 1 addition & 1 deletion it/src/test/scala/com/wavesplatform/it/sync/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ package object sync {

val supportedVersions = List(null, "2") //sign and broadcast use default for V1

val script = ScriptCompiler(s"""true""".stripMargin).explicitGet()._1
val script = ScriptCompiler(s"""true""".stripMargin, isAssetScript = false).explicitGet()._1
val scriptBase64 = script.bytes.value.base64

val errNotAllowedByToken = "Transaction is not allowed by token-script"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AtomicSwapSmartContractSuite extends BaseTransactionSuite with CancelAfter
}""".stripMargin

val pkSwapBC1 = pkByAddress(swapBC1)
val script = ScriptCompiler(scriptText).explicitGet()._1
val script = ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
val sc1SetTx = SetScriptTransaction
.selfSigned(version = SetScriptTransaction.supportedVersions.head,
sender = pkSwapBC1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BigString extends BaseTransactionSuite with CancelAfterFailure {
}
""".stripMargin

val script = ScriptCompiler(scriptText).explicitGet()._1
val script = ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, acc0, Some(script), setScriptFee, System.currentTimeMillis())
.explicitGet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LeaseSmartContractsTestSuite extends BaseTransactionSuite with CancelAfter
}
""".stripMargin

val script = ScriptCompiler(scriptText).explicitGet()._1
val script = ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, acc0, Some(script), setScriptFee, System.currentTimeMillis())
.explicitGet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MassTransferSmartContractSuite extends BaseTransactionSuite with CancelAft
""".stripMargin

// set script
val script = ScriptCompiler(scriptText).explicitGet()._1
val script = ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, sender.privateKey, Some(script), setScriptFee, System.currentTimeMillis())
.explicitGet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ScriptExecutionErrorSuite extends BaseTransactionSuite with CancelAfterFai
|}
""".stripMargin

val compiled = ScriptCompiler(scriptSrc).explicitGet()._1
val compiled = ScriptCompiler(scriptSrc, isAssetScript = false).explicitGet()._1

val tx = sender.signedBroadcast(
SetScriptTransaction.selfSigned(1, acc2, Some(compiled), setScriptFee, ts).explicitGet().json() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SetScriptTransactionSuite extends BaseTransactionSuite with CancelAfterFai
}
""".stripMargin

val script = ScriptCompiler(scriptText).explicitGet()._1
val script = ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, acc0, Some(script), setScriptFee, System.currentTimeMillis())
.explicitGet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class UTXAllowance extends FreeSpec with Matchers with WaitForHeight2 with Cance

val scriptText = s"""true""".stripMargin

val script = ScriptCompiler(scriptText).explicitGet()._1
val script = ScriptCompiler(scriptText, isAssetScript = false).explicitGet()._1
val setScriptTransaction = SetScriptTransaction
.selfSigned(SetScriptTransaction.supportedVersions.head, acc, Some(script), setScriptFee, System.currentTimeMillis())
.right
Expand Down
Loading

0 comments on commit 1e8713c

Please sign in to comment.