public void calculates_rewards_correctly_for_external_addresses() { _block.Header.Number = 10; _block.Body = new BlockBody(_block.Body.Transactions, new[] { Build.A.BlockHeader.WithBeneficiary(TestItem.Addresses[0]).WithNumber(9).TestObject, Build.A.BlockHeader.WithBeneficiary(TestItem.Addresses[1]).WithNumber(8).TestObject }); var expected = new BlockReward[] { new BlockReward(TestItem.AddressA, 1, BlockRewardType.External), new BlockReward(TestItem.AddressB, 3, BlockRewardType.External), new BlockReward(TestItem.AddressC, 5, BlockRewardType.External), new BlockReward(TestItem.AddressD, 8, BlockRewardType.External), }; SetupBlockRewards(new Dictionary <Address, BlockReward[]>() { { _address10, expected } }); var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); }
public void calculates_rewards_correctly_for_ommers(long blockNumber, long expectedReward) { _block.Header.Number = blockNumber; _block.Body = new BlockBody(_block.Body.Transactions, new[] { Build.A.BlockHeader.WithBeneficiary(TestItem.AddressB).WithNumber(blockNumber - 1).TestObject, Build.A.BlockHeader.WithBeneficiary(TestItem.AddressD).WithNumber(blockNumber - 2).TestObject }); var expected = new BlockReward[] { new BlockReward(_block.Beneficiary, expectedReward, BlockRewardType.Block), new BlockReward(_block.Body.Ommers[0].Beneficiary, expectedReward, BlockRewardType.Uncle), new BlockReward(_block.Body.Ommers[1].Beneficiary, expectedReward, BlockRewardType.Uncle), }; SetupBlockRewards(new Dictionary <Address, BlockReward[]>() { { _address10, expected } }); var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); }
public void calculates_rewards_correctly_before_contract_transition(long blockNumber, long expectedReward) { _block.Header.Number = blockNumber; var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(new BlockReward(_block.Beneficiary, expectedReward, BlockRewardType.Block)); }
public void calculates_rewards_correctly_for_genesis() { _block.Header.Number = 0; var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEmpty(); }
public void calculates_rewards_correctly_after_contract_transition(long blockNumber, long expectedReward) { _block.Header.Number = blockNumber; var expected = new BlockReward(_block.Beneficiary, expectedReward, BlockRewardType.Block); SetupBlockRewards(new Dictionary <Address, BlockReward[]>() { { _address10, new[] { expected } } }); var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); }
public void calculates_rewards_correctly_after_subsequent_contract_transitions(long blockNumber, ulong expectedReward, Address address) { _auraParameters.BlockRewardContractTransitions = new Dictionary <long, Address>() { { 50, _address50 }, { 150, _address150 } }; _block.Header.Number = blockNumber; var expected = new BlockReward(_block.Beneficiary, expectedReward, BlockRewardType.External); SetupBlockRewards(new Dictionary <Address, BlockReward[]>() { { address, new[] { expected } } }); var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); }
public void calculates_rewards_correctly_for_ommers(long blockNumber, long expectedReward) { _block.Number = blockNumber; _block.Body.Ommers = new[] { Prepare.A.BlockHeader().WithBeneficiary(Address.FromNumber(777)).WithNumber(blockNumber - 1).TestObject, Prepare.A.BlockHeader().WithBeneficiary(Address.FromNumber(888)).WithNumber(blockNumber - 2).TestObject }; var expected = new BlockReward[] { new BlockReward(_block.Beneficiary, expectedReward, BlockRewardType.Block), new BlockReward(_block.Body.Ommers[0].Beneficiary, expectedReward, BlockRewardType.Uncle), new BlockReward(_block.Body.Ommers[1].Beneficiary, expectedReward, BlockRewardType.Uncle), }; SetupBlockRewards(expected); var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); }
public void calculates_rewards_correctly_for_external_addresses() { _block.Number = 10; _block.Body.Ommers = new[] { Prepare.A.BlockHeader().WithBeneficiary(Address.FromNumber(777)).WithNumber(9).TestObject, Prepare.A.BlockHeader().WithBeneficiary(Address.FromNumber(888)).WithNumber(8).TestObject }; var expected = new BlockReward[] { new BlockReward(TestItem.AddressA, 1, BlockRewardType.External), new BlockReward(TestItem.AddressB, 3, BlockRewardType.External), new BlockReward(TestItem.AddressC, 5, BlockRewardType.External), new BlockReward(TestItem.AddressD, 8, BlockRewardType.External), }; SetupBlockRewards(expected); var calculator = new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); var result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); }