-
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.
NODE-2577: Auto tests for the subscribe request in blockchain updates (…
- Loading branch information
Showing
10 changed files
with
1,530 additions
and
13 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
282 changes: 282 additions & 0 deletions
282
...rver/src/test/scala/com/wavesplatform/events/BlockchainUpdatesSubscribeInvokeTxSpec.scala
Large diffs are not rendered by default.
Oops, something went wrong.
594 changes: 594 additions & 0 deletions
594
grpc-server/src/test/scala/com/wavesplatform/events/BlockchainUpdatesSubscribeSpec.scala
Large diffs are not rendered by default.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
grpc-server/src/test/scala/com/wavesplatform/events/MetadataSpec.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
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
117 changes: 117 additions & 0 deletions
117
grpc-server/src/test/scala/com/wavesplatform/events/fixtures/PrepareInvokeTestData.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,117 @@ | ||
package com.wavesplatform.events.fixtures | ||
|
||
object PrepareInvokeTestData { | ||
val scriptTransferIssueAssetNum: Long = 21000 | ||
val scriptTransferUnitNum: Long = 22000 | ||
val scriptTransferAssetNum: Long = 25000 | ||
val paymentNum: Long = 30000 | ||
val sponsorFeeAssetNum: Long = 35000 | ||
val sponsorFeeIssueAssetNum: Long = 40000 | ||
val reissueNum: Int = 50000 | ||
val burnNum: Int = 100000 | ||
val leaseNum: Long = 200000 | ||
val baz = "baz" | ||
val bar = "bar" | ||
|
||
val issueData: Map[String, Any] = Map( | ||
"name" -> "issuedAssetName", | ||
"description" -> "asset_ride_description", | ||
"amount" -> 416168000, | ||
"decimals" -> 8, | ||
"nonce" -> 1 | ||
) | ||
|
||
val dataMap: Map[String, Any] = Map( | ||
"intVal" -> 25400, | ||
"stringVal" -> "test_string", | ||
"booleanVal" -> "true" | ||
) | ||
|
||
def invokeAssetScript(libVersion: Int): String = | ||
s""" | ||
|{-# STDLIB_VERSION $libVersion #-} | ||
|{-# CONTENT_TYPE DAPP #-} | ||
|{-# SCRIPT_TYPE ACCOUNT #-} | ||
|@Callable(i) | ||
|func setData(assetId:ByteVector, address:ByteVector)={ | ||
|let issueAsset = Issue("${issueData.apply("name")}","${issueData.apply("description")}",${issueData.apply("amount")}, | ||
|${issueData.apply("decimals")},true,unit,${issueData.apply("nonce")}) | ||
|let issueAssetId = issueAsset.calculateAssetId() | ||
|let lease = Lease(Address(address), $leaseNum) | ||
| [ | ||
| issueAsset, | ||
| lease, | ||
| LeaseCancel(lease.calculateLeaseId()), | ||
| IntegerEntry("int", ${dataMap.apply("intVal")}), | ||
| BinaryEntry("byte", assetId), | ||
| BooleanEntry("bool", ${dataMap.apply("booleanVal")}), | ||
| StringEntry("str", "${dataMap.apply("stringVal")}"), | ||
| DeleteEntry("int"), | ||
| Reissue(assetId, $reissueNum,true), | ||
| Burn(assetId, $burnNum), | ||
| ScriptTransfer(Address(address), $scriptTransferAssetNum, assetId), | ||
| ScriptTransfer(Address(address), $scriptTransferIssueAssetNum, issueAssetId), | ||
| ScriptTransfer(Address(address), $scriptTransferUnitNum, unit), | ||
| SponsorFee(assetId, $sponsorFeeAssetNum), | ||
| SponsorFee(issueAssetId, $sponsorFeeIssueAssetNum) | ||
| ] | ||
|} | ||
|""".stripMargin | ||
|
||
def mainDAppScript(libVersion: Int): String = | ||
s""" | ||
|{-# STDLIB_VERSION $libVersion #-} | ||
|{-# CONTENT_TYPE DAPP #-} | ||
|{-# SCRIPT_TYPE ACCOUNT #-} | ||
|@Callable(i) | ||
|func foo(acc1:ByteVector, acc2:ByteVector, a:Int, key1:String, assetId:ByteVector)={ | ||
|strict res = invoke(Address(acc1),"$bar",[a, assetId, acc2],[AttachedPayment(assetId,$paymentNum)]) | ||
|match res { | ||
| case r : Int => | ||
|( | ||
| [ | ||
| IntegerEntry(key1, r) | ||
| ] | ||
|) | ||
| case _ => throw("Incorrect invoke result for res in dApp 1") | ||
| } | ||
|} | ||
|""".stripMargin | ||
|
||
def nestedDAppScript(firstRecipient: String, libVersion: Int): String = | ||
s""" | ||
|{-# STDLIB_VERSION $libVersion #-} | ||
|{-# CONTENT_TYPE DAPP #-} | ||
|{-# SCRIPT_TYPE ACCOUNT #-} | ||
|@Callable(i) | ||
|func $bar(a: Int, assetId: ByteVector, acc1: ByteVector)={ | ||
|strict res2 = invoke(Address(acc1),"$baz",[a],[]) | ||
|match res2 { | ||
|case r: Int => | ||
|( | ||
| [ | ||
| ScriptTransfer($firstRecipient, $scriptTransferAssetNum, assetId) | ||
| ], | ||
| a * 2 | ||
|) | ||
| case _ => throw("Incorrect invoke result for res2") | ||
| } | ||
|} | ||
|""".stripMargin | ||
|
||
def doubleNestedDAppScript(secondRecipient: String, libVersion: Int): String = | ||
s""" | ||
|{-# STDLIB_VERSION $libVersion #-} | ||
|{-# CONTENT_TYPE DAPP #-} | ||
|{-# SCRIPT_TYPE ACCOUNT #-} | ||
|@Callable(i) | ||
|func $baz(a: Int) = { | ||
|( | ||
| [ | ||
| ScriptTransfer($secondRecipient, $scriptTransferUnitNum, unit) | ||
| ], | ||
|a + 2 | ||
|) | ||
|} | ||
|""".stripMargin | ||
} |
Oops, something went wrong.