Files
baji-vc/tests/avatar/UserCandidateCheck.kt

24 lines
1.8 KiB
Kotlin

import com.gorios.lanvoice.avatar.*
@Suppress("UNCHECKED_CAST")
fun userCandidateAdmissionCheck() {
val hash="c".repeat(64);val root=dynamicRuntimeFixture(97,24,1,hash,720,1280)
val rows=root["patches"] as List<Map<String,Any?>>
val compact=root+("patches" to rows.map { it-"path"-"sha256" })
fun read(m: Map<String,Any?>,user: Boolean=false,debug: Boolean=true,expected: String=hash)=
ContinuousAvatarManifest.read(m,hash,expected,debug,"fixture/",userAuthorizedDebug=user)
val admitted=checkNotNull(read(compact));check(admitted.textureImages.size==485 && admitted.patches.first().path.endsWith("l4.png"))
val candidate=compact+("runtimeReady" to false)
check(read(candidate)==null);checkNotNull(read(candidate,true))
check(read(candidate,true,false)==null);check(read(candidate,true,true,"b".repeat(64))==null)
check(read(candidate+("publishApproval" to true),true)==null)
check(read(candidate-"runtimeReady",true)==null)
check(read(continuousFixture()+("runtimeReady" to false),true)==null)
check(read(compact+("patches" to listOf(rows[0]+("path" to "patches/wrong.png"))+rows.drop(1)))==null)
check(read(compact+("patches" to listOf(rows[0]-"sha256")+rows.drop(1)))==null)
check(read(compact+("patches" to listOf(rows[0]-"path")+rows.drop(1)))==null)
val levels=rows[0]["levels"] as List<Map<String,Any?>>
check(read(compact+("patches" to listOf((rows[0]-"path"-"sha256")+("levels" to levels.dropLast(1)))+rows.drop(1)))==null)
check(read(candidate+("body" to (root["body"] as Map<String,Any?>)+("width" to 480)),true)==null)
println("PASS: user-authorized debug-only candidate admission; default/release/hash/self-approval/legacy fences retained; schema2 level-only tracks and explicit-alias consistency, malformed levels rejected")
}