Skip to content
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

Qaseio #23

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/scala/units/BlockBriefValidationTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BlockBriefValidationTestSuite extends BaseIntegrationTestSuite {
)

"Brief validation of EC Block incoming from network" - {
"accepts if it is valid" in test { d =>
"L2-212 accepts if it is valid" in test { d =>
val ecBlock = d.createEcBlockBuilder("0", miner).build()

step(s"Receive ecBlock ${ecBlock.hash} from a peer")
Expand All @@ -26,7 +26,7 @@ class BlockBriefValidationTestSuite extends BaseIntegrationTestSuite {
}
}

"otherwise ignoring" in test { d =>
"L2-384 otherwise ignoring" in test { d =>
val ecBlock = d.createEcBlockBuilder("0", minerRewardL2Address = EthAddress.empty, parent = d.ecGenesisBlock).build()

step(s"Receive ecBlock ${ecBlock.hash} from a peer")
Expand Down
14 changes: 7 additions & 7 deletions src/test/scala/units/BlockFullValidationTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class BlockFullValidationTestSuite extends BaseIntegrationTestSuite {
)

"Full validation when the block is available on EL and CL" - {
"doesn't happen for finalized blocks" in withExtensionDomain(defaultSettings.copy(initialMiners = List(reliable))) { d =>
"L2-315 doesn't happen for finalized blocks" in withExtensionDomain(defaultSettings.copy(initialMiners = List(reliable))) { d =>
step("Start new epoch for ecBlock")
d.advanceNewBlocks(reliable.address)
d.advanceNewBlocks(reliable.address) // Waiting for reliable miner epoch
val ecBlock = d.createEcBlockBuilder("0", reliable).buildAndSetLogs(ecBlockLogs)
d.advanceConsensusLayerChanged()

Expand All @@ -48,7 +48,7 @@ class BlockFullValidationTestSuite extends BaseIntegrationTestSuite {
}
}

"happens for not finalized blocks" - {
"L2-310 happens for not finalized blocks" - {
"successful validation updates the chain information" in withExtensionDomain() { d =>
step("Start new epoch for ecBlock")
d.advanceNewBlocks(reliable.address)
Expand Down Expand Up @@ -76,7 +76,7 @@ class BlockFullValidationTestSuite extends BaseIntegrationTestSuite {
}
}

"unsuccessful causes a fork" - {
"L2-245 unsuccessful causes a fork" - {
def e2CTest(
blockLogs: List[GetLogsResponseEntry],
e2CTransfersRootHashHex: String,
Expand Down Expand Up @@ -110,12 +110,12 @@ class BlockFullValidationTestSuite extends BaseIntegrationTestSuite {
}
}

"CL confirmation without a transfers root hash" in e2CTest(
"L2-361 CL confirmation without a transfers root hash" in e2CTest(
blockLogs = ecBlockLogs,
e2CTransfersRootHashHex = EmptyE2CTransfersRootHashHex
)

"Events from an unexpected EL bridge address" in {
"L2-385 Events from an unexpected EL bridge address" in {
val fakeBridgeAddress = EthAddress.unsafeFrom("0x53481054Ad294207F6ed4B6C2E6EaE34E1Bb8704")
val ecBlock2Logs = transferEvents.map(x => getLogsResponseEntry(x).copy(address = fakeBridgeAddress))
e2CTest(
Expand All @@ -124,7 +124,7 @@ class BlockFullValidationTestSuite extends BaseIntegrationTestSuite {
)
}

"Different miners in CL and EL" in e2CTest(
"L2-256 Different miners in CL and EL" in e2CTest(
blockLogs = ecBlockLogs,
e2CTransfersRootHashHex = e2CTransfersRootHashHex,
badBlockPostProcessing = _.copy(minerRewardL2Address = reliable.elRewardAddress)
Expand Down
10 changes: 5 additions & 5 deletions src/test/scala/units/BlockIssuesForgingTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BlockIssuesForgingTestSuite extends BaseIntegrationTestSuite {
f(d, ecBlock2, ecBlock2Epoch)
}

"EC-block comes within timeout - then we continue forging" in test { (d, ecBlock2, ecBlock2Epoch) =>
"L2-309 EC-block comes within timeout - then we continue forging" in test { (d, ecBlock2, ecBlock2Epoch) =>
d.advanceElu(WaitRequestedBlockTimeout - 1.millis)
d.waitForCS[FollowingChain](s"Still waiting ecBlock2 ${ecBlock2.hash}") { s =>
s.nextExpectedBlock.value.hash shouldBe ecBlock2.hash
Expand All @@ -69,7 +69,7 @@ class BlockIssuesForgingTestSuite extends BaseIntegrationTestSuite {
}
}

"EC-block doesn't come - then we start an alternative chain" in test { (d, _, _) =>
"L2-251 EC-block doesn't come - then we start an alternative chain" in test { (d, _, _) =>
d.waitForCS[WaitForNewChain](s"Switched to alternative chain") { _ => }
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ class BlockIssuesForgingTestSuite extends BaseIntegrationTestSuite {
s.nodeChainInfo.lastBlock.hash shouldBe ecBadBlock2.hash
}

step(s"Start a new epoch of otherMiner2 ${otherMiner2.address} with alternative chain ecBlock2")
step(s"L2-280 Start a new epoch of otherMiner2 ${otherMiner2.address} with alternative chain ecBlock2")
d.advanceNewBlocks(otherMiner2.address)
val ecBlock2 = d.createEcBlockBuilder("0-1", otherMiner2, ecBlock1).rewardPrevMiner().buildAndSetLogs()

Expand Down Expand Up @@ -154,7 +154,7 @@ class BlockIssuesForgingTestSuite extends BaseIntegrationTestSuite {
}
}

"We mined before the alternative chain before and EC-block doesn't come - then we still wait for it" in withExtensionDomain() { d =>
"L2-386 We mined before the alternative chain before and EC-block doesn't come - then we still wait for it" in withExtensionDomain() { d =>
step(s"Start a new epoch of otherMiner1 ${otherMiner1.address} with ecBlock1")
d.advanceNewBlocks(otherMiner1.address)
val ecBlock1 = d.createEcBlockBuilder("0", otherMiner1).buildAndSetLogs()
Expand Down Expand Up @@ -219,7 +219,7 @@ class BlockIssuesForgingTestSuite extends BaseIntegrationTestSuite {
}
}

"We haven't mined the alternative chain before and EC-block doesn't come - then we wait for a new alternative chain" in
"L2-276 We haven't mined the alternative chain before and EC-block doesn't come - then we wait for a new alternative chain" in
withExtensionDomain() { d =>
step(s"Start a new epoch of otherMiner1 ${otherMiner1.address} with ecBlock1")
d.advanceNewBlocks(otherMiner1.address)
Expand Down
12 changes: 7 additions & 5 deletions src/test/scala/units/C2ETransfersTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class C2ETransfersTestSuite extends BaseIntegrationTestSuite {
additionalBalances = List(AddrWithBalance(transferSenderAccount.toAddress))
)

"Pass valid address with valid payment" in {
"L2-351 Pass valid address with valid payment" in {
transferFuncTest(validTransferRecipient) should beRight
}

"Deny invalid address" in forAll(
"L2-348 Deny invalid address" in forAll(
Table(
"invalid address" -> "message",
"" -> "Address should have 40 characters",
Expand All @@ -33,18 +33,20 @@ class C2ETransfersTestSuite extends BaseIntegrationTestSuite {
transferFuncTest(address) should produce(message)
}

"Deny invalid payment amount" in forAll(
"L2-358 Deny invalid payment amount" in forAll(
Table(
("invalid payment amount", "initial queue size", "message"),
(1, 0, "should be >= 1000000 for queue size of 1"),
(1_000_000, 1600, "should be >= 100000000 for queue size of 1601"),
(1_000_000, 160, "should be >= 10000000 for queue size of 161"),
(10_000_000, 1600, "should be >= 100000000 for queue size of 1601"),
(100_000_000, 3200, "should be >= 1000000000 for queue size of 3201"),
(1_000_000_001, 6401, "Transfers denied for queue size of 6402")
)
) { case (transferAmount, initQueueSize, message) =>
transferFuncTest(validTransferRecipient, transferAmount, queueSize = initQueueSize) should produce(message)
}

"Deny invalid asset" in forAll(
"L2-354 Deny invalid asset" in forAll(
Table(
"invalid token" -> "message",
Asset.Waves -> "in the payment, got Waves",
Expand Down
16 changes: 8 additions & 8 deletions src/test/scala/units/E2CTransfersTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
additionalBalances = List(AddrWithBalance(transferReceiver.toAddress, defaultFees.chainContract.withdrawFee))
)

"Multiple withdrawals" in {
"L2-288 Multiple withdrawals" in {
val transferReceiver1 = transferReceiver
val transferReceiver2 = TxHelpers.signer(2)
val transfer1 = Bridge.ElSentNativeEvent(transferReceiver1.toAddress, 1)
Expand Down Expand Up @@ -79,7 +79,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Can't get transferred tokens with index that is out of bounds" in forAll(
"L2-388 Can't get transferred tokens with index that is out of bounds" in forAll(
Table(
"index" -> "errorMessage",
-1 -> "Transfer index in block should be nonnegative, got -1",
Expand All @@ -102,7 +102,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Deny withdrawals with a non-positive amount" in forAll(
"L2-389 Deny withdrawals with a non-positive amount" in forAll(
Table(
"index",
0L,
Expand All @@ -124,7 +124,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Can't get transferred tokens if the data is incorrect and able if it is correct" in withExtensionDomain() { d =>
"L2-339 Can't get transferred tokens if the data is incorrect and able if it is correct" in withExtensionDomain() { d =>
step(s"Start new epoch with ecBlock")
d.advanceNewBlocks(reliable.address)
val ecBlock = d.createEcBlockBuilder("0", reliable).buildAndSetLogs(ecBlockLogs)
Expand All @@ -143,7 +143,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Can't get transferred tokens twice" in {
"L2-273 Can't get transferred tokens twice" in {
val settings = defaultSettings.copy(
additionalBalances = List(AddrWithBalance(transferReceiver.toAddress, defaultFees.chainContract.withdrawFee * 2))
)
Expand All @@ -165,7 +165,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Ignores wrong events" in {
"L2-377 Ignores wrong events" in {
val wrongEventDef: Event = new Event(
"SentSomething",
List[TypeReference[?]](new TypeReference[Bytes20](false) {}).asJava
Expand Down Expand Up @@ -204,7 +204,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Fails on wrong data" in {
"L2-387 Fails on wrong data" in {
val settings = defaultSettings.withEnabledElMining
withExtensionDomain(settings) { d =>
step(s"Start new epoch with ecBlock1")
Expand All @@ -220,7 +220,7 @@ class E2CTransfersTestSuite extends BaseIntegrationTestSuite {
}
}

"Can't get transferred tokens from a fork and can after the fork becomes a main chain" in {
"L2-308 Can't get transferred tokens from a fork and can after the fork becomes a main chain" in {
val settings = defaultSettings.copy(initialMiners = List(reliable, malfunction)).withEnabledElMining
withExtensionDomain(settings) { d =>
step(s"Start a new epoch of malfunction miner ${malfunction.address} with ecBlock1")
Expand Down