mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 14: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)
 | 
							cdc.MustUnmarshalBinaryLengthPrefixed(kvB.Value, &cdpIDsB)
 | 
				
			||||||
		return fmt.Sprintf("%v\n%v", cdpIDsA, 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),
 | 
						case bytes.Equal(kvA.Key[:1], types.CdpIDKey),
 | 
				
			||||||
		bytes.Equal(kvA.Key[:1], types.CollateralRatioIndexPrefix):
 | 
							bytes.Equal(kvA.Key[:1], types.CollateralRatioIndexPrefix):
 | 
				
			||||||
		idA := binary.BigEndian.Uint64(kvA.Value)
 | 
							idA := binary.BigEndian.Uint64(kvA.Value)
 | 
				
			||||||
 | 
				
			|||||||
@ -28,12 +28,15 @@ func TestDecodeDistributionStore(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cdpIds := []uint64{1, 2, 3, 4, 5}
 | 
						cdpIds := []uint64{1, 2, 3, 4, 5}
 | 
				
			||||||
	denom := "denom"
 | 
						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()
 | 
						principal := sdk.OneInt()
 | 
				
			||||||
	prevDistTime := time.Now().UTC()
 | 
						prevDistTime := time.Now().UTC()
 | 
				
			||||||
 | 
						cdp := types.CDP{ID: 1, FeesUpdated: prevDistTime, Collateral: oneCoins, Principal: oneCoins, AccumulatedFees: oneCoins}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvPairs := cmn.KVPairs{
 | 
						kvPairs := cmn.KVPairs{
 | 
				
			||||||
		cmn.KVPair{Key: types.CdpIDKeyPrefix, Value: cdc.MustMarshalBinaryLengthPrefixed(cdpIds)},
 | 
							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.CdpIDKey, Value: sdk.Uint64ToBigEndian(2)},
 | 
				
			||||||
		cmn.KVPair{Key: types.CollateralRatioIndexPrefix, Value: sdk.Uint64ToBigEndian(10)},
 | 
							cmn.KVPair{Key: types.CollateralRatioIndexPrefix, Value: sdk.Uint64ToBigEndian(10)},
 | 
				
			||||||
		cmn.KVPair{Key: []byte(types.DebtDenomKey), Value: cdc.MustMarshalBinaryLengthPrefixed(denom)},
 | 
							cmn.KVPair{Key: []byte(types.DebtDenomKey), Value: cdc.MustMarshalBinaryLengthPrefixed(denom)},
 | 
				
			||||||
@ -49,6 +52,7 @@ func TestDecodeDistributionStore(t *testing.T) {
 | 
				
			|||||||
		expectedLog string
 | 
							expectedLog string
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{"CdpIDs", fmt.Sprintf("%v\n%v", cdpIds, cdpIds)},
 | 
							{"CdpIDs", fmt.Sprintf("%v\n%v", cdpIds, cdpIds)},
 | 
				
			||||||
 | 
							{"CDP", fmt.Sprintf("%v\n%v", cdp, cdp)},
 | 
				
			||||||
		{"CdpID", "2\n2"},
 | 
							{"CdpID", "2\n2"},
 | 
				
			||||||
		{"CollateralRatioIndex", "10\n10"},
 | 
							{"CollateralRatioIndex", "10\n10"},
 | 
				
			||||||
		{"DebtDenom", fmt.Sprintf("%s\n%s", denom, denom)},
 | 
							{"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)
 | 
							return fmt.Sprintf("%s\n%s", priceA, priceB)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case bytes.Contains(kvA.Key, []byte(types.RawPriceFeedPrefix)):
 | 
						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(kvA.Value, &postedPriceA)
 | 
				
			||||||
		cdc.MustUnmarshalBinaryBare(kvB.Value, &postedPriceB)
 | 
							cdc.MustUnmarshalBinaryBare(kvB.Value, &postedPriceB)
 | 
				
			||||||
		return fmt.Sprintf("%s\n%s", postedPriceA, postedPriceB)
 | 
							return fmt.Sprintf("%s\n%s", postedPriceA, postedPriceB)
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@ func TestDecodeDistributionStore(t *testing.T) {
 | 
				
			|||||||
	cdc := makeTestCodec()
 | 
						cdc := makeTestCodec()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	currentPrice := types.CurrentPrice{MarketID: "current", Price: sdk.OneDec()}
 | 
						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{
 | 
						kvPairs := cmn.KVPairs{
 | 
				
			||||||
		cmn.KVPair{Key: []byte(types.CurrentPricePrefix), Value: cdc.MustMarshalBinaryBare(currentPrice)},
 | 
							cmn.KVPair{Key: []byte(types.CurrentPricePrefix), Value: cdc.MustMarshalBinaryBare(currentPrice)},
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ import (
 | 
				
			|||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
						sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			||||||
	"github.com/cosmos/cosmos-sdk/x/auth"
 | 
						"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) {
 | 
					func makeTestCodec() (cdc *codec.Codec) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user