Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freeelancer committed Mar 2, 2024
1 parent 8e08a83 commit a859d3a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
31 changes: 31 additions & 0 deletions app/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/terra-money/alliance/x/alliance"
"github.com/terra-money/core/v2/app"
"github.com/terra-money/core/v2/x/feeshare"
"github.com/terra-money/core/v2/x/smartaccount"
"github.com/terra-money/core/v2/x/tokenfactory"

mocktestutils "github.com/cosmos/cosmos-sdk/testutil/mock"
Expand Down Expand Up @@ -224,6 +225,7 @@ func (s *AppGenesisTestSuite) TestMigration() {
"upgrade": upgrade.AppModule{}.ConsensusVersion(),
"vesting": vesting.AppModule{}.ConsensusVersion(),
"wasm": wasm.AppModule{}.ConsensusVersion(),
"smartaccount": smartaccount.AppModule{}.ConsensusVersion(),
},
)
s.Require().NoError(err)
Expand Down Expand Up @@ -257,6 +259,7 @@ func (s *AppGenesisTestSuite) TestMigration() {
"upgrade": 2,
"vesting": 1,
"wasm": 4,
"smartaccount": 1,
})
}

Expand Down Expand Up @@ -685,6 +688,34 @@ func (s *AppGenesisTestSuite) TestGenesis() {
"redelegations": [],
"exported": false
},
"smartaccount": {
"params": {
},
"settings": [
]
},
"staking": {
"delegations": [
],
"exported": false,
"last_total_power": "0",
"last_validator_powers": [
],
"params": {
"bond_denom": "uluna",
"historical_entries": 10000,
"max_entries": 7,
"max_validators": 100,
"min_commission_rate": "0.000000000000000000",
"unbonding_time": "1814400s"
},
"redelegations": [
],
"unbonding_delegations": [
],
"validators": [
]
},
"tokenfactory": {
"params": {
"denom_creation_fee": [
Expand Down
12 changes: 7 additions & 5 deletions x/smartaccount/ante/tests/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
type AnteTestSuite struct {
test_helpers.SmartAccountTestSuite

Decorator ante.SmartAccountAuthDecorator
WasmKeeper *wasmkeeper.PermissionedKeeper
AuthDecorator ante.SmartAccountAuthDecorator
PreTxDecorator ante.PreTransactionHookDecorator
WasmKeeper *wasmkeeper.PermissionedKeeper
}

func TestAnteSuite(t *testing.T) {
Expand All @@ -33,7 +34,8 @@ func TestAnteSuite(t *testing.T) {
func (s *AnteTestSuite) Setup() {
s.SmartAccountTestSuite.SetupTests()
s.WasmKeeper = wasmkeeper.NewDefaultPermissionKeeper(s.App.Keepers.WasmKeeper)
s.Decorator = ante.NewSmartAccountAuthDecorator(s.SmartAccountKeeper, s.WasmKeeper, s.App.Keepers.AccountKeeper, nil, s.EncodingConfig.TxConfig.SignModeHandler())
s.AuthDecorator = ante.NewSmartAccountAuthDecorator(s.SmartAccountKeeper, s.WasmKeeper, s.App.Keepers.AccountKeeper, nil, s.EncodingConfig.TxConfig.SignModeHandler())
s.PreTxDecorator = ante.NewPreTransactionHookDecorator(s.SmartAccountKeeper, s.WasmKeeper)
s.Ctx = s.Ctx.WithChainID("test")
}

Expand Down Expand Up @@ -81,7 +83,7 @@ func (s *AnteTestSuite) TestAuthAnteHandler() {
ToAddress: acc.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin("uluna", 1)),
})
_, err = s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err = s.AuthDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.Error(s.T(), err)

// signing with testAcc0 pk which should pass
Expand All @@ -90,7 +92,7 @@ func (s *AnteTestSuite) TestAuthAnteHandler() {
ToAddress: acc.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin("uluna", 1)),
})
_, err = s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err = s.AuthDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.NoError(s.T(), err)
}

Expand Down
10 changes: 5 additions & 5 deletions x/smartaccount/ante/tests/pretransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (s *AnteTestSuite) TestPreTransactionHookWithoutSmartAccount() {
ToAddress: s.TestAccs[1].String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin("uluna", 100000000)),
})
_, err := s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err := s.PreTxDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.NoError(s.T(), err)
}

Expand All @@ -28,7 +28,7 @@ func (s *AnteTestSuite) TestPreTransactionHookWithEmptySmartAccount() {
ToAddress: s.TestAccs[1].String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin("uluna", 100000000)),
})
_, err := s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err := s.PreTxDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.NoError(s.T(), err)
}

Expand All @@ -42,7 +42,7 @@ func (s *AnteTestSuite) TestInvalidContractAddress() {
ToAddress: s.TestAccs[1].String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin("uluna", 100000000)),
})
_, err := s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err := s.PreTxDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.ErrorContainsf(s.T(), err, "no such contract", "error message: %s", err)
}

Expand All @@ -63,7 +63,7 @@ func (s *AnteTestSuite) TestSendCoinsWithLimitSendHook() {
ToAddress: acc.String(),
Amount: sdk.NewCoins(sdk.NewInt64Coin("uluna", 100000000)),
})
_, err = s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err = s.PreTxDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.NoError(s.T(), err)
}

Expand All @@ -84,6 +84,6 @@ func (s *AnteTestSuite) TestStakingWithLimitSendHook() {
ValidatorAddress: acc.String(),
Amount: sdk.NewInt64Coin("uluna", 100000000),
})
_, err = s.Decorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
_, err = s.PreTxDecorator.AnteHandle(s.Ctx, txBuilder.GetTx(), false, sdk.ChainAnteDecorators(sdk.Terminator{}))
require.ErrorContainsf(s.T(), err, "Unauthorized message type", "error message: %s", err)
}
8 changes: 4 additions & 4 deletions x/smartaccount/types/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func (suite *CodecTestSuite) TestRegisterInterfaces() {
impls := registry.ListImplementations(sdk.MsgInterfaceProtoName)
suite.Require().Equal(4, len(impls))
suite.Require().ElementsMatch([]string{
"/juno.feeshare.v1.MsgRegisterFeeShare",
"/juno.feeshare.v1.MsgCancelFeeShare",
"/juno.feeshare.v1.MsgUpdateFeeShare",
"/juno.feeshare.v1.MsgUpdateParams",
"/terra.smartaccount.v1.MsgCreateSmartAccount",
"/terra.smartaccount.v1.MsgUpdateAuthorization",
"/terra.smartaccount.v1.MsgUpdateTransactionHooks",
"/terra.smartaccount.v1.MsgDisableSmartAccount",
}, impls)
}

0 comments on commit a859d3a

Please sign in to comment.