channeldb: attach DB to channel in FetchHistoricalChannel

This commit is contained in:
yyforyongyu committed 2021-09-23 13:22:34 +08:00
1 parent e513057eae
commit 556b038398
2 files changed
+6 -3

No files matched your search

+2
View File
@@ -1299,6 +1299,8 @@ func (d *DB) FetchHistoricalChannel(outPoint *wire.OutPoint) (*OpenChannel, erro
} }
channel, err = fetchOpenChannel(chanBucket, outPoint) channel, err = fetchOpenChannel(chanBucket, outPoint)
channel.Db = d
return err return err
}, func() { }, func() {
channel = nil channel = nil
+4 -3
View File
@@ -717,9 +717,10 @@ func TestFetchHistoricalChannel(t *testing.T) {
t.Fatalf("unexepected error getting channel: %v", err) t.Fatalf("unexepected error getting channel: %v", err)
} }
// Set the db on our channel to nil so that we can check that all other // FetchHistoricalChannel will attach the cdb to channel.Db, we set it
// fields on the channel equal those on the historical channel. // here so that we can check that all other fields on the channel equal
channel.Db = nil // those on the historical channel.
channel.Db = cdb
if !reflect.DeepEqual(histChannel, channel) { if !reflect.DeepEqual(histChannel, channel) {
t.Fatalf("expected: %v, got: %v", channel, histChannel) t.Fatalf("expected: %v, got: %v", channel, histChannel)