-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ff68e5
commit 5ef5e87
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/provenance-io/provenance/app" | ||
simapp "github.com/provenance-io/provenance/app" | ||
"github.com/provenance-io/provenance/x/attribute/types" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ParamTestSuite struct { | ||
suite.Suite | ||
|
||
app *app.App | ||
ctx sdk.Context | ||
|
||
startBlockTime time.Time | ||
} | ||
|
||
func (s *ParamTestSuite) SetupTest() { | ||
s.app = simapp.Setup(s.T()) | ||
s.startBlockTime = time.Now() | ||
s.ctx = s.app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: s.startBlockTime}) | ||
} | ||
|
||
func TestParamTestSuite(t *testing.T) { | ||
suite.Run(t, new(ParamTestSuite)) | ||
} | ||
|
||
func (s *ParamTestSuite) TestGetSetParams() { | ||
defaultParams := s.app.AttributeKeeper.GetParams(s.ctx) | ||
s.Require().Equal(int(types.DefaultMaxValueLength), int(defaultParams.MaxValueLength), "GetParams() Default max value length should match") | ||
|
||
defaultValueLength := s.app.AttributeKeeper.GetMaxValueLength(s.ctx) | ||
s.Require().Equal(int(types.DefaultMaxValueLength), int(defaultValueLength), "GetMaxValueLength() Default max value length should match") | ||
|
||
newMaxValueLength := uint32(2048) | ||
newParams := types.Params{ | ||
MaxValueLength: newMaxValueLength, | ||
} | ||
s.app.AttributeKeeper.SetParams(s.ctx, newParams) | ||
|
||
updatedParams := s.app.AttributeKeeper.GetParams(s.ctx) | ||
s.Require().Equal(int(newMaxValueLength), int(updatedParams.MaxValueLength), "GetParams() Updated max value length should match") | ||
|
||
updatedValueLength := s.app.AttributeKeeper.GetMaxValueLength(s.ctx) | ||
s.Require().Equal(int(newMaxValueLength), int(updatedValueLength), "GetMaxValueLength() Updated max value length should match") | ||
} |