diff --git a/testutil/nullify/nullify.go b/testutil/nullify/nullify.go deleted file mode 100644 index e646027769..0000000000 --- a/testutil/nullify/nullify.go +++ /dev/null @@ -1,57 +0,0 @@ -// Package nullify provides methods to init nil value structs for test assertion. -package nullify - -import ( - "reflect" - "unsafe" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - coinType = reflect.TypeOf(sdk.Coin{}) - coinsType = reflect.TypeOf(sdk.Coins{}) -) - -// Fill analyzes all struct fields and slices with -// reflection and initializes the nil and empty slices, -// structs, and pointers. -func Fill(x interface{}) interface{} { - v := reflect.Indirect(reflect.ValueOf(x)) - switch v.Kind() { - case reflect.Slice: - for i := 0; i < v.Len(); i++ { - obj := v.Index(i) - objPt := reflect.NewAt(obj.Type(), unsafe.Pointer(obj.UnsafeAddr())).Interface() - objPt = Fill(objPt) - obj.Set(reflect.ValueOf(objPt)) - } - case reflect.Struct: - for i := 0; i < v.NumField(); i++ { - f := reflect.Indirect(v.Field(i)) - if !f.CanSet() { - continue - } - switch f.Kind() { - case reflect.Slice: - f.Set(reflect.MakeSlice(f.Type(), 0, 0)) - case reflect.Struct: - switch f.Type() { - case coinType: - coin := reflect.New(coinType).Interface() - s := reflect.ValueOf(coin).Elem() - f.Set(s) - case coinsType: - coins := reflect.New(coinsType).Interface() - s := reflect.ValueOf(coins).Elem() - f.Set(s) - default: - objPt := reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Interface() - s := Fill(objPt) - f.Set(reflect.ValueOf(s)) - } - } - } - } - return reflect.Indirect(v).Interface() -} diff --git a/x/payment/genesis_test.go b/x/payment/genesis_test.go index 5e90a38c61..e494439ff9 100644 --- a/x/payment/genesis_test.go +++ b/x/payment/genesis_test.go @@ -4,7 +4,6 @@ import ( "testing" keepertest "github.com/celestiaorg/celestia-app/testutil/keeper" - "github.com/celestiaorg/celestia-app/testutil/nullify" "github.com/celestiaorg/celestia-app/x/payment" "github.com/celestiaorg/celestia-app/x/payment/types" "github.com/stretchr/testify/require" @@ -19,7 +18,4 @@ func TestGenesis(t *testing.T) { payment.InitGenesis(ctx, *k, genesisState) got := payment.ExportGenesis(ctx, *k) require.NotNil(t, got) - - nullify.Fill(&genesisState) - nullify.Fill(got) }