Skip to content

Commit

Permalink
p2p/simulations: add "conns after load" subtest to TestSnapshot
Browse files Browse the repository at this point in the history
and nudge
  • Loading branch information
janos authored and nolash committed Dec 20, 2018
1 parent 834bafd commit a0dfb36
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions p2p/simulations/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,37 @@ OUTER_TWO:
t.Fatalf("Superfluous conn found %v -> %v", ev.Conn.One, ev.Conn.Other)
}
}

// This test validates if all connections from the snapshot
// are created in the network.
t.Run("conns after load", func(t *testing.T) {
// Create new network.
n := NewNetwork(
adapters.NewSimAdapter(adapters.Services{
"noopwoop": func(ctx *adapters.ServiceContext) (node.Service, error) {
return NewNoopService(nil), nil
},
}),
&NetworkConfig{
DefaultService: "noopwoop",
},
)
defer n.Shutdown()

// Load the same snapshot.
err := n.Load(snap)
if err != nil {
t.Fatal(err)
}

// Check every connection from the snapshot
// if it is in the network, too.
for _, c := range snap.Conns {
if n.GetConn(c.One, c.Other) == nil {
t.Errorf("missing connection: %s -> %s", c.One, c.Other)
}
}
})
}

// TestNetworkSimulation creates a multi-node simulation network with each node
Expand Down

0 comments on commit a0dfb36

Please # to comment.