File tree Expand file tree Collapse file tree
contract/AElf.Contracts.Profit
test/AElf.Contracts.Profit.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -719,6 +719,16 @@ public override Empty ContributeProfits(ContributeProfitsInput input)
719719
720720 return new Empty ( ) ;
721721 }
722+
723+ public override Empty IncreaseBackupSubsidyTotalShare ( Hash schemeId )
724+ {
725+ Assert ( ! State . BackupSubsidyTotalShareIncreased . Value , "Already increased" ) ;
726+ State . BackupSubsidyTotalShareIncreased . Value = true ;
727+ var scheme = State . SchemeInfos [ schemeId ] ;
728+ scheme . TotalShares = scheme . TotalShares . Add ( 1 ) ;
729+ State . SchemeInfos [ schemeId ] = scheme ;
730+ return new Empty ( ) ;
731+ }
722732
723733 public override Empty ResetManager ( ResetManagerInput input )
724734 {
Original file line number Diff line number Diff line change @@ -17,4 +17,6 @@ public partial class ProfitContractState : ContractState
1717 public MappedState < string , MethodFees > TransactionFees { get ; set ; }
1818
1919 public SingletonState < AuthorityInfo > MethodFeeController { get ; set ; }
20+
21+ public BoolState BackupSubsidyTotalShareIncreased { get ; set ; }
2022}
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ service ProfitContract {
6060 rpc RemoveSubScheme (RemoveSubSchemeInput ) returns (google.protobuf.Empty ) {
6161 }
6262
63+ // Increase backup subsidy TotalShare
64+ rpc IncreaseBackupSubsidyTotalShare (aelf.Hash ) returns (google.protobuf.Empty ) {
65+ }
66+
6367 // Reset the manager of a scheme.
6468 rpc ResetManager (ResetManagerInput ) returns (google.protobuf.Empty ) {
6569 }
Original file line number Diff line number Diff line change @@ -1679,6 +1679,19 @@ await ProfitContractStub.ClaimProfits.SendAsync(new ClaimProfitsInput
16791679 details . Details . First ( ) . LastProfitPeriod . ShouldBe ( scheme . CurrentPeriod ) ;
16801680 }
16811681 }
1682+
1683+ [ Fact ]
1684+ public async Task IncreaseBackupSubsidyTotalShare_Test ( )
1685+ {
1686+ var schemeId = await CreateSchemeAsync ( ) ;
1687+ var scheme = await ProfitContractStub . GetScheme . CallAsync ( schemeId ) ;
1688+ scheme . TotalShares . ShouldBe ( 0 ) ;
1689+ await ProfitContractStub . IncreaseBackupSubsidyTotalShare . SendAsync ( schemeId ) ;
1690+ scheme = await ProfitContractStub . GetScheme . CallAsync ( schemeId ) ;
1691+ scheme . TotalShares . ShouldBe ( 1 ) ;
1692+ var result = await ProfitContractStub . IncreaseBackupSubsidyTotalShare . SendWithExceptionAsync ( schemeId ) ;
1693+ result . TransactionResult . Error . ShouldContain ( "Already increased" ) ;
1694+ }
16821695
16831696 private async Task ContributeProfits ( Hash schemeId , long amount = 100 )
16841697 {
You can’t perform that action at this time.
0 commit comments