diff --git a/modules/assets/internal/block/block_test.go b/modules/assets/internal/block/block_test.go index a2e121ce5..7b1973810 100644 --- a/modules/assets/internal/block/block_test.go +++ b/modules/assets/internal/block/block_test.go @@ -4,6 +4,7 @@ package block import ( + "fmt" "reflect" "testing" @@ -109,7 +110,9 @@ func Test_block_End(t *testing.T) { } func Test_block_Initialize(t *testing.T) { - // testBlock := block{mapper.Prototype(), parameters.Prototype()} + testMapper := mapper.Prototype() + testParameter := parameters.Prototype() + testBlock := block{testMapper, testParameter} type fields struct { mapper helpers.Mapper parameters helpers.Parameters @@ -125,8 +128,7 @@ func Test_block_Initialize(t *testing.T) { args args want helpers.Block }{ - // TODO: Add test cases. - // {"+ve", fields{mapper.Prototype(), parameters.Prototype()}, args{mapper.Prototype(), parameters.Prototype(), []helpers.Auxiliary{}}, Prototype()}, + {"+ve", fields{testMapper, testParameter}, args{testMapper, testParameter, []interface{}{}}, testBlock}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -134,7 +136,7 @@ func Test_block_Initialize(t *testing.T) { mapper: tt.fields.mapper, parameters: tt.fields.parameters, } - if got := block.Initialize(tt.args.mapper, tt.args.parameters, tt.args.in2...); !reflect.DeepEqual(got, tt.want) { + if got := block.Initialize(tt.args.mapper, tt.args.parameters, tt.args.in2...); !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("Initialize() = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/key/key.go b/modules/assets/internal/key/key.go index a6b01fc95..373cbff58 100644 --- a/modules/assets/internal/key/key.go +++ b/modules/assets/internal/key/key.go @@ -26,7 +26,6 @@ func (key) RegisterCodec(codec *codec.Codec) { codecUtilities.RegisterModuleConcrete(codec, key{}) } func (key key) IsPartial() bool { - // TODO test nil AssetID case return len(key.AssetID.Bytes()) == 0 } func (key key) Equals(compareKey helpers.Key) bool { diff --git a/modules/assets/internal/mapper/prototype_test.go b/modules/assets/internal/mapper/prototype_test.go index b5317d2ff..d8710fd69 100644 --- a/modules/assets/internal/mapper/prototype_test.go +++ b/modules/assets/internal/mapper/prototype_test.go @@ -4,40 +4,28 @@ package mapper import ( + "github.com/AssetMantle/modules/schema/helpers" + "reflect" "testing" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/modules/assets/internal/key" "github.com/AssetMantle/modules/modules/assets/internal/mappable" baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" ) -// func TestPrototype(t *testing.T) { -// storeKey := sdkTypes.NewKVStoreKey("test") -// newMapper := baseHelpers.NewMapper(key.Prototype, mappable.Prototype).Initialize(storeKey) -// -// tests := []struct { -// name string -// want helpers.Mapper -// }{ -// // TODO: Add test cases. -// {"Default Tests", newMapper}, -// //{"dummy tests", baseHelpers.NewMapper(key.Prototype, mappable.Prototype)}, -// //{"Dt1", Prototype()}, -// } -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// if got := Prototype().Initialize(storeKey); !reflect.DeepEqual(got, tt.want) { -// t.Errorf("Prototype() = %v, want %v", got, tt.want) -// } -// }) -// } -// } - func TestPrototype(t *testing.T) { - // storeKey := sdkTypes.NewKVStoreKey("test") - require.Panics(t, func() { - require.Equal(t, Prototype(), baseHelpers.NewMapper(key.Prototype, mappable.Prototype)) - }) + tests := []struct { + name string + want helpers.Mapper + }{ + // TODO: it should pass, but possibly due to a bug in the code, it fails + {"+ve", baseHelpers.NewMapper(key.Prototype, mappable.Prototype)}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := Prototype(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("Prototype() = %v, want %v", got, tt.want) + } + }) + } } diff --git a/modules/assets/internal/parameters/dummy/validator_test.go b/modules/assets/internal/parameters/dummy/validator_test.go index 151bab299..20ace5c4a 100644 --- a/modules/assets/internal/parameters/dummy/validator_test.go +++ b/modules/assets/internal/parameters/dummy/validator_test.go @@ -32,7 +32,7 @@ func Test_validator(t *testing.T) { {"-ve with different type of Data", args{baseData.NewStringData("stringData")}, errorConstants.IncorrectFormat}, {"-ve InvalidParameter", args{baseTypes.NewParameter(baseIDs.NewStringID(""), baseData.NewStringData(""), validator)}, errorConstants.InvalidParameter}, {"-ve with -ve decData", args{baseTypes.NewParameter(baseIDs.NewStringID("ID"), baseData.NewDecData(sdkTypes.NewDec(-1)), validator)}, errorConstants.InvalidParameter}, - {"+ve with +ve decData", args{baseTypes.NewParameter(baseIDs.NewStringID("dummy"), baseData.NewDecData(sdkTypes.NewDec(1)), validator)}, nil}, // TODO: Check whether input provided is right + {"+ve with +ve decData", args{baseTypes.NewParameter(baseIDs.NewStringID("dummy"), baseData.NewDecData(sdkTypes.NewDec(1)), validator)}, nil}, {"-ve nil", args{}, errorConstants.IncorrectFormat}, } for _, tt := range tests { diff --git a/modules/assets/internal/parameters/prototype_test.go b/modules/assets/internal/parameters/prototype_test.go index bd62baf4c..3d6d2afcc 100644 --- a/modules/assets/internal/parameters/prototype_test.go +++ b/modules/assets/internal/parameters/prototype_test.go @@ -4,6 +4,7 @@ package parameters import ( + "github.com/AssetMantle/modules/schema/helpers" "reflect" "testing" @@ -13,17 +14,15 @@ import ( func TestPrototype(t *testing.T) { tests := []struct { - name string - // want helpers.Parameters - want string + name string + want helpers.Parameters wantError error }{ - // TODO: Update test case. - {"+ve", baseHelpers.NewParameters(dummy.Parameter).String(), nil}, + {"+ve", baseHelpers.NewParameters(dummy.Parameter), nil}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := Prototype(); tt.wantError != got.Validate() && !reflect.DeepEqual(got.String(), tt.want) { + if got := Prototype(); tt.wantError != got.Validate() && !reflect.DeepEqual(got.String(), tt.want.String()) { t.Errorf("Prototype() = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/queries/asset/request_test.go b/modules/assets/internal/queries/asset/request_test.go index 0ef96bcd7..5d57322c3 100644 --- a/modules/assets/internal/queries/asset/request_test.go +++ b/modules/assets/internal/queries/asset/request_test.go @@ -7,12 +7,15 @@ import ( "github.com/AssetMantle/modules/modules/assets/internal/common" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/schema/ids" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" baseQualified "github.com/AssetMantle/modules/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -139,6 +142,8 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID}) + viper.Set(constants.AssetID.GetName(), testAssetID.String()) type fields struct { AssetID ids.AssetID } @@ -152,7 +157,9 @@ func Test_queryRequest_FromCLI(t *testing.T) { args args want helpers.QueryRequest wantErr bool - }{} + }{ + {"+ve", fields{testAssetID}, args{cliCommand, context.NewCLIContext()}, newQueryRequest(testAssetID), false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { qu := queryRequest{ diff --git a/modules/assets/internal/transactions/burn/request_test.go b/modules/assets/internal/transactions/burn/request_test.go index 75df6d5c0..ac5a686e8 100644 --- a/modules/assets/internal/transactions/burn/request_test.go +++ b/modules/assets/internal/transactions/burn/request_test.go @@ -5,12 +5,16 @@ package burn import ( "encoding/json" + "fmt" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/utilities/transaction" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -58,9 +62,10 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - //cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromID}) - //cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") - //cliContext.WithInput(os.Stdin) + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.AssetID.GetName(), testAssetID.String()) + viper.Set(constants.FromID.GetName(), fromID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -77,8 +82,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. - //{"+ve", fields{BaseReq: testBaseRequest, FromID: fromID.String(), AssetID: testAssetID.String()}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, fromID.String(), testAssetID.String()), false}, + {"+ve", fields{BaseReq: testBaseRequest, FromID: fromID.String(), AssetID: testAssetID.String()}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, fromID.String(), testAssetID.String()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -92,7 +96,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/transactions/define/request_test.go b/modules/assets/internal/transactions/define/request_test.go index 40a29c4bc..ca3263470 100644 --- a/modules/assets/internal/transactions/define/request_test.go +++ b/modules/assets/internal/transactions/define/request_test.go @@ -5,8 +5,11 @@ package define import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -73,6 +77,13 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.ImmutableMetaProperties.GetName(), immutableMetaPropertiesString) + viper.Set(constants.ImmutableProperties.GetName(), immutablePropertiesString) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) + viper.Set(constants.FromID.GetName(), fromID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -92,7 +103,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, fromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -109,7 +120,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/transactions/deputize/request_test.go b/modules/assets/internal/transactions/deputize/request_test.go index b46bb87ca..7393f4525 100644 --- a/modules/assets/internal/transactions/deputize/request_test.go +++ b/modules/assets/internal/transactions/deputize/request_test.go @@ -8,6 +8,8 @@ import ( "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -16,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -73,6 +76,18 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ToID, constants.FromID, constants.ClassificationID, constants.MaintainedProperties, constants.CanMintAsset, constants.CanBurnAsset, constants.CanRenumerateAsset, constants.CanAddMaintainer, constants.CanRemoveMaintainer, constants.CanMutateMaintainer}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.ToID.GetName(), fromID.String()) + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.ClassificationID.GetName(), classificationID.String()) + viper.Set(constants.MaintainedProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.CanMintAsset.GetName(), true) + viper.Set(constants.CanBurnAsset.GetName(), true) + viper.Set(constants.CanRenumerateAsset.GetName(), true) + viper.Set(constants.CanAddMaintainer.GetName(), true) + viper.Set(constants.CanRemoveMaintainer.GetName(), true) + viper.Set(constants.CanMutateMaintainer.GetName(), true) type fields struct { BaseReq rest.BaseReq FromID string @@ -97,7 +112,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), fromID.String(), classificationID.String(), mutableMetaPropertiesString, true, true, true, true, true, true}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -119,7 +134,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/transactions/mint/request_test.go b/modules/assets/internal/transactions/mint/request_test.go index adad87b79..86b538d53 100644 --- a/modules/assets/internal/transactions/mint/request_test.go +++ b/modules/assets/internal/transactions/mint/request_test.go @@ -5,8 +5,11 @@ package mint import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -75,6 +79,15 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromID, constants.ToID, constants.ClassificationID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.ToID.GetName(), fromID.String()) + viper.Set(constants.ClassificationID.GetName(), classificationID.String()) + viper.Set(constants.ImmutableMetaProperties.GetName(), immutableMetaPropertiesString) + viper.Set(constants.ImmutableProperties.GetName(), immutablePropertiesString) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { BaseReq rest.BaseReq FromID string @@ -96,7 +109,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), fromID.String(), classificationID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -115,7 +128,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/transactions/mutate/request_test.go b/modules/assets/internal/transactions/mutate/request_test.go index 69d0bf7ea..e876c97bc 100644 --- a/modules/assets/internal/transactions/mutate/request_test.go +++ b/modules/assets/internal/transactions/mutate/request_test.go @@ -5,8 +5,11 @@ package mutate import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -68,6 +72,12 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromID, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.AssetID.GetName(), testAssetID.String()) + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { BaseReq rest.BaseReq FromID string @@ -86,7 +96,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, fromID.String(), testAssetID.String(), mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), testAssetID.String(), mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -102,7 +112,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/transactions/renumerate/request_test.go b/modules/assets/internal/transactions/renumerate/request_test.go index ea95bcc37..f730f383d 100644 --- a/modules/assets/internal/transactions/renumerate/request_test.go +++ b/modules/assets/internal/transactions/renumerate/request_test.go @@ -5,12 +5,16 @@ package renumerate import ( "encoding/json" + "fmt" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/utilities/transaction" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -58,6 +62,10 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.AssetID.GetName(), testAssetID.String()) + viper.Set(constants.FromID.GetName(), fromID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -74,8 +82,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. - //{"+ve",fields{testBaseRequest,fromID.String(),testAssetID.String()},args{},newTransactionRequest(testBaseRequest,fromID.String(),testAssetID.String()),false}, + {"+ve", fields{testBaseRequest, fromID.String(), testAssetID.String()}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, fromID.String(), testAssetID.String()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -89,7 +96,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/assets/internal/transactions/revoke/request_test.go b/modules/assets/internal/transactions/revoke/request_test.go index 587d97c27..f700de3ca 100644 --- a/modules/assets/internal/transactions/revoke/request_test.go +++ b/modules/assets/internal/transactions/revoke/request_test.go @@ -5,12 +5,16 @@ package revoke import ( "encoding/json" + "fmt" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/utilities/transaction" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "reflect" "testing" ) @@ -59,6 +63,11 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.ToID, constants.ClassificationID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.ToID.GetName(), fromID.String()) + viper.Set(constants.ClassificationID.GetName(), classificationID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -76,8 +85,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. - //{"+ve", fields{testBaseRequest, fromID.String(), fromID.String(), classificationID.String()},args{},newTransactionRequest(testBaseRequest,fromID.String(),fromID.String(),classificationID.String()),false}, + {"+ve", fields{testBaseRequest, fromID.String(), fromID.String(), classificationID.String()}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, fromID.String(), fromID.String(), classificationID.String()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -92,7 +100,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/identities/internal/key/key_test.go b/modules/identities/internal/key/key_test.go index 099c6acae..e32dbad62 100644 --- a/modules/identities/internal/key/key_test.go +++ b/modules/identities/internal/key/key_test.go @@ -38,7 +38,6 @@ func TestNewKey(t *testing.T) { args args want helpers.Key }{ - // TODO: Add test cases. {"+ve", args{testIdentity}, key{IdentityID: testIdentity}}, } for _, tt := range tests { @@ -55,7 +54,6 @@ func TestPrototype(t *testing.T) { name string want helpers.Key }{ - // TODO: Add test cases. {"+ve", key{}}, } for _, tt := range tests { @@ -79,8 +77,9 @@ func Test_keyFromInterface(t *testing.T) { want key wantErr bool }{ - // TODO: Add test cases. - {"+ve", args{}, key{}, true}, + {"+ve", args{nil}, key{nil}, true}, + {"-ve", args{NewKey(nil)}, key{nil}, false}, + {"-ve", args{testIdentity}, key{nil}, true}, {"+ve", args{NewKey(testIdentity)}, key{testIdentity}, false}, {"-ve", args{baseIds.NewStringID("StringID")}, key{}, true}, } @@ -112,7 +111,9 @@ func Test_key_Equals(t *testing.T) { args args want bool }{ - // TODO: Add test cases. + {"+ve", fields{nil}, args{key{nil}}, true}, + {"-ve", fields{nil}, args{key{testIdentity}}, false}, + {"-ve", fields{testIdentity}, args{key{nil}}, false}, {"+ve", fields{testIdentity}, args{key{testIdentity}}, true}, } for _, tt := range tests { @@ -138,7 +139,6 @@ func Test_key_GenerateStoreKeyBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{testIdentity}, module.StoreKeyPrefix.GenerateStoreKey(key{testIdentity}.Bytes())}, } for _, tt := range tests { @@ -164,7 +164,6 @@ func Test_key_IsPartial(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{testIdentity}, false}, } for _, tt := range tests { @@ -193,7 +192,6 @@ func Test_key_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testIdentity}, args{codec.New()}}, } for _, tt := range tests { diff --git a/modules/identities/internal/queries/identity/keeper_test.go b/modules/identities/internal/queries/identity/keeper_test.go index 5eca611bf..722b1128d 100644 --- a/modules/identities/internal/queries/identity/keeper_test.go +++ b/modules/identities/internal/queries/identity/keeper_test.go @@ -114,7 +114,6 @@ func Test_queryKeeper_Enquire(t *testing.T) { args args want helpers.QueryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, newQueryRequest(testFromID)}, newQueryResponse(keepers.QueryKeeper.(queryKeeper).mapper.NewCollection(context).Fetch(key.NewKey(testFromID)), nil)}, } for _, tt := range tests { @@ -145,7 +144,6 @@ func Test_queryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{}, args{}, queryKeeper{}}, {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, queryKeeper{Mapper}}, } diff --git a/modules/identities/internal/queries/identity/request_test.go b/modules/identities/internal/queries/identity/request_test.go index 2f1aa7a60..e3964b9d7 100644 --- a/modules/identities/internal/queries/identity/request_test.go +++ b/modules/identities/internal/queries/identity/request_test.go @@ -4,6 +4,9 @@ package identity import ( + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" + "github.com/spf13/viper" "reflect" "testing" @@ -172,6 +175,9 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + testIdentity, _ := createTestInput() + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.IdentityID}) + viper.Set(constants.IdentityID.GetName(), testIdentity.String()) type fields struct { IdentityID ids.IdentityID } @@ -185,7 +191,9 @@ func Test_queryRequest_FromCLI(t *testing.T) { args args want helpers.QueryRequest wantErr bool - }{} + }{ + {"+ve", fields{testIdentity}, args{cliCommand, context.NewCLIContext()}, newQueryRequest(testIdentity), false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { queryRequest := queryRequest{ diff --git a/modules/identities/internal/transactions/define/keeper_test.go b/modules/identities/internal/transactions/define/keeper_test.go index 1c0c8b87c..09a3f033b 100644 --- a/modules/identities/internal/transactions/define/keeper_test.go +++ b/modules/identities/internal/transactions/define/keeper_test.go @@ -97,7 +97,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -129,7 +128,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, authenticateAuxiliary, defineAuxiliary, superAuxiliary, supplementAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, authenticateAuxiliary, defineAuxiliary, superAuxiliary, supplementAuxiliary}}, } @@ -184,7 +182,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{mapper, authenticateAuxiliary, defineAuxiliary, superAuxiliary, supplementAuxiliary}, args{context, newMessage(fromAccAddress, baseIds.NewIdentityID(classificationID, immutables), immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, newTransactionResponse(nil)}, {"-ve", fields{mapper, authenticateAuxiliary, defineAuxiliary, superAuxiliary, supplementAuxiliary}, args{context, newMessage(fromAccAddress2, baseIds.NewIdentityID(classificationID, immutables), immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, newTransactionResponse(constants.NotAuthorized)}, } diff --git a/modules/identities/internal/transactions/define/request_test.go b/modules/identities/internal/transactions/define/request_test.go index 3f7152f02..db30b54f4 100644 --- a/modules/identities/internal/transactions/define/request_test.go +++ b/modules/identities/internal/transactions/define/request_test.go @@ -168,7 +168,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, args{jsonMessage}, transactionRequest{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, false}, } for _, tt := range tests { @@ -223,7 +222,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, testBaseReq}, } for _, tt := range tests { @@ -281,7 +279,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{BaseReq: testBaseReq, FromID: testIdentity.String(), ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, newMessage(fromAccAddress, testIdentity, baseLists.NewPropertyList(immutableMetaProperties), immutableProperties.ScrubData(), baseLists.NewPropertyList(mutableMetaProperties), mutableProperties.ScrubData()), false}, {"-ve wrong Identity", fields{BaseReq: testBaseReq, FromID: "WrongIdentity", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, nil, true}, } @@ -332,7 +329,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, args{codec.New()}}, } for _, tt := range tests { @@ -372,7 +368,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, false}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/deputize/keeper_test.go b/modules/identities/internal/transactions/deputize/keeper_test.go index 6383c9f20..38551d698 100644 --- a/modules/identities/internal/transactions/deputize/keeper_test.go +++ b/modules/identities/internal/transactions/deputize/keeper_test.go @@ -90,7 +90,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -121,7 +120,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, Parameters, deputizeAuxiliary, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{deputizeAuxiliary, authenticateAuxiliary}}, transactionKeeper{Mapper, Parameters, deputizeAuxiliary, authenticateAuxiliary}}, } @@ -172,7 +170,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, deputizeAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, fromIdentityID, toIdentityID, classificationID, maintainedProperties, true, true, true, true, true, true)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/deputize/message_test.go b/modules/identities/internal/transactions/deputize/message_test.go index 2a3bf559f..5132e5eb3 100644 --- a/modules/identities/internal/transactions/deputize/message_test.go +++ b/modules/identities/internal/transactions/deputize/message_test.go @@ -370,7 +370,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false, false}, message{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false, false}}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/deputize/request_test.go b/modules/identities/internal/transactions/deputize/request_test.go index f878f5c8f..21c52bdb0 100644 --- a/modules/identities/internal/transactions/deputize/request_test.go +++ b/modules/identities/internal/transactions/deputize/request_test.go @@ -43,7 +43,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}, transactionRequest{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}}, } for _, tt := range tests { @@ -60,7 +59,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -100,7 +98,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{BaseReq: rest.BaseReq{From: cliContext.GetFromAddress().String(), ChainID: cliContext.ChainID, Simulate: cliContext.Simulate}, FromID: "", ToID: "", ClassificationID: "", MaintainedProperties: "", CanMintAsset: false, CanBurnAsset: false, CanRenumerateAsset: false, CanAddMaintainer: false, CanRemoveMaintainer: false, CanMutateMaintainer: false}, args{cliCommand, cliContext}, transactionRequest{BaseReq: rest.BaseReq{From: cliContext.GetFromAddress().String(), ChainID: cliContext.ChainID, Simulate: cliContext.Simulate}, FromID: "", ToID: "", ClassificationID: "", MaintainedProperties: "", CanAddMaintainer: false, CanRemoveMaintainer: false, CanMutateMaintainer: false}, false}, } for _, tt := range tests { @@ -161,7 +158,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}, args{jsonMessage}, transactionRequest{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}, false}, } for _, tt := range tests { @@ -216,7 +212,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}, testBaseReq}, } for _, tt := range tests { @@ -265,7 +260,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testFromID.String(), testFromID.String(), testClassificationID.String(), "maintainedProperty:S|maintainedProperty", false, false, false, false, false, false}, newMessage(fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false, false), false}, // TODO: issue==> getting MetaDataError that is not expected } for _, tt := range tests { @@ -323,7 +317,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}, args{codec.New()}}, } for _, tt := range tests { @@ -371,7 +364,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false, false}, false}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/issue/message_test.go b/modules/identities/internal/transactions/issue/message_test.go index 6b114347f..4816513f9 100644 --- a/modules/identities/internal/transactions/issue/message_test.go +++ b/modules/identities/internal/transactions/issue/message_test.go @@ -154,7 +154,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -196,7 +195,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.New()}}, } for _, tt := range tests { @@ -233,7 +231,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, module.Name}, } for _, tt := range tests { @@ -272,7 +269,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, } for _, tt := range tests { @@ -311,7 +307,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, false}, {"-ve with nil", fields{}, true}, } @@ -351,7 +346,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, newMessage(fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, {"-ve with nil", args{}, message{}}, } diff --git a/modules/identities/internal/transactions/issue/request_test.go b/modules/identities/internal/transactions/issue/request_test.go index b640e70be..0fb131843 100644 --- a/modules/identities/internal/transactions/issue/request_test.go +++ b/modules/identities/internal/transactions/issue/request_test.go @@ -287,7 +287,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, "9UNIA3_tulK2vRE0nSmsHKNzhDxoCBHI4z8XXfLO1FM=", "9UNIA3_tulK2vRE0nSmsHKNzhDxoCBHI4z8XXfLO1FM=", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newMessage(fromAccAddress, toAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, // TODO: issue==> getting MetaDataError that is not expected } for _, tt := range tests { @@ -334,7 +333,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.New()}}, } for _, tt := range tests { @@ -373,7 +371,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, {"+ve", fields{testBaseReq1, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, {"-ve", fields{ClassificationID: ""}, true}, diff --git a/modules/identities/internal/transactions/mutate/keeper_test.go b/modules/identities/internal/transactions/mutate/keeper_test.go index 3646ed22f..c078a2d13 100644 --- a/modules/identities/internal/transactions/mutate/keeper_test.go +++ b/modules/identities/internal/transactions/mutate/keeper_test.go @@ -93,7 +93,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -124,7 +123,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, authenticateAuxiliary, maintainAuxiliary, memberAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, authenticateAuxiliary, maintainAuxiliary, memberAuxiliary}}, } @@ -174,7 +172,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, authenticateAuxiliary, maintainAuxiliary, memberAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testFromID, mutableProperties, toMutateMetaProperties)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/mutate/message_test.go b/modules/identities/internal/transactions/mutate/message_test.go index bad2fe6c8..9c87f866d 100644 --- a/modules/identities/internal/transactions/mutate/message_test.go +++ b/modules/identities/internal/transactions/mutate/message_test.go @@ -50,7 +50,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve with nil", args{}, message{}}, {"+ve", args{message{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}}, message{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}}, } @@ -68,7 +67,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -94,7 +92,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}))}, } for _, tt := range tests { @@ -127,7 +124,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []types.AccAddress }{ - // TODO: Add test cases. {"+ve with nil", fields{}, []types.AccAddress{nil}}, {"+ve", fields{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, []types.AccAddress{testFrom}}, } @@ -164,7 +160,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{codec.New()}}, {"+ve", fields{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, args{codec.New()}}, } @@ -196,7 +191,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve with nil", fields{}, module.Name}, {"+ve", fields{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, module.Name}, } @@ -230,7 +224,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve with nil", fields{}, Transaction.GetName()}, {"+ve", fields{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, Transaction.GetName()}, } @@ -264,7 +257,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve with nil", fields{}, true}, {"+ve", fields{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, false}, } @@ -298,7 +290,6 @@ func Test_newMessage(t *testing.T) { args args want types.Msg }{ - // TODO: Add test cases. {"+ve with nil", args{}, message{}}, {"+ve", args{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, message{testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}}, } diff --git a/modules/identities/internal/transactions/mutate/response_test.go b/modules/identities/internal/transactions/mutate/response_test.go index 179227e30..9b55e7a13 100644 --- a/modules/identities/internal/transactions/mutate/response_test.go +++ b/modules/identities/internal/transactions/mutate/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}, } @@ -43,7 +42,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -70,7 +68,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/identities/internal/transactions/nub/message_test.go b/modules/identities/internal/transactions/nub/message_test.go index 0a0e9ac35..c34220f73 100644 --- a/modules/identities/internal/transactions/nub/message_test.go +++ b/modules/identities/internal/transactions/nub/message_test.go @@ -38,7 +38,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{message{From: fromAccAddress, NubID: testNubID}}, message{From: fromAccAddress, NubID: testNubID}}, {"+ve", args{nil}, message{}}, } @@ -56,7 +55,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -79,7 +77,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testNubID}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{fromAccAddress, testNubID}))}, } for _, tt := range tests { @@ -106,7 +103,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testNubID}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -136,7 +132,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testNubID}, args{codec.New()}}, } for _, tt := range tests { @@ -161,7 +156,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testNubID}, module.Name}, } for _, tt := range tests { @@ -188,7 +182,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testNubID}, Transaction.GetName()}, } for _, tt := range tests { @@ -215,7 +208,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testNubID}, false}, {"-ve", fields{}, true}, } @@ -243,7 +235,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testNubID}, message{fromAccAddress, testNubID}}, } for _, tt := range tests { @@ -254,627 +245,3 @@ func Test_newMessage(t *testing.T) { }) } } - -func Test_messageFromInterface1(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want message - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_messagePrototype1(t *testing.T) { - tests := []struct { - name string - want helpers.Message - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messagePrototype(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messagePrototype() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_GetSignBytes1(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want []byte - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.GetSignBytes(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetSignBytes() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_GetSigners1(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want []sdkTypes.AccAddress - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.GetSigners(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetSigners() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_RegisterCodec1(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - type args struct { - codec *codec.Codec - } - tests := []struct { - name string - fields fields - args args - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - me.RegisterCodec(tt.args.codec) - }) - } -} - -func Test_message_Route1(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.Route(); got != tt.want { - t.Errorf("Route() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_Type1(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_ValidateBasic1(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if err := message.ValidateBasic(); (err != nil) != tt.wantErr { - t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func Test_newMessage1(t *testing.T) { - type args struct { - from sdkTypes.AccAddress - nubID ids.ID - } - tests := []struct { - name string - args args - want sdkTypes.Msg - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newMessage(tt.args.from, tt.args.nubID); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newMessage() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_messageFromInterface2(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want message - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_messagePrototype2(t *testing.T) { - tests := []struct { - name string - want helpers.Message - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messagePrototype(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messagePrototype() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_GetSignBytes2(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want []byte - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.GetSignBytes(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetSignBytes() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_GetSigners2(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want []sdkTypes.AccAddress - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.GetSigners(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetSigners() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_RegisterCodec2(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - type args struct { - codec *codec.Codec - } - tests := []struct { - name string - fields fields - args args - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - me.RegisterCodec(tt.args.codec) - }) - } -} - -func Test_message_Route2(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.Route(); got != tt.want { - t.Errorf("Route() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_Type2(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_ValidateBasic2(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if err := message.ValidateBasic(); (err != nil) != tt.wantErr { - t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func Test_newMessage2(t *testing.T) { - type args struct { - from sdkTypes.AccAddress - nubID ids.ID - } - tests := []struct { - name string - args args - want sdkTypes.Msg - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newMessage(tt.args.from, tt.args.nubID); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newMessage() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_messageFromInterface3(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want message - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_messagePrototype3(t *testing.T) { - tests := []struct { - name string - want helpers.Message - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messagePrototype(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messagePrototype() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_GetSignBytes3(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want []byte - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.GetSignBytes(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetSignBytes() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_GetSigners3(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want []sdkTypes.AccAddress - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.GetSigners(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetSigners() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_RegisterCodec3(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - type args struct { - codec *codec.Codec - } - tests := []struct { - name string - fields fields - args args - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - me.RegisterCodec(tt.args.codec) - }) - } -} - -func Test_message_Route3(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.Route(); got != tt.want { - t.Errorf("Route() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_Type3(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_message_ValidateBasic3(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - NubID ids.ID - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := message{ - From: tt.fields.From, - NubID: tt.fields.NubID, - } - if err := message.ValidateBasic(); (err != nil) != tt.wantErr { - t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func Test_newMessage3(t *testing.T) { - type args struct { - from sdkTypes.AccAddress - nubID ids.ID - } - tests := []struct { - name string - args args - want sdkTypes.Msg - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newMessage(tt.args.from, tt.args.nubID); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newMessage() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/modules/identities/internal/transactions/nub/request_test.go b/modules/identities/internal/transactions/nub/request_test.go index 46ecd9c56..044b1f295 100644 --- a/modules/identities/internal/transactions/nub/request_test.go +++ b/modules/identities/internal/transactions/nub/request_test.go @@ -54,7 +54,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseReq, "nubID"}, transactionRequest{testBaseReq, "nubID"}}, } for _, tt := range tests { @@ -71,7 +70,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -101,7 +99,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "nubID"}, args{cliCommand, cliContext}, transactionRequest{cliCommand.ReadBaseReq(cliContext), cliCommand.ReadString(constants.NubID)}, false}, } for _, tt := range tests { @@ -139,7 +136,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "nubID"}, args{sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{fromAccAddress, baseIds.NewStringID("nubID")}))}, transactionRequest{testBaseReq, "nubID"}, false}, } for _, tt := range tests { @@ -172,7 +168,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "nubID"}, testBaseReq}, } for _, tt := range tests { @@ -201,7 +196,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "nubID"}, message{fromAccAddress, baseIds.NewStringID("nubID")}, false}, } for _, tt := range tests { @@ -237,7 +231,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "nubID"}, args{codec.New()}}, } for _, tt := range tests { @@ -263,7 +256,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, "nubID"}, false}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/nub/response_test.go b/modules/identities/internal/transactions/nub/response_test.go index d87c862f9..6ec4cecbd 100644 --- a/modules/identities/internal/transactions/nub/response_test.go +++ b/modules/identities/internal/transactions/nub/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/identities/internal/transactions/provision/keeper_test.go b/modules/identities/internal/transactions/provision/keeper_test.go index 66996065f..253635970 100644 --- a/modules/identities/internal/transactions/provision/keeper_test.go +++ b/modules/identities/internal/transactions/provision/keeper_test.go @@ -86,7 +86,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -115,7 +114,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{mapper}, args{mapper, _parameters, []interface{}{supplementAuxiliary}}, transactionKeeper{mapper, supplementAuxiliary}}, } @@ -158,7 +156,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve Not Authorized", fields{mapper}, args{context, newMessage(fromAccAddress, fromAccAddress, testFromID)}, newTransactionResponse(errorConstants.NotAuthorized)}, {"+ve already Exists", fields{mapper}, args{context, newMessage(toAccAddress, fromAccAddress, testFromID)}, newTransactionResponse(nil)}, {"+ve", fields{mapper}, args{context, newMessage(toAccAddress, toAccAddress, testFromID)}, newTransactionResponse(errorConstants.EntityAlreadyExists)}, diff --git a/modules/identities/internal/transactions/provision/message_test.go b/modules/identities/internal/transactions/provision/message_test.go index ad7acddee..dbfd680a0 100644 --- a/modules/identities/internal/transactions/provision/message_test.go +++ b/modules/identities/internal/transactions/provision/message_test.go @@ -51,7 +51,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, toAccAddress, testIdentityID}}, } for _, tt := range tests { @@ -68,7 +67,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -92,7 +90,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -122,7 +119,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -155,7 +151,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, args{codec.New()}}, } for _, tt := range tests { @@ -183,7 +178,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, module.Name}, } for _, tt := range tests { @@ -213,7 +207,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, Transaction.GetName()}, } for _, tt := range tests { @@ -243,7 +236,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, false}, {"+ve", fields{}, true}, } @@ -274,7 +266,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, toAccAddress, testIdentityID}, message{fromAccAddress, toAccAddress, testIdentityID}}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/provision/request_test.go b/modules/identities/internal/transactions/provision/request_test.go index 6aa761508..e68ca8dbc 100644 --- a/modules/identities/internal/transactions/provision/request_test.go +++ b/modules/identities/internal/transactions/provision/request_test.go @@ -51,7 +51,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve with nil", args{}, transactionRequest{}}, {"+ve", args{testBaseReq, testToAddress, testFromID.String()}, transactionRequest{testBaseReq, testToAddress, testFromID.String()}}, } @@ -69,7 +68,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -108,7 +106,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, args{cliCommand: cliCommand, cliContext: cliContext}, transactionRequest{cliCommand.ReadBaseReq(cliContext), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID)}, false}, } for _, tt := range tests { @@ -147,7 +144,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, args{types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c"), types.AccAddress(testToAddress), testFromID}))}, transactionRequest{testBaseReq, testToAddress, testFromID.String()}, false}, } for _, tt := range tests { @@ -181,7 +177,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, testBaseReq}, } for _, tt := range tests { @@ -216,7 +211,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, message{fromAccAddress, toAccAddress, testFromID}, false}, } for _, tt := range tests { @@ -253,7 +247,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{codec.New()}}, {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, args{codec.New()}}, } @@ -281,7 +274,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve with nil", fields{}, true}, {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, false}, } diff --git a/modules/identities/internal/transactions/provision/response_test.go b/modules/identities/internal/transactions/provision/response_test.go index 49cddb945..5f3420fb7 100644 --- a/modules/identities/internal/transactions/provision/response_test.go +++ b/modules/identities/internal/transactions/provision/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/identities/internal/transactions/quash/message_test.go b/modules/identities/internal/transactions/quash/message_test.go index ff124e91b..33267bebb 100644 --- a/modules/identities/internal/transactions/quash/message_test.go +++ b/modules/identities/internal/transactions/quash/message_test.go @@ -48,7 +48,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testIdentityID}}, } for _, tt := range tests { @@ -65,7 +64,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -89,7 +87,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testIdentityID}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -119,7 +116,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testIdentityID}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -151,7 +147,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testIdentityID}, args{codec.New()}}, } for _, tt := range tests { @@ -178,7 +173,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testIdentityID}, module.Name}, } for _, tt := range tests { @@ -207,7 +201,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testIdentityID}, Transaction.GetName()}, } for _, tt := range tests { @@ -236,7 +229,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testIdentityID}, false}, {"-ve", fields{}, true}, } @@ -266,7 +258,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testIdentityID}, message{fromAccAddress, testFromID, testIdentityID}}, {"-ve", args{}, message{}}, } diff --git a/modules/identities/internal/transactions/quash/request_test.go b/modules/identities/internal/transactions/quash/request_test.go index 279c9cc47..835f33dc2 100644 --- a/modules/identities/internal/transactions/quash/request_test.go +++ b/modules/identities/internal/transactions/quash/request_test.go @@ -51,7 +51,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve with nil", args{}, transactionRequest{}}, {"+ve", args{testBaseReq, testToAddress, testFromID.String()}, transactionRequest{testBaseReq, testToAddress, testFromID.String()}}, } @@ -69,7 +68,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -108,7 +106,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testFromID.String(), testFromID.String()}, args{cliCommand: cliCommand, cliContext: cliContext}, transactionRequest{cliCommand.ReadBaseReq(cliContext), cliCommand.ReadString(constants.FromID), cliCommand.ReadString(constants.IdentityID)}, false}, } for _, tt := range tests { @@ -147,7 +144,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, args{types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c"), testFromID, testFromID}))}, transactionRequest{testBaseReq, testToAddress, testFromID.String()}, false}, } for _, tt := range tests { @@ -181,7 +177,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, testBaseReq}, } for _, tt := range tests { @@ -214,7 +209,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testFromID.String(), testFromID.String()}, message{fromAccAddress, testFromID, testFromID}, false}, } for _, tt := range tests { @@ -251,7 +245,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{codec.New()}}, {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, args{codec.New()}}, } @@ -279,7 +272,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve with nil", fields{}, true}, {"+ve", fields{testBaseReq, testToAddress, testFromID.String()}, false}, } diff --git a/modules/identities/internal/transactions/quash/response_test.go b/modules/identities/internal/transactions/quash/response_test.go index 1723cdffc..bf1f52081 100644 --- a/modules/identities/internal/transactions/quash/response_test.go +++ b/modules/identities/internal/transactions/quash/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/identities/internal/transactions/revoke/keeper_test.go b/modules/identities/internal/transactions/revoke/keeper_test.go index 67c657220..0e3b50253 100644 --- a/modules/identities/internal/transactions/revoke/keeper_test.go +++ b/modules/identities/internal/transactions/revoke/keeper_test.go @@ -90,7 +90,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -121,7 +120,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, Parameters, revokeAuxiliary, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, revokeAuxiliary, authenticateAuxiliary}}, } @@ -170,7 +168,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, revokeAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testFromID, testClassificationID)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/identities/internal/transactions/revoke/message_test.go b/modules/identities/internal/transactions/revoke/message_test.go index 809e0c4f4..9c233640c 100644 --- a/modules/identities/internal/transactions/revoke/message_test.go +++ b/modules/identities/internal/transactions/revoke/message_test.go @@ -50,7 +50,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testToID, testClassificationID}}, } for _, tt := range tests { @@ -67,7 +66,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -93,7 +91,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -125,7 +122,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -160,7 +156,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID}, args{codec.New()}}, } for _, tt := range tests { @@ -190,7 +185,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID}, module.Name}, } for _, tt := range tests { @@ -222,7 +216,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID}, Transaction.GetName()}, } for _, tt := range tests { @@ -254,7 +247,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID}, false}, {"-ve", fields{}, true}, } @@ -287,7 +279,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testToID, testClassificationID}, message{fromAccAddress, testFromID, testToID, testClassificationID}}, {"-ve with nil", args{}, message{}}, } diff --git a/modules/identities/internal/transactions/revoke/request_test.go b/modules/identities/internal/transactions/revoke/request_test.go index 8ccbcb470..c144a7873 100644 --- a/modules/identities/internal/transactions/revoke/request_test.go +++ b/modules/identities/internal/transactions/revoke/request_test.go @@ -54,7 +54,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve with nil", args{}, transactionRequest{}}, {"+ve", args{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, transactionRequest{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}}, } @@ -72,7 +71,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -112,7 +110,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, args{cliCommand, cliContext}, transactionRequest{cliCommand.ReadBaseReq(cliContext), cliCommand.ReadString(constants.FromID), cliCommand.ReadString(constants.ToID), cliCommand.ReadString(constants.ClassificationID)}, false}, } for _, tt := range tests { @@ -155,7 +152,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, args{types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{fromAccAddress, testFromID, testToID, testClassificationID}))}, transactionRequest{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, false}, } for _, tt := range tests { @@ -191,7 +187,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, testBaseReq}, } for _, tt := range tests { @@ -225,7 +220,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. // TODO: Type & Data same but Not matching {"+ve", fields{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, message{testFromAccAddress, testFromID, testToID, testClassificationID}, false}, } @@ -265,7 +259,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{codec.New()}}, {"+ve", fields{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, args{codec.New()}}, } @@ -295,7 +288,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve with nil", fields{}, true}, {"+ve", fields{testBaseReq, testFromID.String(), testToID.String(), testClassificationID.String()}, false}, } diff --git a/modules/identities/internal/transactions/revoke/response_test.go b/modules/identities/internal/transactions/revoke/response_test.go index e031d09db..87e8625d7 100644 --- a/modules/identities/internal/transactions/revoke/response_test.go +++ b/modules/identities/internal/transactions/revoke/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/identities/internal/transactions/unprovision/keeper_test.go b/modules/identities/internal/transactions/unprovision/keeper_test.go index 37b2e9e92..443a25742 100644 --- a/modules/identities/internal/transactions/unprovision/keeper_test.go +++ b/modules/identities/internal/transactions/unprovision/keeper_test.go @@ -88,7 +88,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -118,7 +117,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{mapper, supplementAuxiliary}, args{mapper, _parameters, []interface{}{supplementAuxiliary}}, transactionKeeper{mapper, supplementAuxiliary}}, } @@ -163,7 +161,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve Not Authorized", fields{mapper, supplementAuxiliary}, args{context, newMessage(fromAccAddress, toAccAddress, testFromID)}, newTransactionResponse(errorConstants.NotAuthorized)}, {"+ve Not Found", fields{mapper, supplementAuxiliary}, args{context, newMessage(toAccAddress, fromAccAddress, testFromID)}, newTransactionResponse(errorConstants.EntityNotFound)}, {"+ve", fields{mapper, supplementAuxiliary}, args{context, newMessage(toAccAddress, toAccAddress, testFromID)}, newTransactionResponse(nil)}, diff --git a/modules/identities/internal/transactions/unprovision/message_test.go b/modules/identities/internal/transactions/unprovision/message_test.go index cc3afa672..473279d4c 100644 --- a/modules/identities/internal/transactions/unprovision/message_test.go +++ b/modules/identities/internal/transactions/unprovision/message_test.go @@ -50,7 +50,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, toAccAddress, testIdentityID}}, } for _, tt := range tests { @@ -67,7 +66,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -92,7 +90,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -122,7 +119,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -155,7 +151,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, args{codec.New()}}, } for _, tt := range tests { @@ -183,7 +178,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, module.Name}, } for _, tt := range tests { @@ -213,7 +207,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, Transaction.GetName()}, } for _, tt := range tests { @@ -243,7 +236,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, toAccAddress, testIdentityID}, false}, {"-ve", fields{}, true}, } @@ -274,7 +266,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, toAccAddress, testIdentityID}, message{fromAccAddress, toAccAddress, testIdentityID}}, {"-ve", args{}, message{}}, } diff --git a/modules/identities/internal/transactions/unprovision/request_test.go b/modules/identities/internal/transactions/unprovision/request_test.go index ce3ef84b7..da9e3e5ea 100644 --- a/modules/identities/internal/transactions/unprovision/request_test.go +++ b/modules/identities/internal/transactions/unprovision/request_test.go @@ -61,7 +61,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve wit nil", args{}, transactionRequest{}}, {"+ve", args{testBaseReq, toAddress, testIdentityID.String()}, transactionRequest{testBaseReq, toAddress, testIdentityID.String()}}, } @@ -79,7 +78,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -118,7 +116,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, testIdentityID.String()}, args{cliCommand, cliContext}, transactionRequest{cliCommand.ReadBaseReq(cliContext), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID)}, false}, } for _, tt := range tests { @@ -157,7 +154,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, testIdentityID.String()}, args{types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c"), toAccAddress, testIdentityID}))}, transactionRequest{testBaseReq, toAddress, testIdentityID.String()}, false}, } for _, tt := range tests { @@ -191,7 +187,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, testIdentityID.String()}, testBaseReq}, } for _, tt := range tests { @@ -224,7 +219,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseReq, toAddress, testIdentityID.String()}, message{fromAccAddress, toAccAddress, testIdentityID}, false}, } for _, tt := range tests { @@ -261,7 +255,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve wit nil", fields{}, args{codec.New()}}, {"+ve", fields{testBaseReq, toAddress, testIdentityID.String()}, args{codec.New()}}, } @@ -289,7 +282,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve wit nil", fields{}, true}, {"+ve", fields{testBaseReq, toAddress, testIdentityID.String()}, false}, } diff --git a/modules/identities/internal/transactions/unprovision/response_test.go b/modules/identities/internal/transactions/unprovision/response_test.go index 489661d59..277134fc8 100644 --- a/modules/identities/internal/transactions/unprovision/response_test.go +++ b/modules/identities/internal/transactions/unprovision/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/maintainers/internal/queries/maintainer/request_test.go b/modules/maintainers/internal/queries/maintainer/request_test.go index dab4f235f..01c8e07cb 100644 --- a/modules/maintainers/internal/queries/maintainer/request_test.go +++ b/modules/maintainers/internal/queries/maintainer/request_test.go @@ -4,6 +4,9 @@ package maintainer import ( + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" + "github.com/spf13/viper" "reflect" "testing" @@ -136,6 +139,8 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.MaintainerID}) + viper.Set(constants.MaintainerID.GetName(), testMaintainerID.String()) type fields struct { MaintainerID ids.MaintainerID } @@ -149,7 +154,9 @@ func Test_queryRequest_FromCLI(t *testing.T) { args args want helpers.QueryRequest wantErr bool - }{} + }{ + {"+ve", fields{testMaintainerID}, args{cliCommand, context.NewCLIContext()}, queryRequest{testMaintainerID}, false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { qu := queryRequest{ diff --git a/modules/metas/internal/queries/meta/request_test.go b/modules/metas/internal/queries/meta/request_test.go index eba713a8b..11e1bc2f9 100644 --- a/modules/metas/internal/queries/meta/request_test.go +++ b/modules/metas/internal/queries/meta/request_test.go @@ -7,9 +7,12 @@ import ( "github.com/AssetMantle/modules/modules/metas/internal/common" base2 "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/schema/ids" "github.com/AssetMantle/modules/schema/ids/base" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -133,6 +136,8 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.DataID}) + viper.Set(constants.DataID.GetName(), testDataID.String()) type fields struct { DataID ids.DataID } @@ -146,7 +151,9 @@ func Test_queryRequest_FromCLI(t *testing.T) { args args want helpers.QueryRequest wantErr bool - }{} + }{ + {"+ve", fields{testDataID}, args{cliCommand, context.CLIContext{}}, newQueryRequest(testDataID), false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { qu := queryRequest{ diff --git a/modules/orders/internal/block/block_test.go b/modules/orders/internal/block/block_test.go index ba814862e..71d62583a 100644 --- a/modules/orders/internal/block/block_test.go +++ b/modules/orders/internal/block/block_test.go @@ -4,6 +4,7 @@ package block import ( + "github.com/AssetMantle/modules/modules/metas/auxiliaries/scrub" "testing" "github.com/cosmos/cosmos-sdk/codec" @@ -26,7 +27,7 @@ import ( baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" ) -func CreateTestInput(t *testing.T) (sdkTypes.Context, helpers.Mapper, helpers.Auxiliary, helpers.Auxiliary) { +func CreateTestInput(t *testing.T) (sdkTypes.Context, helpers.Mapper, helpers.Auxiliary, helpers.Auxiliary, helpers.Auxiliary) { var Codec = codec.New() schema.RegisterCodec(Codec) sdkTypes.RegisterCodec(Codec) @@ -55,20 +56,59 @@ func CreateTestInput(t *testing.T) (sdkTypes.Context, helpers.Mapper, helpers.Au Parameters := parameters.Prototype().Initialize(paramsKeeper.Subspace("test")) transferAuxiliary := transfer.AuxiliaryMock.Initialize(Mapper, Parameters) supplementAuxiliary := supplement.AuxiliaryMock.Initialize(Mapper, Parameters) + scrubAuxiliary := scrub.AuxiliaryMock.Initialize(Mapper, Parameters) context := sdkTypes.NewContext(commitMultiStore, abciTypes.Header{ ChainID: "test", Height: 1000, }, false, log.NewNopLogger()) - return context, Mapper, transferAuxiliary, supplementAuxiliary + return context, Mapper, transferAuxiliary, supplementAuxiliary, scrubAuxiliary } func Test_Block_Methods(t *testing.T) { block := Prototype() - context, mapper, transferAuxiliary, supplementAuxiliary := CreateTestInput(t) + context, mapper, transferAuxiliary, supplementAuxiliary, _ := CreateTestInput(t) block = block.Initialize(mapper, parameters.Prototype(), transferAuxiliary, supplementAuxiliary) block.Begin(context, abciTypes.RequestBeginBlock{}) block.End(context, abciTypes.RequestEndBlock{}) } + +func Test_block_End(t *testing.T) { + context, mapper, transferAuxiliary, supplementAuxiliary, scrubAuxiliary := CreateTestInput(t) + testContext := context.WithBlockHeight(1) + testContext1 := context.WithBlockHeight(-1) + type fields struct { + mapper helpers.Mapper + parameters helpers.Parameters + supplementAuxiliary helpers.Auxiliary + transferAuxiliary helpers.Auxiliary + scrubAuxiliary helpers.Auxiliary + } + type args struct { + context sdkTypes.Context + in1 abciTypes.RequestEndBlock + } + tests := []struct { + name string + fields fields + args args + }{ + {"+ve with block height", fields{mapper, parameters.Prototype(), supplementAuxiliary, transferAuxiliary, scrubAuxiliary}, args{testContext, abciTypes.RequestEndBlock{Height: int64(1)}}}, + {"-ve without block height", fields{mapper, parameters.Prototype(), supplementAuxiliary, transferAuxiliary, scrubAuxiliary}, args{context, abciTypes.RequestEndBlock{}}}, + {"-ve with -ve block height", fields{mapper, parameters.Prototype(), supplementAuxiliary, transferAuxiliary, scrubAuxiliary}, args{testContext1, abciTypes.RequestEndBlock{Height: int64(-1)}}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + block := block{ + mapper: tt.fields.mapper, + parameters: tt.fields.parameters, + supplementAuxiliary: tt.fields.supplementAuxiliary, + transferAuxiliary: tt.fields.transferAuxiliary, + scrubAuxiliary: tt.fields.scrubAuxiliary, + } + block.End(tt.args.context, tt.args.in1) + }) + } +} diff --git a/modules/orders/internal/key/key_test.go b/modules/orders/internal/key/key_test.go index 73c3fc62d..fb37d64f9 100644 --- a/modules/orders/internal/key/key_test.go +++ b/modules/orders/internal/key/key_test.go @@ -33,7 +33,6 @@ func TestNewKey(t *testing.T) { args args want helpers.Key }{ - // TODO: Add test cases. {"+ve", args{testOrderID}, key{OrderID: testOrderID}}, } for _, tt := range tests { @@ -50,7 +49,6 @@ func TestPrototype(t *testing.T) { name string want helpers.Key }{ - // TODO: Add test cases. {"+ve", key{}}, } for _, tt := range tests { @@ -72,7 +70,6 @@ func Test_keyFromInterface(t *testing.T) { want key wantErr bool }{ - // TODO: Add test cases. {"+ve", args{}, key{}, true}, {"+ve", args{NewKey(testOrderID)}, key{testOrderID}, false}, {"-ve", args{baseIds.NewStringID("StringID")}, key{}, true}, @@ -104,7 +101,6 @@ func Test_key_Equals(t *testing.T) { args args want bool }{ - // TODO: Add test cases. {"+ve", fields{testOrderID}, args{key{testOrderID}}, true}, } for _, tt := range tests { @@ -128,7 +124,6 @@ func Test_key_GenerateStoreKeyBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{testOrderID}, module.StoreKeyPrefix.GenerateStoreKey(key{testOrderID}.Bytes())}, } for _, tt := range tests { @@ -152,7 +147,6 @@ func Test_key_IsPartial(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{testOrderID}, false}, } for _, tt := range tests { @@ -179,7 +173,6 @@ func Test_key_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testOrderID}, args{codec.New()}}, } for _, tt := range tests { diff --git a/modules/orders/internal/mappable/mappable_test.go b/modules/orders/internal/mappable/mappable_test.go index 11839c9c4..94236d2bd 100644 --- a/modules/orders/internal/mappable/mappable_test.go +++ b/modules/orders/internal/mappable/mappable_test.go @@ -36,7 +36,6 @@ func TestNewMappable(t *testing.T) { args args want helpers.Mappable }{ - // TODO: Add test cases. {"+ve", args{testOrder}, mappable{baseDocuments.NewOrder(classificationID, immutables, mutables)}}, } for _, tt := range tests { @@ -53,7 +52,6 @@ func TestPrototype(t *testing.T) { name string want helpers.Mappable }{ - // TODO: Add test cases. {"+ve", mappable{}}, } for _, tt := range tests { @@ -75,7 +73,6 @@ func Test_mappable_GetKey(t *testing.T) { want helpers.Key wantPanic bool }{ - // TODO: Add test cases. {"+ve", fields{testOrder}, key.NewKey(baseIds.NewOrderID(classificationID, immutables)), false}, {"panic case nil", fields{nil}, nil, true}, } @@ -107,7 +104,6 @@ func Test_mappable_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testOrder}, args{codec.New()}}, {"+ve nil", fields{nil}, args{codec.New()}}, } diff --git a/modules/orders/internal/queries/order/keeper_test.go b/modules/orders/internal/queries/order/keeper_test.go index 376886764..a90c8d59f 100644 --- a/modules/orders/internal/queries/order/keeper_test.go +++ b/modules/orders/internal/queries/order/keeper_test.go @@ -73,7 +73,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.QueryKeeper }{ - // TODO: Add test cases. {"+ve", queryKeeper{}}, } for _, tt := range tests { @@ -102,7 +101,6 @@ func Test_queryKeeper_Enquire(t *testing.T) { args args want helpers.QueryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, newQueryRequest(testOrderID)}, newQueryResponse(keepers.QueryKeeper.(queryKeeper).mapper.NewCollection(context).Fetch(key.NewKey(testOrderID)), nil)}, } for _, tt := range tests { @@ -135,7 +133,6 @@ func Test_queryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, queryKeeper{}}, {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, queryKeeper{Mapper}}, } diff --git a/modules/orders/internal/queries/order/request_test.go b/modules/orders/internal/queries/order/request_test.go index 9f44fa661..58daf693b 100644 --- a/modules/orders/internal/queries/order/request_test.go +++ b/modules/orders/internal/queries/order/request_test.go @@ -7,12 +7,15 @@ import ( "github.com/AssetMantle/modules/modules/orders/internal/common" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + base2 "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/schema/ids" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" baseQualified "github.com/AssetMantle/modules/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -143,6 +146,8 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + cliCommand := base2.NewCLICommand("", "", "", []helpers.CLIFlag{constants.OrderID}) + viper.Set(constants.OrderID.GetName(), testOrderID.String()) type fields struct { OrderID ids.OrderID } @@ -156,7 +161,9 @@ func Test_queryRequest_FromCLI(t *testing.T) { args args want helpers.QueryRequest wantErr bool - }{} + }{ + {"+ve", fields{testOrderID}, args{cliCommand, context.NewCLIContext()}, newQueryRequest(testOrderID), false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { qu := queryRequest{ diff --git a/modules/orders/internal/transactions/cancel/message_test.go b/modules/orders/internal/transactions/cancel/message_test.go index ac11a051c..67d830444 100644 --- a/modules/orders/internal/transactions/cancel/message_test.go +++ b/modules/orders/internal/transactions/cancel/message_test.go @@ -51,7 +51,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testOrderID}}, } for _, tt := range tests { @@ -68,7 +67,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -93,7 +91,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -123,7 +120,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -156,7 +152,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID}, args{codec.New()}}, } for _, tt := range tests { @@ -184,7 +179,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID}, module.Name}, } for _, tt := range tests { @@ -214,7 +208,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID}, Transaction.GetName()}, } for _, tt := range tests { @@ -244,7 +237,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID}, false}, {"-ve", fields{}, true}, } @@ -275,7 +267,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testOrderID}, message{fromAccAddress, testFromID, testOrderID}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/cancel/request_test.go b/modules/orders/internal/transactions/cancel/request_test.go index 05f565275..f446c9329 100644 --- a/modules/orders/internal/transactions/cancel/request_test.go +++ b/modules/orders/internal/transactions/cancel/request_test.go @@ -5,8 +5,11 @@ package cancel import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + basehelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -73,6 +77,10 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := basehelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.OrderID, constants.FromID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.OrderID.GetName(), testOrderID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -88,7 +96,9 @@ func Test_transactionRequest_FromCLI(t *testing.T) { args args want helpers.TransactionRequest wantErr bool - }{} + }{ + {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String()}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, testFromID.String(), testOrderID.String()), false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ @@ -101,7 +111,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/orders/internal/transactions/cancel/response_test.go b/modules/orders/internal/transactions/cancel/response_test.go index e98e0f0d4..3b8f447ce 100644 --- a/modules/orders/internal/transactions/cancel/response_test.go +++ b/modules/orders/internal/transactions/cancel/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/define/keeper_test.go b/modules/orders/internal/transactions/define/keeper_test.go index 25dca4299..fffbff11c 100644 --- a/modules/orders/internal/transactions/define/keeper_test.go +++ b/modules/orders/internal/transactions/define/keeper_test.go @@ -124,7 +124,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, Parameters, defineAuxiliary, superAuxiliary, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, defineAuxiliary, superAuxiliary, authenticateAuxiliary}}, } @@ -178,7 +177,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, defineAuxiliary, superAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/define/message_test.go b/modules/orders/internal/transactions/define/message_test.go index 68dd649b2..648827465 100644 --- a/modules/orders/internal/transactions/define/message_test.go +++ b/modules/orders/internal/transactions/define/message_test.go @@ -4,46 +4,23 @@ package define import ( + "github.com/AssetMantle/modules/utilities/transaction" "reflect" "testing" - "github.com/cosmos/cosmos-sdk/codec" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/modules/orders/internal/module" "github.com/AssetMantle/modules/schema/helpers" "github.com/AssetMantle/modules/schema/ids" - baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists" - "github.com/AssetMantle/modules/schema/lists/utilities" - baseQualified "github.com/AssetMantle/modules/schema/qualified/base" + "github.com/cosmos/cosmos-sdk/codec" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) -func CreateTestInputForMessage(t *testing.T) (ids.IdentityID, sdkTypes.AccAddress, lists.PropertyList, lists.PropertyList, lists.PropertyList, lists.PropertyList, sdkTypes.Msg) { - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) - require.Nil(t, err) - - immutableMetaProperties, err := utilities.ReadMetaPropertyList("defaultImmutableMeta1:S|defaultImmutableMeta1") - require.Equal(t, nil, err) - immutableProperties, err := utilities.ReadMetaPropertyList("defaultImmutable1:S|defaultImmutable1") - require.Equal(t, nil, err) - mutableMetaProperties, err := utilities.ReadMetaPropertyList("defaultMutableMeta1:S|defaultMutableMeta1") - require.Equal(t, nil, err) - mutableProperties, err := utilities.ReadMetaPropertyList("defaultMutable1:S|defaultMutable1") - require.Equal(t, nil, err) - testClassificationID := baseIDs.NewClassificationID(baseQualified.NewImmutables(immutableProperties), baseQualified.NewMutables(mutableProperties)) - testFromID := baseIDs.NewIdentityID(testClassificationID, baseQualified.NewImmutables(immutableProperties)) - - testMessage := newMessage(fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties) - - return testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, testMessage -} +var ( + testMessage = newMessage(fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties) +) func Test_messageFromInterface(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, testMessage := CreateTestInputForMessage(t) type args struct { msg sdkTypes.Msg } @@ -52,7 +29,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { @@ -69,7 +45,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -82,7 +57,6 @@ func Test_messagePrototype(t *testing.T) { } func Test_message_GetSignBytes(t *testing.T) { - // testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, testMessage := CreateTestInputForMessage(t) type fields struct { From sdkTypes.AccAddress FromID ids.IdentityID @@ -96,8 +70,7 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. - // {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, + {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -117,7 +90,6 @@ func Test_message_GetSignBytes(t *testing.T) { } func Test_message_GetSigners(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _ := CreateTestInputForMessage(t) type fields struct { From sdkTypes.AccAddress FromID ids.IdentityID @@ -131,7 +103,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -152,7 +123,6 @@ func Test_message_GetSigners(t *testing.T) { } func Test_message_RegisterCodec(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _ := CreateTestInputForMessage(t) type fields struct { From sdkTypes.AccAddress FromID ids.IdentityID @@ -169,7 +139,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.New()}}, } for _, tt := range tests { @@ -188,7 +157,6 @@ func Test_message_RegisterCodec(t *testing.T) { } func Test_message_Route(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _ := CreateTestInputForMessage(t) type fields struct { From sdkTypes.AccAddress FromID ids.IdentityID @@ -202,7 +170,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, module.Name}, } for _, tt := range tests { @@ -223,7 +190,6 @@ func Test_message_Route(t *testing.T) { } func Test_message_Type(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _ := CreateTestInputForMessage(t) type fields struct { From sdkTypes.AccAddress FromID ids.IdentityID @@ -237,7 +203,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, } for _, tt := range tests { @@ -258,7 +223,6 @@ func Test_message_Type(t *testing.T) { } func Test_message_ValidateBasic(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _ := CreateTestInputForMessage(t) type fields struct { From sdkTypes.AccAddress FromID ids.IdentityID @@ -272,7 +236,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, false}, {"-ve", fields{}, true}, } @@ -294,7 +257,6 @@ func Test_message_ValidateBasic(t *testing.T) { } func Test_newMessage(t *testing.T) { - testFromID, fromAccAddress, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _ := CreateTestInputForMessage(t) type args struct { from sdkTypes.AccAddress fromID ids.IdentityID @@ -308,7 +270,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, message{fromAccAddress, testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/define/request_test.go b/modules/orders/internal/transactions/define/request_test.go index 987c5fe92..974211e06 100644 --- a/modules/orders/internal/transactions/define/request_test.go +++ b/modules/orders/internal/transactions/define/request_test.go @@ -5,7 +5,10 @@ package define import ( "encoding/json" + "fmt" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/utilities" "github.com/AssetMantle/modules/schema/qualified/base" @@ -13,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -51,7 +55,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, } for _, tt := range tests { @@ -68,7 +71,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -81,6 +83,13 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ImmutableProperties, constants.FromID, constants.ImmutableMetaProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.ImmutableProperties.GetName(), immutablePropertiesString) + viper.Set(constants.ImmutableMetaProperties.GetName(), immutableMetaPropertiesString) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) + viper.Set(constants.FromID.GetName(), testFromID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -100,7 +109,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -117,7 +126,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -145,7 +154,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { @@ -184,7 +192,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, } for _, tt := range tests { @@ -219,7 +226,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newMessage(fromAccAddress, testFromID, immutableMetaProperties, immutableProperties.ScrubData(), mutableMetaProperties, mutableProperties.ScrubData()), false}, } for _, tt := range tests { @@ -261,7 +267,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.New()}}, } for _, tt := range tests { @@ -293,7 +298,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/define/response_test.go b/modules/orders/internal/transactions/define/response_test.go index 9223e1761..e10729c24 100644 --- a/modules/orders/internal/transactions/define/response_test.go +++ b/modules/orders/internal/transactions/define/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/deputize/message_test.go b/modules/orders/internal/transactions/deputize/message_test.go index 579aeba87..6fe9499a8 100644 --- a/modules/orders/internal/transactions/deputize/message_test.go +++ b/modules/orders/internal/transactions/deputize/message_test.go @@ -59,7 +59,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}}, } for _, tt := range tests { @@ -76,7 +75,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -109,7 +107,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -155,7 +152,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -204,7 +200,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, args{codec.New()}}, } for _, tt := range tests { @@ -248,7 +243,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, module.Name}, } for _, tt := range tests { @@ -294,7 +288,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, Transaction.GetName()}, } for _, tt := range tests { @@ -340,7 +333,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, false}, {"-ve", fields{}, true}, } @@ -387,7 +379,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}, message{fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true, true}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/deputize/request_test.go b/modules/orders/internal/transactions/deputize/request_test.go index 292f8f13c..c76d477b0 100644 --- a/modules/orders/internal/transactions/deputize/request_test.go +++ b/modules/orders/internal/transactions/deputize/request_test.go @@ -5,8 +5,11 @@ package deputize import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/base" "github.com/AssetMantle/modules/schema/lists/utilities" @@ -16,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -53,7 +57,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, newTransactionRequest(testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true)}, } for _, tt := range tests { @@ -70,7 +73,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -83,6 +85,18 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.ToID, constants.ClassificationID, constants.MaintainedProperties, constants.CanMintAsset, constants.CanBurnAsset, constants.CanRenumerateAsset, constants.CanAddMaintainer, constants.CanRemoveMaintainer, constants.CanMutateMaintainer}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.ToID.GetName(), testFromID.String()) + viper.Set(constants.ClassificationID.GetName(), testClassificationID.String()) + viper.Set(constants.MaintainedProperties.GetName(), maintainedPropertyString) + viper.Set(constants.CanMintAsset.GetName(), true) + viper.Set(constants.CanBurnAsset.GetName(), true) + viper.Set(constants.CanRenumerateAsset.GetName(), true) + viper.Set(constants.CanAddMaintainer.GetName(), true) + viper.Set(constants.CanRemoveMaintainer.GetName(), true) + viper.Set(constants.CanMutateMaintainer.GetName(), true) type fields struct { BaseReq rest.BaseReq FromID string @@ -107,7 +121,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -129,7 +143,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -162,7 +176,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true), false}, } for _, tt := range tests { @@ -211,7 +224,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, testBaseRequest}, } for _, tt := range tests { @@ -256,7 +268,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, newMessage(fromAccAddress, testFromID, testFromID, testClassificationID, maintainedProperties, true, true, true, true, true, true), false}, } for _, tt := range tests { @@ -308,7 +319,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, args{codec.New()}}, } for _, tt := range tests { @@ -350,7 +360,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String(), maintainedPropertyString, true, true, true, true, true, true}, false}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/deputize/response_test.go b/modules/orders/internal/transactions/deputize/response_test.go index b7c0eebb6..349a64c2d 100644 --- a/modules/orders/internal/transactions/deputize/response_test.go +++ b/modules/orders/internal/transactions/deputize/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/immediate/keeper_test.go b/modules/orders/internal/transactions/immediate/keeper_test.go index 564a43e6a..db4cb9734 100644 --- a/modules/orders/internal/transactions/immediate/keeper_test.go +++ b/modules/orders/internal/transactions/immediate/keeper_test.go @@ -205,7 +205,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, conformAuxiliary, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testClassificationID, testTakerID, testMakerOwnableID, testTakerOwnableID, testHeight, testRate, testRate, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/immediate/message_test.go b/modules/orders/internal/transactions/immediate/message_test.go index 791a75db0..067061f4e 100644 --- a/modules/orders/internal/transactions/immediate/message_test.go +++ b/modules/orders/internal/transactions/immediate/message_test.go @@ -31,7 +31,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { @@ -48,7 +47,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -81,7 +79,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -129,7 +126,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -180,7 +176,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.New()}}, } for _, tt := range tests { @@ -226,7 +221,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, module.Name}, } for _, tt := range tests { @@ -274,7 +268,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, } for _, tt := range tests { @@ -322,7 +315,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, false}, {"-ve", fields{}, true}, } @@ -371,7 +363,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, message{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/immediate/request_test.go b/modules/orders/internal/transactions/immediate/request_test.go index b383036c6..c0c85e9b9 100644 --- a/modules/orders/internal/transactions/immediate/request_test.go +++ b/modules/orders/internal/transactions/immediate/request_test.go @@ -7,6 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/utilities" baseQualified "github.com/AssetMantle/modules/schema/qualified/base" @@ -15,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -64,7 +67,7 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. + {"+ve", args{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, } for _, tt := range tests { @@ -81,7 +84,7 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. + {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -94,6 +97,20 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.ClassificationID, constants.TakerID, constants.MakerOwnableID, constants.TakerOwnableID, constants.ExpiresIn, constants.MakerOwnableSplit, constants.TakerOwnableSplit, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.ClassificationID.GetName(), testClassificationID.String()) + viper.Set(constants.TakerID.GetName(), testFromID.String()) + viper.Set(constants.MakerOwnableID.GetName(), makerOwnableID.String()) + viper.Set(constants.TakerOwnableID.GetName(), takerOwnableID.String()) + viper.Set(constants.ExpiresIn.GetName(), expiresIn) + viper.Set(constants.MakerOwnableSplit.GetName(), makerOwnableSplit.String()) + viper.Set(constants.TakerOwnableSplit.GetName(), takerOwnableSplit.String()) + viper.Set(constants.ImmutableMetaProperties.GetName(), immutableMetaPropertiesString) + viper.Set(constants.ImmutableProperties.GetName(), immutablePropertiesString) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { BaseReq rest.BaseReq FromID string @@ -120,7 +137,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -144,7 +161,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -179,7 +196,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { @@ -232,7 +248,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, } for _, tt := range tests { @@ -281,7 +296,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newMessage(fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, base.NewHeight(60), makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, } for _, tt := range tests { @@ -337,7 +351,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.New()}}, } for _, tt := range tests { @@ -383,7 +396,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/immediate/response_test.go b/modules/orders/internal/transactions/immediate/response_test.go index 40c5117fe..2f47f79aa 100644 --- a/modules/orders/internal/transactions/immediate/response_test.go +++ b/modules/orders/internal/transactions/immediate/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/make/message_test.go b/modules/orders/internal/transactions/make/message_test.go index 07fdae825..6cb6ccab9 100644 --- a/modules/orders/internal/transactions/make/message_test.go +++ b/modules/orders/internal/transactions/make/message_test.go @@ -31,7 +31,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { @@ -48,7 +47,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -81,7 +79,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -129,7 +126,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -180,7 +176,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.New()}}, } for _, tt := range tests { @@ -226,7 +221,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, module.Name}, } for _, tt := range tests { @@ -274,7 +268,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, } for _, tt := range tests { @@ -322,7 +315,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, false}, {"-ve for nil", fields{}, true}, } @@ -371,7 +363,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, message{fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, expiresInHeight, makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/make/request_test.go b/modules/orders/internal/transactions/make/request_test.go index 2bd86dde4..cb5240424 100644 --- a/modules/orders/internal/transactions/make/request_test.go +++ b/modules/orders/internal/transactions/make/request_test.go @@ -7,6 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/utilities" baseQualified "github.com/AssetMantle/modules/schema/qualified/base" @@ -15,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -64,7 +67,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, } for _, tt := range tests { @@ -81,7 +83,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -94,6 +95,20 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.ClassificationID, constants.TakerID, constants.MakerOwnableID, constants.TakerOwnableID, constants.ExpiresIn, constants.MakerOwnableSplit, constants.TakerOwnableSplit, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.ClassificationID.GetName(), testClassificationID.String()) + viper.Set(constants.TakerID.GetName(), testFromID.String()) + viper.Set(constants.MakerOwnableID.GetName(), makerOwnableID.String()) + viper.Set(constants.TakerOwnableID.GetName(), takerOwnableID.String()) + viper.Set(constants.ExpiresIn.GetName(), expiresIn) + viper.Set(constants.MakerOwnableSplit.GetName(), makerOwnableSplit.String()) + viper.Set(constants.TakerOwnableSplit.GetName(), takerOwnableSplit.String()) + viper.Set(constants.ImmutableMetaProperties.GetName(), immutableMetaPropertiesString) + viper.Set(constants.ImmutableProperties.GetName(), immutablePropertiesString) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { BaseReq rest.BaseReq FromID string @@ -120,7 +135,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, cliContext}, newTransactionRequest(testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -144,7 +159,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -179,7 +194,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { @@ -232,7 +246,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, } for _, tt := range tests { @@ -281,7 +294,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newMessage(fromAccAddress, testFromID, testClassificationID, testFromID, makerOwnableID, takerOwnableID, base.NewHeight(60), makerOwnableSplit, takerOwnableSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, } for _, tt := range tests { @@ -337,7 +349,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.New()}}, } for _, tt := range tests { @@ -383,7 +394,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testClassificationID.String(), testFromID.String(), makerOwnableID.String(), takerOwnableID.String(), expiresIn, makerOwnableSplit.String(), takerOwnableSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/make/response_test.go b/modules/orders/internal/transactions/make/response_test.go index cebee85c8..f002d69e7 100644 --- a/modules/orders/internal/transactions/make/response_test.go +++ b/modules/orders/internal/transactions/make/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/modify/keeper_test.go b/modules/orders/internal/transactions/modify/keeper_test.go index 798b31eaa..9a2098342 100644 --- a/modules/orders/internal/transactions/modify/keeper_test.go +++ b/modules/orders/internal/transactions/modify/keeper_test.go @@ -129,7 +129,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, Parameters, conformAuxiliary, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, conformAuxiliary, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}}, } @@ -206,7 +205,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, conformAuxiliary, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testOrderID, testRate, testRate, testHeight, mutableMetaProperties, mutableProperties)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/modify/message_test.go b/modules/orders/internal/transactions/modify/message_test.go index 5a0c1ebaf..9006fe48f 100644 --- a/modules/orders/internal/transactions/modify/message_test.go +++ b/modules/orders/internal/transactions/modify/message_test.go @@ -31,7 +31,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { @@ -48,7 +47,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -76,7 +74,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, sdkTypes.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -114,7 +111,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []sdkTypes.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, []sdkTypes.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -155,7 +151,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, args{codec.New()}}, } for _, tt := range tests { @@ -191,7 +186,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, module.Name}, } for _, tt := range tests { @@ -229,7 +223,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, } for _, tt := range tests { @@ -267,7 +260,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"-ve for nil", fields{}, true}, {"+ve", fields{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, false}, } @@ -306,7 +298,6 @@ func Test_newMessage(t *testing.T) { args args want sdkTypes.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}, message{fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, expiresInHeight, mutableMetaProperties, mutableProperties}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/modify/request_test.go b/modules/orders/internal/transactions/modify/request_test.go index e428a76b6..867fcc46a 100644 --- a/modules/orders/internal/transactions/modify/request_test.go +++ b/modules/orders/internal/transactions/modify/request_test.go @@ -7,6 +7,8 @@ import ( "encoding/json" "fmt" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/utilities" baseQualified "github.com/AssetMantle/modules/schema/qualified/base" @@ -15,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -59,7 +62,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}}, } for _, tt := range tests { @@ -76,7 +78,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -89,6 +90,15 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.OrderID, constants.TakerOwnableSplit, constants.MakerOwnableSplit, constants.ExpiresIn, constants.MutableMetaProperties, constants.MutableProperties}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.OrderID.GetName(), testOrderID.String()) + viper.Set(constants.TakerOwnableSplit.GetName(), takerOwnableSplit.String()) + viper.Set(constants.MakerOwnableSplit.GetName(), makerOwnableSplit.String()) + viper.Set(constants.ExpiresIn.GetName(), expiresIn) + viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) + viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { BaseReq rest.BaseReq FromID string @@ -110,7 +120,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -129,7 +139,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -159,7 +169,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { @@ -202,7 +211,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, } for _, tt := range tests { @@ -241,7 +249,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, newMessage(fromAccAddress, testFromID, testOrderID, takerOwnableSplit, makerOwnableSplit, base.NewHeight(60), mutableMetaProperties, mutableProperties), false}, } for _, tt := range tests { @@ -287,7 +294,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.New()}}, } for _, tt := range tests { @@ -323,7 +329,7 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), testOrderID.String(), takerOwnableSplit.String(), makerOwnableSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/modules/orders/internal/transactions/modify/response_test.go b/modules/orders/internal/transactions/modify/response_test.go index 356689f68..dc9ee387c 100644 --- a/modules/orders/internal/transactions/modify/response_test.go +++ b/modules/orders/internal/transactions/modify/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/revoke/keeper_test.go b/modules/orders/internal/transactions/revoke/keeper_test.go index 57223b78a..6321a08e3 100644 --- a/modules/orders/internal/transactions/revoke/keeper_test.go +++ b/modules/orders/internal/transactions/revoke/keeper_test.go @@ -4,6 +4,28 @@ package revoke import ( + "fmt" + "github.com/AssetMantle/modules/modules/identities/auxiliaries/authenticate" + "github.com/AssetMantle/modules/modules/maintainers/auxiliaries/revoke" + "github.com/AssetMantle/modules/modules/orders/internal/key" + "github.com/AssetMantle/modules/modules/orders/internal/mappable" + "github.com/AssetMantle/modules/modules/orders/internal/parameters" + "github.com/AssetMantle/modules/schema" + baseData "github.com/AssetMantle/modules/schema/data/base" + baseDocuments "github.com/AssetMantle/modules/schema/documents/base" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + baseIDs "github.com/AssetMantle/modules/schema/ids/base" + baseLists "github.com/AssetMantle/modules/schema/lists/base" + baseProperties "github.com/AssetMantle/modules/schema/properties/base" + baseQualified "github.com/AssetMantle/modules/schema/qualified/base" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + "github.com/cosmos/cosmos-sdk/x/params" + "github.com/stretchr/testify/require" + abciTypes "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + tendermintDB "github.com/tendermint/tm-db" "reflect" "testing" @@ -12,12 +34,63 @@ import ( "github.com/AssetMantle/modules/schema/helpers" ) +var ( + authenticateAuxiliary helpers.Auxiliary + revokeAuxiliary helpers.Auxiliary +) + +type TestKeepers struct { + RevokeKeeper helpers.TransactionKeeper +} + +func CreateTestInput(t *testing.T) (types.Context, TestKeepers, helpers.Mapper, helpers.Parameters) { + var Codec = codec.New() + schema.RegisterCodec(Codec) + types.RegisterCodec(Codec) + codec.RegisterCrypto(Codec) + codec.RegisterEvidences(Codec) + vesting.RegisterCodec(Codec) + Codec.Seal() + + storeKey := types.NewKVStoreKey("test") + paramsStoreKey := types.NewKVStoreKey("testParams") + paramsTransientStoreKeys := types.NewTransientStoreKey("testParamsTransient") + Mapper := baseHelpers.NewMapper(key.Prototype, mappable.Prototype).Initialize(storeKey) + paramsKeeper := params.NewKeeper( + Codec, + paramsStoreKey, + paramsTransientStoreKeys, + ) + Parameters := parameters.Prototype().Initialize(paramsKeeper.Subspace("test")) + + memDB := tendermintDB.NewMemDB() + commitMultiStore := store.NewCommitMultiStore(memDB) + commitMultiStore.MountStoreWithDB(storeKey, types.StoreTypeIAVL, memDB) + commitMultiStore.MountStoreWithDB(paramsStoreKey, types.StoreTypeIAVL, memDB) + commitMultiStore.MountStoreWithDB(paramsTransientStoreKeys, types.StoreTypeTransient, memDB) + err := commitMultiStore.LoadLatestVersion() + require.Nil(t, err) + + authenticateAuxiliary = authenticate.AuxiliaryMock.Initialize(Mapper, Parameters) + revokeAuxiliary = revoke.AuxiliaryMock.Initialize(Mapper, Parameters) + + context := types.NewContext(commitMultiStore, abciTypes.Header{ + ChainID: "test", + }, false, log.NewNopLogger()) + + keepers := TestKeepers{ + RevokeKeeper: keeperPrototype().Initialize(Mapper, Parameters, []interface{}{}).(helpers.TransactionKeeper), + } + + return context, keepers, Mapper, Parameters +} + func Test_keeperPrototype(t *testing.T) { tests := []struct { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. + {"+ve", transactionKeeper{}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -29,6 +102,7 @@ func Test_keeperPrototype(t *testing.T) { } func Test_transactionKeeper_Initialize(t *testing.T) { + _, _, Mapper, Parameters := CreateTestInput(t) type fields struct { mapper helpers.Mapper parameters helpers.Parameters @@ -46,7 +120,7 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. + {"+ve", fields{Mapper, Parameters, authenticateAuxiliary, revokeAuxiliary}, args{Mapper, Parameters, []interface{}{authenticateAuxiliary, revokeAuxiliary}}, transactionKeeper{Mapper, Parameters, authenticateAuxiliary, revokeAuxiliary}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -56,7 +130,7 @@ func Test_transactionKeeper_Initialize(t *testing.T) { authenticateAuxiliary: tt.fields.authenticateAuxiliary, revokeAuxiliary: tt.fields.revokeAuxiliary, } - if got := transactionKeeper.Initialize(tt.args.mapper, tt.args.parameters, tt.args.auxiliaries); !reflect.DeepEqual(got, tt.want) { + if got := transactionKeeper.Initialize(tt.args.mapper, tt.args.parameters, tt.args.auxiliaries); !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("Initialize() = %v, want %v", got, tt.want) } }) @@ -64,6 +138,15 @@ func Test_transactionKeeper_Initialize(t *testing.T) { } func Test_transactionKeeper_Transact(t *testing.T) { + context, keepers, Mapper, Parameters := CreateTestInput(t) + mutableMetaProperties := baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("authentication"), baseData.NewListData(baseLists.NewDataList()))) + immutableMetaProperties := baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("ID1"), baseData.NewListData(baseLists.NewDataList()))) + immutablesMeta := baseQualified.NewImmutables(immutableMetaProperties) + mutablesMeta := baseQualified.NewMutables(mutableMetaProperties) + testIdentity := baseDocuments.NewIdentity(testClassificationID, immutablesMeta, mutablesMeta) + testIdentity.ProvisionAddress([]types.AccAddress{fromAccAddress}...) + testOrder := baseDocuments.NewOrder(testClassificationID, immutablesMeta, mutablesMeta) + keepers.RevokeKeeper.(transactionKeeper).mapper.NewCollection(context).Add(mappable.NewMappable(testOrder)) type fields struct { mapper helpers.Mapper parameters helpers.Parameters @@ -80,7 +163,7 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. + {"+ve", fields{Mapper, Parameters, authenticateAuxiliary, revokeAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testFromID, testClassificationID)}, newTransactionResponse(nil)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/modules/orders/internal/transactions/revoke/message_test.go b/modules/orders/internal/transactions/revoke/message_test.go index 09a729ba5..61fcdaf9c 100644 --- a/modules/orders/internal/transactions/revoke/message_test.go +++ b/modules/orders/internal/transactions/revoke/message_test.go @@ -27,7 +27,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, testFromID, testClassificationID}}, } for _, tt := range tests { @@ -44,7 +43,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -68,7 +66,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testFromID, testClassificationID}, types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -98,7 +95,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []types.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testFromID, testClassificationID}, []types.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -131,7 +127,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testFromID, testClassificationID}, args{codec.New()}}, } for _, tt := range tests { @@ -159,7 +154,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testFromID, testClassificationID}, module.Name}, } for _, tt := range tests { @@ -189,7 +183,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, testFromID, testClassificationID}, Transaction.GetName()}, } for _, tt := range tests { @@ -219,7 +212,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve with nil", fields{}, true}, {"+ve", fields{fromAccAddress, testFromID, testFromID, testClassificationID}, false}, } @@ -250,7 +242,6 @@ func Test_newMessage(t *testing.T) { args args want types.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, testFromID, testClassificationID}, message{fromAccAddress, testFromID, testFromID, testClassificationID}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/revoke/request_test.go b/modules/orders/internal/transactions/revoke/request_test.go index c32c99e0e..3bc8bb88c 100644 --- a/modules/orders/internal/transactions/revoke/request_test.go +++ b/modules/orders/internal/transactions/revoke/request_test.go @@ -5,8 +5,11 @@ package revoke import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -43,7 +47,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, transactionRequest{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}}, } for _, tt := range tests { @@ -60,7 +63,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -73,6 +75,11 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.ToID, constants.ClassificationID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.ToID.GetName(), testFromID.String()) + viper.Set(constants.ClassificationID.GetName(), testClassificationID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -90,7 +97,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -105,7 +112,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -131,7 +138,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()), false}, } for _, tt := range tests { @@ -166,7 +172,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, testBaseRequest}, } for _, tt := range tests { @@ -197,7 +202,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, newMessage(fromAccAddress, testFromID, testFromID, testClassificationID), false}, } for _, tt := range tests { @@ -235,7 +239,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, args{codec.New()}}, } for _, tt := range tests { @@ -263,7 +266,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), testFromID.String(), testClassificationID.String()}, false}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/revoke/response_test.go b/modules/orders/internal/transactions/revoke/response_test.go index e031d09db..87e8625d7 100644 --- a/modules/orders/internal/transactions/revoke/response_test.go +++ b/modules/orders/internal/transactions/revoke/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/orders/internal/transactions/take/keeper_test.go b/modules/orders/internal/transactions/take/keeper_test.go index 870e7387c..e74db48af 100644 --- a/modules/orders/internal/transactions/take/keeper_test.go +++ b/modules/orders/internal/transactions/take/keeper_test.go @@ -126,7 +126,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{}, transactionKeeper{}}, {"+ve", fields{Mapper, Parameters, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}}, } @@ -196,7 +195,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve Not Authorized", fields{Mapper, Parameters, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID2, testRate, testOrderID)}, newTransactionResponse(errorConstants.NotAuthorized)}, {"+ve", fields{Mapper, Parameters, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testRate, testOrderID)}, newTransactionResponse(nil)}, {"+ve Entity Not Found", fields{Mapper, Parameters, supplementAuxiliary, transferAuxiliary, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, testFromID, testRate, testOrderID2)}, newTransactionResponse(errorConstants.EntityNotFound)}, diff --git a/modules/orders/internal/transactions/take/message_test.go b/modules/orders/internal/transactions/take/message_test.go index 2e306e250..ce4960b25 100644 --- a/modules/orders/internal/transactions/take/message_test.go +++ b/modules/orders/internal/transactions/take/message_test.go @@ -27,7 +27,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{testMessage}, message{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}}, } for _, tt := range tests { @@ -44,7 +43,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -68,7 +66,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(testMessage))}, } for _, tt := range tests { @@ -98,7 +95,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []types.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, []types.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -131,7 +127,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, args{codec.New()}}, } for _, tt := range tests { @@ -159,7 +154,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, module.Name}, } for _, tt := range tests { @@ -189,7 +183,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, Transaction.GetName()}, } for _, tt := range tests { @@ -219,7 +212,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"-ve with nil", fields{}, true}, {"+ve", fields{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, false}, } @@ -250,7 +242,6 @@ func Test_newMessage(t *testing.T) { args args want types.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}, message{fromAccAddress, testFromID, takerOwnableSplit, testOrderID}}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/take/request_test.go b/modules/orders/internal/transactions/take/request_test.go index cdc31c329..47216e11c 100644 --- a/modules/orders/internal/transactions/take/request_test.go +++ b/modules/orders/internal/transactions/take/request_test.go @@ -5,8 +5,11 @@ package take import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + baseHelpers "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -45,7 +49,6 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", args{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, transactionRequest{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}}, } for _, tt := range tests { @@ -62,7 +65,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.TransactionRequest }{ - // TODO: Add test cases. {"+ve", transactionRequest{}}, } for _, tt := range tests { @@ -75,6 +77,11 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromID, constants.TakerOwnableSplit, constants.OrderID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), testFromID.String()) + viper.Set(constants.TakerOwnableSplit.GetName(), takerOwnableSplit.String()) + viper.Set(constants.OrderID.GetName(), testOrderID.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -92,7 +99,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -107,7 +114,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) @@ -133,7 +140,6 @@ func Test_transactionRequest_FromJSON(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()), false}, } for _, tt := range tests { @@ -168,7 +174,6 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { fields fields want rest.BaseReq }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, testBaseRequest}, } for _, tt := range tests { @@ -199,7 +204,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, newMessage(fromAccAddress, testFromID, takerOwnableSplit, testOrderID), false}, } for _, tt := range tests { @@ -237,7 +241,6 @@ func Test_transactionRequest_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, args{codec.New()}}, } for _, tt := range tests { @@ -265,7 +268,6 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testBaseRequest, testFromID.String(), takerOwnableSplit.String(), testOrderID.String()}, false}, } for _, tt := range tests { diff --git a/modules/orders/internal/transactions/take/response_test.go b/modules/orders/internal/transactions/take/response_test.go index a96f29f31..37234a6e4 100644 --- a/modules/orders/internal/transactions/take/response_test.go +++ b/modules/orders/internal/transactions/take/response_test.go @@ -20,7 +20,6 @@ func Test_newTransactionResponse(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", args{nil}, transactionResponse{true, nil}}, {"-ve", args{constants.IncorrectFormat}, transactionResponse{false, constants.IncorrectFormat}}} for _, tt := range tests { @@ -42,7 +41,6 @@ func Test_transactionResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, false}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, true}, } @@ -69,7 +67,6 @@ func Test_transactionResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{Success: true, Error: nil}, true}, {"-ve", fields{Success: false, Error: constants.IncorrectFormat}, false}, } diff --git a/modules/splits/auxiliaries/burn/keeper_test.go b/modules/splits/auxiliaries/burn/keeper_test.go index 02071ff81..b3e4f103e 100644 --- a/modules/splits/auxiliaries/burn/keeper_test.go +++ b/modules/splits/auxiliaries/burn/keeper_test.go @@ -97,7 +97,6 @@ func Test_auxiliaryKeeper_Help(t *testing.T) { args args want helpers.AuxiliaryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, NewAuxiliaryRequest(testOwnerIdentityID, testOwnableID, testRate)}, newAuxiliaryResponse(nil)}, {"+ve Entity Not Found", fields{Mapper}, args{context, NewAuxiliaryRequest(baseIds.PrototypeIdentityID(), testOwnableID, testRate)}, newAuxiliaryResponse(errorConstants.EntityNotFound)}, } @@ -129,7 +128,6 @@ func Test_auxiliaryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, auxiliaryKeeper{Mapper}}, } for _, tt := range tests { @@ -149,7 +147,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.AuxiliaryKeeper }{ - // TODO: Add test cases. {"+ve", auxiliaryKeeper{}}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/burn/request_test.go b/modules/splits/auxiliaries/burn/request_test.go index aceb27b97..24ee095f9 100644 --- a/modules/splits/auxiliaries/burn/request_test.go +++ b/modules/splits/auxiliaries/burn/request_test.go @@ -38,7 +38,6 @@ func TestNewAuxiliaryRequest(t *testing.T) { args args want helpers.AuxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{testOwnerID, testOwnableID, testValue}, NewAuxiliaryRequest(testOwnerID, testOwnableID, testValue)}, {"+ve with nil", args{baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue}, NewAuxiliaryRequest(baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue)}, } @@ -61,7 +60,6 @@ func Test_auxiliaryRequestFromInterface(t *testing.T) { args args want auxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{NewAuxiliaryRequest(testOwnerID, testOwnableID, testValue)}, auxiliaryRequest{testOwnerID, testOwnableID, testValue}}, } for _, tt := range tests { @@ -85,7 +83,6 @@ func Test_auxiliaryRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnerID, testOwnableID, testValue}, false}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/burn/response_test.go b/modules/splits/auxiliaries/burn/response_test.go index 80383e1ce..52cd0d47b 100644 --- a/modules/splits/auxiliaries/burn/response_test.go +++ b/modules/splits/auxiliaries/burn/response_test.go @@ -4,6 +4,7 @@ package burn import ( + errorConstants "github.com/AssetMantle/modules/schema/errors/constants" "github.com/AssetMantle/modules/schema/helpers" "reflect" "testing" @@ -19,7 +20,8 @@ func Test_auxiliaryResponse_GetError(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{true, nil}, false}, + {"+ve", fields{false, errorConstants.EntityNotFound}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -44,7 +46,8 @@ func Test_auxiliaryResponse_IsSuccessful(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. + {"+ve", fields{true, nil}, true}, + {"+ve", fields{false, errorConstants.EntityNotFound}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -68,7 +71,8 @@ func Test_newAuxiliaryResponse(t *testing.T) { args args want helpers.AuxiliaryResponse }{ - // TODO: Add test cases. + {"+ve", args{nil}, auxiliaryResponse{true, nil}}, + {"-ve", args{errorConstants.EntityNotFound}, auxiliaryResponse{false, errorConstants.EntityNotFound}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/modules/splits/auxiliaries/mint/keeper_test.go b/modules/splits/auxiliaries/mint/keeper_test.go index 121598955..3e4e924e6 100644 --- a/modules/splits/auxiliaries/mint/keeper_test.go +++ b/modules/splits/auxiliaries/mint/keeper_test.go @@ -96,7 +96,6 @@ func Test_auxiliaryKeeper_Help(t *testing.T) { args args want helpers.AuxiliaryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, NewAuxiliaryRequest(testOwnerIdentityID, testOwnableID, testRate)}, newAuxiliaryResponse(nil)}, } for _, tt := range tests { @@ -127,7 +126,6 @@ func Test_auxiliaryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, auxiliaryKeeper{Mapper}}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/mint/request_test.go b/modules/splits/auxiliaries/mint/request_test.go index 227d19f84..6f91214d1 100644 --- a/modules/splits/auxiliaries/mint/request_test.go +++ b/modules/splits/auxiliaries/mint/request_test.go @@ -38,7 +38,6 @@ func TestNewAuxiliaryRequest(t *testing.T) { args args want helpers.AuxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{testOwnerID, testOwnableID, testValue}, NewAuxiliaryRequest(testOwnerID, testOwnableID, testValue)}, {"+ve with nil", args{baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue}, NewAuxiliaryRequest(baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue)}, } @@ -61,7 +60,6 @@ func Test_auxiliaryRequestFromInterface(t *testing.T) { args args want auxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{NewAuxiliaryRequest(testOwnerID, testOwnableID, testValue)}, auxiliaryRequest{testOwnerID, testOwnableID, testValue}}, } for _, tt := range tests { @@ -85,7 +83,6 @@ func Test_auxiliaryRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnerID, testOwnableID, testValue}, false}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/renumerate/keeper_test.go b/modules/splits/auxiliaries/renumerate/keeper_test.go index 5b5364d64..89041affa 100644 --- a/modules/splits/auxiliaries/renumerate/keeper_test.go +++ b/modules/splits/auxiliaries/renumerate/keeper_test.go @@ -96,7 +96,6 @@ func Test_auxiliaryKeeper_Help(t *testing.T) { args args want helpers.AuxiliaryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, NewAuxiliaryRequest(testOwnerIdentityID, testOwnableID, testRate)}, newAuxiliaryResponse(nil)}, } for _, tt := range tests { @@ -127,7 +126,6 @@ func Test_auxiliaryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, auxiliaryKeeper{Mapper}}, } for _, tt := range tests { @@ -147,7 +145,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.AuxiliaryKeeper }{ - // TODO: Add test cases. {"+ve", auxiliaryKeeper{}}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/renumerate/request_test.go b/modules/splits/auxiliaries/renumerate/request_test.go index 44c37ff96..64146fb10 100644 --- a/modules/splits/auxiliaries/renumerate/request_test.go +++ b/modules/splits/auxiliaries/renumerate/request_test.go @@ -38,7 +38,6 @@ func TestNewAuxiliaryRequest(t *testing.T) { args args want helpers.AuxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{testOwnerID, testOwnableID, testValue}, NewAuxiliaryRequest(testOwnerID, testOwnableID, testValue)}, {"+ve with nil", args{baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue}, NewAuxiliaryRequest(baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue)}, } @@ -61,7 +60,6 @@ func Test_auxiliaryRequestFromInterface(t *testing.T) { args args want auxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{NewAuxiliaryRequest(testOwnerID, testOwnableID, testValue)}, auxiliaryRequest{testOwnerID, testOwnableID, testValue}}, } for _, tt := range tests { @@ -85,7 +83,6 @@ func Test_auxiliaryRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnerID, testOwnableID, testValue}, false}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/transfer/keeper_test.go b/modules/splits/auxiliaries/transfer/keeper_test.go index 8ed5f7437..f08c8cd13 100644 --- a/modules/splits/auxiliaries/transfer/keeper_test.go +++ b/modules/splits/auxiliaries/transfer/keeper_test.go @@ -98,7 +98,6 @@ func Test_auxiliaryKeeper_Help(t *testing.T) { args args want helpers.AuxiliaryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, NewAuxiliaryRequest(testOwnerIdentityID, testOwnerIdentityID, testOwnableID, testRate)}, newAuxiliaryResponse(nil)}, {"+ve Not Authorized", fields{Mapper}, args{context, NewAuxiliaryRequest(testOwnerIdentityID, testOwnerIdentityID, testOwnableID, sdkTypes.ZeroDec())}, newAuxiliaryResponse(errorConstants.NotAuthorized)}, {"+ve Entity Not Found", fields{Mapper}, args{context, NewAuxiliaryRequest(testOwnerIdentityID, testOwnerIdentityID, baseIds.NewOwnableID(baseIds.NewStringID("test")), testRate)}, newAuxiliaryResponse(errorConstants.EntityNotFound)}, @@ -131,7 +130,6 @@ func Test_auxiliaryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, auxiliaryKeeper{Mapper}}, } for _, tt := range tests { @@ -151,7 +149,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.AuxiliaryKeeper }{ - // TODO: Add test cases. {"+ve", auxiliaryKeeper{}}, } for _, tt := range tests { diff --git a/modules/splits/auxiliaries/transfer/request_test.go b/modules/splits/auxiliaries/transfer/request_test.go index 95fc5e810..b4bde6813 100644 --- a/modules/splits/auxiliaries/transfer/request_test.go +++ b/modules/splits/auxiliaries/transfer/request_test.go @@ -39,7 +39,6 @@ func TestNewAuxiliaryRequest(t *testing.T) { args args want helpers.AuxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{testOwnerID, testOwnerID, testOwnableID, testValue}, NewAuxiliaryRequest(testOwnerID, testOwnerID, testOwnableID, testValue)}, {"+ve with nil", args{testOwnerID, baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue}, NewAuxiliaryRequest(testOwnerID, baseIds.PrototypeIdentityID(), baseIds.PrototypeOwnableID(), testValue)}, } @@ -62,7 +61,6 @@ func Test_auxiliaryRequestFromInterface(t *testing.T) { args args want auxiliaryRequest }{ - // TODO: Add test cases. {"+ve", args{NewAuxiliaryRequest(testOwnerID, testOwnerID, testOwnableID, testValue)}, auxiliaryRequest{testOwnerID, testOwnerID, testOwnableID, testValue}}, } for _, tt := range tests { @@ -87,7 +85,6 @@ func Test_auxiliaryRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnerID, testOwnerID, testOwnableID, testValue}, false}, } for _, tt := range tests { diff --git a/modules/splits/internal/key/key_test.go b/modules/splits/internal/key/key_test.go index e53cfb0eb..e3869aec0 100644 --- a/modules/splits/internal/key/key_test.go +++ b/modules/splits/internal/key/key_test.go @@ -35,7 +35,6 @@ func TestNewKey(t *testing.T) { args args want helpers.Key }{ - // TODO: Add test cases. {"+ve", args{splitID}, key{splitID}}, {"+ve with nil", args{baseIds.PrototypeSplitID()}, key{baseIds.PrototypeSplitID()}}, } @@ -53,7 +52,6 @@ func TestPrototype(t *testing.T) { name string want helpers.Key }{ - // TODO: Add test cases. {"+ve", key{}}, } for _, tt := range tests { @@ -75,7 +73,6 @@ func Test_keyFromInterface(t *testing.T) { want key wantErr bool }{ - // TODO: Add test cases. {"+ve", args{NewKey(splitID)}, key{splitID}, false}, {"+ve", args{NewKey(baseIds.PrototypeSplitID())}, key{baseIds.PrototypeSplitID()}, false}, } @@ -106,7 +103,6 @@ func Test_key_Equals(t *testing.T) { args args want bool }{ - // TODO: Add test cases. {"+ve", fields{splitID}, args{NewKey(splitID)}, true}, {"+ve", fields{splitID}, args{NewKey(baseIds.PrototypeSplitID())}, false}, } @@ -131,7 +127,6 @@ func Test_key_GenerateStoreKeyBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{splitID}, module.StoreKeyPrefix.GenerateStoreKey(key{splitID}.Bytes())}, {"+ve", fields{baseIds.PrototypeSplitID()}, module.StoreKeyPrefix.GenerateStoreKey(key{baseIds.PrototypeSplitID()}.Bytes())}, } @@ -156,7 +151,6 @@ func Test_key_IsPartial(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{splitID}, false}, {"+ve", fields{baseIds.PrototypeSplitID()}, true}, } @@ -184,7 +178,6 @@ func Test_key_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{splitID}, args{codec.New()}}, } for _, tt := range tests { diff --git a/modules/splits/internal/mappable/mappable_test.go b/modules/splits/internal/mappable/mappable_test.go index 599dc240e..b84a8fa7f 100644 --- a/modules/splits/internal/mappable/mappable_test.go +++ b/modules/splits/internal/mappable/mappable_test.go @@ -39,7 +39,6 @@ func TestNewMappable(t *testing.T) { args args want helpers.Mappable }{ - // TODO: Add test cases. {"+ve", args{split}, mappable{split}}, } for _, tt := range tests { @@ -56,7 +55,6 @@ func TestPrototype(t *testing.T) { name string want helpers.Mappable }{ - // TODO: Add test cases. {"+ve", mappable{}}, } for _, tt := range tests { @@ -77,7 +75,6 @@ func Test_mappable_GetKey(t *testing.T) { fields fields want helpers.Key }{ - // TODO: Add test cases. {"+ve", fields{split}, key.NewKey(splitID)}, } for _, tt := range tests { @@ -104,7 +101,6 @@ func Test_mappable_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{split}, args{codec.New()}}, } for _, tt := range tests { diff --git a/modules/splits/internal/queries/ownable/keeper_test.go b/modules/splits/internal/queries/ownable/keeper_test.go index 6c68ebcc1..d7365a184 100644 --- a/modules/splits/internal/queries/ownable/keeper_test.go +++ b/modules/splits/internal/queries/ownable/keeper_test.go @@ -78,7 +78,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.QueryKeeper }{ - // TODO: Add test cases. {"+ve", queryKeeper{}}, } for _, tt := range tests { @@ -113,7 +112,6 @@ func Test_queryKeeper_Enquire(t *testing.T) { args args want helpers.QueryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, newQueryRequest(testOwnableID)}, newQueryResponse(testRate, nil)}, } for _, tt := range tests { @@ -144,7 +142,6 @@ func Test_queryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, queryKeeper{Mapper}}, } for _, tt := range tests { diff --git a/modules/splits/internal/queries/ownable/request_test.go b/modules/splits/internal/queries/ownable/request_test.go index 3327cc697..69f1b21cf 100644 --- a/modules/splits/internal/queries/ownable/request_test.go +++ b/modules/splits/internal/queries/ownable/request_test.go @@ -6,9 +6,12 @@ package ownable import ( "github.com/AssetMantle/modules/modules/splits/internal/common" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/schema/ids" baseIds "github.com/AssetMantle/modules/schema/ids/base" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -27,7 +30,6 @@ func Test_newQueryRequest(t *testing.T) { args args want helpers.QueryRequest }{ - // TODO: Add test cases. {"+ve", args{testOwnableID}, newQueryRequest(testOwnableID)}, } for _, tt := range tests { @@ -48,7 +50,6 @@ func Test_queryRequestFromInterface(t *testing.T) { args args want queryRequest }{ - // TODO: Add test cases. {"+ve", args{newQueryRequest(testOwnableID)}, newQueryRequest(testOwnableID).(queryRequest)}, } for _, tt := range tests { @@ -78,7 +79,6 @@ func Test_queryRequest_Decode(t *testing.T) { want helpers.QueryRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnableID}, args{encodedReq}, newQueryRequest(testOwnableID), false}, {"+ve", fields{baseIds.PrototypeOwnableID()}, args{encodedReq1}, newQueryRequest(baseIds.PrototypeOwnableID()), false}, } @@ -113,7 +113,6 @@ func Test_queryRequest_Encode(t *testing.T) { want []byte wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnableID}, encodedReq, false}, {"+ve", fields{baseIds.PrototypeOwnableID()}, encodedReq1, false}, } @@ -135,6 +134,8 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.OwnableID}) + viper.Set(constants.OwnableID.GetName(), testOwnableID.String()) type fields struct { OwnableID ids.OwnableID } @@ -149,7 +150,7 @@ func Test_queryRequest_FromCLI(t *testing.T) { want helpers.QueryRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{testOwnableID}, args{cliCommand, context.NewCLIContext()}, newQueryRequest(testOwnableID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -184,7 +185,6 @@ func Test_queryRequest_FromMap(t *testing.T) { want helpers.QueryRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnableID}, args{vars}, newQueryRequest(testOwnableID), false}, } for _, tt := range tests { @@ -213,7 +213,6 @@ func Test_queryRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{testOwnableID}, false}, } for _, tt := range tests { @@ -233,7 +232,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.QueryRequest }{ - // TODO: Add test cases. {"+ve", queryRequest{}}, } for _, tt := range tests { diff --git a/modules/splits/internal/queries/split/keeper_test.go b/modules/splits/internal/queries/split/keeper_test.go index 06ebc06fd..919f49816 100644 --- a/modules/splits/internal/queries/split/keeper_test.go +++ b/modules/splits/internal/queries/split/keeper_test.go @@ -78,7 +78,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.QueryKeeper }{ - // TODO: Add test cases. {"+ve", queryKeeper{}}, } for _, tt := range tests { @@ -113,7 +112,6 @@ func Test_queryKeeper_Enquire(t *testing.T) { args args want helpers.QueryResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{context, newQueryRequest(splitID)}, newQueryResponse(keepers.SplitKeeper.(queryKeeper).mapper.NewCollection(context).Add(mappable.NewMappable(split)), nil)}, } for _, tt := range tests { @@ -144,7 +142,6 @@ func Test_queryKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper}, args{Mapper, Parameters, []interface{}{}}, queryKeeper{Mapper}}, } for _, tt := range tests { diff --git a/modules/splits/internal/queries/split/request_test.go b/modules/splits/internal/queries/split/request_test.go index a7bff7585..72666a057 100644 --- a/modules/splits/internal/queries/split/request_test.go +++ b/modules/splits/internal/queries/split/request_test.go @@ -7,12 +7,15 @@ import ( "github.com/AssetMantle/modules/modules/splits/internal/common" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" "github.com/AssetMantle/modules/schema/ids" baseIds "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" baseQualified "github.com/AssetMantle/modules/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -36,7 +39,6 @@ func Test_newQueryRequest(t *testing.T) { args args want helpers.QueryRequest }{ - // TODO: Add test cases. {"+ve", args{splitID}, newQueryRequest(splitID)}, } for _, tt := range tests { @@ -57,7 +59,6 @@ func Test_queryRequestFromInterface(t *testing.T) { args args want queryRequest }{ - // TODO: Add test cases. {"+ve", args{newQueryRequest(splitID)}, newQueryRequest(splitID).(queryRequest)}, } for _, tt := range tests { @@ -87,7 +88,6 @@ func Test_queryRequest_Decode(t *testing.T) { want helpers.QueryRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{splitID}, args{encodedReq}, newQueryRequest(splitID), false}, {"+ve", fields{baseIds.PrototypeSplitID()}, args{encodedReq1}, newQueryRequest(baseIds.PrototypeSplitID()), false}, } @@ -122,7 +122,6 @@ func Test_queryRequest_Encode(t *testing.T) { want []byte wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{splitID}, encodedReq, false}, {"+ve", fields{baseIds.PrototypeSplitID()}, encodedReq1, false}, } @@ -144,6 +143,8 @@ func Test_queryRequest_Encode(t *testing.T) { } func Test_queryRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.SplitID}) + viper.Set(constants.SplitID.GetName(), splitID.String()) type fields struct { SplitID ids.SplitID } @@ -158,7 +159,7 @@ func Test_queryRequest_FromCLI(t *testing.T) { want helpers.QueryRequest wantErr bool }{ - // TODO: Add test cases. + {"+ve", fields{splitID}, args{cliCommand, context.NewCLIContext()}, newQueryRequest(splitID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -193,7 +194,6 @@ func Test_queryRequest_FromMap(t *testing.T) { want helpers.QueryRequest wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{splitID}, args{vars}, newQueryRequest(splitID), false}, } for _, tt := range tests { @@ -222,7 +222,6 @@ func Test_queryRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{splitID}, false}, } for _, tt := range tests { @@ -242,7 +241,6 @@ func Test_requestPrototype(t *testing.T) { name string want helpers.QueryRequest }{ - // TODO: Add test cases. {"+ve", queryRequest{}}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/prototype_test.go b/modules/splits/internal/transactions/prototype_test.go index f2e4f176d..ee2280205 100644 --- a/modules/splits/internal/transactions/prototype_test.go +++ b/modules/splits/internal/transactions/prototype_test.go @@ -19,7 +19,6 @@ func TestPrototype(t *testing.T) { name string want helpers.Transactions }{ - // TODO: Add test cases. {"+ve", baseHelpers.NewTransactions( send.Transaction, unwrap.Transaction, diff --git a/modules/splits/internal/transactions/send/keeper_test.go b/modules/splits/internal/transactions/send/keeper_test.go index 24313440d..d084a9597 100644 --- a/modules/splits/internal/transactions/send/keeper_test.go +++ b/modules/splits/internal/transactions/send/keeper_test.go @@ -85,7 +85,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -115,7 +114,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, authenticateAuxiliary}}, } for _, tt := range tests { @@ -161,7 +159,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, authenticateAuxiliary}, args{context, newMessage(fromAccAddress, fromID, fromID, testOwnableID, testRate)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/send/message_test.go b/modules/splits/internal/transactions/send/message_test.go index 3242f842b..48f32eb51 100644 --- a/modules/splits/internal/transactions/send/message_test.go +++ b/modules/splits/internal/transactions/send/message_test.go @@ -23,7 +23,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{newMessage(fromAccAddress, fromID, fromID, ownableID, testRate)}, message{fromAccAddress, fromID, fromID, ownableID, testRate}}, } for _, tt := range tests { @@ -40,7 +39,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -65,7 +63,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, fromID, ownableID, testRate}, types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{fromAccAddress, fromID, fromID, ownableID, testRate}))}, } for _, tt := range tests { @@ -97,7 +94,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []types.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, fromID, ownableID, testRate}, []types.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -132,7 +128,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, fromID, ownableID, testRate}, args{codec.New()}}, } for _, tt := range tests { @@ -162,7 +157,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, fromID, ownableID, testRate}, module.Name}, } for _, tt := range tests { @@ -194,7 +188,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, fromID, ownableID, testRate}, Transaction.GetName()}, } for _, tt := range tests { @@ -226,7 +219,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, fromID, ownableID, testRate}, false}, } for _, tt := range tests { @@ -258,7 +250,6 @@ func Test_newMessage(t *testing.T) { args args want types.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, fromID, fromID, ownableID, testRate}, message{fromAccAddress, fromID, fromID, ownableID, testRate}}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/send/request_test.go b/modules/splits/internal/transactions/send/request_test.go index f670d1f66..b68f7614a 100644 --- a/modules/splits/internal/transactions/send/request_test.go +++ b/modules/splits/internal/transactions/send/request_test.go @@ -5,8 +5,11 @@ package send import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -73,6 +77,12 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ToID, constants.FromID, constants.OwnableID, constants.Value}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.ToID.GetName(), fromID.String()) + viper.Set(constants.OwnableID.GetName(), ownableID.String()) + viper.Set(constants.Value.GetName(), testRate.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -90,7 +100,9 @@ func Test_transactionRequest_FromCLI(t *testing.T) { args args want helpers.TransactionRequest wantErr bool - }{} + }{ + {"+ve", fields{testBaseRequest, fromID.String(), fromID.String(), ownableID.String(), testRate.String()}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), fromID.String(), ownableID.String(), testRate.String()}, false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ @@ -105,7 +117,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/splits/internal/transactions/unwrap/keeper_test.go b/modules/splits/internal/transactions/unwrap/keeper_test.go index 10eaf819b..90a94c773 100644 --- a/modules/splits/internal/transactions/unwrap/keeper_test.go +++ b/modules/splits/internal/transactions/unwrap/keeper_test.go @@ -158,7 +158,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -189,7 +188,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, supplyKeeper, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, supplyKeeper, authenticateAuxiliary}}, } for _, tt := range tests { @@ -230,7 +228,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, supplyKeeper, authenticateAuxiliary}, args{context, newMessage(delAddr1, fromID, testOwnableID, testRate)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/unwrap/message_test.go b/modules/splits/internal/transactions/unwrap/message_test.go index 890cae215..ca56deec0 100644 --- a/modules/splits/internal/transactions/unwrap/message_test.go +++ b/modules/splits/internal/transactions/unwrap/message_test.go @@ -23,7 +23,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{newMessage(fromAccAddress, fromID, ownableID, testRate)}, message{fromAccAddress, fromID, ownableID, testRate}}, } for _, tt := range tests { @@ -40,7 +39,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -64,7 +62,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, ownableID, testRate}, types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{fromAccAddress, fromID, ownableID, testRate}))}, } for _, tt := range tests { @@ -94,7 +91,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []types.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, ownableID, testRate}, []types.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -127,7 +123,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, ownableID, testRate}, args{codec.New()}}, } for _, tt := range tests { @@ -155,7 +150,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, ownableID, testRate}, module.Name}, } for _, tt := range tests { @@ -185,7 +179,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, ownableID, testRate}, Transaction.GetName()}, } for _, tt := range tests { @@ -215,7 +208,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, ownableID, testRate}, false}, } for _, tt := range tests { @@ -245,7 +237,6 @@ func Test_newMessage(t *testing.T) { args args want types.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, fromID, ownableID, testRate}, message{fromAccAddress, fromID, ownableID, testRate}}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/unwrap/request_test.go b/modules/splits/internal/transactions/unwrap/request_test.go index 8a22f855f..d49743967 100644 --- a/modules/splits/internal/transactions/unwrap/request_test.go +++ b/modules/splits/internal/transactions/unwrap/request_test.go @@ -5,8 +5,11 @@ package unwrap import ( "encoding/json" + "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -15,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "math/big" "reflect" @@ -73,6 +77,11 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.OwnableID, constants.FromID, constants.Value}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.OwnableID.GetName(), ownableID.String()) + viper.Set(constants.Value.GetName(), testRate.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -89,7 +98,9 @@ func Test_transactionRequest_FromCLI(t *testing.T) { args args want helpers.TransactionRequest wantErr bool - }{} + }{ + {"+ve", fields{testBaseRequest, fromID.String(), ownableID.String(), testRate.String()}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), ownableID.String(), testRate.String()}, false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ @@ -103,7 +114,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/modules/splits/internal/transactions/wrap/keeper_test.go b/modules/splits/internal/transactions/wrap/keeper_test.go index 64babad7c..833f27b70 100644 --- a/modules/splits/internal/transactions/wrap/keeper_test.go +++ b/modules/splits/internal/transactions/wrap/keeper_test.go @@ -152,7 +152,6 @@ func Test_keeperPrototype(t *testing.T) { name string want helpers.TransactionKeeper }{ - // TODO: Add test cases. {"+ve", transactionKeeper{}}, } for _, tt := range tests { @@ -213,7 +212,6 @@ func Test_transactionKeeper_Initialize(t *testing.T) { args args want helpers.Keeper }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, supplyKeeper, authenticateAuxiliary}, args{Mapper, Parameters, []interface{}{}}, transactionKeeper{Mapper, Parameters, supplyKeeper, authenticateAuxiliary}}, } for _, tt := range tests { @@ -253,7 +251,6 @@ func Test_transactionKeeper_Transact(t *testing.T) { args args want helpers.TransactionResponse }{ - // TODO: Add test cases. {"+ve", fields{Mapper, Parameters, supplyKeeper, authenticateAuxiliary}, args{context, newMessage(delAddr1, fromID, testRate1)}, newTransactionResponse(nil)}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/wrap/message_test.go b/modules/splits/internal/transactions/wrap/message_test.go index f0f63a717..f62582a5a 100644 --- a/modules/splits/internal/transactions/wrap/message_test.go +++ b/modules/splits/internal/transactions/wrap/message_test.go @@ -23,7 +23,6 @@ func Test_messageFromInterface(t *testing.T) { args args want message }{ - // TODO: Add test cases. {"+ve", args{newMessage(fromAccAddress, fromID, testRate)}, message{fromAccAddress, fromID, testRate}}, } for _, tt := range tests { @@ -40,7 +39,6 @@ func Test_messagePrototype(t *testing.T) { name string want helpers.Message }{ - // TODO: Add test cases. {"+ve", message{}}, } for _, tt := range tests { @@ -63,7 +61,6 @@ func Test_message_GetSignBytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, testRate}, types.MustSortJSON(transaction.RegisterCodec(messagePrototype).MustMarshalJSON(message{fromAccAddress, fromID, testRate}))}, } for _, tt := range tests { @@ -91,7 +88,6 @@ func Test_message_GetSigners(t *testing.T) { fields fields want []types.AccAddress }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, testRate}, []types.AccAddress{fromAccAddress}}, } for _, tt := range tests { @@ -122,7 +118,6 @@ func Test_message_RegisterCodec(t *testing.T) { fields fields args args }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, testRate}, args{codec.New()}}, } for _, tt := range tests { @@ -148,7 +143,6 @@ func Test_message_Route(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, testRate}, module.Name}, } for _, tt := range tests { @@ -176,7 +170,6 @@ func Test_message_Type(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, testRate}, Transaction.GetName()}, } for _, tt := range tests { @@ -204,7 +197,6 @@ func Test_message_ValidateBasic(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve", fields{fromAccAddress, fromID, testRate}, false}, } for _, tt := range tests { @@ -232,7 +224,6 @@ func Test_newMessage(t *testing.T) { args args want types.Msg }{ - // TODO: Add test cases. {"+ve", args{fromAccAddress, fromID, testRate}, message{fromAccAddress, fromID, testRate}}, } for _, tt := range tests { diff --git a/modules/splits/internal/transactions/wrap/request_test.go b/modules/splits/internal/transactions/wrap/request_test.go index 439a59e75..53642d2f5 100644 --- a/modules/splits/internal/transactions/wrap/request_test.go +++ b/modules/splits/internal/transactions/wrap/request_test.go @@ -8,6 +8,8 @@ import ( "fmt" baseData "github.com/AssetMantle/modules/schema/data/base" "github.com/AssetMantle/modules/schema/helpers" + "github.com/AssetMantle/modules/schema/helpers/base" + "github.com/AssetMantle/modules/schema/helpers/constants" baseIDs "github.com/AssetMantle/modules/schema/ids/base" baseLists "github.com/AssetMantle/modules/schema/lists/base" baseProperties "github.com/AssetMantle/modules/schema/properties/base" @@ -16,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "reflect" "testing" @@ -72,6 +75,10 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { + cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.Coins, constants.FromID}) + cliContext := context.NewCLIContext().WithCodec(codec.New()).WithFromAddress(fromAccAddress).WithChainID("test") + viper.Set(constants.FromID.GetName(), fromID.String()) + viper.Set(constants.Coins.GetName(), testRate.String()) type fields struct { BaseReq rest.BaseReq FromID string @@ -87,7 +94,9 @@ func Test_transactionRequest_FromCLI(t *testing.T) { args args want helpers.TransactionRequest wantErr bool - }{} + }{ + {"+ve", fields{testBaseRequest, fromID.String(), testRate.String()}, args{cliCommand, cliContext}, transactionRequest{testBaseRequest, fromID.String(), testRate.String()}, false}, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ @@ -100,7 +109,7 @@ func Test_transactionRequest_FromCLI(t *testing.T) { t.Errorf("FromCLI() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + if !reflect.DeepEqual(fmt.Sprint(got), fmt.Sprint(tt.want)) { t.Errorf("FromCLI() got = %v, want %v", got, tt.want) } }) diff --git a/schema/data/base/accAddressData.go b/schema/data/base/accAddressData.go index 6f6d48c14..dea02575c 100644 --- a/schema/data/base/accAddressData.go +++ b/schema/data/base/accAddressData.go @@ -47,7 +47,6 @@ func (accAddressData accAddressData) ZeroValue() data.Data { } func (accAddressData accAddressData) GenerateHashID() ids.HashID { if accAddressData.Compare(accAddressData.ZeroValue()) == 0 { - // TODO test return baseIDs.GenerateHashID() } diff --git a/schema/data/base/accAddressData_test.go b/schema/data/base/accAddressData_test.go index 8615c8db8..7b8b25eaa 100644 --- a/schema/data/base/accAddressData_test.go +++ b/schema/data/base/accAddressData_test.go @@ -33,7 +33,6 @@ func TestNewAccAddressData(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve", args{_fromAddress}, accAddressData{_fromAddress}}, {"-ve with empty string", args{_fromAddress1}, accAddressData{_fromAddress1}}, {"-ve", args{nil}, accAddressData{}}, @@ -56,7 +55,6 @@ func Test_accAddressDataFromInterface(t *testing.T) { want accAddressData wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"-ve nil", args{nil}, accAddressData{}, assert.Error}, {"-ve empty String", args{accAddressData{}}, accAddressData{}, assert.NoError}, {"-ve wrong Address", args{stringData{}}, accAddressData{}, assert.Error}, @@ -87,7 +85,6 @@ func Test_accAddressData_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"-ve empty String", fields{fromAccAddress}, args{accAddressData{}}, 1}, {"+ve", fields{fromAccAddress}, args{accAddressData{fromAccAddress}}, 0}, } @@ -111,7 +108,6 @@ func Test_accAddressData_GenerateHashID(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"-ve empty String", fields{}, baseIDs.GenerateHashID()}, {"+ve", fields{fromAccAddress}, baseIDs.GenerateHashID(accAddressData{fromAccAddress}.Bytes())}, } @@ -135,7 +131,6 @@ func Test_accAddressData_Get(t *testing.T) { fields fields want types.AccAddress }{ - // TODO: Add test cases. {"-ve empty String", fields{}, accAddressData{}.Value}, {"+ve", fields{fromAccAddress}, accAddressData{fromAccAddress}.Value}, } @@ -159,7 +154,6 @@ func Test_accAddressData_GetID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve with nil", fields{}, baseIDs.NewDataID(accAddressData{})}, {"+ve", fields{fromAccAddress}, baseIDs.NewDataID(accAddressData{fromAccAddress})}, } @@ -183,7 +177,6 @@ func Test_accAddressData_GetType(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve with nil", fields{}, idsConstants.AccAddressDataID}, {"+ve", fields{fromAccAddress}, idsConstants.AccAddressDataID}, } @@ -207,7 +200,6 @@ func Test_accAddressData_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve with nil", fields{}, accAddressData{}.Value.String()}, {"+ve", fields{fromAccAddress}, accAddressData{fromAccAddress}.Value.String()}, } @@ -232,7 +224,6 @@ func Test_accAddressData_ZeroValue(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve with nil", fields{}, NewAccAddressData(sdkTypes.AccAddress{})}, {"+ve", fields{fromAccAddress}, NewAccAddressData(sdkTypes.AccAddress{})}, } @@ -257,7 +248,6 @@ func Test_accAddressData_Bytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve with nil", fields{}, accAddressData{}.Value.Bytes()}, {"+ve", fields{_fromAddress}, accAddressData{_fromAddress}.Value.Bytes()}, } diff --git a/schema/data/base/booleanData.go b/schema/data/base/booleanData.go index 635399843..52578add6 100644 --- a/schema/data/base/booleanData.go +++ b/schema/data/base/booleanData.go @@ -41,7 +41,6 @@ func (booleanData booleanData) String() string { return strconv.FormatBool(booleanData.Value) } -// TODO test func (booleanData booleanData) Bytes() []byte { if booleanData.Get() { return []byte{0x1} diff --git a/schema/data/base/booleanData_test.go b/schema/data/base/booleanData_test.go index 03fb6812d..c07311928 100644 --- a/schema/data/base/booleanData_test.go +++ b/schema/data/base/booleanData_test.go @@ -25,7 +25,6 @@ func TestNewBooleanData(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve", args{true}, booleanData{true}}, {"+ve", args{false}, booleanData{false}}, } @@ -46,9 +45,9 @@ func TestBooleanDataFromInterface(t *testing.T) { want data.Data wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"-ve", args{NewBooleanData(false)}, booleanData{false}, assert.NoError}, {"+ve", args{NewBooleanData(true)}, booleanData{true}, assert.NoError}, + {"-ve", args{NewStringData("test")}, booleanData{false}, assert.Error}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -71,10 +70,10 @@ func Test_booleanDataFromInterface(t *testing.T) { want booleanData wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"+ve with empty string", args{booleanData{}}, booleanData{}, assert.NoError}, {"+ve", args{booleanData{true}}, booleanData{true}, assert.NoError}, - {"-ve", args{booleanData{false}}, booleanData{false}, assert.NoError}, + {"+ve", args{booleanData{false}}, booleanData{false}, assert.NoError}, + {"-ve", args{NewStringData("test")}, booleanData{false}, assert.Error}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -100,7 +99,6 @@ func Test_booleanData_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"+ve", fields{false}, args{booleanData{true}}, -1}, {"+ve", fields{true}, args{booleanData{false}}, 1}, {"+ve", fields{false}, args{booleanData{false}}, 0}, @@ -124,7 +122,6 @@ func Test_booleanData_GenerateHashID(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve with nil", fields{}, baseIDs.GenerateHashID()}, {"+ve", fields{true}, baseIDs.GenerateHashID(booleanData{true}.Bytes())}, {"+ve", fields{false}, baseIDs.GenerateHashID()}, @@ -148,7 +145,6 @@ func Test_booleanData_Get(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{}, booleanData{}.Value}, {"+ve", fields{true}, booleanData{true}.Value}, {"+ve", fields{false}, booleanData{false}.Value}, @@ -172,7 +168,6 @@ func Test_booleanData_GetID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve", fields{}, baseIDs.NewDataID(booleanData{})}, {"+ve", fields{true}, baseIDs.NewDataID(booleanData{true})}, {"+ve", fields{false}, baseIDs.NewDataID(booleanData{false})}, @@ -196,7 +191,6 @@ func Test_booleanData_GetType(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve", fields{}, idsConstants.BooleanDataID}, {"+ve", fields{true}, idsConstants.BooleanDataID}, {"+ve", fields{false}, idsConstants.BooleanDataID}, @@ -220,7 +214,6 @@ func Test_booleanData_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{}, "false"}, {"+ve", fields{true}, "true"}, {"+ve", fields{false}, "false"}, @@ -244,7 +237,6 @@ func Test_booleanData_ZeroValue(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve", fields{}, booleanData{}}, {"+ve", fields{true}, NewBooleanData(false)}, {"+ve", fields{false}, NewBooleanData(false)}, @@ -258,3 +250,25 @@ func Test_booleanData_ZeroValue(t *testing.T) { }) } } + +func Test_booleanData_Bytes(t *testing.T) { + type fields struct { + Value bool + } + tests := []struct { + name string + fields fields + want []byte + }{ + {"+ve", fields{true}, []byte{0x1}}, + {"+ve", fields{false}, []byte{0x0}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + booleanData := booleanData{ + Value: tt.fields.Value, + } + assert.Equalf(t, tt.want, booleanData.Bytes(), "Bytes()") + }) + } +} diff --git a/schema/data/base/decData_test.go b/schema/data/base/decData_test.go index 78e8f60ba..ddcdb8d21 100644 --- a/schema/data/base/decData_test.go +++ b/schema/data/base/decData_test.go @@ -29,7 +29,6 @@ func TestNewDecData(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve with nil", args{}, decData{}}, {"+ve with zero dec", args{types.ZeroDec()}, decData{types.ZeroDec()}}, {"+ve", args{types.NewDec(100)}, decData{types.NewDec(100)}}, @@ -52,11 +51,13 @@ func Test_decDataFromInterface(t *testing.T) { want decData wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"+ve with nil", args{decData{}}, decData{}, assert.NoError}, + {"+ve with nil", args{decData{types.Dec{}}}, decData{}, assert.NoError}, {"+ve with zero dec", args{decData{types.ZeroDec()}}, decData{types.ZeroDec()}, assert.NoError}, {"+ve", args{decData{types.NewDec(100)}}, decData{types.NewDec(100)}, assert.NoError}, {"+ve with -ve Dec", args{decData{types.NewDec(-100)}}, decData{types.NewDec(-100)}, assert.NoError}, + {"-ve with nil", args{nil}, decData{}, assert.Error}, + {"-ve stringData", args{stringData{"testData"}}, decData{}, assert.Error}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -78,8 +79,7 @@ func Test_decData_Bytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. - // {"+ve with nil", fields{}}, []byte{}}, + {"+ve with nil", fields{}, []byte{0x1}}, // TODO: Update test after fixing the bug {"+ve with zero dec", fields{types.ZeroDec()}, decData{types.ZeroDec()}.Value.Bytes()}, {"+ve", fields{types.NewDec(100)}, decData{types.NewDec(100)}.Value.Bytes()}, {"+ve with -ve Dec", fields{types.NewDec(-100)}, decData{types.NewDec(-100)}.Value.Bytes()}, @@ -95,6 +95,9 @@ func Test_decData_Bytes(t *testing.T) { } func Test_decData_Compare(t *testing.T) { + require.Panics(t, func() { + decData{}.Compare(nil) + }) type fields struct { Value types.Dec } @@ -107,8 +110,8 @@ func Test_decData_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"+ve with nil", fields{}, args{decData{}}, 0}, + {"+ve with nil", fields{types.Dec{}}, args{decData{types.Dec{}}}, 0}, {"+ve with zero dec", fields{types.ZeroDec()}, args{decData{types.ZeroDec()}}, 0}, {"+ve", fields{types.NewDec(100)}, args{decData{types.NewDec(100)}}, 0}, {"-ve", fields{types.NewDec(-100)}, args{decData{types.NewDec(100)}}, -1}, @@ -134,8 +137,7 @@ func Test_decData_GenerateHashID(t *testing.T) { want ids.HashID wantPanic bool }{ - // TODO: Update Unit tests after fix - {"panic case with nil", fields{types.Dec{}}, baseIDs.GenerateHashID([]byte{}), true}, // TODO: Check if Panic case for nil Dec is expected behaviour + {"panic case with nil", fields{types.Dec{}}, baseIDs.GenerateHashID(), false}, {"+ve with zero dec", fields{types.ZeroDec()}, baseIDs.GenerateHashID(), false}, {"+ve", fields{types.NewDec(100)}, baseIDs.GenerateHashID(decData{types.NewDec(100)}.Bytes()), false}, {"+ve with -ve Dec", fields{types.NewDec(-100)}, baseIDs.GenerateHashID(decData{types.NewDec(-100)}.Bytes()), false}, @@ -166,7 +168,6 @@ func Test_decData_Get(t *testing.T) { fields fields want types.Dec }{ - // TODO: Add test cases. {"+ve with nil", fields{}, decData{}.Value}, {"+ve with zero dec", fields{types.ZeroDec()}, decData{types.ZeroDec()}.Value}, {"+ve", fields{types.NewDec(100)}, decData{types.NewDec(100)}.Value}, @@ -192,7 +193,6 @@ func Test_decData_GetID(t *testing.T) { want ids.DataID wantPanic bool }{ - // TODO: Add test cases. {"panic case with nil", fields{types.Dec{}}, nil, true}, // TODO: Check whether planned panic in NewDataID is expected behaviour {"+ve with zero dec", fields{types.ZeroDec()}, baseIDs.NewDataID(decData{types.ZeroDec()}), false}, {"+ve", fields{types.NewDec(100)}, baseIDs.NewDataID(decData{types.NewDec(100)}), false}, @@ -223,7 +223,6 @@ func Test_decData_GetType(t *testing.T) { fields fields want ids.StringID }{ - // TODO: Add test cases. {"+ve with nil", fields{}, dataConstants.DecDataID}, {"+ve with zero dec", fields{types.ZeroDec()}, dataConstants.DecDataID}, {"+ve", fields{types.NewDec(100)}, dataConstants.DecDataID}, @@ -248,7 +247,6 @@ func Test_decData_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve with nil", fields{}, decData{}.Value.String()}, {"+ve with zero dec", fields{types.ZeroDec()}, decData{types.ZeroDec()}.Value.String()}, {"+ve", fields{types.NewDec(100)}, decData{types.NewDec(100)}.Value.String()}, @@ -273,7 +271,6 @@ func Test_decData_ZeroValue(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve with nil", fields{}, decData{types.ZeroDec()}}, {"+ve with zero dec", fields{types.ZeroDec()}, decData{types.ZeroDec()}}, {"+ve", fields{types.NewDec(100)}, decData{types.ZeroDec()}}, diff --git a/schema/data/base/heightData.go b/schema/data/base/heightData.go index 53ba4d577..fedea92bc 100644 --- a/schema/data/base/heightData.go +++ b/schema/data/base/heightData.go @@ -38,7 +38,6 @@ func (heightData heightData) String() string { return strconv.FormatInt(heightData.Value.Get(), 10) } -// TODO test func (heightData heightData) Bytes() []byte { bytes := make([]byte, 8) binary.LittleEndian.PutUint64(bytes, uint64(heightData.Get().Get())) diff --git a/schema/data/base/heightData_test.go b/schema/data/base/heightData_test.go index 6a3d76c39..f50bb03e4 100644 --- a/schema/data/base/heightData_test.go +++ b/schema/data/base/heightData_test.go @@ -31,7 +31,7 @@ func TestNewHeightData(t *testing.T) { args args want data.Data }{ - + {"+ve with nil", args{nil}, heightData{nil}}, {"Test for +ve int", args{baseTypes.NewHeight(100)}, heightData{baseTypes.NewHeight(100)}}, {"Test for +ve int", args{baseTypes.NewHeight(-100)}, heightData{baseTypes.NewHeight(-100)}}, } @@ -59,7 +59,7 @@ func Test_heightDataFromInterface(t *testing.T) { {"Test for empty height data", args{heightData{}}, heightData{}, false, ""}, {"Test for +ve int height data", args{heightData{baseTypes.NewHeight(100)}}, heightData{baseTypes.NewHeight(100)}, false, ""}, {"Test for -ve int height data", args{heightData{baseTypes.NewHeight(-100)}}, heightData{baseTypes.NewHeight(-100)}, false, ""}, - {"Test for Other listable Type", args{decData{typesCosmosSdk.ZeroDec()}.ZeroValue()}, heightData{}, true, constants.MetaDataError.Error()}, + {"-ve Test for Other listable Type", args{decData{typesCosmosSdk.ZeroDec()}.ZeroValue()}, heightData{}, true, constants.MetaDataError.Error()}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -262,3 +262,27 @@ func Test_heightData_ZeroValue(t *testing.T) { }) } } + +func Test_heightData_Bytes(t *testing.T) { + type fields struct { + Value types.Height + } + tests := []struct { + name string + fields fields + want []byte + }{ + {"+ve with ZeroHeight", fields{baseTypes.NewHeight(-1)}, baseTypes.NewHeight(-1).Bytes()}, + {"+ve with nil", fields{nil}, []byte{}}, + {"+ve", fields{baseTypes.NewHeight(100)}, baseTypes.NewHeight(100).Bytes()}, + {"+ve with max int", fields{baseTypes.NewHeight(int64(^uint(0) >> 1))}, baseTypes.NewHeight(int64(^uint(0) >> 1)).Bytes()}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + heightData := heightData{ + Value: tt.fields.Value, + } + assert.Equalf(t, tt.want, heightData.Bytes(), "Bytes()") + }) + } +} diff --git a/schema/data/base/idData_test.go b/schema/data/base/idData_test.go index 4810713a5..f7c7af404 100644 --- a/schema/data/base/idData_test.go +++ b/schema/data/base/idData_test.go @@ -25,7 +25,6 @@ func TestNewIDData(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve", args{NewStringData("Data")}, idData{NewStringData("Data")}}, {"+ve empty string", args{NewStringData("")}, idData{NewStringData("")}}, } @@ -46,9 +45,9 @@ func Test_idDataFromInterface(t *testing.T) { want idData wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"+ve", args{NewIDData(NewStringData("Data"))}, idData{NewStringData("Data")}, assert.NoError}, {"+ve", args{NewIDData(NewStringData(""))}, idData{NewStringData("")}, assert.NoError}, + {"-ve", args{NewStringData("Data")}, idData{}, assert.Error}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -70,7 +69,6 @@ func Test_idData_Bytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("")}, []byte{}}, {"+ve", fields{NewStringData("Data")}, NewStringData("Data").Bytes()}, } @@ -97,7 +95,6 @@ func Test_idData_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, args{idData{NewStringData("Data")}}, 0}, {"+ve", fields{NewStringData("Data")}, args{idData{NewStringData("0")}}, 1}, } @@ -120,7 +117,6 @@ func Test_idData_GenerateHashID(t *testing.T) { fields fields want ids.HashID }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, baseIDs.GenerateHashID(idData{NewStringData("Data")}.Bytes())}, {"+ve with empty String", fields{NewStringData("")}, baseIDs.GenerateHashID(idData{NewStringData("")}.Bytes())}, } @@ -143,7 +139,6 @@ func Test_idData_Get(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, NewStringData("Data")}, {"+ve", fields{NewStringData("")}, NewStringData("")}, } @@ -166,7 +161,6 @@ func Test_idData_GetID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, baseIDs.NewDataID(idData{NewStringData("Data")})}, } for _, tt := range tests { @@ -188,7 +182,6 @@ func Test_idData_GetType(t *testing.T) { fields fields want ids.StringID }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, dataConstants.IDDataID}, } for _, tt := range tests { @@ -210,7 +203,6 @@ func Test_idData_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, "Data"}, } for _, tt := range tests { @@ -232,7 +224,6 @@ func Test_idData_ZeroValue(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve", fields{NewStringData("Data")}, NewIDData(baseIDs.NewStringID(""))}, } for _, tt := range tests { diff --git a/schema/data/base/listData.go b/schema/data/base/listData.go index 9f6397068..30385e3c8 100644 --- a/schema/data/base/listData.go +++ b/schema/data/base/listData.go @@ -76,7 +76,6 @@ func (listData listData) ZeroValue() data.Data { return NewListData(base.NewDataList([]data.Data{}...)) } -// TODO test func (listData listData) GenerateHashID() ids.HashID { if listData.Compare(listData.ZeroValue()) == 0 { return baseIDs.GenerateHashID() diff --git a/schema/data/base/listData_test.go b/schema/data/base/listData_test.go index d0477301a..ca8facca3 100644 --- a/schema/data/base/listData_test.go +++ b/schema/data/base/listData_test.go @@ -37,7 +37,6 @@ func TestListDataPrototype(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve", args{}, listData{}.ZeroValue()}, } for _, tt := range tests { @@ -56,7 +55,6 @@ func TestNewListData(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve for some id", args{baseLists.NewDataList(NewStringData("Data"))}, listData{baseLists.NewDataList(NewStringData("Data"))}}, {"+ve for empty String", args{baseLists.NewDataList(NewStringData(""))}, listData{baseLists.NewDataList(NewStringData(""))}}, @@ -82,10 +80,10 @@ func Test_listDataFromInterface(t *testing.T) { want listData wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"+ve for some id", args{listData{baseLists.NewDataList(NewStringData("Data"))}}, listData{baseLists.NewDataList(NewStringData("Data"))}, assert.NoError}, {"+ve for empty String", args{listData{baseLists.NewDataList(NewStringData(""))}}, listData{baseLists.NewDataList(NewStringData(""))}, assert.NoError}, - {"+ve for empty String", args{heightData{}}, listData{}, assert.Error}, + {"-ve for empty String", args{heightData{}}, listData{}, assert.Error}, + {"-ve for empty String", args{NewStringData("")}, listData{}, assert.Error}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -112,7 +110,6 @@ func Test_listData_Add(t *testing.T) { want data.ListData wantFailure bool }{ - // TODO: Add test cases. {"+ve for multiple ids", fields{baseLists.NewDataList(NewStringData("Data"), NewStringData("Data"), NewStringData("Data"))}, args{}, listData{baseLists.NewDataList(NewStringData("Data"), NewStringData("Data"), NewStringData("Data"))}, false}, {"+ve for multiple ids/nils", fields{baseLists.NewDataList(NewStringData("Data"), NewStringData(""), NewStringData("Data"))}, args{}, listData{baseLists.NewDataList(NewStringData("Data"), NewStringData("Data"), NewStringData(""))}, false}, {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, args{}, listData{baseLists.NewDataList(NewStringData("Data"))}, false}, @@ -143,7 +140,6 @@ func Test_listData_Bytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, NewStringData("Data").Bytes()}, // for a single data no loop iteration is required, so directly it's byte should match {"+ve for multiple ids", fields{baseLists.NewDataList(NewStringData("Data"), NewStringData("Data1"))}, bytes.Join([][]byte{NewStringData("Data").Bytes(), NewStringData("Data1").Bytes()}, nil)}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, []byte(nil)}, @@ -172,7 +168,6 @@ func Test_listData_Compare(t *testing.T) { want int wantPanic bool }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, args{listData{baseLists.NewDataList(NewStringData("Data"))}}, 0, false}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, args{listData{baseLists.NewDataList(NewStringData("Data"))}}, -1, false}, {"Test for Equal case", fields{baseLists.NewDataList(NewStringData(fromAddress))}, args{listData{baseLists.NewDataList(NewStringData(fromAddress))}}, 0, false}, @@ -204,7 +199,6 @@ func Test_listData_GenerateHashID(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, baseIDs.GenerateHashID(listData{baseLists.NewDataList(NewStringData("Data"))}.Bytes()).String()}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, baseIDs.GenerateHashID(listData{baseLists.NewDataList(NewStringData(""))}.Bytes()).String()}, {"empty string", fields{baseLists.NewDataList()}, baseIDs.NewStringID("").String()}, @@ -232,7 +226,6 @@ func Test_listData_Get(t *testing.T) { fields fields want []data.Data }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, listData{baseLists.NewDataList(NewStringData("Data"))}.Value.GetList()}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, listData{baseLists.NewDataList(NewStringData(""))}.Value.GetList()}, } @@ -255,7 +248,6 @@ func Test_listData_GetID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, baseIDs.NewDataID(listData{baseLists.NewDataList(NewStringData("Data"))})}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, baseIDs.NewDataID(listData{baseLists.NewDataList(NewStringData(""))})}, } @@ -278,7 +270,6 @@ func Test_listData_GetType(t *testing.T) { fields fields want ids.StringID }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, dataConstants.ListDataID}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, dataConstants.ListDataID}, } @@ -305,7 +296,6 @@ func Test_listData_Remove(t *testing.T) { args args want data.ListData }{ - // TODO: Add test cases. {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, args{[]data.Data{}}, listData{baseLists.NewDataList(NewStringData(""))}}, {"+ve for empty String & removing it", fields{baseLists.NewDataList(NewStringData(""))}, args{[]data.Data{NewStringData("")}}, listData{baseLists.NewDataList()}}, {"+ve ", fields{baseLists.NewDataList(NewStringData("data"))}, args{[]data.Data{NewStringData("data")}}, listData{baseLists.NewDataList()}}, @@ -334,7 +324,6 @@ func Test_listData_Search(t *testing.T) { want int want1 bool }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, args{NewStringData("Data")}, 0, true}, {"+ve for empty String", fields{baseLists.NewDataList([]data.Data{NewStringData("Data"), NewStringData("")}...)}, args{NewStringData("")}, 0, true}, {"-ve", fields{baseLists.NewDataList([]data.Data{NewStringData("Data"), NewStringData("")}...)}, args{NewStringData("test")}, 2, false}, @@ -360,7 +349,6 @@ func Test_listData_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, "Data"}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, ""}, } @@ -383,7 +371,6 @@ func Test_listData_ZeroValue(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve for some id", fields{baseLists.NewDataList(NewStringData("Data"))}, NewListData(baseLists.NewDataList([]data.Data{}...))}, {"+ve for empty String", fields{baseLists.NewDataList(NewStringData(""))}, NewListData(baseLists.NewDataList([]data.Data{}...))}, } diff --git a/schema/data/base/stringData_test.go b/schema/data/base/stringData_test.go index c2ed9b81d..69aa1d753 100644 --- a/schema/data/base/stringData_test.go +++ b/schema/data/base/stringData_test.go @@ -25,7 +25,6 @@ func TestNewStringData(t *testing.T) { args args want data.Data }{ - // TODO: Add test cases. {"+ve data", args{"data"}, stringData{"data"}}, {"special char data", args{"data%/@1!"}, stringData{"data%/@1!"}}, } @@ -46,10 +45,10 @@ func Test_stringDataFromInterface(t *testing.T) { want stringData wantErr assert.ErrorAssertionFunc }{ - // TODO: Add test cases. {"+ve data", args{stringData{"data"}}, stringData{"data"}, assert.NoError}, {"data with special char", args{stringData{"data_!@#$%^&*("}}, stringData{"data_!@#$%^&*("}, assert.NoError}, {"empty string", args{stringData{""}}, stringData{""}, assert.NoError}, + {"-ve with decData", args{decData{}}, stringData{}, assert.Error}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -71,7 +70,7 @@ func Test_stringData_Bytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. + {"+ve data", fields{"data"}, []byte("data")}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -96,7 +95,6 @@ func Test_stringData_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, args{stringData{"data"}}, 0}, {"data with special char", fields{"data"}, args{stringData{"data_!@#$%^&*("}}, -1}, {"empty string", fields{"data"}, args{stringData{""}}, 1}, @@ -120,7 +118,6 @@ func Test_stringData_GenerateHashID(t *testing.T) { fields fields want ids.HashID }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, baseIDs.GenerateHashID(stringData{"data"}.Bytes())}, {"data with special char", fields{"data_!@#$%^&*("}, baseIDs.GenerateHashID(stringData{"data_!@#$%^&*("}.Bytes())}, {"empty string", fields{""}, baseIDs.GenerateHashID(stringData{""}.Bytes())}, @@ -144,7 +141,6 @@ func Test_stringData_Get(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, "data"}, {"data with special char", fields{"data_!@#$%^&*("}, "data_!@#$%^&*("}, {"empty string", fields{""}, ""}, @@ -168,7 +164,6 @@ func Test_stringData_GetID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, baseIDs.NewDataID(stringData{"data"})}, {"data with special char", fields{"data_!@#$%^&*("}, baseIDs.NewDataID(stringData{"data_!@#$%^&*("})}, {"empty string", fields{""}, baseIDs.NewDataID(stringData{""})}, @@ -192,7 +187,6 @@ func Test_stringData_GetType(t *testing.T) { fields fields want ids.StringID }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, idsConstants.StringDataID}, {"data with special char", fields{"data_!@#$%^&*("}, idsConstants.StringDataID}, {"empty string", fields{""}, idsConstants.StringDataID}, @@ -216,7 +210,6 @@ func Test_stringData_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, "data"}, {"data with special char", fields{"data_!@#$%^&*("}, "data_!@#$%^&*("}, {"empty string", fields{""}, ""}, @@ -240,7 +233,6 @@ func Test_stringData_ZeroValue(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve data", fields{"data"}, stringData{""}}, {"data with special char", fields{"data_!@#$%^&*("}, stringData{""}}, } diff --git a/schema/data/utilities/string_test.go b/schema/data/utilities/string_test.go index 2a847a470..a6504f806 100644 --- a/schema/data/utilities/string_test.go +++ b/schema/data/utilities/string_test.go @@ -17,15 +17,15 @@ import ( "github.com/AssetMantle/modules/schema/data/base" ) -func TestReadData(t *testing.T) { - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAddress1 := "cosmos1x53dugvr4xvew442l9v2r5x7j8gfvged2zk5ef" - fromAccAddress, _ := types.AccAddressFromBech32(fromAddress) - fromAccAddress1, _ := types.AccAddressFromBech32(fromAddress1) - dataList := make([]data.Data, 2) - dataList[0] = base.NewAccAddressData(fromAccAddress) - dataList[1] = base.NewAccAddressData(fromAccAddress1) +var ( + fromAddress = "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" + fromAddress1 = "cosmos1x53dugvr4xvew442l9v2r5x7j8gfvged2zk5ef" + fromAccAddress, _ = types.AccAddressFromBech32(fromAddress) + fromAccAddress1, _ = types.AccAddressFromBech32(fromAddress1) + dataList = []data.Data{base.NewAccAddressData(fromAccAddress), base.NewAccAddressData(fromAccAddress1)} +) +func TestReadData(t *testing.T) { type args struct { dataString string } @@ -35,16 +35,17 @@ func TestReadData(t *testing.T) { want data.Data wantErr bool }{ - // TODO: fix after issue #50 fix, https://github.com/AssetMantle/modules/issues/50 {"String Data", args{"S|newFact"}, base.NewStringData("newFact"), false}, - {"Unknown Data", args{"SomeRandomData"}, nil, true}, - {"List Data", args{"L|A|cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c,A|cosmos1x53dugvr4xvew442l9v2r5x7j8gfvged2zk5ef"}, base.NewListData(baseLists.NewDataList(dataList...)), false}, // TODO: stack overflow - {"List Data empty list", args{"L|"}, base.NewListData(baseLists.NewDataList()), false}, // TODO: stack overflow + {"-ve Unknown Data", args{"SomeRandomData"}, nil, true}, + {"List Data", args{"L|A|cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c,A|cosmos1x53dugvr4xvew442l9v2r5x7j8gfvged2zk5ef"}, base.NewListData(baseLists.NewDataList(dataList...)), false}, + {"List Data empty list", args{"L|"}, base.NewListData(baseLists.NewDataList()), false}, {"Id Data", args{"I|data"}, base.NewIDData(baseIDs.NewStringID("data")), false}, {"Height Data", args{"H|100"}, base.NewHeightData(baseTypes.NewHeight(100)), false}, {"Dec Data", args{"D|100"}, base.NewDecData(types.NewDec(100)), false}, {"Bool Data", args{"B|true"}, base.NewBooleanData(true), false}, {"AccAddress data", args{"A|cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c"}, base.NewAccAddressData(fromAccAddress), false}, + {"-ve String Data", args{"S|S,|newFact"}, base.NewStringData("S,|newFact"), true}, + {"-ve List Data String", args{"L|S|,TestData,S|,Test"}, base.NewListData(baseLists.NewDataList([]data.Data{base.NewStringData("S|,TestData"), base.NewStringData("S|,Test")}...)), true}, } for _, tt := range tests { @@ -59,3 +60,257 @@ func TestReadData(t *testing.T) { }) } } + +func Test_joinDataTypeAndValueStrings(t *testing.T) { + type args struct { + dataType string + dataValue string + } + tests := []struct { + name string + args args + want string + }{ + {"+ve string", args{"S", "Data"}, "S|Data"}, + {"+ve Id Data", args{"I", "Data"}, "I|Data"}, + {"-ve", args{"F", "SFw"}, "F|SFw"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := joinDataTypeAndValueStrings(tt.args.dataType, tt.args.dataValue); got != tt.want { + t.Errorf("joinDataTypeAndValueStrings() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readAccAddressData(t *testing.T) { + fromAccAddress, nil := types.AccAddressFromBech32("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c") + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.AccAddressData + wantErr bool + }{ + {"+ve nil", args{}, base.AccAddressDataPrototype(), false}, + {"+ve string", args{"cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c"}, base.NewAccAddressData(fromAccAddress), false}, + {"-ve", args{"testData"}, base.AccAddressDataPrototype(), true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readAccAddressData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readAccAddressData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readAccAddressData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readBooleanData(t *testing.T) { + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.BooleanData + wantErr bool + }{ + {"+ve nil", args{}, base.BooleanDataPrototype(), false}, + {"+ve string", args{"true"}, base.NewBooleanData(true), false}, + {"+ve string", args{"false"}, base.NewBooleanData(false), false}, + {"-ve", args{"testData"}, base.BooleanDataPrototype(), true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readBooleanData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readBooleanData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readBooleanData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readDecData(t *testing.T) { + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.DecData + wantErr bool + }{ + {"+ve nil", args{}, base.DecDataPrototype(), false}, + {"+ve string", args{"100"}, base.NewDecData(types.NewDec(100)), false}, + {"+ve with nil", args{"-100"}, base.NewDecData(types.NewDec(-100)), false}, + {"-ve", args{"testData"}, base.DecDataPrototype(), true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readDecData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readDecData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readDecData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readHeightData(t *testing.T) { + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.HeightData + wantErr bool + }{ + {"+ve nil", args{}, base.HeightDataPrototype(), false}, + {"+ve string", args{"100"}, base.NewHeightData(baseTypes.NewHeight(100)), false}, + {"+ve with nil", args{"-100"}, base.NewHeightData(baseTypes.NewHeight(-100)), false}, + {"-ve", args{"testData"}, base.HeightDataPrototype(), true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readHeightData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readHeightData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readHeightData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readIDData(t *testing.T) { + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.IDData + wantErr bool + }{ + {"+ve nil", args{}, base.IDDataPrototype(), false}, + {"+ve", args{"L|A|cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c,A|cosmos1x53dugvr4xvew442l9v2r5x7j8gfvged2zk5ef"}, base.NewIDData(baseIDs.NewStringID("L|A|cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c,A|cosmos1x53dugvr4xvew442l9v2r5x7j8gfvged2zk5ef")), false}, + {"-ve string with special char", args{"testDataString|,"}, base.NewIDData(baseIDs.NewStringID("testDataString|,")), false}, + {"-ve", args{"testData"}, base.NewIDData(baseIDs.NewStringID("testData")), false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readIDData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readIDData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readIDData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readListData(t *testing.T) { + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.ListData + wantErr bool + }{ + {"+ve nil", args{}, base.ListDataPrototype(), false}, + {"+ve string", args{"S|1,S|2,S|3"}, base.NewListData(baseLists.NewDataList([]data.Data{base.NewStringData("1"), base.NewStringData("2"), base.NewStringData("3")}...)), false}, + {"-ve", args{"testData"}, base.ListDataPrototype(), true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readListData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readListData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readListData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_readStringData(t *testing.T) { + type args struct { + dataString string + } + tests := []struct { + name string + args args + want data.StringData + wantErr bool + }{ + {"+ve nil", args{}, base.StringDataPrototype(), false}, + {"+ve string", args{"testDataString"}, base.NewStringData("testDataString"), false}, + {"-ve", args{"testData"}, base.NewStringData("testData"), false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := readStringData(tt.args.dataString) + if (err != nil) != tt.wantErr { + t.Errorf("readStringData() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("readStringData() got = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_splitDataTypeAndValueStrings(t *testing.T) { + type args struct { + dataTypeAndValueString string + } + tests := []struct { + name string + args args + wantDataType string + wantDataValue string + }{ + {"+ve String", args{"S|data"}, "S", "data"}, + {"+ve Bool", args{"B|true"}, "B", "true"}, + {"+ve Int", args{"I|100"}, "I", "100"}, + {"+ve Dec", args{"D|100.00"}, "D", "100.00"}, + {"+ve Height", args{"H|100"}, "H", "100"}, + {"+ve ID", args{"ID|100"}, "ID", "100"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotDataType, gotDataValue := splitDataTypeAndValueStrings(tt.args.dataTypeAndValueString) + if gotDataType != tt.wantDataType { + t.Errorf("splitDataTypeAndValueStrings() gotDataType = %v, want %v", gotDataType, tt.wantDataType) + } + if gotDataValue != tt.wantDataValue { + t.Errorf("splitDataTypeAndValueStrings() gotDataValue = %v, want %v", gotDataValue, tt.wantDataValue) + } + }) + } +} diff --git a/schema/documents/base/asset_test.go b/schema/documents/base/asset_test.go index 6530360d9..0ebcab38b 100644 --- a/schema/documents/base/asset_test.go +++ b/schema/documents/base/asset_test.go @@ -30,7 +30,6 @@ func TestNewAsset(t *testing.T) { args args want documentsSchema.Asset }{ - // TODO: Add test cases. {"+ve", args{classificationID: classificationID, immutables: immutables, mutables: mutables}, asset{Document: NewDocument(classificationID, immutables, mutables)}}, } for _, tt := range tests { @@ -54,7 +53,6 @@ func Test_asset_GetBurn(t *testing.T) { fields fields want properties.Property }{ - // TODO: Add test cases. {"+ve", fields{Document: testDocumentWithBurn}, baseProperties.NewMesaProperty(constants.BurnHeightProperty.GetKey(), baseData.NewHeightData(baseTypes.NewHeight(1)))}, {"+ve", fields{Document: testDocument}, constants.BurnHeightProperty}, } @@ -81,7 +79,6 @@ func Test_asset_GetLock(t *testing.T) { fields fields want properties.Property }{ - // TODO: Add test cases. {"+ve with default lock", fields{testDocument}, constants.LockProperty}, {"+ve with mutated", fields{testDocumentWithLock}, baseProperties.NewMesaProperty(constants.LockProperty.GetKey(), baseData.NewHeightData(baseTypes.NewHeight(1)))}, } @@ -108,7 +105,6 @@ func Test_asset_GetSupply(t *testing.T) { fields fields want properties.Property }{ - // TODO: Add test cases. {"+ve", fields{testDocument}, constants.SupplyProperty}, {"+ve", fields{testDocumentWithSupply}, baseProperties.NewMesaProperty(constants.SupplyProperty.GetKey(), baseData.NewDecData(types.NewDec(1)))}, } diff --git a/schema/documents/base/document_test.go b/schema/documents/base/document_test.go index 854195b44..39373d6b5 100644 --- a/schema/documents/base/document_test.go +++ b/schema/documents/base/document_test.go @@ -40,7 +40,6 @@ func TestNewDocument(t *testing.T) { args args want documents.Document }{ - // TODO: Add test cases. {"+ve", args{classificationID: classificationID, immutables: testImmutables, mutables: testMutables}, document{ClassificationID: classificationID, Immutables: testImmutables, Mutables: testMutables}}, {"+ve with nil classificationID", args{classificationID: nil, immutables: testImmutables, mutables: testMutables}, document{ClassificationID: nil, Immutables: testImmutables, Mutables: testMutables}}, {"+ve with nil immutables", args{classificationID: classificationID, immutables: nil, mutables: testMutables}, document{ClassificationID: classificationID, Immutables: nil, Mutables: testMutables}}, @@ -68,7 +67,6 @@ func Test_document_GetClassificationID(t *testing.T) { fields fields want ids.ClassificationID }{ - // TODO: Add test cases. {"+ve", fields{ClassificationID: classificationID, Immutables: testImmutables, Mutables: testMutables}, classificationID}, {"+ve with nil classificationID", fields{ClassificationID: nil, Immutables: testImmutables, Mutables: testMutables}, nil}, {"+ve with nil immutables", fields{ClassificationID: classificationID, Immutables: nil, Mutables: testMutables}, classificationID}, @@ -101,7 +99,6 @@ func Test_document_GetImmutables(t *testing.T) { fields fields want qualified.Immutables }{ - // TODO: Add test cases. {"+ve", fields{ClassificationID: classificationID, Immutables: testImmutables, Mutables: testMutables}, testImmutables}, {"+ve with nil classificationID", fields{ClassificationID: nil, Immutables: testImmutables, Mutables: testMutables}, testImmutables}, {"+ve with nil immutables", fields{ClassificationID: classificationID, Immutables: nil, Mutables: testMutables}, nil}, @@ -134,7 +131,6 @@ func Test_document_GetMutables(t *testing.T) { fields fields want qualified.Mutables }{ - // TODO: Add test cases. {"+ve", fields{ClassificationID: classificationID, Immutables: testImmutables, Mutables: testMutables}, testMutables}, {"+ve with nil classificationID", fields{ClassificationID: nil, Immutables: testImmutables, Mutables: testMutables}, testMutables}, {"+ve with nil immutables", fields{ClassificationID: classificationID, Immutables: nil, Mutables: testMutables}, testMutables}, diff --git a/schema/helpers/base/query_test.go b/schema/helpers/base/query_test.go index aa56f65bc..f3b4d230e 100644 --- a/schema/helpers/base/query_test.go +++ b/schema/helpers/base/query_test.go @@ -45,9 +45,13 @@ func TestQuery(t *testing.T) { command := Query.Command(codec) command.SetArgs([]string{ "test"}) - require.Equal(t, `ABCIQuery: Post failed: Post "http://localhost:26657": dial tcp [::1]:26657: connect: connection refused`, + err = command.ParseFlags([]string{"--node", "tcp://localhost:26657"}) + require.Nil(t, err) + require.Equal(t, `ABCIQuery: Post failed: Post "http://localhost:26657": dial tcp 127.0.0.1:26657: connect: connection refused`, command.ExecuteContext(context.Context()).Error()) + //require.Equal(t, nil, command.ExecuteContext(context.Context())) + // RESTQueryHandler cliContext := clientContext.NewCLIContext().WithCodec(codec).WithChainID("test") Query.RESTQueryHandler(cliContext) diff --git a/schema/helpers/base/transaction_test.go b/schema/helpers/base/transaction_test.go index a22eb2b53..32ef3a9bf 100644 --- a/schema/helpers/base/transaction_test.go +++ b/schema/helpers/base/transaction_test.go @@ -43,7 +43,9 @@ func TestTransaction(t *testing.T) { // Command : No Panics command := Transaction.Command(codec) - require.Equal(t, `ABCIQuery: Post failed: Post "http://localhost:26657": dial tcp [::1]:26657: connect: connection refused`, + err = command.ParseFlags([]string{"--node", "tcp://localhost:26657"}) + require.Nil(t, err) + require.Equal(t, `ABCIQuery: Post failed: Post "http://localhost:26657": dial tcp 127.0.0.1:26657: connect: connection refused`, command.ExecuteContext(context.Context()).Error()) // HandleMessage _, err = Transaction.HandleMessage(context, message) @@ -61,7 +63,7 @@ func TestTransaction(t *testing.T) { require.Nil(t, err) responseRecorder := httptest.NewRecorder() Transaction.RESTRequestHandler(cliContext).ServeHTTP(responseRecorder, testRequest1) - require.Equal(t, `{"error":"ABCIQuery: Post failed: Post \"http://localhost:26657\": dial tcp [::1]:26657: connect: connection refused"}`, responseRecorder.Body.String()) + require.Equal(t, `{"error":"ABCIQuery: Post failed: Post \"http://localhost:26657\": dial tcp 127.0.0.1:26657: connect: connection refused"}`, responseRecorder.Body.String()) require.Equal(t, http.StatusBadRequest, responseRecorder.Code) // invalid request diff --git a/schema/ids/base/dataID_test.go b/schema/ids/base/dataID_test.go index 906b3c81e..ea9cfef36 100644 --- a/schema/ids/base/dataID_test.go +++ b/schema/ids/base/dataID_test.go @@ -4,7 +4,10 @@ package base import ( + "github.com/AssetMantle/modules/schema/errors/constants" + stringUtilities "github.com/AssetMantle/modules/schema/ids/utilities" "reflect" + "strconv" "testing" "github.com/AssetMantle/modules/schema/data" @@ -23,8 +26,9 @@ func TestNewDataID(t *testing.T) { want ids.DataID wantError bool }{ - // TODO: Add test cases. - {"+ve nil", args{}, dataID{}, true}, + {"-ve with nil", args{}, dataID{}, true}, + {"+ve", args{NewBooleanData(true)}, dataID{NewStringID("B"), NewBooleanData(true).GenerateHashID()}, false}, + {"-ve with invalid data", args{nil}, dataID{}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -46,16 +50,23 @@ func Test_dataIDFromInterface(t *testing.T) { i interface{} } tests := []struct { - name string - args args - want dataID + name string + args args + want dataID + wantError bool }{ - // TODO: Add test cases. - // {"+ve", args{dataID{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}}, dataID{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}}, - {"-ve", args{dataID{}}, dataID{}}, + {"+ve", args{dataID{NewStringID("B"), NewBooleanData(true).GenerateHashID()}}, dataID{NewStringID("B"), NewBooleanData(true).GenerateHashID()}, false}, + {"-ve", args{dataID{}}, dataID{}, false}, + {"-ve", args{nil}, dataID{}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + defer func() { + r := recover() + if (r != nil) != tt.wantError { + t.Errorf("MetadataFromInterface() error = %v, wantError %v", r, tt.wantError) + } + }() got := dataIDFromInterface(tt.args.i) if !reflect.DeepEqual(got, tt.want) { t.Errorf("dataIDFromInterface() got = %v, want %v", got, tt.want) @@ -74,9 +85,8 @@ func Test_dataID_Bytes(t *testing.T) { fields fields want []byte }{ - // TODO: Add test cases. - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}, append(append([]byte{}, NewStringID("B").Bytes()...), base.NewBooleanData(true).GenerateHashID().Bytes()...)}, - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(false).GenerateHashID()}, append(append([]byte{}, NewStringID("B").Bytes()...), base.NewBooleanData(false).GenerateHashID().Bytes()...)}, + {"+ve", fields{NewStringID("B"), NewBooleanData(true).GenerateHashID()}, append(append([]byte{}, NewStringID("B").Bytes()...), NewBooleanData(true).GenerateHashID().Bytes()...)}, + {"+ve", fields{NewStringID("B"), NewBooleanData(false).GenerateHashID()}, append(append([]byte{}, NewStringID("B").Bytes()...), NewBooleanData(false).GenerateHashID().Bytes()...)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -105,9 +115,8 @@ func Test_dataID_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}, args{dataID{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}}, 0}, - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(false).GenerateHashID()}, args{dataID{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}}, -1}, + {"+ve", fields{NewStringID("B"), NewBooleanData(true).GenerateHashID()}, args{dataID{NewStringID("B"), NewBooleanData(true).GenerateHashID()}}, 0}, + {"+ve", fields{NewStringID("B"), NewBooleanData(false).GenerateHashID()}, args{dataID{NewStringID("B"), NewBooleanData(true).GenerateHashID()}}, -1}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -132,10 +141,9 @@ func Test_dataID_GetHashID(t *testing.T) { fields fields want ids.HashID }{ - // TODO: Add test cases. {"+ve", fields{}, dataID{}.HashID}, - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}, base.NewBooleanData(true).GenerateHashID()}, - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(false).GenerateHashID()}, base.NewBooleanData(false).GenerateHashID()}, + {"+ve", fields{NewStringID("B"), NewBooleanData(true).GenerateHashID()}, NewBooleanData(true).GenerateHashID()}, + {"+ve", fields{NewStringID("B"), NewBooleanData(false).GenerateHashID()}, NewBooleanData(false).GenerateHashID()}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -160,9 +168,8 @@ func Test_dataID_String(t *testing.T) { fields fields want string }{ - // TODO: Add test cases. - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(true).GenerateHashID()}, stringUtilities.JoinIDStrings(NewStringID("B").String(), base.NewBooleanData(true).GenerateHashID().String())}, - // {"+ve", fields{NewStringID("B"), base.NewBooleanData(false).GenerateHashID()}, stringUtilities.JoinIDStrings(NewStringID("B").String(), base.NewBooleanData(false).GenerateHashID().String())}, + {"+ve", fields{NewStringID("B"), NewBooleanData(true).GenerateHashID()}, stringUtilities.JoinIDStrings(NewStringID("B").String(), NewBooleanData(true).GenerateHashID().String())}, + {"+ve", fields{NewStringID("B"), NewBooleanData(false).GenerateHashID()}, stringUtilities.JoinIDStrings(NewStringID("B").String(), NewBooleanData(false).GenerateHashID().String())}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -176,3 +183,103 @@ func Test_dataID_String(t *testing.T) { }) } } + +// mocks for decData +type booleanData struct { + Value bool `json:"value"` +} + +var _ data.BooleanData = (*booleanData)(nil) + +func (booleanData booleanData) GetID() ids.DataID { + return NewDataID(booleanData) +} +func (booleanData booleanData) Compare(listable traits.Listable) int { + compareBooleanData, err := booleanDataFromInterface(listable) + if err != nil { + panic(err) + } + + if booleanData.Value == compareBooleanData.Value { + return 0 + } else if booleanData.Value == true { + return 1 + } + + return -1 +} +func (booleanData booleanData) String() string { + return strconv.FormatBool(booleanData.Value) +} + +func (booleanData booleanData) Bytes() []byte { + if booleanData.Get() { + return []byte{0x1} + } + return []byte{0x0} +} +func (booleanData booleanData) GetType() ids.StringID { + return NewStringID("B") +} +func (booleanData booleanData) ZeroValue() data.Data { + return NewBooleanData(false) +} +func (booleanData booleanData) GenerateHashID() ids.HashID { + if booleanData.Compare(booleanData.ZeroValue()) == 0 { + return GenerateHashID() + } + + return GenerateHashID(booleanData.Bytes()) +} +func (booleanData booleanData) Get() bool { + return booleanData.Value +} + +func booleanDataFromInterface(listable traits.Listable) (booleanData, error) { + switch value := listable.(type) { + case booleanData: + return value, nil + default: + return booleanData{}, constants.MetaDataError + } +} + +func BooleanDataPrototype() data.BooleanData { + return booleanData{}.ZeroValue().(data.BooleanData) +} + +func NewBooleanData(value bool) data.BooleanData { + return booleanData{ + Value: value, + } +} + +func TestReadDataID(t *testing.T) { + type args struct { + dataIDString string + } + tests := []struct { + name string + args args + want ids.DataID + wantErr bool + }{ + // TODO: Add test cases. + {"+ve", args{stringUtilities.JoinIDStrings(NewStringID("B").String(), NewBooleanData(true).GenerateHashID().String())}, NewDataID(NewBooleanData(true)), false}, + {"+ve with empty string", args{""}, PrototypeDataID(), false}, + {"+ve with nil", args{}, PrototypeDataID(), false}, + {"-ve", args{stringUtilities.JoinIDStrings(NewStringID("j").String(), "0")}, dataID{}, true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ReadDataID(tt.args.dataIDString) + if (err != nil) != tt.wantErr { + t.Errorf("ReadDataID() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("ReadDataID() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/schema/ids/base/stringID_test.go b/schema/ids/base/stringID_test.go index fbdac17cd..b6cb75ed2 100644 --- a/schema/ids/base/stringID_test.go +++ b/schema/ids/base/stringID_test.go @@ -20,8 +20,8 @@ func TestNewStringID(t *testing.T) { args args want ids.StringID }{ - - {"+ve", args{"ID"}, NewStringID("ID")}, + {"+ve", args{"ID"}, stringID{"ID"}}, + {"+ve", args{"S|ID"}, stringID{"S|ID"}}, //TODO: It should fail } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/schema/lists/base/idList_test.go b/schema/lists/base/idList_test.go index 4c475df8f..72100f68d 100644 --- a/schema/lists/base/idList_test.go +++ b/schema/lists/base/idList_test.go @@ -51,6 +51,7 @@ func Test_idList_GetList(t *testing.T) { want []ids.ID }{ {"+ve with nil", fields{NewList()}, []ids.ID{}}, + {"+ve", fields{NewList(idsToListables([]ids.ID{NewStringID("Data")}...)...)}, []ids.ID{NewStringID("Data").(ids.ID)}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -77,7 +78,7 @@ func Test_idList_Remove(t *testing.T) { args args want lists.IDList }{ - {"+ve with no removal", fields{NewList(idsToListables(NewStringID("ID1"), NewStringID("ID2"), NewStringID("ID3"))...)}, args{}, idList{NewList(idsToListables(NewStringID("ID1"), NewStringID("ID2"), NewStringID("ID3"))...)}}, + {"-ve with no removal", fields{NewList(idsToListables(NewStringID("ID1"), NewStringID("ID2"), NewStringID("ID3"))...)}, args{}, idList{NewList(idsToListables(NewStringID("ID1"), NewStringID("ID2"), NewStringID("ID3"))...)}}, {"+ve with removal", fields{NewList(idsToListables(NewStringID("ID1"), NewStringID("ID2"), NewStringID("ID3"))...)}, args{[]ids.ID{NewStringID("ID3")}}, idList{NewList(idsToListables(NewStringID("ID1"), NewStringID("ID2"))...)}}, } for _, tt := range tests { @@ -108,7 +109,7 @@ func Test_idList_Search(t *testing.T) { }{ {"+ve with nil", fields{NewList(idsToListables([]ids.ID{}...)...)}, args{NewStringID("ID")}, 0, false}, // TODO report issue {"+ve", fields{NewList(idsToListables([]ids.ID{NewStringID("ID")}...)...)}, args{NewStringID("ID")}, 0, true}, - {"+ve with no entry", fields{NewList(idsToListables([]ids.ID{NewStringID("ID")}...)...)}, args{NewStringID("ID1")}, 1, false}, + {"-ve with no entry", fields{NewList(idsToListables([]ids.ID{NewStringID("ID")}...)...)}, args{NewStringID("ID1")}, 1, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/schema/lists/base/list_test.go b/schema/lists/base/list_test.go index dd93e3f38..6d4cf7dd1 100644 --- a/schema/lists/base/list_test.go +++ b/schema/lists/base/list_test.go @@ -4,14 +4,19 @@ package base import ( + "github.com/AssetMantle/modules/schema/ids/base" "github.com/AssetMantle/modules/schema/lists" baseProperties "github.com/AssetMantle/modules/schema/properties/base" "github.com/AssetMantle/modules/schema/traits" + "github.com/stretchr/testify/assert" "reflect" "testing" ) func TestNewList(t *testing.T) { + assert.Panics(t, func() { + NewList(base.NewPropertyID(NewStringID("ID"), NewStringID("Data")), NewStringID("ID")) + }) type args struct { listables []traits.Listable } diff --git a/schema/lists/utilities/propertyList_test.go b/schema/lists/utilities/propertyList_test.go index 2f7c3b3fa..aeff33da7 100644 --- a/schema/lists/utilities/propertyList_test.go +++ b/schema/lists/utilities/propertyList_test.go @@ -24,7 +24,6 @@ func TestReadMetaProperties(t *testing.T) { want lists.PropertyList wantErr bool }{ - // TODO: Add test cases. {"+ve with empty string", args{""}, base.NewPropertyList([]properties2.Property{}...), false}, {"+ve", args{"ID:S|Data,ID1:S|Data1,ID2:S|Data2"}, base.NewPropertyList([]properties2.Property{baseProperties.NewMetaProperty(baseIds.NewStringID("ID"), baseData.NewStringData("Data")), baseProperties.NewMetaProperty(baseIds.NewStringID("ID1"), baseData.NewStringData("Data1")), baseProperties.NewMetaProperty(baseIds.NewStringID("ID2"), baseData.NewStringData("Data2"))}...), false}, } diff --git a/schema/parameters/base/parameter_test.go b/schema/parameters/base/parameter_test.go index 5e2a78614..6d3283617 100644 --- a/schema/parameters/base/parameter_test.go +++ b/schema/parameters/base/parameter_test.go @@ -253,7 +253,6 @@ func Test_parameter_Validate(t *testing.T) { fields fields wantErr bool }{ - // TODO: Add test cases. {"+ve with stringData", fields{id, testData, dummyValidator}, false}, {"+ve with decData", fields{baseIDs.NewStringID("ID"), baseData.NewDecData(sdkTypes.SmallestDec()), dummyValidator}, false}, } diff --git a/schema/properties/base/mesaProperty_test.go b/schema/properties/base/mesaProperty_test.go index b6fb2df6a..bd3752797 100644 --- a/schema/properties/base/mesaProperty_test.go +++ b/schema/properties/base/mesaProperty_test.go @@ -36,7 +36,6 @@ func TestNewEmptyMesaPropertyFromID(t *testing.T) { args args want properties.Property }{ - // TODO: Add test cases. {"+ve", args{testPropertyID}, mesaProperty{ID: testPropertyID}}, {"+ve with nil", args{}, mesaProperty{}}, } @@ -61,7 +60,6 @@ func TestNewMesaProperty(t *testing.T) { want properties.Property wantPanic bool }{ - // TODO: Add test cases. {"nil", args{}, mesaProperty{}, true}, {"+ve", args{testKey, testData}, mesaProperty{testPropertyID, testData.GetID()}, false}, } @@ -91,7 +89,6 @@ func Test_mesaPropertyFromInterface(t *testing.T) { want mesaProperty wantErr bool }{ - // TODO: Add test cases. {"+ve with nil", args{}, mesaProperty{}, true}, {"+ve", args{testMesaProperty}, mesaProperty{testMesaPropertyID, testData.GetID()}, false}, } @@ -124,7 +121,6 @@ func Test_mesaProperty_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"+ve compare with property with no Data", fields{testMesaPropertyID, testData.GetID()}, args{mesaProperty{ID: base.NewPropertyID(base.NewStringID("ID"), base.NewStringID("S"))}}, 0}, {"+ve", fields{testMesaPropertyID, testData.GetID()}, args{mesaProperty{ID: base.NewPropertyID(base.NewStringID("ID"), base.NewStringID("S")), DataID: NewStringData("Data2").GetID()}}, 0}, {"+ve", fields{testMesaPropertyID, testData.GetID()}, args{testMesaProperty}, 0}, @@ -153,7 +149,6 @@ func Test_mesaProperty_GetDataID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve with nil", fields{}, nil}, {"+ve", fields{testMesaPropertyID, testData.GetID()}, testData.GetID()}, } @@ -182,7 +177,6 @@ func Test_mesaProperty_GetHash(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve", fields{testMesaPropertyID, testData.GetID()}, testData.GetID().GetHashID()}, } for _, tt := range tests { @@ -209,7 +203,6 @@ func Test_mesaProperty_GetID(t *testing.T) { fields fields want ids.PropertyID }{ - // TODO: Add test cases. {"+ve with nil", fields{}, nil}, {"+ve", fields{testMesaPropertyID, testData.GetID()}, testMesaPropertyID}, } @@ -238,7 +231,6 @@ func Test_mesaProperty_GetKey(t *testing.T) { fields fields want ids.StringID }{ - // TODO: Add test cases. {"+ve", fields{testMesaPropertyID, testData.GetID()}, testKey}, } for _, tt := range tests { @@ -265,7 +257,6 @@ func Test_mesaProperty_GetType(t *testing.T) { fields fields want ids.StringID }{ - // TODO: Add test cases. {"+ve", fields{testMesaPropertyID, testData.GetID()}, base.NewStringID("S")}, } for _, tt := range tests { @@ -292,7 +283,6 @@ func Test_mesaProperty_IsMesa(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{testMesaPropertyID, testData.GetID()}, true}, } for _, tt := range tests { @@ -319,7 +309,6 @@ func Test_mesaProperty_IsMeta(t *testing.T) { fields fields want bool }{ - // TODO: Add test cases. {"+ve", fields{testMesaPropertyID, testData.GetID()}, false}, } for _, tt := range tests { diff --git a/schema/properties/base/metaProperty_test.go b/schema/properties/base/metaProperty_test.go index 66092f7ea..ae3760833 100644 --- a/schema/properties/base/metaProperty_test.go +++ b/schema/properties/base/metaProperty_test.go @@ -32,7 +32,6 @@ func TestNewEmptyMetaPropertyFromID(t *testing.T) { args args want properties.MetaProperty }{ - // TODO: Add test cases. {"+ve", args{testPropertyID}, metaProperty{ID: testPropertyID}}, {"+ve with nil", args{}, metaProperty{}}, } @@ -57,7 +56,6 @@ func TestNewMetaProperty(t *testing.T) { want properties.MetaProperty shouldPanic bool }{ - // TODO: Add test cases. {"+ve", args{testKey, testData}, metaProperty{testPropertyID, testData}, false}, {"+ve", args{nil, nil}, metaProperty{nil, nil}, true}, } @@ -87,7 +85,6 @@ func Test_metaProperty_Compare(t *testing.T) { args args want int }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, args{testMetaProperty}, 0}, {"+ve compare with metaProperty with no Data", fields{testPropertyID, testData}, args{metaProperty{ID: base.NewPropertyID(base.NewStringID("ID"), base.NewStringID("S"))}}, 0}, {"+ve", fields{testPropertyID, testData}, args{metaProperty{ID: base.NewPropertyID(base.NewStringID("ID"), base.NewStringID("S")), Data: NewStringData("Data2")}}, 0}} @@ -115,7 +112,6 @@ func Test_metaProperty_GetData(t *testing.T) { fields fields want data.Data }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, testData}, {"+ve with nil", fields{}, nil}, } @@ -143,7 +139,6 @@ func Test_metaProperty_GetDataID(t *testing.T) { fields fields want ids.DataID }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, testMetaProperty.GetData().GetID()}, } for _, tt := range tests { @@ -170,7 +165,6 @@ func Test_metaProperty_GetID(t *testing.T) { fields fields want ids.PropertyID }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, testPropertyID}, {"+ve", fields{}, metaProperty{}.ID}, } @@ -198,7 +192,6 @@ func Test_metaProperty_GetKey(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, testKey}, } for _, tt := range tests { @@ -225,7 +218,6 @@ func Test_metaProperty_GetType(t *testing.T) { fields fields want ids.ID }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, testData.GetType()}, } for _, tt := range tests { @@ -252,7 +244,6 @@ func Test_metaProperty_RemoveData(t *testing.T) { fields fields want properties.Property }{ - // TODO: Add test cases. {"+ve", fields{testPropertyID, testData}, mesaProperty{ID: testPropertyID, DataID: testData.GetID()}}, } for _, tt := range tests { diff --git a/schema/properties/utilities/metaProperty_test.go b/schema/properties/utilities/metaProperty_test.go index 7df0cae72..e3231cd36 100644 --- a/schema/properties/utilities/metaProperty_test.go +++ b/schema/properties/utilities/metaProperty_test.go @@ -23,7 +23,6 @@ func TestReadMetaProperty(t *testing.T) { want properties.MetaProperty wantErr bool }{ - // TODO: Add test cases. {"+ve with empty string", args{""}, nil, true}, {"+ve", args{"id:S|Data"}, base.NewMetaProperty(baseIDs.NewStringID("id"), baseData.NewStringData("Data")), false}, {"-ve incorrectFormat", args{"idS|Data"}, nil, true}, diff --git a/schema/qualified/base/immutables_test.go b/schema/qualified/base/immutables_test.go index 80f858fbb..8dad88719 100644 --- a/schema/qualified/base/immutables_test.go +++ b/schema/qualified/base/immutables_test.go @@ -26,7 +26,6 @@ func TestNewImmutables(t *testing.T) { args args want qualified.Immutables }{ - // TODO: Add test cases. {"+ve", args{}, immutables{}}, {"+ve", args{testImmutablePropertyList}, immutables{testImmutablePropertyList}}, } @@ -52,7 +51,6 @@ func Test_immutables_GenerateHashID(t *testing.T) { fields fields want ids.HashID }{ - // TODO: Add test cases. {"+ve", fields{base.NewPropertyList()}, baseIDs.GenerateHashID([][]byte{}...)}, {"+ve", fields{testImmutablePropertyList}, baseIDs.GenerateHashID(metaList2...)}, } @@ -78,7 +76,6 @@ func Test_immutables_GetImmutablePropertyList(t *testing.T) { fields fields want lists.PropertyList }{ - // TODO: Add test cases. {"+ve with nil", fields{base.NewPropertyList()}, base.NewPropertyList()}, {"+ve", fields{testImmutablePropertyList}, immutables{testImmutablePropertyList}.PropertyList}, } diff --git a/schema/qualified/base/mutables_test.go b/schema/qualified/base/mutables_test.go index 3f637a909..8472dcfd2 100644 --- a/schema/qualified/base/mutables_test.go +++ b/schema/qualified/base/mutables_test.go @@ -26,7 +26,6 @@ func TestNewMutables(t *testing.T) { args args want qualified.Mutables }{ - // TODO: Add test cases. {"+ve", args{}, mutables{}}, {"+ve", args{base.NewPropertyList(testMutableProperties)}, mutables{base.NewPropertyList(testMutableProperties)}}, } @@ -49,7 +48,6 @@ func Test_mutables_GetMutablePropertyList(t *testing.T) { fields fields want lists.PropertyList }{ - // TODO: Add test cases. {"+ve", fields{}, base.NewPropertyList()}, {"+ve", fields{base.NewPropertyList(testMutableProperties)}, mutables{base.NewPropertyList(testMutableProperties)}.PropertyList}, } @@ -81,7 +79,6 @@ func Test_mutables_Mutate(t *testing.T) { args args want qualified.Mutables }{ - // TODO: Add test cases. {"+ve", fields{}, args{}, mutables{}}, {"+ve mutate", fields{base.NewPropertyList(testMutableProperties)}, args{[]properties.Property{testMutableProperties1}}, mutables{base.NewPropertyList(testMutableProperties).Mutate(testMutableProperties1)}}, // TODO: it seems incorrect, not failing for wrong check {"+ve nil mutate", fields{base.NewPropertyList(testMutableProperties)}, args{}, mutables{base.NewPropertyList(testMutableProperties)}},