feat: introduce identity-backed goat
This commit is contained in:
@@ -19,8 +19,10 @@ func _run() -> void:
|
||||
_test_previous_world_provenance_migration()
|
||||
_test_previous_world_retention_migration()
|
||||
_test_previous_world_opportunity_migration()
|
||||
_test_previous_world_animal_migration()
|
||||
_test_relationship_schema_rejection()
|
||||
_test_opportunity_schema_rejection()
|
||||
_test_animal_schema_rejection()
|
||||
_test_schema_rejection()
|
||||
|
||||
if failures.is_empty():
|
||||
@@ -481,6 +483,51 @@ func _test_previous_world_opportunity_migration() -> void:
|
||||
manager.free()
|
||||
|
||||
|
||||
func _test_previous_world_animal_migration() -> void:
|
||||
var manager := _create_manager(63)
|
||||
var v9_data: Dictionary = _build_opportunity_world(manager, false)
|
||||
v9_data["schema_version"] = SimulationStateRecord.ANIMAL_LEGACY_SCHEMA_VERSION
|
||||
v9_data.erase("animals")
|
||||
var migrated := SimulationStateRecord.from_dictionary(v9_data)
|
||||
_check(migrated != null, "World schema v9 should add an empty animal stream")
|
||||
if migrated != null:
|
||||
_check(
|
||||
migrated.animals.is_empty() and migrated.opportunities.size() == 1,
|
||||
"World v9 migration should preserve opportunity history while adding animals"
|
||||
)
|
||||
manager.free()
|
||||
|
||||
|
||||
func _test_animal_schema_rejection() -> void:
|
||||
var manager := _create_manager(64)
|
||||
var missing_animals: Dictionary = manager.create_state_record().to_dictionary()
|
||||
missing_animals.erase("animals")
|
||||
_check(
|
||||
SimulationStateRecord.from_dictionary(missing_animals) == null,
|
||||
"Current world records should require the authoritative animal array"
|
||||
)
|
||||
var invalid_position := (
|
||||
AnimalStateRecord
|
||||
. from_dictionary(
|
||||
{
|
||||
"schema_version": AnimalStateRecord.SCHEMA_VERSION,
|
||||
"animal_id": "invalid_goat",
|
||||
"display_name": "Invalid",
|
||||
"species_id": String(SimulationIds.SPECIES_GOAT),
|
||||
"position": [NAN, 0.0, 0.0],
|
||||
"hunger": 70.0,
|
||||
"last_fed_tick": AnimalStateRecord.NEVER_FED_TICK,
|
||||
"reserved_by": -1,
|
||||
"enabled": true,
|
||||
"can_npcs_feed": true,
|
||||
"can_player_feed": true,
|
||||
}
|
||||
)
|
||||
)
|
||||
_check(invalid_position == null, "Animal records should reject non-finite positions")
|
||||
manager.free()
|
||||
|
||||
|
||||
func _test_relationship_schema_rejection() -> void:
|
||||
var manager := _create_manager(58)
|
||||
var missing_cause_data: Dictionary = manager.create_state_record().to_dictionary()
|
||||
|
||||
Reference in New Issue
Block a user