Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema testcases fix merge with master #67

Merged
merged 5 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions data/base/height_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,20 @@ func Test_HeightDataGetID(t *testing.T) {
args data.HeightData
want ids.DataID
}{
{"+ve", NewHeightData(base.NewHeight(10)), &baseIDs.DataID{
TypeID: idsConstants.HeightDataTypeID.(*baseIDs.StringID),
HashID: baseIDs.GenerateHashID(NewHeightData(base.NewHeight(10)).Bytes()).(*baseIDs.HashID),
}},
{"+ve", &HeightData{&base.Height{-1}}, &baseIDs.DataID{
TypeID: idsConstants.HeightDataTypeID.(*baseIDs.StringID),
HashID: baseIDs.GenerateHashID().(*baseIDs.HashID),
}},
{"+ve",
NewHeightData(base.NewHeight(10)),
&baseIDs.DataID{
TypeID: idsConstants.HeightDataTypeID.(*baseIDs.StringID),
HashID: baseIDs.GenerateHashID(NewHeightData(base.NewHeight(10)).Bytes()).(*baseIDs.HashID),
},
},
{"+ve",
&HeightData{&base.Height{-1}},
&baseIDs.DataID{
TypeID: idsConstants.HeightDataTypeID.(*baseIDs.StringID),
HashID: baseIDs.GenerateHashID(NewHeightData(base.NewHeight(-1)).Bytes()).(*baseIDs.HashID),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -183,7 +189,7 @@ func Test_HeightDataZeroValue(t *testing.T) {
args data.HeightData
want data.Data
}{
{"+ve", NewHeightData(base.NewHeight(10)), &HeightData{&base.Height{-1}}},
{"+ve", NewHeightData(base.NewHeight(10)), &HeightData{&base.Height{0}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions data/base/list_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ func Test_listData_AsString(t *testing.T) {
args data.ListData
want string
}{
{"+ve", testListData, "Data1,,Data2"},
{"+ve", NewListData(NewHeightData(base.NewHeight(20)), NewHeightData(base.NewHeight(11))), "11,,20"},
{"+ve", NewListData(NewStringData("")), ""},
{"+ve", NewListData(NewHeightData(base.NewHeight(-1))), "-1"},
{"+ve", testListData, "S|Data1,,S|Data2"},
{"+ve", NewListData(NewHeightData(base.NewHeight(20)), NewHeightData(base.NewHeight(11))), "H|11,,H|20"},
{"+ve", NewListData(NewStringData("")), "S|"},
{"+ve", NewListData(NewHeightData(base.NewHeight(-1))), "H|-1"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions documents/base/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
want types.Height
}{
{"+ve", fields{Document: testDocumentWithBurn}, baseTypes.NewHeight(99)},
{"+ve", fields{Document: testDocument}, baseTypes.NewHeight(-1)},
{"+ve", fields{Document: testDocument}, baseTypes.NewHeight(0)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -79,7 +79,7 @@
fields fields
want types.Height
}{
{"+ve with default lock", fields{testDocument}, baseTypes.NewHeight(-1)},
{"+ve with default lock", fields{testDocument}, baseTypes.NewHeight(0)},
{"+ve with mutated", fields{testDocumentWithLock}, baseTypes.NewHeight(100)},
}
for _, tt := range tests {
Expand All @@ -94,7 +94,7 @@
}
}

func Test_asset_GetSupply(t *testing.T) {

Check failure on line 97 in documents/base/asset_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

97-119 lines are duplicate of `documents/base/classification_test.go:53-75` (dupl)
classificationID, immutables, _, testDocument := createTestInput()
testDocumentWithSupply := NewDocument(classificationID, immutables, baseQualified.NewMutables(base.NewPropertyList(baseProperties.NewMetaProperty(constants.SupplyProperty.GetKey(), baseData.NewNumberData(sdkTypes.NewInt(77))))))
type fields struct {
Expand Down
4 changes: 2 additions & 2 deletions documents/base/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ func Test_DocumentValidateBasic(t *testing.T) {
args documents.Document
want bool
}{
{"-ve 1", document1, true},
{"-ve 2", document2, true},
{"-ve 1", document1, false},
{"-ve 2", document2, false},
{"-ve 3", document4, true},
{"+ve 4", document3, false},
}
Expand Down
2 changes: 1 addition & 1 deletion documents/base/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func Test_identity_GetExpiry(t *testing.T) {
want types.Height
}{
{"+ve", fields{testIdentity1}, baseTypes.NewHeight(100)},
{"+ve", fields{testIdentity2}, baseTypes.NewHeight(-1)},
{"+ve", fields{testIdentity2}, baseTypes.NewHeight(0)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion ids/base/any_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

var (
testValidBase64String = "nBuFnhfmBVznCR9vS5/V1mqZim8aclm1jBlqR8NGU94="
testStringID = "testStringID"
testValidBase64URLString = "nBuFnhfmBVznCR9vS5/V1mqZim8aclm1jBlqR8NGU94="
testBytes, _ = base64.StdEncoding.DecodeString(testValidBase64String)
)
Expand Down Expand Up @@ -68,7 +69,7 @@ func Test_AnyIDFromString(t *testing.T) {
{"+ve", arg{constants.OrderIDType, testValidBase64String}, (&OrderID{&HashID{testBytes}}).ToAnyID(), nil},
{"+ve", arg{constants.PropertyIDType, strings.Join([]string{"keyID", "typeID"}, utilities.IDSeparator)}, (&PropertyID{&StringID{"keyID"}, &StringID{"typeID"}}).ToAnyID(), nil},
{"+ve", arg{constants.SplitIDType, strings.Join([]string{testValidBase64String, testValidBase64String}, utilities.IDSeparator)}, (&SplitID{&AssetID{&HashID{testBytes}}, &IdentityID{&HashID{testBytes}}}).ToAnyID(), nil},
{"+ve", arg{constants.StringIDType, testValidBase64String}, (&StringID{testValidBase64String}).ToAnyID(), nil},
{"+ve", arg{constants.StringIDType, testStringID}, (&StringID{testStringID}).ToAnyID(), nil},
{"+ve", arg{"", ""}, &AnyID{}, nil},
{"-ve", arg{"unknown", ""}, nil, fmt.Errorf("unknown type identifier is not recognised")},
}
Expand Down
2 changes: 1 addition & 1 deletion ids/base/data_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Test_DataIDFromString(t *testing.T) {
}{
{"+ve", strings.Join([]string{"S", testValidBase64URLString}, utilities.IDSeparator), &DataID{&StringID{"S"}, &HashID{testBytes}}, nil},
{"+ve", ".", PrototypeDataID(), nil},
{"+ve", "test", PrototypeDataID(), fmt.Errorf("expected composite id")},
{"+ve", "test", PrototypeDataID(), fmt.Errorf("invalid dataID string test")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ids/base/property_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Test_PropertyIDFromString(t *testing.T) {
}{
{"+ve", strings.Join([]string{"keyID", "typeID"}, utilities.IDSeparator), &PropertyID{&StringID{"keyID"}, &StringID{"typeID"}}, nil},
{"+ve", "", &PropertyID{&StringID{}, &StringID{}}, nil},
{"+ve", "test", &PropertyID{&StringID{}, &StringID{}}, fmt.Errorf("expected composite id")},
{"+ve", "test", &PropertyID{&StringID{}, &StringID{}}, fmt.Errorf("invalid propertyID string test")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions lists/base/property_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func anyPropertiesToProperties(anyProperties ...*base.AnyProperty) []properties.

return returnProperties
}

func propertiesToAnyProperties(properties ...properties.Property) []*base.AnyProperty {
anyProperties := make([]*base.AnyProperty, 0)

Expand Down
23 changes: 15 additions & 8 deletions lists/base/property_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var (
maxProperties = 100
randomIndex = rand.Intn(maxProperties)
randomUnsortedProperties, randomProperties = randomPropertiesGenerator(maxProperties)
testPropertyGeneratorOne = baseProperties.NewMetaProperty(baseIDs.NewStringID("Test 1"), baseData.NewStringData("Test 2")).ToAnyProperty().(*baseProperties.AnyProperty)
testPropertyGeneratorTwo = baseProperties.NewMetaProperty(baseIDs.NewStringID("Test 3"), baseData.NewStringData("Test 4")).ToAnyProperty().(*baseProperties.AnyProperty)
veryLargeNumber = 50000
veryLargeNumberOfUnsortedProperties, veryLargeNumberOfProperties = randomPropertiesGenerator(veryLargeNumber)
)
Expand Down Expand Up @@ -93,11 +95,11 @@ func Test_propertyList_NewPropertyList(t *testing.T) {
},
{
"add prototype property with other properties",
[]properties.Property{baseProperties.PrototypeMetaProperty(), randomProperties[0], randomProperties[1]},
&PropertyList{[]*baseProperties.AnyProperty{baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty), randomProperties[0], randomProperties[1]}},
[]properties.Property{baseProperties.PrototypeMetaProperty(), testPropertyGeneratorOne, testPropertyGeneratorTwo},
&PropertyList{[]*baseProperties.AnyProperty{testPropertyGeneratorOne, testPropertyGeneratorTwo, baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty)}},
},
{
"add multiple nils",
"add multi3ple nils",
[]properties.Property{nil, nil, nil},
&PropertyList{},
},
Expand Down Expand Up @@ -191,8 +193,8 @@ func Test_propertyList_Add(t *testing.T) {
{
"add prototype property with other properties",
NewPropertyList(),
[]properties.Property{baseProperties.PrototypeMetaProperty(), randomProperties[0], randomProperties[1]},
&PropertyList{[]*baseProperties.AnyProperty{baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty), randomProperties[0], randomProperties[1]}},
[]properties.Property{baseProperties.PrototypeMetaProperty(), testPropertyGeneratorOne, testPropertyGeneratorTwo},
&PropertyList{[]*baseProperties.AnyProperty{testPropertyGeneratorOne, testPropertyGeneratorTwo, baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty)}},
},
{
"add multiple nils",
Expand Down Expand Up @@ -784,7 +786,7 @@ func TestPropertyList_search(t *testing.T) {
"prototype property with other properties",
NewPropertyList(baseProperties.PrototypeMetaProperty(), randomProperties[0], randomProperties[1]),
baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty),
0,
2,
true,
},
{
Expand Down Expand Up @@ -878,8 +880,8 @@ func TestPropertyList_sort(t *testing.T) {
},
{
"prototype property with other properties",
&PropertyList{[]*baseProperties.AnyProperty{baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty), randomProperties[0], randomProperties[1]}},
&PropertyList{[]*baseProperties.AnyProperty{baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty), randomProperties[0], randomProperties[1]}},
&PropertyList{[]*baseProperties.AnyProperty{baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty), testPropertyGeneratorOne, testPropertyGeneratorTwo}},
&PropertyList{[]*baseProperties.AnyProperty{testPropertyGeneratorOne, testPropertyGeneratorTwo, baseProperties.PrototypeMetaProperty().ToAnyProperty().(*baseProperties.AnyProperty)}},
},
}
for _, tt := range tests {
Expand All @@ -891,6 +893,11 @@ func TestPropertyList_sort(t *testing.T) {
if !reflect.DeepEqual(tt.added.Get(), tt.want.Get()) {
t.Errorf("sort() got = %v, want %v", tt.added.Get(), tt.want.Get())
}

//if reflect.TypeOf(tt.added.Get()) != reflect.TypeOf(tt.want.Get()) {
// t.Errorf("\n got type: \n %v \n want type: \n %v", reflect.TypeOf(tt.added.Get()), reflect.TypeOf(tt.want.Get()))
//}

})
}
}
Expand Down
2 changes: 1 addition & 1 deletion qualified/base/immutables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestNewImmutables(t *testing.T) {
args args
want qualified.Immutables
}{
{"nil", args{}, &Immutables{}},
{"nil", args{}, &Immutables{PropertyList: &base.PropertyList{}}},
{"+ve empty list", args{base.NewPropertyList()}, &Immutables{PropertyList: &base.PropertyList{}}},
{"+ve", args{testImmutablePropertyList}, &Immutables{testImmutablePropertyList.(*base.PropertyList)}},
}
Expand Down
2 changes: 1 addition & 1 deletion qualified/base/mutables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestNewMutables(t *testing.T) {
args args
want qualified.Mutables
}{
{"+ve", args{}, &Mutables{}},
{"+ve", args{}, &Mutables{PropertyList: &base.PropertyList{}}},
{"+ve empty list", args{base.NewPropertyList()}, &Mutables{PropertyList: &base.PropertyList{}}},
{"+ve", args{base.NewPropertyList(testMutableProperties)}, &Mutables{base.NewPropertyList(testMutableProperties).(*base.PropertyList)}},
}
Expand Down
Loading