mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-29 01:35:18 +00:00
a9583b16f4
* feat(community): add AnnualizedRewards grpc query (#1751)
* add annualized_reward query proto
* use sdkmath.LegacyDec to match RPS param...
* add AnnualizedRewards grpc query
* add changelog entry
* simplify calculation & expand test cases
(cherry picked from commit 0efe7f2281
)
* fix conflicts, remove community param references
* backport update to lint CI
* disable internal testnet genesis check
* fix initialization order of keepers in app.go
---------
Co-authored-by: Robert Pirtle <Astropirtle@gmail.com>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package testutil
|
|
|
|
import (
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
tmtime "github.com/tendermint/tendermint/types/time"
|
|
|
|
"github.com/kava-labs/kava/app"
|
|
"github.com/kava-labs/kava/x/community/keeper"
|
|
"github.com/kava-labs/kava/x/community/types"
|
|
)
|
|
|
|
// Test suite used for all community tests
|
|
type Suite struct {
|
|
suite.Suite
|
|
App app.TestApp
|
|
Ctx sdk.Context
|
|
Keeper keeper.Keeper
|
|
|
|
MaccAddress sdk.AccAddress
|
|
}
|
|
|
|
// The default state used by each test
|
|
func (suite *Suite) SetupTest() {
|
|
app.SetSDKConfig()
|
|
tApp := app.NewTestApp()
|
|
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
|
|
|
suite.App = tApp.InitializeFromGenesisStates()
|
|
|
|
suite.Ctx = ctx
|
|
suite.Keeper = tApp.GetCommunityKeeper()
|
|
communityPoolAddress := tApp.GetAccountKeeper().GetModuleAddress(types.ModuleAccountName)
|
|
// hello, greppers!
|
|
suite.Equal("kava17d2wax0zhjrrecvaszuyxdf5wcu5a0p4qlx3t5", communityPoolAddress.String())
|
|
suite.MaccAddress = communityPoolAddress
|
|
}
|
|
|
|
// CreateFundedAccount creates a random account and mints `coins` to it.
|
|
func (suite *Suite) CreateFundedAccount(coins sdk.Coins) sdk.AccAddress {
|
|
addr := app.RandomAddress()
|
|
err := suite.App.FundAccount(suite.Ctx, addr, coins)
|
|
suite.Require().NoError(err)
|
|
return addr
|
|
}
|