Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ellemouton committed Aug 13, 2024
1 parent 676eeac commit 1842f7d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
9 changes: 5 additions & 4 deletions routing/integrated_routing_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ func (c *integratedRoutingContext) testPayment(maxParts uint32,

// Instantiate a new mission control with the current configuration
// values.
mc, err := NewMissionControl(db, c.source.pubkey, &c.mcCfg)
if err != nil {
c.t.Fatal(err)
}
mcMgr, err := NewMissionControl(db, c.source.pubkey, &c.mcCfg)
require.NoError(c.t, err)

mc, err := mcMgr.GetNamespacedStore(DefaultMissionControlNamespace)
require.NoError(c.t, err)

getBandwidthHints := func(_ Graph) (bandwidthHints, error) {
// Create bandwidth hints based on local channel balances.
Expand Down
10 changes: 6 additions & 4 deletions routing/missioncontrol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (

type mcTestContext struct {
t *testing.T
mc *MissionControlMgr
mc *MissionControl
now time.Time

db kvdb.Backend
Expand Down Expand Up @@ -87,8 +87,7 @@ func (ctx *mcTestContext) restartMc() {
// Since we don't run a timer to store results in unit tests, we store
// them here before fetching back everything in NewMissionControl.
if ctx.mc != nil {
require.NoError(ctx.t, ctx.mc.mc[DefaultMissionControlNamespace].store.
storeResults())
require.NoError(ctx.t, ctx.mc.store.storeResults())
}

aCfg := AprioriConfig{
Expand All @@ -100,14 +99,17 @@ func (ctx *mcTestContext) restartMc() {
estimator, err := NewAprioriEstimator(aCfg)
require.NoError(ctx.t, err)

mc, err := NewMissionControl(
mcMgr, err := NewMissionControl(
ctx.db, mcTestSelf,
&MissionControlConfig{Estimator: estimator},
)
if err != nil {
ctx.t.Fatal(err)
}

mc, err := mcMgr.GetNamespacedStore(DefaultMissionControlNamespace)
require.NoError(ctx.t, err)

mc.now = func() time.Time { return ctx.now }
ctx.mc = mc
}
Expand Down
4 changes: 2 additions & 2 deletions routing/payment_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
return &mockBandwidthHints{}, nil
},
newMockGraphSessionFactory(&sessionGraph{}),
&MissionControlMgr{},
&MissionControl{},
PathFindingConfig{},
)
require.NoError(t, err, "failed to create payment session")
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestRequestRoute(t *testing.T) {
return &mockBandwidthHints{}, nil
},
newMockGraphSessionFactory(&sessionGraph{}),
&MissionControlMgr{},
&MissionControl{},
PathFindingConfig{},
)
if err != nil {
Expand Down
11 changes: 7 additions & 4 deletions routing/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,

mcConfig := &MissionControlConfig{Estimator: estimator}

mc, err := NewMissionControl(
mcMgr, err := NewMissionControl(
graphInstance.graphBackend, route.Vertex{}, mcConfig,
)
require.NoError(t, err, "failed to create missioncontrol")

mc, err := mcMgr.GetNamespacedStore(DefaultMissionControlNamespace)
require.NoError(t, err, "failed to create missioncontrol")

sourceNode, err := graphInstance.graph.SourceNode()
require.NoError(t, err)
sessionSource := &SessionSource{
Expand Down Expand Up @@ -1078,7 +1081,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
return preImage, nil
})

ctx.router.cfg.MissionControl.(*MissionControlMgr).ResetHistory()
ctx.router.cfg.MissionControl.(*MissionControl).ResetHistory()

// When we try to dispatch that payment, we should receive an error as
// both attempts should fail and cause both routes to be pruned.
Expand Down Expand Up @@ -1106,7 +1109,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
_, ok = msg.(*lnwire.FailUnknownNextPeer)
require.True(t, ok, "unexpected fail message")

err = ctx.router.cfg.MissionControl.(*MissionControlMgr).ResetHistory()
err = ctx.router.cfg.MissionControl.(*MissionControl).ResetHistory()
require.NoError(t, err, "reset history failed")

// Next, we'll modify the SendToSwitch method to indicate that the
Expand Down Expand Up @@ -1141,7 +1144,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
getAliasFromPubKey(rt.Hops[0].PubKeyBytes, ctx.aliases),
)

ctx.router.cfg.MissionControl.(*MissionControlMgr).ResetHistory()
ctx.router.cfg.MissionControl.(*MissionControl).ResetHistory()

// Finally, we'll modify the SendToSwitch function to indicate that the
// roasbeef -> luoji channel has insufficient capacity. This should
Expand Down
2 changes: 1 addition & 1 deletion rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service,
}
graph := s.graphDB

mc, err := r.server.missionControl.GetNamespacedStore(
mc, err := s.missionControl.GetNamespacedStore(
routing.DefaultMissionControlNamespace,
)
if err != nil {
Expand Down

0 comments on commit 1842f7d

Please sign in to comment.