htlcswitch/test: convert TestChannelLinkSingleHopPayment to two hop network
This commit is contained in:
parent
037913fd28
commit
af7d0e5ff5
@ -179,7 +179,8 @@ func createInterceptorFunc(prefix, receiver string, messages []expectedMessage,
|
|||||||
func TestChannelLinkSingleHopPayment(t *testing.T) {
|
func TestChannelLinkSingleHopPayment(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
channels, cleanUp, _, err := createClusterChannels(
|
// Setup a alice-bob network.
|
||||||
|
aliceChannel, bobChannel, cleanUp, err := createTwoClusterChannels(
|
||||||
btcutil.SatoshiPerBitcoin*3,
|
btcutil.SatoshiPerBitcoin*3,
|
||||||
btcutil.SatoshiPerBitcoin*5)
|
btcutil.SatoshiPerBitcoin*5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -187,15 +188,14 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
n := newThreeHopNetwork(t, channels.aliceToBob, channels.bobToAlice,
|
n := newTwoHopNetwork(t, aliceChannel, bobChannel, testStartingHeight)
|
||||||
channels.bobToCarol, channels.carolToBob, testStartingHeight)
|
|
||||||
if err := n.start(); err != nil {
|
if err := n.start(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer n.stop()
|
defer n.stop()
|
||||||
|
|
||||||
aliceBandwidthBefore := n.aliceChannelLink.Bandwidth()
|
aliceBandwidthBefore := n.aliceChannelLink.Bandwidth()
|
||||||
bobBandwidthBefore := n.firstBobChannelLink.Bandwidth()
|
bobBandwidthBefore := n.bobChannelLink.Bandwidth()
|
||||||
|
|
||||||
debug := false
|
debug := false
|
||||||
if debug {
|
if debug {
|
||||||
@ -205,12 +205,12 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
|
|||||||
|
|
||||||
// Log message that bob receives.
|
// Log message that bob receives.
|
||||||
n.bobServer.intersect(createLogFunc("bob",
|
n.bobServer.intersect(createLogFunc("bob",
|
||||||
n.firstBobChannelLink.ChanID()))
|
n.bobChannelLink.ChanID()))
|
||||||
}
|
}
|
||||||
|
|
||||||
amount := lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin)
|
amount := lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin)
|
||||||
htlcAmt, totalTimelock, hops := generateHops(amount, testStartingHeight,
|
htlcAmt, totalTimelock, hops := generateHops(amount, testStartingHeight,
|
||||||
n.firstBobChannelLink)
|
n.bobChannelLink)
|
||||||
|
|
||||||
// Wait for:
|
// Wait for:
|
||||||
// * HTLC add request to be sent to bob.
|
// * HTLC add request to be sent to bob.
|
||||||
@ -219,7 +219,7 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
|
|||||||
// * alice<->bob commitment state to be updated.
|
// * alice<->bob commitment state to be updated.
|
||||||
// * user notification to be sent.
|
// * user notification to be sent.
|
||||||
receiver := n.bobServer
|
receiver := n.bobServer
|
||||||
firstHop := n.firstBobChannelLink.ShortChanID()
|
firstHop := n.bobChannelLink.ShortChanID()
|
||||||
rhash, err := makePayment(
|
rhash, err := makePayment(
|
||||||
n.aliceServer, receiver, firstHop, hops, amount, htlcAmt,
|
n.aliceServer, receiver, firstHop, hops, amount, htlcAmt,
|
||||||
totalTimelock,
|
totalTimelock,
|
||||||
@ -248,10 +248,10 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
|
|||||||
"amount")
|
"amount")
|
||||||
}
|
}
|
||||||
|
|
||||||
if bobBandwidthBefore+amount != n.firstBobChannelLink.Bandwidth() {
|
if bobBandwidthBefore+amount != n.bobChannelLink.Bandwidth() {
|
||||||
t.Fatalf("bob bandwidth isn't match: expected %v, got %v",
|
t.Fatalf("bob bandwidth isn't match: expected %v, got %v",
|
||||||
bobBandwidthBefore+amount,
|
bobBandwidthBefore+amount,
|
||||||
n.firstBobChannelLink.Bandwidth())
|
n.bobChannelLink.Bandwidth())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user