Skip to content

Commit

Permalink
retiring:legacy amino
Browse files Browse the repository at this point in the history
Signed-off-by: Deepanshu Tripathi <[email protected]>
  • Loading branch information
deepanshutr committed Sep 2, 2024
1 parent 17b2dc7 commit 51cdf2e
Show file tree
Hide file tree
Showing 45 changed files with 36 additions and 3,188 deletions.
30 changes: 1 addition & 29 deletions x/assets/mappable/mappable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
})
}
}
73 changes: 0 additions & 73 deletions x/assets/queries/asset/query_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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})

Expand Down
67 changes: 0 additions & 67 deletions x/assets/transactions/burn/transaction_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
79 changes: 0 additions & 79 deletions x/assets/transactions/define/transaction_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 51cdf2e

Please sign in to comment.