mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 09:57:27 +00:00 
			
		
		
		
	address comments from review
This commit is contained in:
		
							parent
							
								
									f827d896ba
								
							
						
					
					
						commit
						66c73362c8
					
				@ -22,6 +22,12 @@ func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string {
 | 
			
		||||
		cdc.MustUnmarshalBinaryLengthPrefixed(kvB.Value, &cdpIDsB)
 | 
			
		||||
		return fmt.Sprintf("%v\n%v", cdpIDsA, cdpIDsB)
 | 
			
		||||
 | 
			
		||||
	case bytes.Equal(kvA.Key[:1], types.CdpKeyPrefix):
 | 
			
		||||
		var cdpA, cdpB types.CDP
 | 
			
		||||
		cdc.MustUnmarshalBinaryLengthPrefixed(kvA.Value, &cdpA)
 | 
			
		||||
		cdc.MustUnmarshalBinaryLengthPrefixed(kvB.Value, &cdpB)
 | 
			
		||||
		return fmt.Sprintf("%v\n%v", cdpA, cdpB)
 | 
			
		||||
 | 
			
		||||
	case bytes.Equal(kvA.Key[:1], types.CdpIDKey),
 | 
			
		||||
		bytes.Equal(kvA.Key[:1], types.CollateralRatioIndexPrefix):
 | 
			
		||||
		idA := binary.BigEndian.Uint64(kvA.Value)
 | 
			
		||||
 | 
			
		||||
@ -28,12 +28,15 @@ func TestDecodeDistributionStore(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	cdpIds := []uint64{1, 2, 3, 4, 5}
 | 
			
		||||
	denom := "denom"
 | 
			
		||||
	deposit := types.Deposit{CdpID: 1, Amount: sdk.NewCoins(sdk.NewCoin(denom, sdk.OneInt()))}
 | 
			
		||||
	oneCoins := sdk.NewCoins(sdk.NewCoin(denom, sdk.OneInt()))
 | 
			
		||||
	deposit := types.Deposit{CdpID: 1, Amount: oneCoins}
 | 
			
		||||
	principal := sdk.OneInt()
 | 
			
		||||
	prevDistTime := time.Now().UTC()
 | 
			
		||||
	cdp := types.CDP{ID: 1, FeesUpdated: prevDistTime, Collateral: oneCoins, Principal: oneCoins, AccumulatedFees: oneCoins}
 | 
			
		||||
 | 
			
		||||
	kvPairs := cmn.KVPairs{
 | 
			
		||||
		cmn.KVPair{Key: types.CdpIDKeyPrefix, Value: cdc.MustMarshalBinaryLengthPrefixed(cdpIds)},
 | 
			
		||||
		cmn.KVPair{Key: types.CdpKeyPrefix, Value: cdc.MustMarshalBinaryLengthPrefixed(cdp)},
 | 
			
		||||
		cmn.KVPair{Key: types.CdpIDKey, Value: sdk.Uint64ToBigEndian(2)},
 | 
			
		||||
		cmn.KVPair{Key: types.CollateralRatioIndexPrefix, Value: sdk.Uint64ToBigEndian(10)},
 | 
			
		||||
		cmn.KVPair{Key: []byte(types.DebtDenomKey), Value: cdc.MustMarshalBinaryLengthPrefixed(denom)},
 | 
			
		||||
@ -49,6 +52,7 @@ func TestDecodeDistributionStore(t *testing.T) {
 | 
			
		||||
		expectedLog string
 | 
			
		||||
	}{
 | 
			
		||||
		{"CdpIDs", fmt.Sprintf("%v\n%v", cdpIds, cdpIds)},
 | 
			
		||||
		{"CDP", fmt.Sprintf("%v\n%v", cdp, cdp)},
 | 
			
		||||
		{"CdpID", "2\n2"},
 | 
			
		||||
		{"CollateralRatioIndex", "10\n10"},
 | 
			
		||||
		{"DebtDenom", fmt.Sprintf("%s\n%s", denom, denom)},
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string {
 | 
			
		||||
		return fmt.Sprintf("%s\n%s", priceA, priceB)
 | 
			
		||||
 | 
			
		||||
	case bytes.Contains(kvA.Key, []byte(types.RawPriceFeedPrefix)):
 | 
			
		||||
		var postedPriceA, postedPriceB types.PostedPrice
 | 
			
		||||
		var postedPriceA, postedPriceB []types.PostedPrice
 | 
			
		||||
		cdc.MustUnmarshalBinaryBare(kvA.Value, &postedPriceA)
 | 
			
		||||
		cdc.MustUnmarshalBinaryBare(kvB.Value, &postedPriceB)
 | 
			
		||||
		return fmt.Sprintf("%s\n%s", postedPriceA, postedPriceB)
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ func TestDecodeDistributionStore(t *testing.T) {
 | 
			
		||||
	cdc := makeTestCodec()
 | 
			
		||||
 | 
			
		||||
	currentPrice := types.CurrentPrice{MarketID: "current", Price: sdk.OneDec()}
 | 
			
		||||
	postedPrice := types.PostedPrice{MarketID: "posted", Price: sdk.OneDec(), Expiry: time.Now().UTC()}
 | 
			
		||||
	postedPrice := []types.PostedPrice{{MarketID: "posted", Price: sdk.OneDec(), Expiry: time.Now().UTC()}}
 | 
			
		||||
 | 
			
		||||
	kvPairs := cmn.KVPairs{
 | 
			
		||||
		cmn.KVPair{Key: []byte(types.CurrentPricePrefix), Value: cdc.MustMarshalBinaryBare(currentPrice)},
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ import (
 | 
			
		||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
			
		||||
	"github.com/cosmos/cosmos-sdk/x/auth"
 | 
			
		||||
 | 
			
		||||
	"github.com/kava-labs/kava/x/validator-vesting/internal/types"
 | 
			
		||||
	"github.com/kava-labs/kava/x/validator-vesting/types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func makeTestCodec() (cdc *codec.Codec) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user