refactor(schema)!: rename ObjectType -> StateObjectType (#21691)
Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
This commit is contained in:
co-authored by
cool-developer
parent
397ff0bd22
commit
ae40e809b9
+12
-12
@@ -7,8 +7,8 @@ import (
|
||||
"cosmossdk.io/schema"
|
||||
)
|
||||
|
||||
// ObjectTypeGen generates random ObjectType's based on the validity criteria of object types.
|
||||
func ObjectTypeGen(typeSet schema.TypeSet) *rapid.Generator[schema.ObjectType] {
|
||||
// StateObjectTypeGen generates random StateObjectType's based on the validity criteria of object types.
|
||||
func StateObjectTypeGen(typeSet schema.TypeSet) *rapid.Generator[schema.StateObjectType] {
|
||||
keyFieldsGen := rapid.SliceOfNDistinct(KeyFieldGen(typeSet), 1, 6, func(f schema.Field) string {
|
||||
return f.Name
|
||||
})
|
||||
@@ -17,8 +17,8 @@ func ObjectTypeGen(typeSet schema.TypeSet) *rapid.Generator[schema.ObjectType] {
|
||||
return f.Name
|
||||
})
|
||||
|
||||
return rapid.Custom(func(t *rapid.T) schema.ObjectType {
|
||||
typ := schema.ObjectType{
|
||||
return rapid.Custom(func(t *rapid.T) schema.StateObjectType {
|
||||
typ := schema.StateObjectType{
|
||||
Name: NameGen.Filter(func(s string) bool {
|
||||
// filter out names that already exist in the schema
|
||||
_, found := typeSet.LookupType(s)
|
||||
@@ -31,7 +31,7 @@ func ObjectTypeGen(typeSet schema.TypeSet) *rapid.Generator[schema.ObjectType] {
|
||||
typ.RetainDeletions = boolGen.Draw(t, "retainDeletions")
|
||||
|
||||
return typ
|
||||
}).Filter(func(typ schema.ObjectType) bool {
|
||||
}).Filter(func(typ schema.StateObjectType) bool {
|
||||
// filter out duplicate field names
|
||||
fieldNames := map[string]bool{}
|
||||
if hasDuplicateFieldNames(fieldNames, typ.KeyFields) {
|
||||
@@ -55,14 +55,14 @@ func hasDuplicateFieldNames(typeNames map[string]bool, fields []schema.Field) bo
|
||||
return false
|
||||
}
|
||||
|
||||
// ObjectInsertGen generates object updates that are valid for insertion.
|
||||
func ObjectInsertGen(objectType schema.ObjectType, typeSet schema.TypeSet) *rapid.Generator[schema.ObjectUpdate] {
|
||||
return ObjectUpdateGen(objectType, nil, typeSet)
|
||||
// StateObjectInsertGen generates object updates that are valid for insertion.
|
||||
func StateObjectInsertGen(objectType schema.StateObjectType, typeSet schema.TypeSet) *rapid.Generator[schema.StateObjectUpdate] {
|
||||
return StateObjectUpdateGen(objectType, nil, typeSet)
|
||||
}
|
||||
|
||||
// ObjectUpdateGen generates object updates that are valid for updates using the provided state map as a source
|
||||
// StateObjectUpdateGen generates object updates that are valid for updates using the provided state map as a source
|
||||
// of valid existing keys.
|
||||
func ObjectUpdateGen(objectType schema.ObjectType, state *btree.Map[string, schema.ObjectUpdate], sch schema.TypeSet) *rapid.Generator[schema.ObjectUpdate] {
|
||||
func StateObjectUpdateGen(objectType schema.StateObjectType, state *btree.Map[string, schema.StateObjectUpdate], sch schema.TypeSet) *rapid.Generator[schema.StateObjectUpdate] {
|
||||
keyGen := ObjectKeyGen(objectType.KeyFields, sch).Filter(func(key interface{}) bool {
|
||||
// filter out keys that exist in the state
|
||||
if state != nil {
|
||||
@@ -73,8 +73,8 @@ func ObjectUpdateGen(objectType schema.ObjectType, state *btree.Map[string, sche
|
||||
})
|
||||
insertValueGen := ObjectValueGen(objectType.ValueFields, false, sch)
|
||||
updateValueGen := ObjectValueGen(objectType.ValueFields, true, sch)
|
||||
return rapid.Custom(func(t *rapid.T) schema.ObjectUpdate {
|
||||
update := schema.ObjectUpdate{
|
||||
return rapid.Custom(func(t *rapid.T) schema.StateObjectUpdate {
|
||||
update := schema.StateObjectUpdate{
|
||||
TypeName: objectType.Name,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user