-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bee0913
commit 3588126
Showing
4 changed files
with
92 additions
and
9 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
59 changes: 59 additions & 0 deletions
59
consensus-client-it/src/test/scala/units/BridgeC2ETestSuite.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,59 @@ | ||
package units | ||
|
||
import com.wavesplatform.transaction.TxHelpers | ||
import units.eth.EthAddress | ||
|
||
class BridgeC2ETestSuite extends OneNodeTestSuite { | ||
protected val clSender = clRichAccount1 | ||
protected val elReceiver = elRichAccount1 | ||
protected val userAmount = 1 | ||
protected val wavesAmount = UnitsConvert.toWavesAmount(userAmount) | ||
|
||
"L2-380 Checking balances in CL->EL transfers" in { | ||
def clAssetQuantity: Long = waves1.api.assetQuantity(waves1.chainContract.token) | ||
def chainContractBalance: Long = waves1.api.balance(chainContractAddress, waves1.chainContract.token) | ||
|
||
val clAssetQuantityBefore = clAssetQuantity | ||
val chainContractBalanceBefore = chainContractBalance | ||
|
||
waves1.api.broadcastAndWait( | ||
chainContract.transfer( | ||
sender = clSender, | ||
destElAddress = EthAddress.unsafeFrom(elReceiver.getAddress), | ||
asset = waves1.chainContract.token, | ||
amount = wavesAmount | ||
) | ||
) | ||
|
||
val chainContractBalanceAfter = chainContractBalance | ||
withClue("1. Chain contract balance unchanged: ") { | ||
chainContractBalanceAfter shouldBe chainContractBalanceBefore | ||
} | ||
|
||
val clAssetQuantityAfter = clAssetQuantity | ||
withClue("1. Tokens burned: ") { | ||
clAssetQuantityAfter shouldBe (clAssetQuantityBefore - wavesAmount) | ||
} | ||
} | ||
|
||
override def beforeAll(): Unit = { | ||
super.beforeAll() | ||
|
||
log.info("Prepare: issue tokens on chain contract and transfer to a user") | ||
waves1.api.broadcastAndWait( | ||
TxHelpers.reissue( | ||
asset = waves1.chainContract.token, | ||
sender = chainContractAccount, | ||
amount = wavesAmount | ||
) | ||
) | ||
waves1.api.broadcastAndWait( | ||
TxHelpers.transfer( | ||
from = chainContractAccount, | ||
to = clSender.toAddress, | ||
amount = wavesAmount, | ||
asset = waves1.chainContract.token | ||
) | ||
) | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
consensus-client-it/src/test/scala/units/UnitsConvert.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,11 @@ | ||
package units | ||
|
||
import com.wavesplatform.settings.Constants | ||
import org.web3j.utils.Convert | ||
|
||
import java.math.BigInteger | ||
|
||
object UnitsConvert { | ||
def toWavesAmount(userAmount: BigDecimal): Long = (userAmount * Constants.UnitsInWave).toLongExact | ||
def toEthAmount(userAmount: BigDecimal): BigInteger = Convert.toWei(userAmount.bigDecimal, Convert.Unit.ETHER).toBigIntegerExact | ||
} |