diff --git a/x/assets/mappable/mappable_test.go b/x/assets/mappable/mappable_test.go index 803ce009d..0a24dcd42 100644 --- a/x/assets/mappable/mappable_test.go +++ b/x/assets/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" documentsSchema "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,9 +17,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/AssetMantle/schema/qualified" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestInput() (ids.ClassificationID, qualified.Immutables, qualified.Mutables, *Mappable) { @@ -65,29 +63,3 @@ func TestNewMappable(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - _, _, _, testMappable := createTestInput() - type fields struct { - Document *Mappable - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testMappable}, args{legacyAmino: codec.NewLegacyAmino()}}, - {"+ve nil", fields{&Mappable{nil}}, args{legacyAmino: codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - as := &Mappable{ - Asset: tt.fields.Document.Asset, - } - as.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/assets/queries/asset/query_request_test.go b/x/assets/queries/asset/query_request_test.go index fe95a0660..9a2e71a77 100644 --- a/x/assets/queries/asset/query_request_test.go +++ b/x/assets/queries/asset/query_request_test.go @@ -16,7 +16,6 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" "reflect" "testing" ) @@ -70,78 +69,6 @@ func Test_queryRequestFromInterface(t *testing.T) { } } -func Test_queryRequest_Decode(t *testing.T) { - encodedQuery, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedQuery1, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID().(*baseIDs.AssetID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedQuery}, newQueryRequest(testAssetID), false}, - {"+ve", fields{key.NewKey(baseIDs.PrototypeAssetID()).(*key.Key)}, args{encodedQuery1}, newQueryRequest(baseIDs.PrototypeAssetID().(*baseIDs.AssetID)), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedQuery, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedQuery1, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID().(*baseIDs.AssetID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedQuery, false}, - {"+ve with nil", fields{key.NewKey(baseIDs.PrototypeAssetID().(*baseIDs.AssetID)).(*key.Key)}, encodedQuery1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID}) diff --git a/x/assets/transactions/burn/transaction_request_test.go b/x/assets/transactions/burn/transaction_request_test.go index 3e38710a1..d5ffc1fa0 100644 --- a/x/assets/transactions/burn/transaction_request_test.go +++ b/x/assets/transactions/burn/transaction_request_test.go @@ -4,12 +4,10 @@ package burn import ( - "encoding/json" "fmt" "reflect" "testing" - baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" sdkTypes "github.com/cosmos/cosmos-sdk/types" @@ -104,43 +102,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - AssetID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID.(*baseIDs.IdentityID), testAssetID.(*baseIDs.AssetID)}))}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), testAssetID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -201,34 +162,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - AssetID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/define/transaction_request_test.go b/x/assets/transactions/define/transaction_request_test.go index c648cf477..8b269e218 100644 --- a/x/assets/transactions/define/transaction_request_test.go +++ b/x/assets/transactions/define/transaction_request_test.go @@ -4,13 +4,11 @@ package define import ( - "encoding/json" "fmt" baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "reflect" "testing" @@ -128,49 +126,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}))}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -243,40 +198,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/deputize/transaction_request_test.go b/x/assets/transactions/deputize/transaction_request_test.go index 465c16f57..d30ed0bc9 100644 --- a/x/assets/transactions/deputize/transaction_request_test.go +++ b/x/assets/transactions/deputize/transaction_request_test.go @@ -4,7 +4,6 @@ package deputize import ( - "encoding/json" "fmt" baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -141,59 +140,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, fromID, classificationID, mutableMetaProperties, true, true, true, true, true, true}))}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -286,50 +232,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/mint/transaction_request_test.go b/x/assets/transactions/mint/transaction_request_test.go index fa1111bde..c62fbd4fb 100644 --- a/x/assets/transactions/mint/transaction_request_test.go +++ b/x/assets/transactions/mint/transaction_request_test.go @@ -4,7 +4,6 @@ package mint import ( - "encoding/json" "fmt" baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -135,53 +134,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, fromID, classificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}))}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -262,44 +214,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/mutate/transaction_request_test.go b/x/assets/transactions/mutate/transaction_request_test.go index 2fac005e9..c7c9b7a6f 100644 --- a/x/assets/transactions/mutate/transaction_request_test.go +++ b/x/assets/transactions/mutate/transaction_request_test.go @@ -4,7 +4,6 @@ package mutate import ( - "encoding/json" "fmt" "reflect" "testing" @@ -118,48 +117,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { }) } } - -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, testAssetID, mutableMetaProperties, mutableProperties}))}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -228,38 +185,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/renumerate/transaction_request_test.go b/x/assets/transactions/renumerate/transaction_request_test.go index 5f0cdab69..a1e4a8437 100644 --- a/x/assets/transactions/renumerate/transaction_request_test.go +++ b/x/assets/transactions/renumerate/transaction_request_test.go @@ -4,7 +4,6 @@ package renumerate import ( - "encoding/json" "fmt" "reflect" "testing" @@ -103,43 +102,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - AssetID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, testAssetID}))}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), testAssetID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -200,34 +162,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - AssetID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/revoke/transaction_request_test.go b/x/assets/transactions/revoke/transaction_request_test.go index 9474c1f73..a55c8ef8e 100644 --- a/x/assets/transactions/revoke/transaction_request_test.go +++ b/x/assets/transactions/revoke/transaction_request_test.go @@ -4,7 +4,6 @@ package revoke import ( - "encoding/json" "fmt" "reflect" "testing" @@ -107,45 +106,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, fromID, classificationID}))}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -210,36 +170,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/send/transaction_request_test.go b/x/assets/transactions/send/transaction_request_test.go index 7fed43a68..f88ba5577 100644 --- a/x/assets/transactions/send/transaction_request_test.go +++ b/x/assets/transactions/send/transaction_request_test.go @@ -4,22 +4,18 @@ package send import ( - "encoding/json" "fmt" baseIDs "github.com/AssetMantle/schema/ids/base" "reflect" "testing" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -117,49 +113,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String())) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - AssetID string - Value string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, args{jsonMessage}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -228,38 +181,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - AssetID string - Value string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/unwrap/transaction_request_test.go b/x/assets/transactions/unwrap/transaction_request_test.go index 3d52fe4e5..835f858bf 100644 --- a/x/assets/transactions/unwrap/transaction_request_test.go +++ b/x/assets/transactions/unwrap/transaction_request_test.go @@ -4,7 +4,6 @@ package unwrap import ( - "encoding/json" "fmt" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" @@ -16,10 +15,8 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" - "github.com/stretchr/testify/require" "reflect" "testing" ) @@ -120,45 +117,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, fromID.AsString(), coins.String())) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - Coins string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), coins.String()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -219,34 +177,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - Coins string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/assets/transactions/wrap/message_test.go b/x/assets/transactions/wrap/message_test.go index 6c2c47693..0f7a9cf9b 100644 --- a/x/assets/transactions/wrap/message_test.go +++ b/x/assets/transactions/wrap/message_test.go @@ -11,7 +11,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -189,34 +188,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - Coins types.Coins - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, coins}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_NewMessage(t *testing.T) { type args struct { from types.AccAddress diff --git a/x/assets/transactions/wrap/transaction_request_test.go b/x/assets/transactions/wrap/transaction_request_test.go index 13173a9c5..4a1493820 100644 --- a/x/assets/transactions/wrap/transaction_request_test.go +++ b/x/assets/transactions/wrap/transaction_request_test.go @@ -4,26 +4,22 @@ package wrap import ( - "encoding/json" "fmt" baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "reflect" "testing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -117,45 +113,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, fromID.AsString(), coins.String())) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - Coins string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), coins.String()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -216,34 +173,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - Coins string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/classifications/mappable/mappable_test.go b/x/classifications/mappable/mappable_test.go index 43ad9511b..116ed5810 100644 --- a/x/classifications/mappable/mappable_test.go +++ b/x/classifications/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" documentsSchema "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,9 +17,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/AssetMantle/schema/qualified" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestInput() (ids.ClassificationID, qualified.Immutables, qualified.Mutables, *Mappable) { @@ -65,29 +63,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - _, _, _, testMappable := createTestInput() - type fields struct { - Document *Mappable - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testMappable}, args{legacyAmino: codec.NewLegacyAmino()}}, - {"+ve nil", fields{&Mappable{nil}}, args{legacyAmino: codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - as := &Mappable{ - Classification: tt.fields.Document.Classification, - } - as.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/identities/mappable/mappable_test.go b/x/identities/mappable/mappable_test.go index 9fc182331..16843fabb 100644 --- a/x/identities/mappable/mappable_test.go +++ b/x/identities/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,9 +17,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/AssetMantle/schema/qualified" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestInput() (documents.Identity, ids.ClassificationID, qualified.Immutables, qualified.Mutables) { @@ -68,30 +66,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_identity_RegisterCodec(t *testing.T) { - testIdentity, _, _, _ := createTestInput() - - type fields struct { - Document documents.Identity - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testIdentity}, args{codec.NewLegacyAmino()}}, - {"+ve nil", fields{nil}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - id := &Mappable{ - Identity: tt.fields.Document.Get().(*baseDocuments.Document), - } - id.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/identities/transactions/define/transaction_request_test.go b/x/identities/transactions/define/transaction_request_test.go index ceda56ad9..f50772450 100644 --- a/x/identities/transactions/define/transaction_request_test.go +++ b/x/identities/transactions/define/transaction_request_test.go @@ -4,7 +4,6 @@ package define import ( - "encoding/json" "reflect" "testing" @@ -13,7 +12,6 @@ import ( "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -122,57 +120,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" - immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutablePropertiesString := "defaultMutable1:S|defaultMutable1" - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) - jsonMessage, _ := json.Marshal(transactionRequest{commonTransactionRequest, "fromID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}) - - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, args{jsonMessage}, transactionRequest{CommonTransactionRequest: commonTransactionRequest, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" @@ -274,46 +221,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" - immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutablePropertiesString := "defaultMutable1:S|defaultMutable1" - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" diff --git a/x/identities/transactions/deputize/transaction_request_test.go b/x/identities/transactions/deputize/transaction_request_test.go index 2b588553f..1fdbff2bf 100644 --- a/x/identities/transactions/deputize/transaction_request_test.go +++ b/x/identities/transactions/deputize/transaction_request_test.go @@ -4,12 +4,10 @@ package deputize import ( - "encoding/json" "reflect" "testing" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -120,62 +118,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - maintainedProperty := "maintainedProperties:S|maintainedProperties" - commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) - jsonMessage, _ := json.Marshal(newTransactionRequest(commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false)) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, args{jsonMessage}, transactionRequest{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" @@ -267,52 +209,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - maintainedProperty := "maintainedProperties:S|maintainedProperties" - commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" diff --git a/x/identities/transactions/issue/transaction_request_test.go b/x/identities/transactions/issue/transaction_request_test.go index 1809b1392..644a2db1e 100644 --- a/x/identities/transactions/issue/transaction_request_test.go +++ b/x/identities/transactions/issue/transaction_request_test.go @@ -4,7 +4,6 @@ package issue import ( - "encoding/json" "fmt" "reflect" "testing" @@ -159,59 +158,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.Equal(t, nil, err) - jsonMessage1, err := json.Marshal(newTransactionRequest(commonTransactionRequest, "", "", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.Equal(t, nil, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - - {"+ve", fields{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{commonTransactionRequest, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - {"+ve", fields{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage1}, transactionRequest{commonTransactionRequest, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) type fields struct { @@ -297,44 +243,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) commonTransactionRequest1 := helpers.PrototypeCommonTransactionRequest() diff --git a/x/identities/transactions/name/transaction_request_test.go b/x/identities/transactions/name/transaction_request_test.go index f96157a64..9eda9eff0 100644 --- a/x/identities/transactions/name/transaction_request_test.go +++ b/x/identities/transactions/name/transaction_request_test.go @@ -4,7 +4,6 @@ package name import ( - "encoding/json" "reflect" "testing" @@ -109,43 +108,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - _, _, _, _, fromAccAddress, commonTransactionRequest := CreateTestInputForRequest(t) - - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - NubID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, "nubID"}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), baseIDs.NewStringID("nubID").(*baseIDs.StringID)}))}, transactionRequest{commonTransactionRequest, "nubID"}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - Name: tt.fields.NubID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { _, _, _, _, _, commonTransactionRequest := CreateTestInputForRequest(t) @@ -206,34 +168,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - _, _, _, _, _, commonTransactionRequest := CreateTestInputForRequest(t) - - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - NubID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, "nubID"}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - Name: tt.fields.NubID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { _, _, _, _, _, commonTransactionRequest := CreateTestInputForRequest(t) diff --git a/x/identities/transactions/provision/transaction_request_test.go b/x/identities/transactions/provision/transaction_request_test.go index 27a8df25f..3432f68fa 100644 --- a/x/identities/transactions/provision/transaction_request_test.go +++ b/x/identities/transactions/provision/transaction_request_test.go @@ -4,7 +4,6 @@ package provision import ( - "encoding/json" "reflect" "testing" @@ -14,7 +13,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -116,44 +114,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - commonTransactionRequest, testToAddress, testFromID := createTestInput(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - To string - IdentityID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{sdkTypes.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c").String(), sdkTypes.AccAddress(testToAddress).String(), testFromID}))}, transactionRequest{commonTransactionRequest, testToAddress, testFromID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { @@ -221,36 +181,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - commonTransactionRequest, testToAddress, testFromID := createTestInput(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - To string - IdentityID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { diff --git a/x/identities/transactions/quash/transaction_request_test.go b/x/identities/transactions/quash/transaction_request_test.go index f4464ae18..32e8562c1 100644 --- a/x/identities/transactions/quash/transaction_request_test.go +++ b/x/identities/transactions/quash/transaction_request_test.go @@ -4,7 +4,6 @@ package quash import ( - "encoding/json" "reflect" "testing" @@ -14,7 +13,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -116,44 +114,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - commonTransactionRequest, testToAddress, testFromID := createTestInput(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - IdentityID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c").String(), testFromID, testFromID}))}, transactionRequest{commonTransactionRequest, testToAddress, testFromID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { @@ -219,36 +179,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - commonTransactionRequest, testToAddress, testFromID := createTestInput(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - IdentityID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { diff --git a/x/identities/transactions/revoke/transaction_request_test.go b/x/identities/transactions/revoke/transaction_request_test.go index cba75346d..11b89486b 100644 --- a/x/identities/transactions/revoke/transaction_request_test.go +++ b/x/identities/transactions/revoke/transaction_request_test.go @@ -4,7 +4,6 @@ package revoke import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,7 +14,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -121,48 +119,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - commonTransactionRequest, fromAddress, testFromID, testToID, testClassificationID := createTestInput(t) - fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) - require.Nil(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), testFromID, testToID, testClassificationID}))}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) type fields struct { @@ -232,38 +188,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) type fields struct { diff --git a/x/identities/transactions/unprovision/transaction_request_test.go b/x/identities/transactions/unprovision/transaction_request_test.go index 480f102de..dcd1b5671 100644 --- a/x/identities/transactions/unprovision/transaction_request_test.go +++ b/x/identities/transactions/unprovision/transaction_request_test.go @@ -4,7 +4,6 @@ package unprovision import ( - "encoding/json" "reflect" "testing" @@ -14,7 +13,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -126,44 +124,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - testIdentityID, toAddress, toAccAddress, _, commonTransactionRequest := createInputForMessage(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - To string - IdentityID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, toAddress, testIdentityID.AsString()}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c").String(), toAccAddress.String(), testIdentityID}))}, transactionRequest{commonTransactionRequest, toAddress, testIdentityID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) type fields struct { @@ -229,36 +189,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - To string - IdentityID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve wit nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{commonTransactionRequest, toAddress, testIdentityID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) type fields struct { diff --git a/x/identities/transactions/update/transaction_request_test.go b/x/identities/transactions/update/transaction_request_test.go index f789b9076..4c08eaf8b 100644 --- a/x/identities/transactions/update/transaction_request_test.go +++ b/x/identities/transactions/update/transaction_request_test.go @@ -4,7 +4,6 @@ package update import ( - "encoding/json" "reflect" "testing" @@ -131,50 +130,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) - jsonMessage, _ := json.Marshal(transactionRequest{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}) - - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) @@ -251,40 +206,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) - - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) diff --git a/x/maintainers/mappable/mappable_test.go b/x/maintainers/mappable/mappable_test.go index bcbf8e701..8ad07ac46 100644 --- a/x/maintainers/mappable/mappable_test.go +++ b/x/maintainers/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/documents/base" @@ -14,9 +15,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestData() documents.Maintainer { @@ -64,28 +62,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - testMaintainer := createTestData() - type fields struct { - Maintainer documents.Maintainer - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testMaintainer}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Maintainer: tt.fields.Maintainer.Get().(*base.Document), - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/maintainers/queries/maintainer/query_request_test.go b/x/maintainers/queries/maintainer/query_request_test.go index bc11eb621..ecd79e5b7 100644 --- a/x/maintainers/queries/maintainer/query_request_test.go +++ b/x/maintainers/queries/maintainer/query_request_test.go @@ -8,15 +8,13 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -68,78 +66,6 @@ func Test_queryRequestFromInterface(t *testing.T) { } } -func Test_queryRequest_Decode(t *testing.T) { - encodedQuery, err := (&QueryRequest{testKey}).Encode() - require.NoError(t, err) - encodedQuery1, err := (&QueryRequest{testKey1}).Encode() - require.NoError(t, err) - type fields struct { - key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedQuery}, &QueryRequest{testKey}, false}, - {"+ve", fields{testKey1}, args{encodedQuery1}, &QueryRequest{testKey1}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedQuery, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(&QueryRequest{testKey}) - require.NoError(t, err) - encodedQuery1, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(&QueryRequest{testKey1}) - require.NoError(t, err) - type fields struct { - key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedQuery, false}, - {"+ve with nil", fields{testKey1}, encodedQuery1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.MaintainerID}) viper.Set(constants.MaintainerID.GetName(), testMaintainerID.AsString()) diff --git a/x/metas/mappable/mappable_test.go b/x/metas/mappable/mappable_test.go index 99be94491..a0fd502d9 100644 --- a/x/metas/mappable/mappable_test.go +++ b/x/metas/mappable/mappable_test.go @@ -7,11 +7,9 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/data/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func TestNewMappable(t *testing.T) { @@ -50,27 +48,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - type fields struct { - Data data.Data - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{base.NewStringData("Data")}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Data: tt.fields.Data.ToAnyData().(*base.AnyData), - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/metas/queries/meta/query_request_test.go b/x/metas/queries/meta/query_request_test.go index 9995be8e0..e0cc7283a 100644 --- a/x/metas/queries/meta/query_request_test.go +++ b/x/metas/queries/meta/query_request_test.go @@ -8,16 +8,14 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -65,79 +63,6 @@ func Test_queryRequestFromInterface(t *testing.T) { }) } } - -func Test_queryRequest_Decode(t *testing.T) { - encodedQuery, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testDataID)) - require.NoError(t, err) - encodedQuery1, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeDataID().(*baseIDs.DataID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedQuery}, newQueryRequest(testDataID), false}, - {"+ve with nil", fields{key.NewKey(baseIDs.PrototypeDataID()).(*key.Key)}, args{encodedQuery1}, newQueryRequest(baseIDs.PrototypeDataID().(*baseIDs.DataID)), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedQuery, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testDataID)) - require.NoError(t, err) - encodedQuery1, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeDataID().(*baseIDs.DataID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedQuery, false}, - {"+ve with nil", fields{key.NewKey(baseIDs.PrototypeDataID()).(*key.Key)}, encodedQuery1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.DataID}) viper.Set(constants.DataID.GetName(), testKey) diff --git a/x/metas/transactions/reveal/transaction_request_test.go b/x/metas/transactions/reveal/transaction_request_test.go index 19f56cd65..ea8610bcc 100644 --- a/x/metas/transactions/reveal/transaction_request_test.go +++ b/x/metas/transactions/reveal/transaction_request_test.go @@ -2,58 +2,3 @@ // SPDX-License-Identifier: Apache-2.0 package reveal - -import ( - "encoding/json" - "github.com/cosmos/cosmos-sdk/client" - "testing" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" -) - -func Test_Reveal_Request(t *testing.T) { - cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.Data}) - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - data := "S|newData" - commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() - testTransactionRequest := newTransactionRequest(commonTransactionRequest, data) - - require.Equal(t, transactionRequest{CommonTransactionRequest: commonTransactionRequest, Data: data}, testTransactionRequest) - require.Equal(t, nil, testTransactionRequest.Validate()) - - requestFromCLI, err := transactionRequest{}.FromCLI(cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())) - require.Equal(t, nil, err) - require.Equal(t, transactionRequest{CommonTransactionRequest: helpers.PrototypeCommonTransactionRequest(), Data: ""}, requestFromCLI) - - jsonMessage, _ := json.Marshal(testTransactionRequest) - transactionRequestUnmarshalled, err := transactionRequest{}.FromJSON(jsonMessage) - require.Equal(t, nil, err) - require.Equal(t, testTransactionRequest, transactionRequestUnmarshalled) - - randomUnmarshall, err := transactionRequest{}.FromJSON([]byte{}) - require.Equal(t, nil, randomUnmarshall) - require.NotNil(t, err) - - require.Equal(t, commonTransactionRequest, testTransactionRequest.GetCommonTransactionRequest()) - - require.Nil(t, err) - - msg2, err := newTransactionRequest(helpers.PrototypeCommonTransactionRequest(), data).MakeMsg() - require.NotNil(t, err) - require.Nil(t, msg2) - - msg2, err = newTransactionRequest(helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress), "randomString").MakeMsg() - require.NotNil(t, err) - require.Nil(t, msg2) - - require.Equal(t, transactionRequest{}, requestPrototype()) - require.NotPanics(t, func() { - requestPrototype().RegisterLegacyAminoCodec(codec.NewLegacyAmino()) - }) -} diff --git a/x/orders/mappable/mappable_test.go b/x/orders/mappable/mappable_test.go index 4a3d9b87d..dcdd63f3f 100644 --- a/x/orders/mappable/mappable_test.go +++ b/x/orders/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -14,9 +15,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var ( @@ -62,28 +60,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - type fields struct { - Order documents.Order - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testOrder}, args{codec.NewLegacyAmino()}}, - {"+ve nil", fields{nil}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Order: tt.fields.Order.Get().(*baseDocuments.Document), - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/orders/queries/order/query_request_test.go b/x/orders/queries/order/query_request_test.go index bc599faee..2848ce6f4 100644 --- a/x/orders/queries/order/query_request_test.go +++ b/x/orders/queries/order/query_request_test.go @@ -8,6 +8,9 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -16,11 +19,6 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -75,78 +73,6 @@ func Test_queryRequestFromInterface(t *testing.T) { } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID)) - require.NoError(t, err) - encodedReq1, err1 := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID1)) - require.NoError(t, err1) - type fields struct { - Key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedReq}, newQueryRequest(testOrderID), false}, - {"+ve", fields{testKey1}, args{encodedReq1}, newQueryRequest(testOrderID1), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID)) - require.NoError(t, err) - encodedReq1, err1 := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID1)) - require.NoError(t, err1) - type fields struct { - Key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedReq, false}, - {"+ve", fields{testKey1}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.OrderID}) diff --git a/x/orders/transactions/cancel/transaction_request_test.go b/x/orders/transactions/cancel/transaction_request_test.go index c765ba66f..d499139f9 100644 --- a/x/orders/transactions/cancel/transaction_request_test.go +++ b/x/orders/transactions/cancel/transaction_request_test.go @@ -4,7 +4,6 @@ package cancel import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -120,49 +116,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString())) - require.NoError(t, err) - jsonMessage1, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString())) - require.NoError(t, err) - - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - OrderID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, args{jsonMessage}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, false}, - {"+ve with nil", fields{commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString()}, args{jsonMessage1}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -224,35 +177,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - OrderID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, args{codec.NewLegacyAmino()}}, - {"+ve with nil", fields{commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/define/transaction_request_test.go b/x/orders/transactions/define/transaction_request_test.go index 403679a67..fbec54862 100644 --- a/x/orders/transactions/define/transaction_request_test.go +++ b/x/orders/transactions/define/transaction_request_test.go @@ -4,7 +4,6 @@ package define import ( - "encoding/json" "fmt" "reflect" "testing" @@ -13,15 +12,12 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -139,51 +135,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -256,40 +207,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/deputize/transaction_request_test.go b/x/orders/transactions/deputize/transaction_request_test.go index a4a26c151..98943ed06 100644 --- a/x/orders/transactions/deputize/transaction_request_test.go +++ b/x/orders/transactions/deputize/transaction_request_test.go @@ -4,7 +4,6 @@ package deputize import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -148,59 +144,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true)) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -289,48 +232,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/get/transaction_request_test.go b/x/orders/transactions/get/transaction_request_test.go index 656aede4f..ee8b124cb 100644 --- a/x/orders/transactions/get/transaction_request_test.go +++ b/x/orders/transactions/get/transaction_request_test.go @@ -4,7 +4,6 @@ package get import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -121,45 +117,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString())) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - OrderID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -222,34 +179,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - OrderID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/immediate/transaction_request_test.go b/x/orders/transactions/immediate/transaction_request_test.go index 0c585f5c0..6020ee70f 100644 --- a/x/orders/transactions/immediate/transaction_request_test.go +++ b/x/orders/transactions/immediate/transaction_request_test.go @@ -4,7 +4,6 @@ package immediate import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -171,65 +167,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -330,54 +267,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/make/transaction_request_test.go b/x/orders/transactions/make/transaction_request_test.go index 99c72d675..29420b90f 100644 --- a/x/orders/transactions/make/transaction_request_test.go +++ b/x/orders/transactions/make/transaction_request_test.go @@ -4,7 +4,6 @@ package make import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -169,65 +165,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -328,54 +265,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/modify/transaction_request_test.go b/x/orders/transactions/modify/transaction_request_test.go index 4ea99a267..083ebc8a5 100644 --- a/x/orders/transactions/modify/transaction_request_test.go +++ b/x/orders/transactions/modify/transaction_request_test.go @@ -4,7 +4,6 @@ package modify import ( - "encoding/json" "fmt" "reflect" "testing" @@ -14,15 +13,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -148,55 +144,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -277,44 +224,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/put/transaction_request_test.go b/x/orders/transactions/put/transaction_request_test.go index 5cadcf1a1..5c0254309 100644 --- a/x/orders/transactions/put/transaction_request_test.go +++ b/x/orders/transactions/put/transaction_request_test.go @@ -4,7 +4,6 @@ package put import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -146,53 +142,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight)) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - tt.fields.commonTransactionRequest, - tt.fields.FromID, - tt.fields.MakerAssetID, - tt.fields.TakerAssetID, - tt.fields.MakerSplit, - tt.fields.TakerSplit, - tt.fields.ExpiryHeight, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -269,42 +218,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - tt.fields.commonTransactionRequest, - tt.fields.FromID, - tt.fields.MakerAssetID, - tt.fields.TakerAssetID, - tt.fields.MakerSplit, - tt.fields.TakerSplit, - tt.fields.ExpiryHeight, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/revoke/transaction_request_test.go b/x/orders/transactions/revoke/transaction_request_test.go index 503a2d991..db5d19af1 100644 --- a/x/orders/transactions/revoke/transaction_request_test.go +++ b/x/orders/transactions/revoke/transaction_request_test.go @@ -4,7 +4,6 @@ package revoke import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -121,47 +117,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString())) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -226,36 +181,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - ToID string - ClassificationID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/orders/transactions/take/transaction_request_test.go b/x/orders/transactions/take/transaction_request_test.go index 3781534bf..08ff28164 100644 --- a/x/orders/transactions/take/transaction_request_test.go +++ b/x/orders/transactions/take/transaction_request_test.go @@ -4,7 +4,6 @@ package take import ( - "encoding/json" "fmt" "reflect" "testing" @@ -15,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -123,47 +119,6 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString())) - require.NoError(t, err) - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - TakerSplit string - OrderID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, args{jsonMessage}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest @@ -228,36 +183,6 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - commonTransactionRequest helpers.CommonTransactionRequest - FromID string - TakerSplit string - OrderID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - CommonTransactionRequest: tt.fields.commonTransactionRequest, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { commonTransactionRequest helpers.CommonTransactionRequest diff --git a/x/splits/mappable/mappable_test.go b/x/splits/mappable/mappable_test.go index 8de671acd..b7b4609a3 100644 --- a/x/splits/mappable/mappable_test.go +++ b/x/splits/mappable/mappable_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -55,27 +54,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - type fields struct { - Split *baseTypes.Split - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{split}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Split: tt.fields.Split, - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/splits/queries/balances/query_request_test.go b/x/splits/queries/balances/query_request_test.go index 7bca4476a..578a261bd 100644 --- a/x/splits/queries/balances/query_request_test.go +++ b/x/splits/queries/balances/query_request_test.go @@ -7,15 +7,13 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -62,78 +60,6 @@ func Test_queryRequestFromInterface(t *testing.T) { } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testIdentityID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeIdentityID())) - require.NoError(t, err1) - type fields struct { - identityID ids.IdentityID - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testIdentityID}, args{encodedReq}, newQueryRequest(testIdentityID), false}, - {"+ve", fields{baseIDs.PrototypeIdentityID()}, args{encodedReq1}, newQueryRequest(baseIDs.PrototypeIdentityID()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - IdentityID: tt.fields.identityID.(*baseIDs.IdentityID), - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testIdentityID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeIdentityID())) - require.NoError(t, err1) - type fields struct { - identityID ids.IdentityID - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testIdentityID}, encodedReq, false}, - {"+ve", fields{baseIDs.PrototypeIdentityID().(*baseIDs.IdentityID)}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - IdentityID: tt.fields.identityID.(*baseIDs.IdentityID), - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID}) diff --git a/x/splits/queries/split/query_request_test.go b/x/splits/queries/split/query_request_test.go index 44ab82f77..4824d3c64 100644 --- a/x/splits/queries/split/query_request_test.go +++ b/x/splits/queries/split/query_request_test.go @@ -9,6 +9,9 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -17,11 +20,6 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -73,78 +71,6 @@ func Test_queryRequestFromInterface(t *testing.T) { } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(splitID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeSplitID())) - require.NoError(t, err1) - type fields struct { - SplitID *baseIDs.SplitID - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{splitID}, args{encodedReq}, newQueryRequest(splitID), false}, - {"+ve", fields{baseIDs.PrototypeSplitID().(*baseIDs.SplitID)}, args{encodedReq1}, newQueryRequest(baseIDs.PrototypeSplitID()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: key.NewKey(tt.fields.SplitID).(*key.Key), - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(splitID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeSplitID())) - require.NoError(t, err1) - type fields struct { - SplitID *baseIDs.SplitID - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{splitID}, encodedReq, false}, - {"+ve", fields{baseIDs.PrototypeSplitID().(*baseIDs.SplitID)}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: key.NewKey(tt.fields.SplitID).(*key.Key), - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.SplitID}) diff --git a/x/splits/queries/supply/query_request_test.go b/x/splits/queries/supply/query_request_test.go index 2da88492c..bc9430e93 100644 --- a/x/splits/queries/supply/query_request_test.go +++ b/x/splits/queries/supply/query_request_test.go @@ -7,16 +7,14 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseDocuments "github.com/AssetMantle/schema/documents/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -63,78 +61,6 @@ func Test_queryRequestFromInterface(t *testing.T) { } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID())) - require.NoError(t, err1) - type fields struct { - AssetID *baseIDs.AssetID - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testAssetID}, args{encodedReq}, newQueryRequest(testAssetID), false}, - {"+ve", fields{baseIDs.PrototypeAssetID().(*baseIDs.AssetID)}, args{encodedReq1}, newQueryRequest(baseIDs.PrototypeAssetID()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - AssetID: tt.fields.AssetID, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID())) - require.NoError(t, err1) - type fields struct { - AssetID *baseIDs.AssetID - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testAssetID}, encodedReq, false}, - {"+ve", fields{baseIDs.PrototypeAssetID().(*baseIDs.AssetID)}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - AssetID: tt.fields.AssetID, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID})