4
4
"testing"
5
5
"time"
6
6
7
+ sdk "github.com/cosmos/cosmos-sdk/types"
7
8
testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper"
8
9
"github.com/sei-protocol/sei-chain/x/evm/types"
9
10
"github.com/stretchr/testify/require"
@@ -20,3 +21,28 @@ func TestParams(t *testing.T) {
20
21
21
22
require .Nil (t , k .GetParams (ctx ).Validate ())
22
23
}
24
+
25
+ func TestGetParamsIfExists (t * testing.T ) {
26
+ k := & testkeeper .EVMTestApp .EvmKeeper
27
+ ctx := testkeeper .EVMTestApp .GetContextForDeliverTx ([]byte {}).WithBlockTime (time .Now ())
28
+
29
+ // Define the expected parameters
30
+ expectedParams := types.Params {
31
+ PriorityNormalizer : sdk .NewDec (1 ),
32
+ BaseFeePerGas : sdk .NewDec (1 ),
33
+ }
34
+
35
+ // Set only a subset of the parameters in the keeper
36
+ k .Paramstore .Set (ctx , types .KeyPriorityNormalizer , expectedParams .PriorityNormalizer )
37
+ k .Paramstore .Set (ctx , types .KeyBaseFeePerGas , expectedParams .BaseFeePerGas )
38
+
39
+ // Retrieve the parameters using GetParamsIfExists
40
+ params := k .GetParamsIfExists (ctx )
41
+
42
+ // Assert that the retrieved parameters match the expected parameters
43
+ require .Equal (t , expectedParams .PriorityNormalizer , params .PriorityNormalizer )
44
+ require .Equal (t , expectedParams .BaseFeePerGas , params .BaseFeePerGas )
45
+
46
+ // Assert that the missing parameter has its default value
47
+ require .Equal (t , types .DefaultParams ().DeliverTxHookWasmGasLimit , params .DeliverTxHookWasmGasLimit )
48
+ }
0 commit comments