load_test.go raw
1 package serve
2
3 import (
4 "crypto/ed25519"
5 "path/filepath"
6 "testing"
7
8 "git.smesh.lol/btcd-lite/internal/store"
9 )
10
11 // TestLoadAndPublish is the binary's path: a store opened from a directory
12 // publishes a manifest, with the same sequence the command uses.
13 func TestLoadAndPublish(t *testing.T) {
14 dir := t.TempDir()
15 b, hdr := putBlocks(t, dir, 20)
16 b.Close()
17 hdr.Close()
18
19 b2, err := store.NewBlockStore(filepath.Join(dir, "blocks"))
20 if err != nil {
21 t.Fatal(err)
22 }
23 defer b2.Close()
24 hdr2, err := store.NewHeaderStore(filepath.Join(dir, "headers"))
25 if err != nil {
26 t.Fatal(err)
27 }
28 defer hdr2.Close()
29 v := New(map[string]*store.HeaderStore{"btc": hdr2}, b2)
30 v.Key = ed25519.NewKeyFromSeed(make([]byte, 32))
31 raw, ok := v.Manifest()
32 if !ok || len(raw) == 0 {
33 t.Fatalf("a reopened store published no manifest")
34 }
35 }
36