package serve import ( "crypto/ed25519" "path/filepath" "testing" "git.smesh.lol/btcd-lite/internal/store" ) // TestLoadAndPublish is the binary's path: a store opened from a directory // publishes a manifest, with the same sequence the command uses. func TestLoadAndPublish(t *testing.T) { dir := t.TempDir() b, hdr := putBlocks(t, dir, 20) b.Close() hdr.Close() b2, err := store.NewBlockStore(filepath.Join(dir, "blocks")) if err != nil { t.Fatal(err) } defer b2.Close() hdr2, err := store.NewHeaderStore(filepath.Join(dir, "headers")) if err != nil { t.Fatal(err) } defer hdr2.Close() v := New(map[string]*store.HeaderStore{"btc": hdr2}, b2) v.Key = ed25519.NewKeyFromSeed(make([]byte, 32)) raw, ok := v.Manifest() if !ok || len(raw) == 0 { t.Fatalf("a reopened store published no manifest") } }