From 556b0383980c70595d405f8da40d4a4b739fc9bb Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 30 Aug 2021 18:58:43 +0800 Subject: [PATCH] channeldb: attach DB to channel in FetchHistoricalChannel --- channeldb/db.go | 2 ++ channeldb/db_test.go | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/channeldb/db.go b/channeldb/db.go index 514b730f9..57ebfdb24 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -1299,6 +1299,8 @@ func (d *DB) FetchHistoricalChannel(outPoint *wire.OutPoint) (*OpenChannel, erro } channel, err = fetchOpenChannel(chanBucket, outPoint) + + channel.Db = d return err }, func() { channel = nil diff --git a/channeldb/db_test.go b/channeldb/db_test.go index 60e82e680..04c0dcd41 100644 --- a/channeldb/db_test.go +++ b/channeldb/db_test.go @@ -717,9 +717,10 @@ func TestFetchHistoricalChannel(t *testing.T) { t.Fatalf("unexepected error getting channel: %v", err) } - // Set the db on our channel to nil so that we can check that all other - // fields on the channel equal those on the historical channel. - channel.Db = nil + // FetchHistoricalChannel will attach the cdb to channel.Db, we set it + // here so that we can check that all other fields on the channel equal + // those on the historical channel. + channel.Db = cdb if !reflect.DeepEqual(histChannel, channel) { t.Fatalf("expected: %v, got: %v", channel, histChannel)