github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/simapp/utils_test.go (about) 1 package simapp 2 3 import ( 4 "fmt" 5 "testing" 6 7 tmkv "github.com/fibonacci-chain/fbc/libs/tendermint/libs/kv" 8 "github.com/stretchr/testify/require" 9 10 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 11 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 12 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth" 13 ) 14 15 func TestGetSimulationLog(t *testing.T) { 16 cdc := MakeCodec() 17 18 decoders := make(sdk.StoreDecoderRegistry) 19 decoders[auth.StoreKey] = func(cdc *codec.Codec, kvAs, kvBs tmkv.Pair) string { return "10" } 20 21 tests := []struct { 22 store string 23 kvPairs []tmkv.Pair 24 expectedLog string 25 }{ 26 { 27 "Empty", 28 []tmkv.Pair{{}}, 29 "", 30 }, 31 { 32 auth.StoreKey, 33 []tmkv.Pair{{Key: auth.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryLengthPrefixed(uint64(10))}}, 34 "10", 35 }, 36 { 37 "OtherStore", 38 []tmkv.Pair{{Key: []byte("key"), Value: []byte("value")}}, 39 fmt.Sprintf("store A %X => %X\nstore B %X => %X\n", []byte("key"), []byte("value"), []byte("key"), []byte("value")), 40 }, 41 } 42 43 for _, tt := range tests { 44 tt := tt 45 t.Run(tt.store, func(t *testing.T) { 46 require.Equal(t, tt.expectedLog, GetSimulationLog(tt.store, decoders, cdc, tt.kvPairs, tt.kvPairs), tt.store) 47 }) 48 } 49 }