github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/testing/simapp/utils_test.go (about) 1 package simapp 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 8 ibc_tx "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/ibc-tx" 9 tmkv "github.com/fibonacci-chain/fbc/libs/tendermint/libs/kv" 10 11 "github.com/stretchr/testify/require" 12 13 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec/types" 14 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 15 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module" 16 authtypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/types" 17 ) 18 19 func makeCodec(bm module.BasicManager) types.InterfaceRegistry { 20 // cdc := codec.NewLegacyAmino() 21 22 // bm.RegisterLegacyAminoCodec(cdc) 23 // std.RegisterLegacyAminoCodec(cdc) 24 interfaceReg := types.NewInterfaceRegistry() 25 bm.RegisterInterfaces(interfaceReg) 26 27 ibc_tx.PubKeyRegisterInterfaces(interfaceReg) 28 29 return interfaceReg 30 } 31 32 func TestGetSimulationLog(t *testing.T) { 33 //cdc := makeCodec(ModuleBasics) 34 cdc := codec.NewCodecProxy(codec.NewProtoCodec(makeCodec(ModuleBasics)), codec.New()) 35 36 decoders := make(sdk.StoreDecoderRegistry) 37 decoders[authtypes.StoreKey] = func(cdc *codec.Codec, kvAs, kvBs tmkv.Pair) string { return "10" } 38 39 tests := []struct { 40 store string 41 kvPairs []tmkv.Pair 42 expectedLog string 43 }{ 44 { 45 "Empty", 46 []tmkv.Pair{{}}, 47 "", 48 }, 49 { 50 authtypes.StoreKey, 51 // todo old one is MustMarshal. does it want to test pb codec? 52 []tmkv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.GetCdc().MustMarshalBinaryBare(uint64(10))}}, 53 "10", 54 }, 55 { 56 "OtherStore", 57 []tmkv.Pair{{Key: []byte("key"), Value: []byte("value")}}, 58 fmt.Sprintf("store A %X => %X\nstore B %X => %X\n", []byte("key"), []byte("value"), []byte("key"), []byte("value")), 59 }, 60 } 61 62 for _, tt := range tests { 63 tt := tt 64 t.Run(tt.store, func(t *testing.T) { 65 require.Equal(t, tt.expectedLog, GetSimulationLog(tt.store, decoders, tt.kvPairs, tt.kvPairs), tt.store) 66 }) 67 } 68 }