任务名称:使用TestKit AEDPoS扩展 #1915 重构投票合约的测试用例
难度:难度系数相对较大,一个测试工程师一天的任务量
奖励:1122个ELF (或者等值1000人民币)
附上issue详情和教程,如下:
① issue介绍:https://github.com/AElfProject/AElf/issues/1915
② AElf的issue解决方案-中文社区教程:https://github.com/AElfProject/AElf/issues/1846
如有兴趣,可以在issue上直接跟技术团队沟通。或者直接加入开发者社区QQ群:群号:102857654
任务说明:
这个任务是基于分支refactor/Vote-contract-tests,所以有兴趣的人投票合同的重构测试用例需要从签他支dev到refactor/Vote-contract-tests。(或者根据此分支在您自己的仓库上创建一个新分支。)
检查项目test/AElf.Contracts.AEDPoSExtension.Demo.Tests基本知道如何使用TestKit AEDPoS扩展。 测试用例DemoTest(如下图所示)显示了区块链系统的工作原理:选择一些事务然后将它们打包到一个块,每个新块都基于前一个块。 通过使用XXStub,您可以像调用/发送事务的特定用户一样调用测试用例中的特定合同方法。此外,您可以XXStub用于生成交易。
[Fact] public async Task Demotest() { // Check round information after initialization. { var round = await Consensusstub.GetCurrentRoundinformation.CallAsync(new Empty()); round.RoundNumber.ShouldBe(1); round.TermNumber.ShouldBe(1); round.RealTimeminersinformation.Count.ShouldBe(AEDPoSExtensionConstants.InitialKeyPairCount); } // We can use this method process testing. // Basically this will produce one block with no transaction. await BlockMiningService.mineBlockAsync(); // And this will produce one block with one transaction. // This transaction will call Create method of Token Contract. await BlockMiningService.mineBlockAsync(new List<Transaction> { TokenStub.Create.GetTransaction(new Createinput { Symbol = "ELF",Decimals = 8,Tokenname = "Test",Issuer = Address.FrompublicKey(SampleECKeyPairs.KeyPairs[0].PublicKey),IsBurnable = true,TotalSupply = 1_000_000_000_00000000 }) }); // Check whether prevIoUs Create transaction successfully executed. { var tokenInfo = await TokenStub.GetTokenInfo.CallAsync(new GetTokenInfoinput {Symbol = "ELF"}); tokenInfo.Symbol.ShouldBe("ELF"); } // Next steps will check whether the AEDPoS process is correct. // Now 2 miners produced block during first round,so there should be 2 miners‘ OutValue isn‘t null. { var round = await Consensusstub.GetCurrentRoundinformation.CallAsync(new Empty()); round.RealTimeminersinformation.Values.Count(m => m.OutValue != null).ShouldBe(2); } await BlockMiningService.mineBlockAsync(new List<Transaction>()); { var round = await Consensusstub.GetCurrentRoundinformation.CallAsync(new Empty()); round.RealTimeminersinformation.Values.Count(m => m.OutValue != null).ShouldBe(3); } // Currently we have 5 miners,and before this line,3 miners already produced blocks. // 3 more blocks will end current round. for (var i = 0; i < 3; i++) { await BlockMiningService.mineBlockAsync(new List<Transaction>()); } // Check round number. { var round = await Consensusstub.GetCurrentRoundinformation.CallAsync(new Empty()); round.RoundNumber.ShouldBe(2); } // 6 more blocks will end second round. for (var i = 0; i < 6; i++) { await BlockMiningService.mineBlockAsync(new List<Transaction>()); } // Check round number. { var round = await Consensusstub.GetCurrentRoundinformation.CallAsync(new Empty()); round.RoundNumber.ShouldBe(3); } }
知道这一点后,您可以去
test/AElf.Contracts.Vote.AEDPoSExtension.Tests
尝试重构投票合同的测试用例。对于测试逻辑,只需复制当前测试用例的逻辑即可 AElf.Contracts.Vote.Tests
。 此外,欢迎重构其他系统合同(位于其中contract/
)。README
in test/AElf.Contracts.AEDPoSExtension.Demo.Tests
解释了如何创建测试项目。
以上是内存溢出为你收集整理的【AELF开发者社区任务活动】c#任务-使用TestKit AEDPoS扩展 #1915 重构投票合约的测试用例全部内容,希望文章能够帮你解决【AELF开发者社区任务活动】c#任务-使用TestKit AEDPoS扩展 #1915 重构投票合约的测试用例所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)