htlcswitch: remove Switch reference from channelLink

This commit is contained in:
Keagan McClelland 2024-02-22 17:38:40 -08:00
parent 38db17b8cc
commit be69b022d9
5 changed files with 395 additions and 303 deletions

View File

@ -92,13 +92,6 @@ type ChannelLinkConfig struct {
// allowing the link to open and close circuits.
Circuits CircuitModifier
// Switch provides a reference to the HTLC switch, we only use this in
// testing to access circuit operations not typically exposed by the
// CircuitModifier.
//
// TODO(conner): remove after refactoring htlcswitch testing framework.
Switch *Switch
// BestHeight returns the best known height.
BestHeight func() uint32

View File

@ -13,6 +13,7 @@ import (
type linkTestContext struct {
t *testing.T
aliceSwitch *Switch
aliceLink ChannelLink
bobChannel *lnwallet.LightningChannel
aliceMsgs <-chan lnwire.Message
@ -39,7 +40,7 @@ func (l *linkTestContext) sendHtlcAliceToBob(htlcID int,
l.t.Helper()
circuitMap := l.aliceLink.(*channelLink).cfg.Switch.circuits
circuitMap := l.aliceSwitch.circuits
fwdActions, err := circuitMap.CommitCircuits(
&PaymentCircuit{
Incoming: CircuitKey{

File diff suppressed because it is too large Load Diff

View File

@ -5263,10 +5263,12 @@ func testSwitchHandlePacketForward(t *testing.T, zeroConf, private,
t.Parallel()
// Create a link for Alice that we'll add to the switch.
aliceLink, _, _, _, _, err :=
harness, err :=
newSingleLinkTestHarness(t, btcutil.SatoshiPerBitcoin, 0)
require.NoError(t, err)
aliceLink := harness.aliceLink
s, err := initSwitchWithTempDB(t, testStartingHeight)
if err != nil {
t.Fatalf("unable to init switch: %v", err)

View File

@ -1129,7 +1129,6 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
link := NewChannelLink(
ChannelLinkConfig{
Switch: server.htlcSwitch,
BestHeight: server.htlcSwitch.BestHeight,
FwrdingPolicy: h.globalPolicy,
Peer: peer,