mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
44 lines
976 B
Go
44 lines
976 B
Go
|
package v0_13
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
"testing"
|
||
|
|
||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||
|
|
||
|
"github.com/kava-labs/kava/app"
|
||
|
v0_11cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_11"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestMain(m *testing.M) {
|
||
|
config := sdk.GetConfig()
|
||
|
app.SetBech32AddressPrefixes(config)
|
||
|
app.SetBip44CoinType(config)
|
||
|
|
||
|
os.Exit(m.Run())
|
||
|
}
|
||
|
|
||
|
func TestMigrateCdp(t *testing.T) {
|
||
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-cdp-state-block-500000.json"))
|
||
|
require.NoError(t, err)
|
||
|
var oldGenState v0_11cdp.GenesisState
|
||
|
cdc := app.MakeCodec()
|
||
|
require.NotPanics(t, func() {
|
||
|
cdc.MustUnmarshalJSON(bz, &oldGenState)
|
||
|
})
|
||
|
|
||
|
newGenState := MigrateCDP(oldGenState)
|
||
|
err = newGenState.Validate()
|
||
|
require.NoError(t, err)
|
||
|
|
||
|
require.Equal(t, len(newGenState.Params.CollateralParams), len(newGenState.PreviousAccumulationTimes))
|
||
|
|
||
|
cdp1 := newGenState.CDPs[0]
|
||
|
require.Equal(t, sdk.OneDec(), cdp1.InterestFactor)
|
||
|
|
||
|
}
|