Choose even the first region in the browser; update Docker and Nix
A node now starts without any region (it only helps others connect, and prints a hint). The owner's sign-in link leads straight to the Regions page when none is followed, visitors get a notice instead of an empty search, and status always lists regions as an array. The Docker image no longer pins Bonn, the NixOS module no longer requires regions, and the VM test now starts without any, chooses the first region over the API and checks it survives a restart. README and the init hint follow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
+7
-2
@@ -65,11 +65,16 @@ type RegionKeeper interface {
|
||||
// in them, so this keeps "follow the world" from being one click.
|
||||
const MaxRegions = 20
|
||||
|
||||
// regions is what the node follows now, never nil: the UI reads it as a list.
|
||||
func (s *server) regions() []string {
|
||||
r := s.Regions
|
||||
if s.RegionKeeper != nil {
|
||||
return s.RegionKeeper.Regions()
|
||||
r = s.RegionKeeper.Regions()
|
||||
}
|
||||
return s.Regions
|
||||
if r == nil {
|
||||
return []string{}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type server struct {
|
||||
|
||||
@@ -373,3 +373,16 @@ func TestRegionsCannotBeChangedWithoutAKeeper(t *testing.T) {
|
||||
t.Fatal("regions changed on a node that has no keeper")
|
||||
}
|
||||
}
|
||||
|
||||
type noRegions struct{}
|
||||
|
||||
func (noRegions) Regions() []string { return nil }
|
||||
func (noRegions) SetRegions([]string) error { return nil }
|
||||
|
||||
func TestAStatusWithoutRegionsListsNone(t *testing.T) {
|
||||
f := newFixture(t, token, func(c *Config) { c.Regions = nil; c.RegionKeeper = noRegions{} })
|
||||
_, body := f.do(t, "GET", "/api/v1/status", "", false)
|
||||
if !strings.Contains(string(body), `"regions":[]`) {
|
||||
t.Fatalf("regions must be an empty list the UI can read, not null: %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,3 +385,24 @@ func TestRegionsChangeWhileRunning(t *testing.T) {
|
||||
t.Fatalf("regions changed to %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestANodeWithoutRegionsFollowsTheFirstOneWhenChosen(t *testing.T) {
|
||||
a := startNode(t, nil, "u1x")
|
||||
b := startNode(t, nil) // no region yet
|
||||
connect(t, b, a)
|
||||
if got := b.Regions(); len(got) != 0 {
|
||||
t.Fatalf("regions = %v", got)
|
||||
}
|
||||
l := a.listing(t, "u1xjhx")
|
||||
if err := a.Publish(context.Background(), l); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
if count(b) != 0 {
|
||||
t.Fatal("a node without regions stored a listing")
|
||||
}
|
||||
if err := b.SetRegions([]string{"u1x"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
eventually(t, "the first region is followed and caught up", func() bool { return count(b) == 1 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user