Skip to content

Commit

Permalink
define tk test cases fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid-AssetMantle committed Jul 25, 2024
1 parent 6ae05a2 commit 541804e
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 159 deletions.
4 changes: 2 additions & 2 deletions x/assets/transactions/define/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
baseIDs "github.com/AssetMantle/schema/ids/base"
"github.com/AssetMantle/schema/lists"
baseLists "github.com/AssetMantle/schema/lists/base"
"github.com/cosmos/cosmos-sdk/codec"
sdkCodec "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdkTypes "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -54,7 +54,7 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress {
}
return []sdkTypes.AccAddress{from}
}
func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) {
func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) {
codecUtilities.RegisterModuleConcrete(legacyAmino, Message{})
}
func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) {
Expand Down
6 changes: 3 additions & 3 deletions x/assets/transactions/define/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
baseLists "github.com/AssetMantle/schema/lists/base"
baseProperties "github.com/AssetMantle/schema/properties/base"
baseQualified "github.com/AssetMantle/schema/qualified/base"
"github.com/cosmos/cosmos-sdk/codec"
sdkCodec "github.com/cosmos/cosmos-sdk/codec"
sdkTypes "github.com/cosmos/cosmos-sdk/types"

"github.com/AssetMantle/modules/helpers"
Expand Down Expand Up @@ -107,14 +107,14 @@ func Test_message_GetSigners(t *testing.T) {
func Test_message_RegisterCodec(t *testing.T) {

type args struct {
legacyAmino *codec.LegacyAmino
legacyAmino *sdkCodec.LegacyAmino
}
tests := []struct {
name string
fields fields
args args
}{
{"+ve", fields{fromAccAddress.String(), fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.NewLegacyAmino()}},
{"+ve", fields{fromAccAddress.String(), fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{sdkCodec.NewLegacyAmino()}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
342 changes: 205 additions & 137 deletions x/assets/transactions/define/transaction_keeper_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions x/assets/transactions/define/transaction_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
baseIDs "github.com/AssetMantle/schema/ids/base"
"github.com/AssetMantle/schema/lists/base"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdkCodec "github.com/cosmos/cosmos-sdk/codec"
sdkTypes "github.com/cosmos/cosmos-sdk/types"

"github.com/AssetMantle/modules/helpers"
Expand Down Expand Up @@ -111,7 +111,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) {
mutableProperties,
), nil
}
func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) {
func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) {
codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{})
}
func requestPrototype() helpers.TransactionRequest {
Expand Down
6 changes: 3 additions & 3 deletions x/assets/transactions/define/transaction_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
baseLists "github.com/AssetMantle/schema/lists/base"
baseProperties "github.com/AssetMantle/schema/properties/base"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdkCodec "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types"

"github.com/spf13/viper"
Expand Down Expand Up @@ -254,14 +254,14 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) {
MutableProperties string
}
type args struct {
legacyAmino *codec.LegacyAmino
legacyAmino *sdkCodec.LegacyAmino
}
tests := []struct {
name string
fields fields
args args
}{
{"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}},
{"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{sdkCodec.NewLegacyAmino()}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions x/assets/transactions/send/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
codecUtilities "github.com/AssetMantle/schema/codec/utilities"
"github.com/AssetMantle/schema/ids"
baseIDs "github.com/AssetMantle/schema/ids/base"
"github.com/cosmos/cosmos-sdk/codec"
sdkCodec "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdkTypes "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -60,7 +60,7 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress {
}
return []sdkTypes.AccAddress{from}
}
func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) {
func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) {
codecUtilities.RegisterModuleConcrete(legacyAmino, Message{})
}
func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) {
Expand Down
3 changes: 2 additions & 1 deletion x/assets/transactions/send/transaction_keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ func TestTransactionKeeperTransact(t *testing.T) {
},
nil,
errorConstants.MockError,
}, {
},
{
"transferAuxiliaryFailure",
args{fromAddress, transferAuxiliaryFailureAssetID, 1},
func() {
Expand Down
4 changes: 2 additions & 2 deletions x/assets/transactions/send/transaction_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/AssetMantle/schema/ids"
baseIDs "github.com/AssetMantle/schema/ids/base"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdkCodec "github.com/cosmos/cosmos-sdk/codec"
sdkTypes "github.com/cosmos/cosmos-sdk/types"

"github.com/AssetMantle/modules/helpers"
Expand Down Expand Up @@ -100,7 +100,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) {
value,
), nil
}
func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) {
func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) {
codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{})
}
func requestPrototype() helpers.TransactionRequest {
Expand Down
4 changes: 2 additions & 2 deletions x/classifications/auxiliaries/define/auxiliary_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (auxiliaryKeeper auxiliaryKeeper) Help(context context.Context, AuxiliaryRe
classificationID := baseIDs.NewClassificationID(auxiliaryRequest.Immutables, auxiliaryRequest.Mutables)
classifications := auxiliaryKeeper.mapper.NewCollection(context).Fetch(key.NewKey(classificationID))
if classifications.GetMappable(key.NewKey(classificationID)) != nil {
return newAuxiliaryResponse(classificationID), errorConstants.EntityAlreadyExists.Wrapf("classification with ID %s already exists", classificationID.AsString())
return NewAuxiliaryResponse(classificationID), errorConstants.EntityAlreadyExists.Wrapf("classification with ID %s already exists", classificationID.AsString())
}

if err := auxiliaryKeeper.bankKeeper.SendCoinsFromAccountToModule(sdkTypes.UnwrapSDKContext(context), auxiliaryRequest.AccAddress, constants.ModuleName, sdkTypes.NewCoins(sdkTypes.NewCoin(auxiliaryKeeper.stakingKeeper.BondDenom(sdkTypes.UnwrapSDKContext(context)), bondAmount.Get()))); err != nil {
Expand All @@ -93,7 +93,7 @@ func (auxiliaryKeeper auxiliaryKeeper) Help(context context.Context, AuxiliaryRe

classifications.Add(record.NewRecord(classification))

return newAuxiliaryResponse(classificationID), nil
return NewAuxiliaryResponse(classificationID), nil
}

func (auxiliaryKeeper auxiliaryKeeper) Initialize(mapper helpers.Mapper, parameterManager helpers.ParameterManager, auxiliaries []interface{}) helpers.Keeper {
Expand Down
2 changes: 1 addition & 1 deletion x/classifications/auxiliaries/define/auxiliary_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type auxiliaryResponse struct {

var _ helpers.AuxiliaryResponse = (*auxiliaryResponse)(nil)

func newAuxiliaryResponse(classificationID ids.ClassificationID) helpers.AuxiliaryResponse {
func NewAuxiliaryResponse(classificationID ids.ClassificationID) helpers.AuxiliaryResponse {
return auxiliaryResponse{
ClassificationID: classificationID,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func TestGetClassificationIDFromResponse(t *testing.T) {
want ids.ClassificationID
wantErr bool
}{
{"+ve", args{newAuxiliaryResponse(classificationID)}, classificationID, false},
{"+ve", args{newAuxiliaryResponse(nil)}, nil, false},
{"+ve", args{NewAuxiliaryResponse(classificationID)}, classificationID, false},
{"+ve", args{NewAuxiliaryResponse(nil)}, nil, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -66,8 +66,8 @@ func Test_newAuxiliaryResponse(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := newAuxiliaryResponse(tt.args.classificationID); !reflect.DeepEqual(got, tt.want) {
t.Errorf("newAuxiliaryResponse() = %v, want %v", got, tt.want)
if got := NewAuxiliaryResponse(tt.args.classificationID); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewAuxiliaryResponse() = %v, want %v", got, tt.want)
}
})
}
Expand Down

0 comments on commit 541804e

Please sign in to comment.