Skip to content

Commit

Permalink
Merge pull request #1464 from wavesplatform/it-v14-fixes
Browse files Browse the repository at this point in the history
[Tests only] Updated TransferSending to send TransferV2 transactions
  • Loading branch information
Nastya Urlapova authored Sep 5, 2018
2 parents a1e8a80 + a01bab6 commit ea548ca
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
16 changes: 9 additions & 7 deletions it/src/main/scala/com/wavesplatform/it/TransferSending.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.wavesplatform.state.EitherExt2
import com.wavesplatform.utils.{Base58, ScorexLogging}
import org.scalatest.Suite
import com.wavesplatform.account.{Address, AddressOrAlias, AddressScheme, PrivateKeyAccount}
import com.wavesplatform.api.http.assets.SignedTransferV1Request
import com.wavesplatform.api.http.assets.SignedTransferV2Request
import com.wavesplatform.transaction.transfer._

import scala.concurrent.Future
Expand Down Expand Up @@ -110,7 +110,7 @@ trait TransferSending extends ScorexLogging {
.map {
case (x, i) =>
createSignedTransferRequest(
TransferTransactionV1
TransferTransactionV2
.selfSigned(
assetId = None,
sender = PrivateKeyAccount.fromSeed(x.senderSeed).explicitGet(),
Expand All @@ -121,7 +121,8 @@ trait TransferSending extends ScorexLogging {
feeAmount = x.fee,
attachment = if (includeAttachment) {
Array.fill(TransferTransaction.MaxAttachmentSize)(ThreadLocalRandom.current().nextInt().toByte)
} else Array.emptyByteArray
} else Array.emptyByteArray,
version = 2
)
.right
.get)
Expand All @@ -134,18 +135,19 @@ trait TransferSending extends ScorexLogging {
.map(_.flatten)
}

protected def createSignedTransferRequest(tx: TransferTransactionV1): SignedTransferV1Request = {
protected def createSignedTransferRequest(tx: TransferTransactionV2): SignedTransferV2Request = {
import tx._
SignedTransferV1Request(
SignedTransferV2Request(
Base58.encode(tx.sender.publicKey),
assetId.map(_.base58),
recipient.stringRepr,
amount,
fee,
feeAssetId.map(_.base58),
fee,
timestamp,
2,
attachment.headOption.map(_ => Base58.encode(attachment)),
signature.base58
proofs.base58().toList
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ object AsyncHttpApi extends Assertions {
def signedIssue(issue: SignedIssueV1Request): Future[Transaction] =
postJson("/assets/broadcast/issue", issue).as[Transaction]

def batchSignedTransfer(transfers: Seq[SignedTransferV1Request], timeout: FiniteDuration = 1.minute): Future[Seq[Transaction]] = {
def batchSignedTransfer(transfers: Seq[SignedTransferV2Request], timeout: FiniteDuration = 1.minute): Future[Seq[Transaction]] = {
val request = _post(s"${n.nodeApiEndpoint}/assets/broadcast/batch-transfer")
.setHeader("Content-type", "application/json")
.withApiKey(n.apiKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class OrdersFromScriptedAccTestSuite

// sell order should be in the aliceNode orderbook
matcherNode.fullOrderHistory(aliceNode).head.status shouldBe "Accepted"

// Bob gets error message
assertBadRequestAndResponse(
matcherNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wavesplatform.it.sync.transactions

import com.wavesplatform.it.TransferSending
import com.wavesplatform.it.api.SyncHttpApi._
import com.wavesplatform.it.sync._
import com.wavesplatform.it.transactions.BaseTransactionSuite
Expand All @@ -15,7 +14,7 @@ import com.wavesplatform.transaction.transfer._

import scala.concurrent.duration._

class TransferTransactionV1Suite extends BaseTransactionSuite with TransferSending with CancelAfterFailure {
class TransferTransactionV1Suite extends BaseTransactionSuite with CancelAfterFailure {

test("asset transfer changes sender's and recipient's asset balance; issuer's.waves balance is decreased by fee") {
val (firstBalance, firstEffBalance) = notMiner.accountBalances(firstAddress)
Expand Down

0 comments on commit ea548ca

Please sign in to comment.