-
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
6091958
commit 7cdaa71
Showing
16 changed files
with
158 additions
and
28 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
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
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
51 changes: 51 additions & 0 deletions
51
consensus-client-it/src/test/scala/units/AlternativeChainTestSuite.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,51 @@ | ||
package units | ||
|
||
import com.wavesplatform.account.KeyPair | ||
import com.wavesplatform.common.state.ByteStr | ||
import units.client.contract.HasConsensusLayerDappTxHelpers.EmptyE2CTransfersRootHashHex | ||
import units.docker.WavesNodeContainer | ||
|
||
class AlternativeChainTestSuite extends OneNodeTestSuite with OneNodeTestSuite.OneMiner { | ||
"L2-383 Start an alternative chain after not getting an EL-block" in { | ||
step("EL miner #2 join") | ||
waves1.api.broadcastAndWait( | ||
chainContract.join( | ||
minerAccount = miner21Account, | ||
elRewardAddress = miner21RewardAddress | ||
) | ||
) | ||
|
||
step("Wait miner #2 epoch") | ||
waitMinerEpoch(miner21Account) | ||
|
||
step("Issue miner #2 block confirmation") | ||
val lastContractBlock = waves1.chainContract.getLastBlockMeta(0).getOrElse(fail("Can't get last block")) | ||
val lastWavesBlock = waves1.api.blockHeader(waves1.api.height).getOrElse(fail("Can't get current block header")) | ||
waves1.api.broadcastAndWait( | ||
chainContract.extendMainChain( | ||
minerAccount = miner21Account, | ||
blockHash = BlockHash("0x0000000000000000000000000000000000000000000000000000000000000001"), | ||
parentBlockHash = lastContractBlock.hash, | ||
e2cTransfersRootHashHex = EmptyE2CTransfersRootHashHex, | ||
lastC2ETransferIndex = -1, | ||
vrf = ByteStr.decodeBase58(lastWavesBlock.VRF).get | ||
) | ||
) | ||
|
||
step("Wait miner #1 epoch") | ||
waitMinerEpoch(miner11Account) | ||
|
||
step("Checking an alternative chain started") | ||
retry { | ||
waves1.chainContract.getChainInfo(1L).getOrElse(fail("Can't get an alternative chain info")) | ||
} | ||
} | ||
|
||
private def waitMinerEpoch(minerAccount: KeyPair): Unit = { | ||
val expectedGenerator = minerAccount.toAddress | ||
retry { | ||
val actualGenerator = waves1.chainContract.computedGenerator | ||
if (actualGenerator != expectedGenerator) fail(s"Expected $expectedGenerator generator, got $actualGenerator") | ||
}(patienceConfig.copy(timeout = WavesNodeContainer.AverageBlockDelay * 5)) | ||
} | ||
} |
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
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
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
9 changes: 9 additions & 0 deletions
9
consensus-client-it/src/test/scala/units/docker/DockerImages.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,9 @@ | ||
package units.docker | ||
|
||
import org.testcontainers.utility.DockerImageName.parse | ||
import units.test.TestEnvironment.WavesDockerImage | ||
|
||
object DockerImages { | ||
val WavesNode = parse(WavesDockerImage) | ||
val ExecutionClient = parse("hyperledger/besu:latest") | ||
} |
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
11 changes: 11 additions & 0 deletions
11
consensus-client-it/src/test/scala/units/test/TestEnvironment.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.test | ||
|
||
import java.nio.file.{Files, Path} | ||
|
||
object TestEnvironment { | ||
val ConfigsDir: Path = Path.of(System.getProperty("cc.it.configs.dir")) | ||
val DefaultLogsDir: Path = Path.of(System.getProperty("cc.it.logs.dir")) | ||
Files.createDirectories(DefaultLogsDir) | ||
|
||
val WavesDockerImage: String = System.getProperty("cc.it.docker.image") | ||
} |
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