-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(evmengine): add test cases for params (#136)
increased coverage to 77.3%
- Loading branch information
Showing
1 changed file
with
48 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,48 @@ | ||
package keeper | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/piplabs/story/client/x/evmengine/types" | ||
) | ||
|
||
func TestKeeper_ExecutionBlockHash(t *testing.T) { | ||
t.Parallel() | ||
ctx, keeper := createTestKeeper(t) | ||
|
||
// check existing execution block hash | ||
execHash, err := keeper.ExecutionBlockHash(ctx) | ||
require.NoError(t, err) | ||
require.Nil(t, execHash, "execution block hash should be nil because it is not set yet") | ||
|
||
// set execution block hash | ||
dummyHash := common.HexToHash("0x047e24c3455107d87c68dffa307b3b7fa1877f3e9d7f30c7ee359f2eff3a75d9") | ||
require.NoError(t, keeper.SetParams(ctx, types.Params{ExecutionBlockHash: dummyHash.Bytes()})) | ||
|
||
// check execution block hash whether it is set correctly | ||
execHash, err = keeper.ExecutionBlockHash(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, dummyHash.Bytes(), execHash, "execution block hash should be equal to the dummy hash") | ||
} | ||
|
||
func TestKeeper_GetSetParams(t *testing.T) { | ||
t.Parallel() | ||
ctx, keeper := createTestKeeper(t) | ||
|
||
// check existing params | ||
params, err := keeper.GetParams(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, types.DefaultParams(), params, "params should be equal to the default params") | ||
|
||
// set execution block hash | ||
dummyHash := common.HexToHash("0x047e24c3455107d87c68dffa307b3b7fa1877f3e9d7f30c7ee359f2eff3a75d9") | ||
require.NoError(t, keeper.SetParams(ctx, types.Params{ExecutionBlockHash: dummyHash.Bytes()})) | ||
|
||
// check params whether it is set correctly | ||
params, err = keeper.GetParams(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, types.Params{ExecutionBlockHash: dummyHash.Bytes()}, params) | ||
} |