htlcswitch: update unit tests to account for recent API changes

This commit is contained in:
Olaoluwa Osuntokun 2018-04-03 20:09:51 -07:00
parent 0a47b2c4ad
commit ec8e3b626d
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
3 changed files with 37 additions and 29 deletions

@ -1476,8 +1476,8 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
return obfuscator, lnwire.CodeNone return obfuscator, lnwire.CodeNone
}, },
GetLastChannelUpdate: mockGetChanUpdateMessage, FetchLastChannelUpdate: mockGetChanUpdateMessage,
PreimageCache: pCache, PreimageCache: pCache,
UpdateContractSignals: func(*contractcourt.ContractSignals) error { UpdateContractSignals: func(*contractcourt.ContractSignals) error {
return nil return nil
}, },

@ -604,6 +604,10 @@ func (f *mockChannelLink) HandleChannelUpdate(lnwire.Message) {
func (f *mockChannelLink) UpdateForwardingPolicy(_ ForwardingPolicy) { func (f *mockChannelLink) UpdateForwardingPolicy(_ ForwardingPolicy) {
} }
func (f *mockChannelLink) HtlcSatifiesPolicy([32]byte, lnwire.MilliSatoshi,
lnwire.MilliSatoshi) lnwire.FailureMessage {
return nil
}
func (f *mockChannelLink) Stats() (uint64, lnwire.MilliSatoshi, lnwire.MilliSatoshi) { func (f *mockChannelLink) Stats() (uint64, lnwire.MilliSatoshi, lnwire.MilliSatoshi) {
return 0, 0, 0 return 0, 0, 0

@ -116,9 +116,9 @@ func genIDs() (lnwire.ChannelID, lnwire.ChannelID, lnwire.ShortChannelID,
return chanID1, chanID2, aliceChanID, bobChanID return chanID1, chanID2, aliceChanID, bobChanID
} }
// mockGetChanUpdateMessage helper function which returns topology update // mockGetChanUpdateMessage helper function which returns topology update of
// of the channel // the channel
func mockGetChanUpdateMessage() (*lnwire.ChannelUpdate, error) { func mockGetChanUpdateMessage(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
return &lnwire.ChannelUpdate{ return &lnwire.ChannelUpdate{
Signature: wireSig, Signature: wireSig,
}, nil }, nil
@ -902,6 +902,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
aliceTicker := time.NewTicker(50 * time.Millisecond) aliceTicker := time.NewTicker(50 * time.Millisecond)
aliceChannelLink := NewChannelLink( aliceChannelLink := NewChannelLink(
ChannelLinkConfig{ ChannelLinkConfig{
Switch: aliceServer.htlcSwitch,
FwrdingPolicy: globalPolicy, FwrdingPolicy: globalPolicy,
Peer: bobServer, Peer: bobServer,
Circuits: aliceServer.htlcSwitch.CircuitModifier(), Circuits: aliceServer.htlcSwitch.CircuitModifier(),
@ -911,11 +912,11 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
return obfuscator, lnwire.CodeNone return obfuscator, lnwire.CodeNone
}, },
GetLastChannelUpdate: mockGetChanUpdateMessage, FetchLastChannelUpdate: mockGetChanUpdateMessage,
Registry: aliceServer.registry, Registry: aliceServer.registry,
BlockEpochs: aliceEpoch, BlockEpochs: aliceEpoch,
FeeEstimator: feeEstimator, FeeEstimator: feeEstimator,
PreimageCache: pCache, PreimageCache: pCache,
UpdateContractSignals: func(*contractcourt.ContractSignals) error { UpdateContractSignals: func(*contractcourt.ContractSignals) error {
return nil return nil
}, },
@ -928,7 +929,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
aliceChannel, aliceChannel,
startingHeight, startingHeight,
) )
if err := aliceServer.htlcSwitch.addLink(aliceChannelLink); err != nil { if err := aliceServer.htlcSwitch.AddLink(aliceChannelLink); err != nil {
t.Fatalf("unable to add alice channel link: %v", err) t.Fatalf("unable to add alice channel link: %v", err)
} }
go func() { go func() {
@ -950,6 +951,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
firstBobTicker := time.NewTicker(50 * time.Millisecond) firstBobTicker := time.NewTicker(50 * time.Millisecond)
firstBobChannelLink := NewChannelLink( firstBobChannelLink := NewChannelLink(
ChannelLinkConfig{ ChannelLinkConfig{
Switch: bobServer.htlcSwitch,
FwrdingPolicy: globalPolicy, FwrdingPolicy: globalPolicy,
Peer: aliceServer, Peer: aliceServer,
Circuits: bobServer.htlcSwitch.CircuitModifier(), Circuits: bobServer.htlcSwitch.CircuitModifier(),
@ -959,11 +961,11 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
return obfuscator, lnwire.CodeNone return obfuscator, lnwire.CodeNone
}, },
GetLastChannelUpdate: mockGetChanUpdateMessage, FetchLastChannelUpdate: mockGetChanUpdateMessage,
Registry: bobServer.registry, Registry: bobServer.registry,
BlockEpochs: bobFirstEpoch, BlockEpochs: bobFirstEpoch,
FeeEstimator: feeEstimator, FeeEstimator: feeEstimator,
PreimageCache: pCache, PreimageCache: pCache,
UpdateContractSignals: func(*contractcourt.ContractSignals) error { UpdateContractSignals: func(*contractcourt.ContractSignals) error {
return nil return nil
}, },
@ -976,7 +978,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
firstBobChannel, firstBobChannel,
startingHeight, startingHeight,
) )
if err := bobServer.htlcSwitch.addLink(firstBobChannelLink); err != nil { if err := bobServer.htlcSwitch.AddLink(firstBobChannelLink); err != nil {
t.Fatalf("unable to add first bob channel link: %v", err) t.Fatalf("unable to add first bob channel link: %v", err)
} }
go func() { go func() {
@ -998,6 +1000,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
secondBobTicker := time.NewTicker(50 * time.Millisecond) secondBobTicker := time.NewTicker(50 * time.Millisecond)
secondBobChannelLink := NewChannelLink( secondBobChannelLink := NewChannelLink(
ChannelLinkConfig{ ChannelLinkConfig{
Switch: bobServer.htlcSwitch,
FwrdingPolicy: globalPolicy, FwrdingPolicy: globalPolicy,
Peer: carolServer, Peer: carolServer,
Circuits: bobServer.htlcSwitch.CircuitModifier(), Circuits: bobServer.htlcSwitch.CircuitModifier(),
@ -1007,11 +1010,11 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
return obfuscator, lnwire.CodeNone return obfuscator, lnwire.CodeNone
}, },
GetLastChannelUpdate: mockGetChanUpdateMessage, FetchLastChannelUpdate: mockGetChanUpdateMessage,
Registry: bobServer.registry, Registry: bobServer.registry,
BlockEpochs: bobSecondEpoch, BlockEpochs: bobSecondEpoch,
FeeEstimator: feeEstimator, FeeEstimator: feeEstimator,
PreimageCache: pCache, PreimageCache: pCache,
UpdateContractSignals: func(*contractcourt.ContractSignals) error { UpdateContractSignals: func(*contractcourt.ContractSignals) error {
return nil return nil
}, },
@ -1024,7 +1027,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
secondBobChannel, secondBobChannel,
startingHeight, startingHeight,
) )
if err := bobServer.htlcSwitch.addLink(secondBobChannelLink); err != nil { if err := bobServer.htlcSwitch.AddLink(secondBobChannelLink); err != nil {
t.Fatalf("unable to add second bob channel link: %v", err) t.Fatalf("unable to add second bob channel link: %v", err)
} }
go func() { go func() {
@ -1046,6 +1049,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
carolTicker := time.NewTicker(50 * time.Millisecond) carolTicker := time.NewTicker(50 * time.Millisecond)
carolChannelLink := NewChannelLink( carolChannelLink := NewChannelLink(
ChannelLinkConfig{ ChannelLinkConfig{
Switch: carolServer.htlcSwitch,
FwrdingPolicy: globalPolicy, FwrdingPolicy: globalPolicy,
Peer: bobServer, Peer: bobServer,
Circuits: carolServer.htlcSwitch.CircuitModifier(), Circuits: carolServer.htlcSwitch.CircuitModifier(),
@ -1055,11 +1059,11 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
ErrorEncrypter, lnwire.FailCode) { ErrorEncrypter, lnwire.FailCode) {
return obfuscator, lnwire.CodeNone return obfuscator, lnwire.CodeNone
}, },
GetLastChannelUpdate: mockGetChanUpdateMessage, FetchLastChannelUpdate: mockGetChanUpdateMessage,
Registry: carolServer.registry, Registry: carolServer.registry,
BlockEpochs: carolEpoch, BlockEpochs: carolEpoch,
FeeEstimator: feeEstimator, FeeEstimator: feeEstimator,
PreimageCache: pCache, PreimageCache: pCache,
UpdateContractSignals: func(*contractcourt.ContractSignals) error { UpdateContractSignals: func(*contractcourt.ContractSignals) error {
return nil return nil
}, },
@ -1072,7 +1076,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
carolChannel, carolChannel,
startingHeight, startingHeight,
) )
if err := carolServer.htlcSwitch.addLink(carolChannelLink); err != nil { if err := carolServer.htlcSwitch.AddLink(carolChannelLink); err != nil {
t.Fatalf("unable to add carol channel link: %v", err) t.Fatalf("unable to add carol channel link: %v", err)
} }
go func() { go func() {