From 578c160cdf49b7c885ef82198284f20cf09ad452 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 3 Mar 2023 12:43:19 +0100 Subject: [PATCH] fix: revert double close fix (#15255) --- snapshots/helpers_test.go | 1 + snapshots/manager_test.go | 2 +- snapshots/stream.go | 4 ++++ snapshots/types/format.go | 2 +- store/rootmulti/snapshot_test.go | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/snapshots/helpers_test.go b/snapshots/helpers_test.go index 412b7de6caa..24051a17a92 100644 --- a/snapshots/helpers_test.go +++ b/snapshots/helpers_test.go @@ -77,6 +77,7 @@ func snapshotItems(items [][]byte) [][]byte { _ = snapshottypes.WriteExtensionItem(protoWriter, item) } _ = protoWriter.Close() + _ = zWriter.Close() _ = bufWriter.Flush() _ = chunkWriter.Close() }() diff --git a/snapshots/manager_test.go b/snapshots/manager_test.go index 8f8e8d3da8d..b7104302282 100644 --- a/snapshots/manager_test.go +++ b/snapshots/manager_test.go @@ -91,7 +91,7 @@ func TestManager_Take(t *testing.T) { Height: 5, Format: snapshotter.SnapshotFormat(), Chunks: 1, - Hash: []uint8{0xcf, 0xd8, 0x16, 0xd2, 0xf8, 0x11, 0xe8, 0x90, 0x92, 0xf1, 0xfe, 0x3b, 0xea, 0xd2, 0x94, 0xfc, 0xfa, 0x4f, 0x9e, 0x2a, 0x91, 0xbe, 0xb0, 0x50, 0x83, 0xe9, 0x28, 0x62, 0x48, 0x6a, 0x4b, 0x4}, + Hash: []uint8{0x14, 0x38, 0x97, 0x96, 0xba, 0xe4, 0x81, 0xaf, 0x6c, 0xac, 0xff, 0xa5, 0xb8, 0x7e, 0x63, 0x4b, 0xac, 0x69, 0x3f, 0x38, 0x90, 0x5c, 0x7d, 0x57, 0xb3, 0xf, 0x69, 0x73, 0xb3, 0xa0, 0xe0, 0xad}, Metadata: types.Metadata{ ChunkHashes: checksums(expectChunks), }, diff --git a/snapshots/stream.go b/snapshots/stream.go index ce000f3e9c3..935028313bb 100644 --- a/snapshots/stream.go +++ b/snapshots/stream.go @@ -57,6 +57,10 @@ func (sw *StreamWriter) Close() error { sw.chunkWriter.CloseWithError(err) return err } + if err := sw.zWriter.Close(); err != nil { + sw.chunkWriter.CloseWithError(err) + return err + } if err := sw.bufWriter.Flush(); err != nil { sw.chunkWriter.CloseWithError(err) return err diff --git a/snapshots/types/format.go b/snapshots/types/format.go index 317b6a6e329..d5e960660ac 100644 --- a/snapshots/types/format.go +++ b/snapshots/types/format.go @@ -3,4 +3,4 @@ package types // CurrentFormat is the currently used format for snapshots. Snapshots using the same format // must be identical across all nodes for a given height, so this must be bumped when the binary // snapshot output changes. -const CurrentFormat uint32 = 3 +const CurrentFormat uint32 = 2 diff --git a/store/rootmulti/snapshot_test.go b/store/rootmulti/snapshot_test.go index de7880788ee..f8b058656d3 100644 --- a/store/rootmulti/snapshot_test.go +++ b/store/rootmulti/snapshot_test.go @@ -128,7 +128,7 @@ func TestMultistoreSnapshot_Checksum(t *testing.T) { "aa048b4ee0f484965d7b3b06822cf0772cdcaad02f3b1b9055e69f2cb365ef3c", "7921eaa3ed4921341e504d9308a9877986a879fe216a099c86e8db66fcba4c63", "a4a864e6c02c9fca5837ec80dc84f650b25276ed7e4820cf7516ced9f9901b86", - "980925390cc50f14998ecb1e87de719ca9dd7e72f5fefbe445397bf670f36c31", + "8ca5b957e36fa13e704c31494649b2a74305148d70d70f0f26dee066b615c1d0", }}, } for _, tc := range testcases {