diff --git a/data/base/height_data_test.go b/data/base/height_data_test.go index ba38cfd2a..314f61741 100644 --- a/data/base/height_data_test.go +++ b/data/base/height_data_test.go @@ -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) { @@ -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) { diff --git a/data/base/list_data_test.go b/data/base/list_data_test.go index f8fc04138..2cbc38c09 100644 --- a/data/base/list_data_test.go +++ b/data/base/list_data_test.go @@ -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) { diff --git a/documents/base/asset_test.go b/documents/base/asset_test.go index 0a11883d3..4dec5b9e3 100644 --- a/documents/base/asset_test.go +++ b/documents/base/asset_test.go @@ -54,7 +54,7 @@ func Test_asset_GetBurnHeight(t *testing.T) { 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) { @@ -79,7 +79,7 @@ func Test_asset_GetLockHeight(t *testing.T) { 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 { diff --git a/documents/base/document_test.go b/documents/base/document_test.go index 7c78647c1..58348917d 100644 --- a/documents/base/document_test.go +++ b/documents/base/document_test.go @@ -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}, } diff --git a/documents/base/identity_test.go b/documents/base/identity_test.go index d7a576b05..3aaa8c1f5 100644 --- a/documents/base/identity_test.go +++ b/documents/base/identity_test.go @@ -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) { diff --git a/ids/base/any_id_test.go b/ids/base/any_id_test.go index a8eda0ae1..ac8bcf907 100644 --- a/ids/base/any_id_test.go +++ b/ids/base/any_id_test.go @@ -16,6 +16,7 @@ import ( var ( testValidBase64String = "nBuFnhfmBVznCR9vS5/V1mqZim8aclm1jBlqR8NGU94=" + testStringID = "testStringID" testValidBase64URLString = "nBuFnhfmBVznCR9vS5/V1mqZim8aclm1jBlqR8NGU94=" testBytes, _ = base64.StdEncoding.DecodeString(testValidBase64String) ) @@ -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")}, } diff --git a/ids/base/data_id_test.go b/ids/base/data_id_test.go index 2ce1f379a..38d5fe267 100644 --- a/ids/base/data_id_test.go +++ b/ids/base/data_id_test.go @@ -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) { diff --git a/ids/base/property_id_test.go b/ids/base/property_id_test.go index c7c1f233c..d8478b3f4 100644 --- a/ids/base/property_id_test.go +++ b/ids/base/property_id_test.go @@ -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) { diff --git a/lists/base/property_list.go b/lists/base/property_list.go index 7b9136a77..48bdfce74 100644 --- a/lists/base/property_list.go +++ b/lists/base/property_list.go @@ -164,6 +164,7 @@ func anyPropertiesToProperties(anyProperties ...*base.AnyProperty) []properties. return returnProperties } + func propertiesToAnyProperties(properties ...properties.Property) []*base.AnyProperty { anyProperties := make([]*base.AnyProperty, 0) diff --git a/lists/base/property_list_test.go b/lists/base/property_list_test.go index 99c79e41c..fa8b3e467 100644 --- a/lists/base/property_list_test.go +++ b/lists/base/property_list_test.go @@ -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) ) @@ -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{}, }, @@ -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", @@ -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, }, { @@ -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 { @@ -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())) + //} + }) } } diff --git a/qualified/base/immutables_test.go b/qualified/base/immutables_test.go index c94397634..93c2d7364 100644 --- a/qualified/base/immutables_test.go +++ b/qualified/base/immutables_test.go @@ -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)}}, } diff --git a/qualified/base/mutables_test.go b/qualified/base/mutables_test.go index 9185038cf..d960a8182 100644 --- a/qualified/base/mutables_test.go +++ b/qualified/base/mutables_test.go @@ -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)}}, }