peer_test.go: comment clarifications
This commit is contained in:
1 parent
d23b30d889
commit
bfaef46579
1 file changed
+28
-24
+28
-24
@@ -73,8 +73,9 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
|||||||
|
|
||||||
respDeliveryScript := shutdownMsg.Address
|
respDeliveryScript := shutdownMsg.Address
|
||||||
|
|
||||||
// Alice will thereafter send a ClosingSigned message, indicating her
|
// Alice will then send a ClosingSigned message, indicating her proposed
|
||||||
// proposed closing transaction fee.
|
// closing transaction fee. Alice sends the ClosingSigned message as she is
|
||||||
|
// the initiator of the channel.
|
||||||
select {
|
select {
|
||||||
case outMsg := <-responder.outgoingQueue:
|
case outMsg := <-responder.outgoingQueue:
|
||||||
msg = outMsg.msg
|
msg = outMsg.msg
|
||||||
@@ -107,8 +108,8 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
|||||||
msg: closingSigned,
|
msg: closingSigned,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The responder will now see that we agreed on the fee, and broadcast
|
// Alice should now see that we agreed on the fee, and should broadcast the
|
||||||
// the closing transaction.
|
// closing transaction.
|
||||||
select {
|
select {
|
||||||
case <-broadcastTxChan:
|
case <-broadcastTxChan:
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
@@ -137,7 +138,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
// We make the initiator send a shutdown request.
|
// We make Alice send a shutdown request.
|
||||||
updateChan := make(chan interface{}, 1)
|
updateChan := make(chan interface{}, 1)
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
closeCommand := &htlcswitch.ChanClose{
|
closeCommand := &htlcswitch.ChanClose{
|
||||||
@@ -149,7 +150,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
|||||||
}
|
}
|
||||||
initiator.localCloseChanReqs <- closeCommand
|
initiator.localCloseChanReqs <- closeCommand
|
||||||
|
|
||||||
// We should now be getting the shutdown request.
|
// We can now pull a Shutdown message off of Alice's outgoingQueue.
|
||||||
var msg lnwire.Message
|
var msg lnwire.Message
|
||||||
select {
|
select {
|
||||||
case outMsg := <-initiator.outgoingQueue:
|
case outMsg := <-initiator.outgoingQueue:
|
||||||
@@ -165,8 +166,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
|||||||
|
|
||||||
initiatorDeliveryScript := shutdownMsg.Address
|
initiatorDeliveryScript := shutdownMsg.Address
|
||||||
|
|
||||||
// We'll answer the shutdown message with our own Shutdown, and then a
|
// Bob will respond with his own Shutdown message.
|
||||||
// ClosingSigned message.
|
|
||||||
chanID := shutdownMsg.ChannelID
|
chanID := shutdownMsg.ChannelID
|
||||||
initiator.chanCloseMsgs <- &closeMsg{
|
initiator.chanCloseMsgs <- &closeMsg{
|
||||||
cid: chanID,
|
cid: chanID,
|
||||||
@@ -197,8 +197,10 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
|||||||
msg: closingSigned,
|
msg: closingSigned,
|
||||||
}
|
}
|
||||||
|
|
||||||
// And we expect the initiator to accept the fee, and broadcast the
|
// Alice should accept Bob's fee, broadcast the cooperative close tx, and
|
||||||
// closing transaction.
|
// send a ClosingSigned message back to Bob.
|
||||||
|
|
||||||
|
// Alice should now broadcast the closing transaction.
|
||||||
select {
|
select {
|
||||||
case outMsg := <-initiator.outgoingQueue:
|
case outMsg := <-initiator.outgoingQueue:
|
||||||
msg = outMsg.msg
|
msg = outMsg.msg
|
||||||
@@ -273,8 +275,8 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
|||||||
|
|
||||||
respDeliveryScript := shutdownMsg.Address
|
respDeliveryScript := shutdownMsg.Address
|
||||||
|
|
||||||
// Alice will thereafter send a ClosingSigned message, indicating her
|
// As Alice is the channel initiator, she will send her ClosingSigned
|
||||||
// proposed closing transaction fee.
|
// message.
|
||||||
select {
|
select {
|
||||||
case outMsg := <-responder.outgoingQueue:
|
case outMsg := <-responder.outgoingQueue:
|
||||||
msg = outMsg.msg
|
msg = outMsg.msg
|
||||||
@@ -287,7 +289,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
|||||||
t.Fatalf("expected ClosingSigned message, got %T", msg)
|
t.Fatalf("expected ClosingSigned message, got %T", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't agree with the fee, and will send back one that's 2.5x.
|
// Bob doesn't agree with the fee and will send one back that's 2.5x.
|
||||||
preferredRespFee := responderClosingSigned.FeeSatoshis
|
preferredRespFee := responderClosingSigned.FeeSatoshis
|
||||||
increasedFee := btcutil.Amount(float64(preferredRespFee) * 2.5)
|
increasedFee := btcutil.Amount(float64(preferredRespFee) * 2.5)
|
||||||
initiatorSig, _, _, err := initiatorChan.CreateCloseProposal(
|
initiatorSig, _, _, err := initiatorChan.CreateCloseProposal(
|
||||||
@@ -307,10 +309,10 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
|||||||
msg: closingSigned,
|
msg: closingSigned,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The responder will see the new fee we propose, but with current
|
// Alice will now see the new fee we propose, but with current settings it
|
||||||
// settings it won't accept it immediately as it differs too much by
|
// won't accept it immediately as it differs too much by its ideal fee. We
|
||||||
// its ideal fee. We should get a new proposal back, which should have
|
// should get a new proposal back, which should have the average fee rate
|
||||||
// the average fee rate proposed.
|
// proposed.
|
||||||
select {
|
select {
|
||||||
case outMsg := <-responder.outgoingQueue:
|
case outMsg := <-responder.outgoingQueue:
|
||||||
msg = outMsg.msg
|
msg = outMsg.msg
|
||||||
@@ -351,8 +353,9 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
|||||||
msg: closingSigned,
|
msg: closingSigned,
|
||||||
}
|
}
|
||||||
|
|
||||||
// It still won't be accepted, and we should get a new proposal, the
|
// Bob's latest proposal still won't be accepted and Alice should send over
|
||||||
// average of what we proposed, and what they proposed last time.
|
// a new ClosingSigned message. It should be the average of what Bob and
|
||||||
|
// Alice each proposed last time.
|
||||||
select {
|
select {
|
||||||
case outMsg := <-responder.outgoingQueue:
|
case outMsg := <-responder.outgoingQueue:
|
||||||
msg = outMsg.msg
|
msg = outMsg.msg
|
||||||
@@ -396,8 +399,8 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
|||||||
msg: closingSigned,
|
msg: closingSigned,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The responder will now see that we agreed on the fee, and broadcast
|
// Alice will now see that Bob agreed on the fee, and broadcast the coop
|
||||||
// the closing transaction.
|
// close transaction.
|
||||||
select {
|
select {
|
||||||
case <-broadcastTxChan:
|
case <-broadcastTxChan:
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
@@ -476,7 +479,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
|||||||
increasedFee, dummyDeliveryScript, initiatorDeliveryScript,
|
increasedFee, dummyDeliveryScript, initiatorDeliveryScript,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create close proposal: %v", err)
|
t.Fatalf("error creating close proposal: %v", err)
|
||||||
}
|
}
|
||||||
parsedSig, err := lnwire.NewSigFromSignature(closeSig)
|
parsedSig, err := lnwire.NewSigFromSignature(closeSig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -555,8 +558,9 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
|||||||
msg: closingSigned,
|
msg: closingSigned,
|
||||||
}
|
}
|
||||||
|
|
||||||
// It still won't be accepted, and we should get a new proposal, the
|
// Alice won't accept Bob's new proposal, and Bob should receive a new
|
||||||
// average of what we proposed, and what they proposed last time.
|
// proposal which is the average of what Bob proposed and Alice proposed
|
||||||
|
// last time.
|
||||||
select {
|
select {
|
||||||
case outMsg := <-initiator.outgoingQueue:
|
case outMsg := <-initiator.outgoingQueue:
|
||||||
msg = outMsg.msg
|
msg = outMsg.msg
|
||||||
|
|||||||
Reference in new issue
Block a user