Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
akremstudy committed Mar 21, 2024
1 parent 2beea22 commit 1cfa51b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
11 changes: 6 additions & 5 deletions tests/integration/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,17 @@ func (s *IntegrationTestSuite) SetupTest() {
s.app = app
}

func (s *IntegrationTestSuite) mintTokens(addr sdk.AccAddress, amount sdk.Coin) {
func (s *IntegrationTestSuite) mintTokens(addr sdk.AccAddress, amount math.Int) {
ctx := s.ctx
// s.accountKeeper.SetAccount(ctx, authtypes.NewBaseAccountWithAddress(addr))
s.NoError(s.bankKeeper.MintCoins(ctx, authtypes.Minter, sdk.NewCoins(amount)))
s.NoError(s.bankKeeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, addr, sdk.NewCoins(amount)))
coins := sdk.NewCoins(sdk.NewCoin(s.denom, amount))
s.NoError(s.bankKeeper.MintCoins(ctx, authtypes.Minter, coins))
s.NoError(s.bankKeeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, addr, coins))
}

func (s *IntegrationTestSuite) newKeysWithTokens() sdk.AccAddress {
Addr := sample.AccAddressBytes()
s.mintTokens(Addr, sdk.NewCoin(s.denom, math.NewInt(1_000_000)))
s.mintTokens(Addr, math.NewInt(1_000_000))
return Addr
}

Expand Down Expand Up @@ -350,7 +351,7 @@ func (s *IntegrationTestSuite) CreateAccountsWithTokens(numofAccs int, amountOfT
accs := make([]sdk.AccAddress, numofAccs)
for i, pk := range privKeys {
accs[i] = sdk.AccAddress(pk.PubKey().Address())
s.mintTokens(accs[i], sdk.NewCoin(s.denom, math.NewInt(amountOfTokens)))
s.mintTokens(accs[i], math.NewInt(amountOfTokens))
}
return accs
}
Expand Down
5 changes: 3 additions & 2 deletions types/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ var (
BondDenom = "loya"

OneTrb = math.NewInt(1_000_000)
// ten percent of 1TRB
TenPercent = math.NewInt(10_000)
// one percent of 1TRB
// min stake is 1TRB so min dispute fee would be 1% of 1TRB
OnePercent = math.NewInt(1_000)

PowerReduction = sdk.DefaultPowerReduction
)
4 changes: 1 addition & 3 deletions x/dispute/keeper/dispute.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ func (k Keeper) AddDisputeRound(ctx sdk.Context, dispute types.Dispute, msg type
if err != nil {
return err
}
// How does second round of dispute fee work?
// If fee is not paid then doubling the burnAmount means reducing the fee total?
// Reducing the fee total means that feeTotal - burnAmount could be zero and the fee payers don't get anything from the feePaid or who gets what is not clear

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions x/dispute/keeper/msg_server_propose_dispute.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func (k msgServer) ProposeDispute(goCtx context.Context, msg *types.MsgProposeDi
return nil, types.ErrInvalidFeeDenom.Wrapf("wrong fee denom: %s, expected: %s", msg.Fee.Denom, layer.BondDenom)
}

if msg.Fee.Amount.LT(layer.TenPercent) {
return nil, types.ErrMinimumTRBrequired.Wrapf("fee %s dosen't meet minimum fee required", msg.Fee.Amount)
if msg.Fee.Amount.LT(layer.OnePercent) {
return nil, types.ErrMinimumTRBrequired.Wrapf("fee %s doesn't meet minimum fee required", msg.Fee.Amount)
}
dispute := k.GetDisputeByReporter(ctx, *msg.Report, msg.DisputeCategory)

Expand Down
15 changes: 14 additions & 1 deletion x/reporter/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,15 @@ func (k Keeper) ReturnSlashedTokens(ctx context.Context, reporterAddr string, he
del.Amount = source.Amount
del.Reporter = repAcc.String()
// call hooks :todo
if err := k.BeforeDelegationCreated(ctx, reporter); err != nil {
return err
}
if err := k.Delegators.Set(ctx, delAddr, del); err != nil {
return err
}
if err := k.AfterDelegationModified(ctx, delAddr, repAcc.Bytes(), del.Amount); err != nil {
return err
}
vals, err := k.GetBondedValidators(ctx, 1)
if err != nil {
return err
Expand All @@ -929,11 +935,18 @@ func (k Keeper) ReturnSlashedTokens(ctx context.Context, reporterAddr string, he
continue
}
// if delegator exists, add tokens to it
del.Amount = del.Amount.Add(source.Amount)
// call hooks :todo
if err := k.BeforeDelegationModified(ctx, delAddr, del, reporter); err != nil {
return err
}
del.Amount = del.Amount.Add(source.Amount)

if err := k.Delegators.Set(ctx, delAddr, del); err != nil {
return err
}
if err := k.AfterDelegationModified(ctx, delAddr, repAcc.Bytes(), del.Amount); err != nil {
return err
}
// get token origin and see if it still exists
prevAmt, err := k.TokenOrigin.Get(ctx, collections.Join(delAddr, valAddr))
if err != nil {
Expand Down

0 comments on commit 1cfa51b

Please sign in to comment.