Ship POST /api/v1/forge/launch-template with cloud-init user-data embedding genesis snapshot hash and strain card ID; first template-tagged auth pins SpreadGeneration=0 and ParentAgentID=template.
25 lines
584 B
Go
25 lines
584 B
Go
package spreadgenesis
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"crypto-miner-server/internal/models"
|
|
)
|
|
|
|
func TestIsFirstAuth(t *testing.T) {
|
|
if !IsFirstAuth(true, AuthProbe{GenesisSnapshotHash: "abc"}) {
|
|
t.Fatal("expected tag")
|
|
}
|
|
if IsFirstAuth(false, AuthProbe{GenesisSnapshotHash: "abc"}) {
|
|
t.Fatal("reconnect skip")
|
|
}
|
|
}
|
|
|
|
func TestApplyFirstAuth(t *testing.T) {
|
|
agent := &models.Agent{SpreadGeneration: 3}
|
|
ApplyFirstAuth(agent, true, AuthProbe{ParentAgentID: "template"})
|
|
if agent.SpreadGeneration != 0 || agent.ParentAgentID != LaunchTemplateParentAgentID {
|
|
t.Fatalf("%+v", agent)
|
|
}
|
|
}
|