feat: Integrating POB into sim-app base app. (#130)
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
parent
e96831c244
commit
4da95939f5
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/ory/dockertest/v3"
|
||||
"github.com/ory/dockertest/v3/docker"
|
||||
"github.com/skip-mev/pob/tests/app"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@@ -105,10 +106,21 @@ func (s *IntegrationTestSuite) initNodes() {
|
||||
|
||||
// initialize a genesis file for the first validator
|
||||
val0ConfigDir := s.chain.validators[0].configDir()
|
||||
|
||||
// Define the builder module parameters
|
||||
params := types.Params{
|
||||
MaxBundleSize: 5,
|
||||
EscrowAccountAddress: "cosmos14j5j2lsx7629590jvpk3vj0xe9w8203jf4yknk",
|
||||
ReserveFee: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
MinBuyInFee: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
MinBidIncrement: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
ProposerFee: sdk.NewDecWithPrec(1, 2),
|
||||
}
|
||||
|
||||
for _, val := range s.chain.validators {
|
||||
valAddr, err := val.keyInfo.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(addGenesisAccount(val0ConfigDir, "", initBalanceStr, valAddr))
|
||||
s.Require().NoError(initGenesisFile(val0ConfigDir, "", initBalanceStr, valAddr, params))
|
||||
}
|
||||
|
||||
// copy the genesis file to the remaining validators
|
||||
@@ -283,7 +295,7 @@ func (s *IntegrationTestSuite) runValidators() {
|
||||
|
||||
return true
|
||||
},
|
||||
5*time.Minute,
|
||||
2*time.Minute,
|
||||
time.Second,
|
||||
"POB TestApp node failed to produce blocks",
|
||||
)
|
||||
|
||||
+12
-1
@@ -12,6 +12,7 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
)
|
||||
|
||||
func getGenDoc(path string) (*comettypes.GenesisDoc, error) {
|
||||
@@ -38,7 +39,7 @@ func getGenDoc(path string) (*comettypes.GenesisDoc, error) {
|
||||
return doc, nil
|
||||
}
|
||||
|
||||
func addGenesisAccount(path, moniker, amountStr string, accAddr sdk.AccAddress) error {
|
||||
func initGenesisFile(path, moniker, amountStr string, accAddr sdk.AccAddress, params types.Params) error {
|
||||
serverCtx := server.NewDefaultContext()
|
||||
config := serverCtx.Config
|
||||
|
||||
@@ -100,6 +101,16 @@ func addGenesisAccount(path, moniker, amountStr string, accAddr sdk.AccAddress)
|
||||
|
||||
appState[banktypes.ModuleName] = bankGenStateBz
|
||||
|
||||
builderGenState := types.GetGenesisStateFromAppState(cdc, appState)
|
||||
builderGenState.Params = params
|
||||
|
||||
builderGenStateBz, err := cdc.MarshalJSON(&builderGenState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal builder genesis state: %w", err)
|
||||
}
|
||||
|
||||
appState[types.ModuleName] = builderGenStateBz
|
||||
|
||||
appStateJSON, err := json.Marshal(appState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal application genesis state: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user