-
Notifications
You must be signed in to change notification settings - Fork 333
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
bda4959
commit da37a62
Showing
5 changed files
with
191 additions
and
39 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
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,3 @@ | ||
mockgen -source=precompile.go \ | ||
-package v3_test \ | ||
-destination=precompile_mock_test.go |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,47 +1,38 @@ | ||
package v3_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/testutil" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/kava-labs/kava/app" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/evmos/ethermint/x/evm/statedb" | ||
"github.com/golang/mock/gomock" | ||
"github.com/stretchr/testify/require" | ||
|
||
v3 "github.com/kava-labs/kava/x/evmutil/migrations/v3" | ||
"testing" | ||
) | ||
|
||
func getAccountCallback(ctx sdk.Context, addr common.Address) {} | ||
|
||
func mkSetAccountCallback(t *testing.T) func(ctx sdk.Context, addr common.Address, account statedb.Account) error { | ||
return func(ctx sdk.Context, addr common.Address, account statedb.Account) error { | ||
require.True(t, account.Nonce >= 0 && account.Nonce <= 1) | ||
return nil | ||
} | ||
} | ||
|
||
func TestMigratePrecompiles(t *testing.T) { | ||
tApp := app.NewTestApp() | ||
//cdc := tApp.AppCodec() | ||
storeKey := sdk.NewKVStoreKey("evmutil") | ||
ctx := testutil.DefaultContext(storeKey, sdk.NewTransientStoreKey("transient_test")) | ||
//store := ctx.KVStore(storeKey) | ||
|
||
//ctx sdk.Context, | ||
//evmKeeper *evmkeeper.Keeper, | ||
v3.Migrate(ctx) | ||
|
||
//require.Nil( | ||
// t, | ||
// store.Get(types.ParamsKey), | ||
// "params shouldn't exist in store before migration", | ||
//) | ||
// | ||
//require.NoError(t, v2.Migrate(ctx, store, cdc)) | ||
// | ||
//paramsBytes := store.Get(types.ParamsKey) | ||
//require.NotNil(t, paramsBytes, "params should be in store after migration") | ||
// | ||
//var params types.Params | ||
//cdc.MustUnmarshal(paramsBytes, ¶ms) | ||
// | ||
//t.Logf("params: %+v", params) | ||
// | ||
//require.Equal( | ||
// t, | ||
// types.NewParams( | ||
// time.Date(2023, 11, 1, 0, 0, 0, 0, time.UTC), | ||
// sdk.NewInt(744191), | ||
// ), | ||
// params, | ||
// "params should be correct after migration", | ||
//) | ||
|
||
ctrl := gomock.NewController(t) | ||
evmKeeperMock := NewMockEvmKeeper(ctrl) | ||
evmKeeperMock.EXPECT().GetAccount(gomock.Any(), v3.ContractAddress).Do(getAccountCallback).Times(2) | ||
evmKeeperMock.EXPECT().SetAccount(gomock.Any(), v3.ContractAddress, gomock.Any()).DoAndReturn(mkSetAccountCallback(t)).Times(2) | ||
|
||
evmKeeperMock.EXPECT().SetCode(gomock.Any(), gomock.Any(), gomock.Any()).Times(1) | ||
|
||
err := v3.Migrate(ctx, evmKeeperMock) | ||
require.NoError(t, err) | ||
} |