tka: reduce boilerplate code in the tests

Updates #cleanup

Change-Id: Id69d509f5e470fb5fb50b5c5c4ca61f000389c53
Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
Alex Chan
2026-04-28 10:25:55 +01:00
committed by Alex Chan
parent cb239808a6
commit 0ac09721df
7 changed files with 63 additions and 109 deletions
+4 -10
View File
@@ -173,11 +173,8 @@ func TestSigNested_DeepNesting(t *testing.T) {
}
// Test this works with our public API
a, _ := Open(newTestchain(t, "G1\nG1.template = genesis",
optTemplate("genesis", AUM{MessageKind: AUMCheckpoint, State: &State{
Keys: []Key{k},
DisablementValues: [][]byte{DisablementKDF([]byte{1, 2, 3})},
}})).Chonk())
c := newTestchain(t, "G1\nG1.template = genesis", genesisTemplate(k))
a, _ := Open(c.Chonk())
if err := a.NodeKeyAuthorized(lastNodeKey.Public(), outer.Serialize()); err != nil {
t.Errorf("NodeKeyAuthorized(lastNodeKey) failed: %v", err)
}
@@ -238,11 +235,8 @@ func TestSigCredential(t *testing.T) {
}
// Test someone can't misuse our public API for verifying node-keys
a, _ := Open(newTestchain(t, "G1\nG1.template = genesis",
optTemplate("genesis", AUM{MessageKind: AUMCheckpoint, State: &State{
Keys: []Key{k},
DisablementValues: [][]byte{DisablementKDF([]byte{1, 2, 3})},
}})).Chonk())
c := newTestchain(t, "G1\nG1.template = genesis", genesisTemplate(k))
a, _ := Open(c.Chonk())
if err := a.NodeKeyAuthorized(node.Public(), nestedSig.Serialize()); err == nil {
t.Error("NodeKeyAuthorized(SigCredential, node) did not fail")
}