-
Notifications
You must be signed in to change notification settings - Fork 7
EC-749 #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CapDev12
wants to merge
57
commits into
EncryFoundation:master
Choose a base branch
from
CapDev12:EC-749
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
EC-749 #370
Changes from 53 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
7c24305
frame
3554ad9
add test draft: Late node should sync with chain
4775c79
add test draft: Late node should sync with chain
736394b
add test Late node should sync with one node
74edce8
maxTries -> implicit duration
0346c3e
add test draft "Node should sync after change offlineGeneration and p…
363ae2c
add /peers/connect api route
3fcf2c9
add /node/shutdown api route
16f127e
add node api shutdown
b0f3672
add Config wrappers
baab41f
passthrough volume param
6efc443
add stopNode
a5f9630
add test "Nodes should sync after restart with new offlineGeneration …
b5ff812
add test "Nodes should sync after restart with new offlineGeneration …
2014d59
fix remove container
8d700d4
general refactoring of tests
39e49a5
cleanup debug info
b3f9325
constant class name should be passed through application.conf
e65b4ee
MainConstants rename to Constants
58d65c5
add SlowMiningConstants
abc87eb
add constantsClass wrapper
26a5ff9
add fixed network port
8f56ecb
add SyncThreeNodesKnowAboutEachOtherTest
63e07f4
add SyncThreeNodesСonnectedWithFirstTest
415d329
refactoring
eb5d14b
refactor to implicits
508fd20
cleanup
a0b0a99
fix bug with two setting instance
a6a0fae
link to EncryApp.settings replaced
7256360
EncryApp.settings to local param settings replaced
12b130f
fix null cmdArgs
434883e
refactor load settings
36c6279
refactoring EncryApp.settings global links to params
650bd0c
more settings refactoring
7ae12ea
replace DummyEncryAppSettingsReader with Settings trait
ddd0fce
more settings refactoring
d16cca1
replace val settings with Settings trait
d0b477a
replace DummyEncryAppSettingsReader with TestSettings trait
97b4040
replace MainTestSettings.conf with MainTestSettings trait
b27c856
remove unused constants
eeeb2d2
more refactoring
71bcca3
fix args
25e41b0
benchmark mix settings
17f9543
PR fixes
dd0e82c
rename MainTestSettings
53f3164
fix AdditionalTestSettings
34a4741
fix settings
5b9a64c
Merge branch 'SunFrost-EC-751'
caeb564
merge branch
6214ce3
merge branch
14f5438
merge branch
efc53e4
Merge remote-tracking branch 'origin/master' into EC-749
ae30aa6
Merge remote-tracking branch 'origin/master' into EC-749
fc460f7
PR fixes
a942218
Merge remote-tracking branch 'origin/master' into EC-749
f98e344
rename
fa270cc
Merge branch 'master' into EC-749
CapDev12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| package encry.it.util | ||
|
|
||
| import scala.annotation.tailrec | ||
| import scala.concurrent.duration.Duration | ||
|
|
||
| object WaitUtils { | ||
|
|
||
| def waitForEqualsId(id1Func: => String, id2Func: => String)(implicit duration: Duration): (String, String) = { | ||
| @tailrec | ||
| def loop(id1Func: => String, id2Func: => String, maxTries: Long): (String, String) = { | ||
| val id1: String = id1Func | ||
| val id2: String = id2Func | ||
| if (id1 != id2 && maxTries > 0) { | ||
| Thread.sleep(1000) | ||
| loop(id1Func, id2Func, maxTries - 1) | ||
| } else (id1, id2) | ||
| } | ||
|
|
||
| loop(id1Func, id2Func, duration.toSeconds) | ||
| } | ||
|
|
||
| } |
2 changes: 1 addition & 1 deletion
2
...ala/encry/it/MinerWalletBalanceTest.scala → ...cry/it/miner/MinerWalletBalanceTest.scala
This file contains hidden or 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 hidden or 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
3 changes: 2 additions & 1 deletion
3
it/src/test/scala/encry/it/transactions/DataTransactionTest.scala
This file contains hidden or 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
...rc/test/scala/encry/it/transactions/ProcessingTransferTransactionWithEncryCoinsTest.scala
This file contains hidden or 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 hidden or 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,12 @@ | ||
| package encry.it.utils | ||
|
|
||
| import scala.concurrent.{Await, Future} | ||
| import scala.concurrent.duration.Duration | ||
|
|
||
| object FutureBlockedRun { | ||
|
|
||
| implicit class FutureBlockedRun[T](future: Future[T]) { | ||
| def run(implicit duration: Duration): T = Await.result(future, duration) | ||
| } | ||
|
|
||
| } |
2 changes: 1 addition & 1 deletion
2
...ansactionGenerator/TransactionsUtil.scala → ...ala/encry/it/utils/TransactionsUtil.scala
This file contains hidden or 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
78 changes: 78 additions & 0 deletions
78
it/src/test/scala/encry/it/variousСompound/NodeRestartTest.scala
This file contains hidden or 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,78 @@ | ||
| package encry.it.variousСompound | ||
CapDev12 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import java.nio.file.Paths | ||
|
|
||
| import encry.it.configs.Configs | ||
| import encry.it.docker.Docker.defaultConf | ||
| import encry.it.docker.DockerAfterAll | ||
| import encry.it.util.WaitUtils._ | ||
| import encry.it.utils.FutureBlockedRun._ | ||
| import org.encryfoundation.common.utils.Algos | ||
| import org.scalatest.{AsyncFunSuite, Matchers} | ||
| import scorex.utils.Random | ||
|
|
||
| import scala.concurrent.duration._ | ||
|
|
||
| class NodeRestartTest extends AsyncFunSuite with Matchers with DockerAfterAll { | ||
|
|
||
| implicit val futureDuration: FiniteDuration = 10 minutes | ||
|
|
||
| test("Nodes should sync after restart with new offlineGeneration and port") { | ||
| val node1 = docker | ||
| .startNodeInternal(Configs.mining(true) | ||
| .withFallback(Configs.nodeName("node1")) | ||
| .withFallback(Configs.offlineGeneration(true)) | ||
| .withFallback(Configs.knownPeers(Seq())) | ||
| .withFallback(defaultConf) | ||
| ) | ||
|
|
||
| val userDir = Paths.get(System.getProperty("user.dir")) | ||
| val volumeName = Algos.encode(Random.randomBytes(32)) | ||
| val containerMountPath = userDir + "/encry/data" | ||
|
|
||
| val node21 = docker | ||
| .startNodeInternal(Configs.mining(true) | ||
| .withFallback(Configs.nodeName("node21")) | ||
| .withFallback(Configs.offlineGeneration(false)) | ||
| .withFallback(Configs.knownPeers(Seq())) | ||
| .withFallback(defaultConf), | ||
| Some(volumeName, containerMountPath) | ||
| ) | ||
|
|
||
| node1.connect(s"${node21.nodeIp}:9001").run | ||
| node21.connect(s"${node1.nodeIp}:9001").run | ||
|
|
||
| node1.waitForFullHeight(5).run | ||
|
|
||
| node21.shutdown | ||
| Thread.sleep(5000) | ||
| docker.stopNode(node21, 5) | ||
| Thread.sleep(7000) | ||
|
|
||
| node1.waitForFullHeight(10).run | ||
|
|
||
| val node22 = docker | ||
| .startNodeInternal(Configs.mining(true) | ||
| .withFallback(Configs.nodeName("node22")) | ||
| .withFallback(Configs.offlineGeneration(true)) | ||
| .withFallback(Configs.knownPeers(Seq())) | ||
| .withFallback(Configs.networkAddress("0.0.0.0:9002")) | ||
| .withFallback(Configs.apiAddress("0.0.0.0:9052")) | ||
| .withFallback(defaultConf), | ||
| Some(volumeName, containerMountPath) | ||
| ) | ||
|
|
||
| node1.waitForFullHeight(15).run | ||
|
|
||
| node1.connect(s"${node22.nodeIp}:9002").run | ||
| node22.connect(s"${node1.nodeIp}:9001").run | ||
|
|
||
| node1.waitForFullHeight(20).run | ||
|
|
||
| val (bestFullHeaderId1, bestFullHeaderId2) = | ||
| waitForEqualsId(node1.bestFullHeaderId.run, node22.bestFullHeaderId.run) | ||
|
|
||
| bestFullHeaderId2 shouldEqual bestFullHeaderId1 | ||
| } | ||
|
|
||
| } | ||
59 changes: 59 additions & 0 deletions
59
it/src/test/scala/encry/it/variousСompound/ThreeNodesKnowAboutEachOtherTest.scala
This file contains hidden or 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 encry.it.variousСompound | ||
|
|
||
| import encry.it.configs.Configs | ||
| import encry.it.docker.Docker.defaultConf | ||
| import encry.it.docker.DockerAfterAll | ||
| import encry.it.util.WaitUtils._ | ||
| import encry.it.utils.FutureBlockedRun._ | ||
| import org.scalatest.{FunSuite, Matchers} | ||
|
|
||
| import scala.concurrent.duration._ | ||
|
|
||
| class ThreeNodesKnowAboutEachOtherTest extends FunSuite with Matchers with DockerAfterAll { | ||
|
|
||
| implicit val futureDuration: FiniteDuration = 10 minutes | ||
| val heightSeparation = 10 //blocks | ||
|
|
||
| test("nodes know about each other should sync") { | ||
|
|
||
| val node1 = docker | ||
| .startNodeInternal(Configs.nodeName("node1") | ||
| .withFallback(Configs.mining(true)) | ||
| .withFallback(Configs.offlineGeneration(true)) | ||
| .withFallback(Configs.networkAddress("0.0.0.0:9001")) | ||
| .withFallback(Configs.knownPeers(Seq())) | ||
| .withFallback(defaultConf) | ||
| ) | ||
|
|
||
| node1.waitForFullHeight(heightSeparation).run | ||
|
|
||
| val node2 = docker | ||
| .startNodeInternal(Configs.nodeName("node2") | ||
| .withFallback(Configs.mining(true)) | ||
| .withFallback(Configs.offlineGeneration(false)) | ||
| .withFallback(Configs.networkAddress("0.0.0.0:9001")) | ||
| .withFallback(Configs.knownPeers(Seq((node1.nodeIp, 9001)))) | ||
| .withFallback(defaultConf) | ||
| ) | ||
|
|
||
| node1.connect(s"${node2.nodeIp}:9001").run | ||
|
|
||
| node1.waitForFullHeight(heightSeparation * 2).run | ||
|
|
||
| val node3 = docker | ||
| .startNodeInternal(Configs.nodeName("node3") | ||
| .withFallback(Configs.mining(true)) | ||
| .withFallback(Configs.offlineGeneration(false)) | ||
| .withFallback(Configs.networkAddress("0.0.0.0:9001")) | ||
| .withFallback(Configs.knownPeers(Seq((node1.nodeIp, 9001), (node2.nodeIp, 9001)))) | ||
| .withFallback(defaultConf) | ||
| ) | ||
|
|
||
| waitForEqualsId(node1.bestFullHeaderId.run, node3.bestFullHeaderId.run) | ||
|
|
||
| val (bestFullHeaderId2, bestFullHeaderId3) = | ||
| waitForEqualsId(node2.bestFullHeaderId.run, node3.bestFullHeaderId.run) | ||
|
|
||
| bestFullHeaderId2 shouldEqual bestFullHeaderId3 | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.