@@ -14,6 +14,7 @@ import com.wavesplatform.events.protobuf.BlockchainUpdated.Rollback.RollbackType
1414import com .wavesplatform .events .protobuf .BlockchainUpdated .Update
1515import com .wavesplatform .events .protobuf .serde .*
1616import com .wavesplatform .events .protobuf .{TransactionMetadata , BlockchainUpdated as PBBlockchainUpdated }
17+ import com .wavesplatform .features .BlockchainFeatures .BlockReward
1718import com .wavesplatform .history .Domain
1819import com .wavesplatform .lang .directives .values .V5
1920import com .wavesplatform .lang .v1 .FunctionHeader
@@ -278,9 +279,74 @@ class BlockchainUpdatesSpec extends FreeSpec with WithBUDomain with ScalaFutures
278279 )
279280 }
280281
281- " should include correct waves amount" in withNEmptyBlocksSubscription(settings = currentSettings) { result =>
282- val balances = result.collect { case b if b.update.isAppend => b.getAppend.getBlock.updatedWavesAmount }
283- balances shouldBe Seq (10000000000000000L , 10000000600000000L , 10000001200000000L )
282+ " should include correct waves amount" - {
283+ val totalWaves = 100_000_000_0000_0000L
284+ val reward = 6_0000_0000
285+
286+ " on preactivated block reward" in {
287+ val settings = currentSettings.setFeaturesHeight((BlockReward , 0 ))
288+
289+ withDomainAndRepo(settings) { case (d, repo) =>
290+ d.appendBlock()
291+ d.blockchain.wavesAmount(1 ) shouldBe totalWaves + reward
292+ repo.getBlockUpdate(1 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward
293+
294+ d.appendBlock()
295+ d.blockchain.wavesAmount(2 ) shouldBe totalWaves + reward * 2
296+ repo.getBlockUpdate(2 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward * 2
297+ }
298+ }
299+
300+ " on activation of block reward" in {
301+ val settings = currentSettings.setFeaturesHeight((BlockReward , 3 ))
302+
303+ withNEmptyBlocksSubscription(settings = settings, count = 3 ) { result =>
304+ val balances = result.collect { case b if b.update.isAppend => b.getAppend.getBlock.updatedWavesAmount }
305+ balances shouldBe Seq (totalWaves, totalWaves, totalWaves + reward, totalWaves + reward * 2 )
306+ }
307+
308+ withDomainAndRepo(settings) { case (d, repo) =>
309+ d.appendBlock()
310+ d.blockchain.wavesAmount(1 ) shouldBe totalWaves
311+ repo.getBlockUpdate(1 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves
312+
313+ d.appendBlock()
314+ d.blockchain.wavesAmount(2 ) shouldBe totalWaves
315+ repo.getBlockUpdate(2 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves
316+
317+ d.appendBlock()
318+ d.blockchain.wavesAmount(3 ) shouldBe totalWaves + reward
319+ repo.getBlockUpdate(3 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward
320+
321+ d.appendBlock()
322+ d.blockchain.wavesAmount(4 ) shouldBe totalWaves + reward * 2
323+ repo.getBlockUpdate(4 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward * 2
324+ }
325+ }
326+
327+ " on rollbacks" in {
328+ withDomainAndRepo(currentSettings) { case (d, repo) =>
329+ d.appendBlock()
330+
331+ // block and micro append
332+ val block = d.appendBlock()
333+ block.sender shouldBe defaultSigner.publicKey
334+
335+ d.appendMicroBlock(TxHelpers .transfer(defaultSigner))
336+ d.blockchain.wavesAmount(2 ) shouldBe totalWaves + reward * 2
337+ repo.getBlockUpdate(2 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward * 2
338+
339+ // micro rollback
340+ d.appendKeyBlock(Some (block.id()))
341+ d.blockchain.wavesAmount(3 ) shouldBe totalWaves + reward * 3
342+ repo.getBlockUpdate(3 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward * 3
343+
344+ // block rollback
345+ d.rollbackTo(2 )
346+ d.blockchain.wavesAmount(2 ) shouldBe totalWaves + reward * 2
347+ repo.getBlockUpdate(2 ).getUpdate.vanillaAppend.updatedWavesAmount shouldBe totalWaves + reward * 2
348+ }
349+ }
284350 }
285351
286352 " should include correct heights" in withNEmptyBlocksSubscription(settings = currentSettings) { result =>
0 commit comments