package codex import "testing" // The amd64 pins are the certified ones and must not move with the arm64 // ones beside them. The arm64 digests are the official rust-v0.165.0 // aarch64-unknown-linux-musl binaries. func TestReleasePinsByArchitecture(t *testing.T) { executable, host, ok := ReleasePins("amd64") if !ok || executable != ExecutableSHA256 || host != CodeModeHostSHA256 { t.Fatalf("amd64 must be the certified pins, got %q %q %v", executable, host, ok) } executable, host, ok = ReleasePins("arm64") if !ok || executable != "b32ece31af06440da980b733fb8fefdd1f193439595fda84096f1caaceec543f" || host != "fd7a4a1f29871fb0015c19ad2f885ef6a878244643260703e17663418695aa14" { t.Fatalf("arm64 pins changed: %q %q %v", executable, host, ok) } if executable == ExecutableSHA256 || host == CodeModeHostSHA256 { t.Fatal("arm64 pins equal the certified amd64 pins") } if executable, host, ok = ReleasePins("riscv64"); ok || executable != "" || host != "" { t.Fatal("an architecture with no official build has pins") } } // A launcher trusts only the certified pins, whatever machine builds it. func TestLauncherKeepsCertifiedPins(t *testing.T) { l, err := New(offlineCodexHost{t}, fakeCapture{}) if err != nil { t.Fatal(err) } if l.digest != ExecutableSHA256 || l.hostDigest != CodeModeHostSHA256 { t.Fatal("launcher pins are not the certified ones") } }