Skip to content

Commit a0804d7

Browse files
authored
Merge pull request #3396 from AElfProject/hotfix/increase-backup-subsidy-totalshare
Increase backup subsidy total share
2 parents b4df4f6 + 6be5cd9 commit a0804d7

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

contract/AElf.Contracts.Profit/ProfitContract.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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
{

contract/AElf.Contracts.Profit/ProfitContractState.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

protobuf/profit_contract.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

test/AElf.Contracts.Profit.Tests/ProfitTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)