OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / vendor / github.com / btcsuite / btcd / database / ffldb / export_test.go
1 // Copyright (c) 2015-2016 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
4
5 /*
6 This test file is part of the ffldb package rather than than the ffldb_test
7 package so it can bridge access to the internals to properly test cases which
8 are either not possible or can't reliably be tested via the public interface.
9 The functions are only exported while the tests are being run.
10 */
11
12 package ffldb
13
14 import "github.com/btcsuite/btcd/database"
15
16 // TstRunWithMaxBlockFileSize runs the passed function with the maximum allowed
17 // file size for the database set to the provided value.  The value will be set
18 // back to the original value upon completion.
19 func TstRunWithMaxBlockFileSize(idb database.DB, size uint32, fn func()) {
20         ffldb := idb.(*db)
21         origSize := ffldb.store.maxBlockFileSize
22
23         ffldb.store.maxBlockFileSize = size
24         fn()
25         ffldb.store.maxBlockFileSize = origSize
26 }