Skip to content

Commit

Permalink
Added integration tests timeouts. Downgraded test methods to JUnit 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingela committed Nov 27, 2018
1 parent c4b8022 commit 469efa4
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package integration

import org.junit.Rule
import org.junit.rules.Timeout
import org.junit.runner.notification.RunListener

/**
* Base test class provides default timeout for test methods
* Rules only works with JUnit 4 Test methods
* There is no built global mechanism in JUnit 5 yet
*/
abstract class BaseIntergrationTest : RunListener() {

@Rule
@JvmField
var globalTimeout: Timeout = Timeout.seconds(TIMEOUT_VALUE)

companion object {
// 5 minutes
private const val TIMEOUT_VALUE = 300L
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration.btc

import generation.btc.BtcAddressGenerationInitialization
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import kotlinx.coroutines.experimental.launch
import model.IrohaCredential
Expand All @@ -10,10 +11,10 @@ import org.bitcoinj.core.Utils
import org.bitcoinj.params.RegTestParams
import org.bitcoinj.script.ScriptBuilder
import org.bitcoinj.wallet.Wallet
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.fail
import provider.NotaryPeerListProviderImpl
Expand All @@ -32,8 +33,9 @@ import java.io.File
private const val WAIT_PREGEN_INIT_MILLIS = 10_000L
private const val WAIT_PREGEN_PROCESS_MILLIS = 15_000L


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BtcAddressGenerationIntegrationTest {
class BtcAddressGenerationIntegrationTest : BaseIntergrationTest() {

private val integrationHelper = IntegrationHelperUtil()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package integration.btc

import com.github.kittinunf.result.failure
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import integration.helper.btcAsset
import model.IrohaCredential
import notary.btc.BtcNotaryInitialization
import org.bitcoinj.core.Address
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.fail
import provider.btc.address.BtcRegisteredAddressesProvider
Expand All @@ -23,8 +24,9 @@ import java.math.BigDecimal

private val integrationHelper = IntegrationHelperUtil()


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BtcNotaryIntegrationTest {
class BtcNotaryIntegrationTest : BaseIntergrationTest() {

private val notaryConfig = integrationHelper.configHelper.createBtcNotaryConfig()
private val irohaCredential = IrohaCredential(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package integration.btc

import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import jp.co.soramitsu.iroha.ModelCrypto
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.runBlocking
import model.IrohaCredential
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.fail
import provider.btc.account.IrohaBtcAccountCreator
Expand All @@ -22,8 +23,9 @@ import sidechain.iroha.util.ModelUtil
import util.getRandomString
import java.math.BigInteger


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BtcRegistrationIntegrationTest {
class BtcRegistrationIntegrationTest : BaseIntergrationTest() {

private val integrationHelper = IntegrationHelperUtil()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ package integration.btc

import com.github.kittinunf.result.failure
import helper.address.outPutToBase58Address
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import integration.helper.btcAsset
import jp.co.soramitsu.iroha.ModelCrypto
import model.IrohaCredential
import mu.KLogging
import org.bitcoinj.core.Address
import org.bitcoinj.core.TransactionOutput
import org.junit.jupiter.api.*
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.fail
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.TestInstance
import provider.btc.address.BtcRegisteredAddressesProvider
import provider.btc.network.BtcNetworkConfigProvider
import provider.btc.network.BtcRegTestConfigProvider
Expand All @@ -34,8 +39,9 @@ import kotlin.test.assertFalse
private const val WITHDRAWAL_WAIT_MILLIS = 15_000L
private const val TOTAL_TESTS = 9


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BtcWithdrawalIntegrationTest {
class BtcWithdrawalIntegrationTest : BaseIntergrationTest() {
private val integrationHelper = IntegrationHelperUtil()

private val createdTransactions = ConcurrentHashMap<String, TimedTx>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package integration.eth

import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import provider.eth.ETH_PRECISION
import sidechain.iroha.CLIENT_DOMAIN
Expand All @@ -14,8 +15,9 @@ import java.math.BigInteger
/**
* Integration tests for deposit case.
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class DepositIntegrationTest {
class DepositIntegrationTest : BaseIntergrationTest() {
/** Utility functions for integration tests */
private val integrationHelper = IntegrationHelperUtil()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package integration.eth

import config.IrohaCredentialConfig
import config.loadEthPasswords
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.Test
import org.junit.jupiter.api.TestInstance
import provider.eth.ETH_PRECISION
import sidechain.iroha.CLIENT_DOMAIN
Expand All @@ -17,8 +18,9 @@ import java.math.BigInteger
/**
* Integration tests with multiple notaries for deposit case.
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class DepositMultiIntegrationTest {
class DepositMultiIntegrationTest : BaseIntergrationTest() {
/** Utility functions for integration tests */
private val integrationHelper = IntegrationHelperUtil()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package integration.eth
import com.github.kittinunf.result.failure
import com.github.kittinunf.result.map
import com.google.gson.Gson
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.TestInstance
import provider.eth.EthTokensProviderImpl
import sidechain.iroha.consumer.IrohaNetworkImpl
import token.EthTokenInfo
Expand All @@ -17,8 +20,9 @@ import java.io.File
/**
* Requires Iroha is running
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ERC20TokenRegistrationTest {
class ERC20TokenRegistrationTest : BaseIntergrationTest() {
private val integrationHelper = IntegrationHelperUtil()
private val tokensFilePath = "tokens-for-test.json"
private val tokenRegistrationConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package integration.eth

import com.github.kittinunf.result.failure
import com.github.kittinunf.result.success
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.fail
import provider.eth.EthFreeRelayProvider
Expand All @@ -14,8 +15,9 @@ import sidechain.iroha.consumer.IrohaNetworkImpl
import sidechain.iroha.util.ModelUtil.setAccountDetail
import java.io.File


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class EthFreeRelayProviderTest {
class EthFreeRelayProviderTest : BaseIntergrationTest() {

/** Test configurations */
val integrationHelper = IntegrationHelperUtil()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package integration.eth

import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.fail
import provider.eth.EthRelayProviderIrohaImpl
Expand All @@ -12,8 +13,9 @@ import sidechain.iroha.consumer.IrohaNetworkImpl
/**
* Requires Iroha is running
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class EthRelayProviderIrohaTest {
class EthRelayProviderIrohaTest : BaseIntergrationTest() {
val integrationHelper = IntegrationHelperUtil()
val testConfig = integrationHelper.configHelper.testConfig

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package integration.eth

import com.github.kittinunf.result.success
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.fail
import provider.eth.ETH_ADDRESS
Expand All @@ -17,8 +18,9 @@ import util.getRandomString
/**
* Test Iroha Ethereum ERC20 tokens provider
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class EthTokensProviderTest {
class EthTokensProviderTest : BaseIntergrationTest() {
private val integrationHelper = IntegrationHelperUtil()

private val ethTokensProvider = integrationHelper.ethTokensProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package integration.eth

import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.web3j.protocol.exceptions.TransactionException
import sidechain.iroha.CLIENT_DOMAIN
Expand All @@ -11,8 +12,9 @@ import java.math.BigDecimal
import java.math.BigInteger
import kotlin.test.assertEquals


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class FailedTransactionTest {
class FailedTransactionTest : BaseIntergrationTest() {
val integrationHelper = IntegrationHelperUtil()

init {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package integration.eth

import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import mu.KLogging
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.math.BigInteger

/**
* Integration tests for vacuum use case
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class VacuumIntegrationTest {
class VacuumIntegrationTest : BaseIntergrationTest() {

private val integrationHelper = IntegrationHelperUtil()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package integration.eth

import com.squareup.moshi.Moshi
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import notary.endpoint.eth.BigIntegerMoshiAdapter
import notary.endpoint.eth.EthNotaryResponse
import notary.endpoint.eth.EthNotaryResponseMoshiAdapter
import notary.eth.ENDPOINT_ETHEREUM
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import provider.eth.ETH_PRECISION
import provider.eth.EthRelayProviderIrohaImpl
Expand All @@ -24,8 +25,9 @@ import java.math.BigInteger
/**
* Class for Ethereum sidechain infrastructure deployment and communication.
*/

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class WithdrawalIntegrationTest {
class WithdrawalIntegrationTest : BaseIntergrationTest() {

/** Integration tests util */
private val integrationHelper = IntegrationHelperUtil()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package integration.eth
import com.squareup.moshi.Moshi
import config.loadConfigs
import config.loadEthPasswords
import integration.BaseIntergrationTest
import integration.helper.IntegrationHelperUtil
import notary.endpoint.eth.BigIntegerMoshiAdapter
import notary.endpoint.eth.EthNotaryResponse
import notary.endpoint.eth.EthNotaryResponseMoshiAdapter
import notary.eth.ENDPOINT_ETHEREUM
import notary.eth.EthNotaryConfig
import org.junit.Test
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.web3j.crypto.ECKeyPair
import provider.eth.ETH_PRECISION
Expand All @@ -26,8 +27,9 @@ import util.getRandomString
import java.math.BigDecimal
import java.math.BigInteger


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class WithdrawalMultinotaryIntegrationTest {
class WithdrawalMultinotaryIntegrationTest : BaseIntergrationTest() {
/** Utility functions for integration tests */
private val integrationHelper = IntegrationHelperUtil()

Expand Down
Loading

0 comments on commit 469efa4

Please sign in to comment.