multi: rename ChannelUpdate to ChannelUpdate1

In preparation for adding a new ChannelUpdate2 message and a
ChannelUpdate interface, we rename the existing message to
ChannelUpdate1.
This commit is contained in:
Elle Mouton committed 2024-09-18 16:13:17 +02:00
1 parent bb44efa21f
commit 60f331edb1
43 files changed
+198 -172

No files matched your search

+3 -3
View File
@@ -197,7 +197,7 @@ func TestMissionControl(t *testing.T) {
// A node level failure should bring probability of all known channels
// back to zero.
ctx.reportFailure(0, lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate{}))
ctx.reportFailure(0, lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate1{}))
ctx.expectP(1000, 0)
// Check whether history snapshot looks sane.
@@ -219,14 +219,14 @@ func TestMissionControlChannelUpdate(t *testing.T) {
// Report a policy related failure. Because it is the first, we don't
// expect a penalty.
ctx.reportFailure(
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}),
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate1{}),
)
ctx.expectP(100, testAprioriHopProbability)
// Report another failure for the same channel. We expect it to be
// pruned.
ctx.reportFailure(
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}),
0, lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate1{}),
)
ctx.expectP(100, 0)
}
+2 -2
View File
@@ -186,7 +186,7 @@ func (m *mockPaymentSessionOld) RequestRoute(_, _ lnwire.MilliSatoshi,
return r, nil
}
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate,
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate1,
_ *btcec.PublicKey, _ *models.CachedEdgePolicy) bool {
return false
@@ -710,7 +710,7 @@ func (m *mockPaymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
return args.Get(0).(*route.Route), args.Error(1)
}
func (m *mockPaymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
func (m *mockPaymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool {
args := m.Called(msg, pubKey, policy)
+3 -3
View File
@@ -147,8 +147,8 @@ type PaymentSession interface {
// (private channels) and applies the update from the message. Returns
// a boolean to indicate whether the update has been applied without
// error.
UpdateAdditionalEdge(msg *lnwire.ChannelUpdate, pubKey *btcec.PublicKey,
policy *models.CachedEdgePolicy) bool
UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool
// GetAdditionalEdgePolicy uses the public key and channel ID to query
// the ephemeral channel edge policy for additional edges. Returns a nil
@@ -436,7 +436,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
// validates the message signature and checks it's up to date, then applies the
// updates to the supplied policy. It returns a boolean to indicate whether
// there's an error when applying the updates.
func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate1,
pubKey *btcec.PublicKey, policy *models.CachedEdgePolicy) bool {
// Validate the message signature.
+1 -1
View File
@@ -147,7 +147,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
)
// Create the channel update message and sign.
msg := &lnwire.ChannelUpdate{
msg := &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(testChannelID),
Timestamp: uint32(time.Now().Unix()),
BaseFee: newFeeBaseMSat,
+4 -3
View File
@@ -164,7 +164,7 @@ var resultTestCases = []resultTestCase{
name: "fail expiry too soon",
route: &routeFourHop,
failureSrcIdx: 3,
failure: lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate{}),
failure: lnwire.NewExpiryTooSoon(lnwire.ChannelUpdate1{}),
expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{
@@ -266,8 +266,9 @@ var resultTestCases = []resultTestCase{
name: "fail fee insufficient intermediate",
route: &routeFourHop,
failureSrcIdx: 2,
failure: lnwire.NewFeeInsufficient(0, lnwire.ChannelUpdate{}),
failure: lnwire.NewFeeInsufficient(
0, lnwire.ChannelUpdate1{},
),
expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{
getTestPair(0, 1): {
+3 -3
View File
@@ -288,7 +288,7 @@ type Config struct {
// ApplyChannelUpdate can be called to apply a new channel update to the
// graph that we received from a payment failure.
ApplyChannelUpdate func(msg *lnwire.ChannelUpdate) bool
ApplyChannelUpdate func(msg *lnwire.ChannelUpdate1) bool
// ClosedSCIDs is used by the router to fetch closed channels.
//
@@ -1329,9 +1329,9 @@ func (r *ChannelRouter) sendPayment(ctx context.Context,
// extractChannelUpdate examines the error and extracts the channel update.
func (r *ChannelRouter) extractChannelUpdate(
failure lnwire.FailureMessage) *lnwire.ChannelUpdate {
failure lnwire.FailureMessage) *lnwire.ChannelUpdate1 {
var update *lnwire.ChannelUpdate
var update *lnwire.ChannelUpdate1
switch onionErr := failure.(type) {
case *lnwire.FailExpiryTooSoon:
update = &onionErr.Update
+8 -8
View File
@@ -223,7 +223,7 @@ func createTestCtxFromFile(t *testing.T,
// Add valid signature to channel update simulated as error received from the
// network.
func signErrChanUpdate(t *testing.T, key *btcec.PrivateKey,
errChanUpdate *lnwire.ChannelUpdate) {
errChanUpdate *lnwire.ChannelUpdate1) {
chanUpdateMsg, err := errChanUpdate.DataToSign()
require.NoError(t, err, "failed to retrieve data to sign")
@@ -488,7 +488,7 @@ func TestChannelUpdateValidation(t *testing.T) {
// Set up a channel update message with an invalid signature to be
// returned to the sender.
var invalidSignature lnwire.Sig
errChanUpdate := lnwire.ChannelUpdate{
errChanUpdate := lnwire.ChannelUpdate1{
Signature: invalidSignature,
FeeRate: 500,
ShortChannelID: lnwire.NewShortChanIDFromInt(1),
@@ -593,7 +593,7 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
)
require.NoError(t, err, "unable to fetch chan id")
errChanUpdate := lnwire.ChannelUpdate{
errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(
songokuSophonChanID,
),
@@ -712,7 +712,7 @@ func TestSendPaymentErrorFeeInsufficientPrivateEdge(t *testing.T) {
// Prepare an error update for the private channel, with twice the
// original fee.
updatedFeeBaseMSat := feeBaseMSat * 2
errChanUpdate := lnwire.ChannelUpdate{
errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID),
Timestamp: uint32(testTime.Add(time.Minute).Unix()),
BaseFee: updatedFeeBaseMSat,
@@ -838,7 +838,7 @@ func TestSendPaymentPrivateEdgeUpdateFeeExceedsLimit(t *testing.T) {
// Prepare an error update for the private channel. The updated fee
// will exceeds the feeLimit.
updatedFeeBaseMSat := feeBaseMSat + uint32(feeLimit)
errChanUpdate := lnwire.ChannelUpdate{
errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(privateChannelID),
Timestamp: uint32(testTime.Add(time.Minute).Unix()),
BaseFee: updatedFeeBaseMSat,
@@ -939,7 +939,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(chanID)
require.NoError(t, err, "unable to fetch chan id")
errChanUpdate := lnwire.ChannelUpdate{
errChanUpdate := lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(chanID),
Timestamp: uint32(edgeUpdateToFail.LastUpdate.Unix()),
MessageFlags: edgeUpdateToFail.MessageFlags,
@@ -1402,7 +1402,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
testCases := map[int]lnwire.FailureMessage{
finalHopIndex: lnwire.NewFailIncorrectDetails(payAmt, 100),
1: &lnwire.FailFeeInsufficient{
Update: lnwire.ChannelUpdate{},
Update: lnwire.ChannelUpdate1{},
},
}
@@ -2967,7 +2967,7 @@ func (m *mockGraphBuilder) setNextReject(reject bool) {
m.rejectUpdate = reject
}
func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate) bool {
func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
if m.rejectUpdate {
return false
}