From 8f4e9d68d0852b99b57fceb96d499156fad8c418 Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 24 Jan 2023 21:41:11 +0100 Subject: [PATCH] lnwire_test: fix BenchmarkReadMessage test The addition of AliasScid in the tlv_stream field of the funding_locked msg made the requirement for testdata of the ExtraOpaqueData part for the funding_locked msg type more strict. Now the input testdata for the funding_locked test is more specific and includes the new added AliasScid tlv record. --- lnwire/message_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lnwire/message_test.go b/lnwire/message_test.go index f39a88995..1df0b5c55 100644 --- a/lnwire/message_test.go +++ b/lnwire/message_test.go @@ -452,8 +452,20 @@ func newMsgChannelReady(t testing.TB, r io.Reader) *lnwire.ChannelReady { pubKey := randPubKey(t) - msg := lnwire.NewChannelReady(lnwire.ChannelID(c), pubKey) - msg.ExtraData = createExtraData(t, r) + // When testing the ChannelReady msg type in the WriteMessage + // function we need to populate the alias here to test the encoding + // of the TLV stream. + aliasScid := lnwire.NewShortChanIDFromInt(rand.Uint64()) + msg := &lnwire.ChannelReady{ + ChanID: lnwire.ChannelID(c), + NextPerCommitmentPoint: pubKey, + AliasScid: &aliasScid, + ExtraData: make([]byte, 0), + } + + // We do not include the TLV record (aliasScid) into the ExtraData + // because when the msg is encoded the ExtraData is overwritten + // with the current aliasScid value. return msg }