From 9e9bb5c9340a916cc6ef541556dd23887d1e3462 Mon Sep 17 00:00:00 2001
From: erick yan <46879318+erickyan86@users.noreply.github.com>
Date: Thu, 12 Sep 2019 15:17:14 +0800
Subject: [PATCH] modify fractal db interface (#487)
---
accountmanager/accountmanager_test.go | 4 +--
asset/asset_test.go | 6 ++--
blockchain/forkcontroller_test.go | 10 +++----
blockchain/genesis.go | 3 +-
blockchain/genesis_test.go | 3 +-
blockchain/test_utils.go | 6 ++--
consensus/dpos/ldb_test.go | 4 +--
feemanager/fee_test.go | 4 +--
node/service.go | 7 ++---
processor/vm/runtime/run_test.go | 7 ++---
processor/vm/runtime/runtime_test.go | 12 ++++----
processor/vm/vm_example_test.go | 14 ++++------
rawdb/accessors_chain_test.go | 17 ++++++------
rawdb/accessors_indexes_test.go | 3 +-
rawdb/database.go | 40 +++++++++++++++++++++++++++
rpcapi/filters/filter_system_test.go | 10 +++----
snapshot/snapshot_test.go | 5 ++--
state/mtp/iterator_test.go | 4 ++-
state/mtp/secure_trie_test.go | 6 ++--
state/mtp/sync_test.go | 22 +++++++--------
state/mtp/trie_test.go | 12 ++++----
state/statedb_test.go | 19 ++++++-------
txpool/handler_test.go | 4 +--
txpool/test_utils.go | 4 +--
txpool/txpool_test.go | 34 +++++++++++------------
utils/fdb/memdb/memdb.go | 2 +-
utils/fdb/memdb/memdb_test.go | 2 +-
27 files changed, 146 insertions(+), 118 deletions(-)
create mode 100644 rawdb/database.go
diff --git a/accountmanager/accountmanager_test.go b/accountmanager/accountmanager_test.go
index 8ba2cc89..1148d470 100644
--- a/accountmanager/accountmanager_test.go
+++ b/accountmanager/accountmanager_test.go
@@ -27,9 +27,9 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/crypto"
"github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/fractalplatform/fractal/utils/rlp"
)
@@ -40,7 +40,7 @@ var sysName = "fractal.account"
var blockNumber = uint64(0)
func getStateDB() *state.StateDB {
- db := memdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
trieDB := state.NewDatabase(db)
stateDB, err := state.New(common.Hash{}, trieDB)
if err != nil {
diff --git a/asset/asset_test.go b/asset/asset_test.go
index 108344a4..e0e96d49 100644
--- a/asset/asset_test.go
+++ b/asset/asset_test.go
@@ -22,8 +22,8 @@ import (
"testing"
"github.com/fractalplatform/fractal/common"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
var assetDB = getStateDB()
@@ -31,7 +31,7 @@ var assetDB = getStateDB()
var ast = getAsset()
func getStateDB() *state.StateDB {
- db := memdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
trieDB := state.NewDatabase(db)
stateDB, err := state.New(common.Hash{}, trieDB)
if err != nil {
@@ -48,7 +48,7 @@ func TestAsset_InitAssetCount(t *testing.T) {
type fields struct {
sdb *state.StateDB
}
- db := memdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
trieDB := state.NewDatabase(db)
stateDB, err := state.New(common.Hash{}, trieDB)
if err != nil {
diff --git a/blockchain/forkcontroller_test.go b/blockchain/forkcontroller_test.go
index ef8e928b..5c8b6fe6 100644
--- a/blockchain/forkcontroller_test.go
+++ b/blockchain/forkcontroller_test.go
@@ -22,9 +22,9 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/stretchr/testify/assert"
)
@@ -40,7 +40,7 @@ func (h headerMap) setHeader(num uint64, header *types.Header) {
func TestForkController1(t *testing.T) {
var (
testcfg = &ForkConfig{ForkBlockNum: 10, Forkpercentage: 80}
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db))
hm = make(headerMap)
)
@@ -80,7 +80,7 @@ func TestForkController1(t *testing.T) {
func TestForkController2(t *testing.T) {
var (
testcfg = &ForkConfig{ForkBlockNum: 10, Forkpercentage: 80}
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db))
hm = make(headerMap)
)
@@ -143,7 +143,7 @@ func TestForkController2(t *testing.T) {
func TestUpdateDifferentForkBlock(t *testing.T) {
var (
testcfg = &ForkConfig{ForkBlockNum: 10, Forkpercentage: 80}
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db))
hm = make(headerMap)
)
@@ -175,7 +175,7 @@ func TestUpdateDifferentForkBlock(t *testing.T) {
func TestFillForkID(t *testing.T) {
var (
testcfg = &ForkConfig{ForkBlockNum: 10, Forkpercentage: 80}
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db))
)
if err := initForkController(params.DefaultChainconfig.ChainName, statedb, 0); err != nil {
diff --git a/blockchain/genesis.go b/blockchain/genesis.go
index bcb3d695..60bab804 100644
--- a/blockchain/genesis.go
+++ b/blockchain/genesis.go
@@ -37,7 +37,6 @@ import (
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
"github.com/fractalplatform/fractal/utils/fdb"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/fractalplatform/fractal/utils/rlp"
)
@@ -183,7 +182,7 @@ func SetupGenesisBlock(db fdb.Database, genesis *Genesis) (*params.ChainConfig,
// to the given database (or discards it if nil).
func (g *Genesis) ToBlock(db fdb.Database) (*types.Block, []*types.Receipt, error) {
if db == nil {
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
}
detailTx := &types.DetailTx{}
var internals []*types.DetailAction
diff --git a/blockchain/genesis_test.go b/blockchain/genesis_test.go
index 54238bb7..c20f1ca4 100644
--- a/blockchain/genesis_test.go
+++ b/blockchain/genesis_test.go
@@ -29,7 +29,6 @@ import (
"github.com/fractalplatform/fractal/params"
"github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/utils/fdb"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
var defaultgenesisBlockHash = common.HexToHash("0xfff77195a34bae2cbe56990436ef0ae4f41f1a466a1a7943f7040ecdd19eceba")
@@ -115,7 +114,7 @@ func TestSetupGenesis(t *testing.T) {
}
for _, test := range tests {
- db := memdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
config, _, hash, err := test.fn(db)
diff --git a/blockchain/test_utils.go b/blockchain/test_utils.go
index c0775baa..76817b1b 100644
--- a/blockchain/test_utils.go
+++ b/blockchain/test_utils.go
@@ -38,7 +38,7 @@ import (
"github.com/fractalplatform/fractal/txpool"
"github.com/fractalplatform/fractal/types"
"github.com/fractalplatform/fractal/utils/fdb"
- memDB "github.com/fractalplatform/fractal/utils/fdb/memdb"
+ "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
var (
@@ -56,7 +56,7 @@ func (fe *fakeEngine) VerifySeal(chain consensus.IChainReader, header *types.Hea
func newCanonical(t *testing.T, genesis *Genesis) *BlockChain {
// Initialize a fresh chain with only a genesis block
- chainDb := memDB.NewMemDatabase()
+ chainDb := rawdb.NewMemoryDatabase()
chainCfg, dposCfg, _, err := SetupGenesisBlock(chainDb, genesis)
if err != nil {
@@ -130,7 +130,7 @@ func makeNewChain(t *testing.T, genesis *Genesis, chain *BlockChain, n, seed int
}
func deepCopyDB(db fdb.Database) (fdb.Database, error) {
- mdb, ok := db.(*memDB.MemDatabase)
+ mdb, ok := db.(*memdb.MemDatabase)
if !ok {
return nil, errors.New("db must fdb.MemDatabase")
}
diff --git a/consensus/dpos/ldb_test.go b/consensus/dpos/ldb_test.go
index da7858f1..4144e6ad 100644
--- a/consensus/dpos/ldb_test.go
+++ b/consensus/dpos/ldb_test.go
@@ -24,9 +24,9 @@ import (
"reflect"
"testing"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/types"
"github.com/fractalplatform/fractal/utils/fdb"
- ldb "github.com/fractalplatform/fractal/utils/fdb/leveldb"
)
type levelDB struct {
@@ -75,7 +75,7 @@ func newTestLDB() (*levelDB, func()) {
if err != nil {
panic("failed to create test file: " + err.Error())
}
- db, err := ldb.NewLDBDatabase(dirname, 0, 0)
+ db, err := rawdb.NewLevelDBDatabase(dirname, 0, 0)
if err != nil {
panic("failed to create test database: " + err.Error())
}
diff --git a/feemanager/fee_test.go b/feemanager/fee_test.go
index 4992c179..2f2d5c25 100644
--- a/feemanager/fee_test.go
+++ b/feemanager/fee_test.go
@@ -24,8 +24,8 @@ import (
"github.com/fractalplatform/fractal/asset"
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
var sdb = getStateDB()
@@ -38,7 +38,7 @@ func getAsset() *asset.Asset {
}
func getStateDB() *state.StateDB {
- db := memdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
tridb := state.NewDatabase(db)
statedb, err := state.New(common.Hash{}, tridb)
if err != nil {
diff --git a/node/service.go b/node/service.go
index a0789b01..fc2c66a9 100644
--- a/node/service.go
+++ b/node/service.go
@@ -22,10 +22,9 @@ import (
"github.com/fractalplatform/fractal/p2p"
"github.com/fractalplatform/fractal/p2p/enode"
adaptor "github.com/fractalplatform/fractal/p2p/protoadaptor"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/rpc"
"github.com/fractalplatform/fractal/utils/fdb"
- ldb "github.com/fractalplatform/fractal/utils/fdb/leveldb"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
// ServiceContext is a collection of service independent options inherited from
@@ -42,9 +41,9 @@ type ServiceContext struct {
// node is an ephemeral one, a memory database is returned.
func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (fdb.Database, error) {
if ctx.config.DataDir == "" {
- return mdb.NewMemDatabase(), nil
+ return rawdb.NewMemoryDatabase(), nil
}
- db, err := ldb.NewLDBDatabase(ctx.config.resolvePath(name), cache, handles)
+ db, err := rawdb.NewLevelDBDatabase(ctx.config.resolvePath(name), cache, handles)
if err != nil {
return nil, err
}
diff --git a/processor/vm/runtime/run_test.go b/processor/vm/runtime/run_test.go
index 43690c61..b8f5e1fc 100644
--- a/processor/vm/runtime/run_test.go
+++ b/processor/vm/runtime/run_test.go
@@ -21,19 +21,18 @@ import (
"math/big"
"testing"
- "github.com/fractalplatform/fractal/params"
-
"github.com/fractalplatform/fractal/accountmanager"
"github.com/fractalplatform/fractal/common"
+ "github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
//TestRunCode run runtime code directly
func TestRunCode(t *testing.T) {
//fmt.Println("in TestRunCode ...")
- state, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ state, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
account, _ := accountmanager.NewAccountManager(state)
//fmt.Println("in TestRunCode2 ...")
//sender
diff --git a/processor/vm/runtime/runtime_test.go b/processor/vm/runtime/runtime_test.go
index b070d50d..009d179a 100644
--- a/processor/vm/runtime/runtime_test.go
+++ b/processor/vm/runtime/runtime_test.go
@@ -25,17 +25,15 @@ import (
"strings"
"testing"
- "github.com/fractalplatform/fractal/params"
- "github.com/stretchr/testify/assert"
-
"github.com/fractalplatform/fractal/accountmanager"
- //"github.com/fractalplatform/fractal/asset"
"github.com/fractalplatform/fractal/common"
+ "github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
"github.com/fractalplatform/fractal/utils/abi"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/fractalplatform/fractal/utils/rlp"
+ "github.com/stretchr/testify/assert"
)
func input(abifile string, method string, params ...interface{}) ([]byte, error) {
@@ -115,7 +113,7 @@ func issueAssetAction(ownerName, toName common.Name) *types.Action {
}
func TestAsset(t *testing.T) {
- state, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ state, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
account, _ := accountmanager.NewAccountManager(state)
senderName := common.Name("jacobwolf12345")
@@ -308,7 +306,7 @@ func TestAsset(t *testing.T) {
}
}
func TestVEN(t *testing.T) {
- state, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ state, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
account, _ := accountmanager.NewAccountManager(state)
senderName := common.Name("jacobwolf12345")
diff --git a/processor/vm/vm_example_test.go b/processor/vm/vm_example_test.go
index 1c33c08b..5f5736cc 100644
--- a/processor/vm/vm_example_test.go
+++ b/processor/vm/vm_example_test.go
@@ -25,18 +25,16 @@ import (
"strings"
"testing"
- "github.com/fractalplatform/fractal/params"
- "github.com/fractalplatform/fractal/processor/vm/runtime"
- "github.com/stretchr/testify/assert"
-
"github.com/fractalplatform/fractal/accountmanager"
- //"github.com/fractalplatform/fractal/asset"
"github.com/fractalplatform/fractal/common"
+ "github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/processor/vm/runtime"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
"github.com/fractalplatform/fractal/utils/abi"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/fractalplatform/fractal/utils/rlp"
+ "github.com/stretchr/testify/assert"
)
func input(abifile string, method string, params ...interface{}) ([]byte, error) {
@@ -116,7 +114,7 @@ func issueAssetAction(ownerName, toName common.Name) *types.Action {
}
func TestAsset(t *testing.T) {
- state, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ state, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
account, _ := accountmanager.NewAccountManager(state)
senderName := common.Name("jacobwolf12345")
@@ -309,7 +307,7 @@ func TestAsset(t *testing.T) {
}
}
func TestVEN(t *testing.T) {
- state, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ state, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
account, _ := accountmanager.NewAccountManager(state)
senderName := common.Name("jacobwolf12345")
diff --git a/rawdb/accessors_chain_test.go b/rawdb/accessors_chain_test.go
index d71db1ae..d68c56dd 100644
--- a/rawdb/accessors_chain_test.go
+++ b/rawdb/accessors_chain_test.go
@@ -23,14 +23,13 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/fractalplatform/fractal/utils/rlp"
"golang.org/x/crypto/sha3"
)
// Tests block header storage and retrieval operations.
func TestHeaderStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
// Create a test header to move around the database and make sure it's really new
header := &types.Header{
@@ -68,7 +67,7 @@ func TestHeaderStorage(t *testing.T) {
// Tests block body storage and retrieval operations.
func TestBodyStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
action1 := types.NewAction(types.Transfer, common.Name("fromtest"), common.Name("tototest"), uint64(3), uint64(1), uint64(2000), big.NewInt(1000), []byte("test action"), []byte("test remark"))
action2 := types.NewAction(types.Transfer, common.Name("fromtest"), common.Name("tototest"), uint64(3), uint64(1), uint64(2000), big.NewInt(1000), []byte("test action"), []byte("test remark"))
@@ -123,7 +122,7 @@ func TestBodyStorage(t *testing.T) {
// Tests block storage and retrieval operations.
func TestBlockStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
// Create a test block to move around the database and make sure it's really new
header := &types.Header{
@@ -173,7 +172,7 @@ func TestBlockStorage(t *testing.T) {
// Tests block total difficulty storage and retrieval operations.
func TestTdStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
// Create a test TD to move around the database and make sure it's really new
hash, td := common.Hash{}, big.NewInt(314)
@@ -196,7 +195,7 @@ func TestTdStorage(t *testing.T) {
// Tests that canonical numbers can be mapped to hashes and retrieved.
func TestCanonicalMappingStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
// Create a test canonical number and assinged hash to move around
hash, number := common.Hash{0: 0xff}, uint64(314)
@@ -219,7 +218,7 @@ func TestCanonicalMappingStorage(t *testing.T) {
// Tests that head headers and head blocks can be assigned, individually.
func TestHeadStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
blockHead := &types.Block{
Head: &types.Header{Extra: []byte("test block header")},
@@ -250,7 +249,7 @@ func TestHeadStorage(t *testing.T) {
// Tests that receipts associated with a single block can be stored and retrieved.
func TestBlockReceiptStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
receipt1 := &types.Receipt{
ActionResults: []*types.ActionResult{&types.ActionResult{Status: types.ReceiptStatusFailed, Index: uint64(0), GasUsed: uint64(100)}},
@@ -304,7 +303,7 @@ func TestBlockReceiptStorage(t *testing.T) {
}
func TestIrreversibleNumberStore(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
number := uint64(100)
diff --git a/rawdb/accessors_indexes_test.go b/rawdb/accessors_indexes_test.go
index defb4a04..e8617f4c 100644
--- a/rawdb/accessors_indexes_test.go
+++ b/rawdb/accessors_indexes_test.go
@@ -22,12 +22,11 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
// Tests that positional lookup metadata can be stored and retrieved.
func TestLookupStorage(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := NewMemoryDatabase()
action1 := types.NewAction(types.Transfer, common.Name("fromtest"), common.Name("tototest"), uint64(3), uint64(3), uint64(2000), big.NewInt(1000), []byte("test action1"), []byte("test remark1"))
action2 := types.NewAction(types.Transfer, common.Name("fromtest"), common.Name("tototest"), uint64(3), uint64(3), uint64(2000), big.NewInt(1000), []byte("test action2"), []byte("test remark2"))
diff --git a/rawdb/database.go b/rawdb/database.go
new file mode 100644
index 00000000..bd67c140
--- /dev/null
+++ b/rawdb/database.go
@@ -0,0 +1,40 @@
+// Copyright 2018 The Fractal Team Authors
+// This file is part of the fractal project.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+package rawdb
+
+import (
+ "github.com/fractalplatform/fractal/utils/fdb"
+ "github.com/fractalplatform/fractal/utils/fdb/leveldb"
+ "github.com/fractalplatform/fractal/utils/fdb/memdb"
+)
+
+// NewMemoryDatabase creates an ephemeral in-memory key-value database .
+func NewMemoryDatabase() fdb.Database {
+ return memdb.NewMemDatabase()
+
+}
+
+// NewMemoryDatabaseWithCap creates an ephemeral in-memory key-value database
+// with an initial starting capacity.
+func NewMemoryDatabaseWithCap(size int) fdb.Database {
+ return memdb.NewMemDatabaseWithCap(size)
+}
+
+// NewLevelDBDatabase creates a persistent key-value database.
+func NewLevelDBDatabase(file string, cache int, handles int) (fdb.Database, error) {
+ return leveldb.NewLDBDatabase(file, cache, handles)
+}
diff --git a/rpcapi/filters/filter_system_test.go b/rpcapi/filters/filter_system_test.go
index d79e2985..3eacad1d 100644
--- a/rpcapi/filters/filter_system_test.go
+++ b/rpcapi/filters/filter_system_test.go
@@ -23,13 +23,11 @@ import (
"time"
"github.com/fractalplatform/fractal/common"
- "github.com/fractalplatform/fractal/rawdb"
-
"github.com/fractalplatform/fractal/event"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/rpc"
"github.com/fractalplatform/fractal/types"
"github.com/fractalplatform/fractal/utils/fdb"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
type testBackend struct {
@@ -102,7 +100,7 @@ func TestBlockSubscription(t *testing.T) {
t.Parallel()
var (
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
txFeed = new(event.Feed)
rmLogsFeed = new(event.Feed)
logsFeed = new(event.Feed)
@@ -167,7 +165,7 @@ func TestPendingTxFilter(t *testing.T) {
t.Parallel()
var (
- db = memdb.NewMemDatabase()
+ db = rawdb.NewMemoryDatabase()
txFeed = new(event.Feed)
rmLogsFeed = new(event.Feed)
logsFeed = new(event.Feed)
@@ -226,7 +224,7 @@ func TestPendingTxFilter(t *testing.T) {
// t.Parallel()
// var (
-// db = memdb.NewMemDatabase()
+// db = rawdb.NewMemoryDatabase()
// txFeed = new(event.Feed)
// rmLogsFeed = new(event.Feed)
// logsFeed = new(event.Feed)
diff --git a/snapshot/snapshot_test.go b/snapshot/snapshot_test.go
index 62918ed9..caf79b5b 100644
--- a/snapshot/snapshot_test.go
+++ b/snapshot/snapshot_test.go
@@ -23,11 +23,10 @@ import (
"github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
func TestSnapshot(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
batch := db.NewBatch()
cachedb := state.NewDatabase(db)
prevHash := common.Hash{}
@@ -96,7 +95,7 @@ func TestSnapshot(t *testing.T) {
}
func TestSnapshotError(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
batch := db.NewBatch()
cachedb := state.NewDatabase(db)
prevHash := common.Hash{}
diff --git a/state/mtp/iterator_test.go b/state/mtp/iterator_test.go
index 1f0ed549..56613bf4 100644
--- a/state/mtp/iterator_test.go
+++ b/state/mtp/iterator_test.go
@@ -23,6 +23,7 @@ import (
"testing"
"github.com/fractalplatform/fractal/common"
+ "github.com/fractalplatform/fractal/rawdb"
mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
@@ -311,6 +312,7 @@ func testIteratorContinueAfterError(t *testing.T, memonly bool) {
} else {
diskKeys = diskdb.Keys()
}
+
for i := 0; i < 20; i++ {
// Create trie that will load all nodes from DB.
tr, _ := New(tr.Hash(), triedb)
@@ -376,7 +378,7 @@ func TestIteratorContinueAfterSeekErrorMemonly(t *testing.T) {
func testIteratorContinueAfterSeekError(t *testing.T, memonly bool) {
// Commit test trie to db, then remove the node containing "bars".
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
ctr, _ := New(common.Hash{}, triedb)
diff --git a/state/mtp/secure_trie_test.go b/state/mtp/secure_trie_test.go
index 4a9a0925..5660450d 100644
--- a/state/mtp/secure_trie_test.go
+++ b/state/mtp/secure_trie_test.go
@@ -24,18 +24,18 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/crypto"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
+ "github.com/fractalplatform/fractal/rawdb"
)
func newEmptySecure() *SecureTrie {
- trie, _ := NewSecure(common.Hash{}, NewDatabase(mdb.NewMemDatabase()), 0)
+ trie, _ := NewSecure(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()), 0)
return trie
}
// makeTestSecureTrie creates a large enough secure trie for testing.
func makeTestSecureTrie() (*Database, *SecureTrie, map[string][]byte) {
// Create an empty trie
- triedb := NewDatabase(mdb.NewMemDatabase())
+ triedb := NewDatabase(rawdb.NewMemoryDatabase())
trie, _ := NewSecure(common.Hash{}, triedb, 0)
diff --git a/state/mtp/sync_test.go b/state/mtp/sync_test.go
index 144deac0..84b43e00 100644
--- a/state/mtp/sync_test.go
+++ b/state/mtp/sync_test.go
@@ -21,13 +21,13 @@ import (
"testing"
"github.com/fractalplatform/fractal/common"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
+ "github.com/fractalplatform/fractal/rawdb"
)
// makeTestTrie create a sample test trie to test node-wise reconstruction.
func makeTestTrie() (*Database, *Trie, map[string][]byte) {
// Create an empty trie
- triedb := NewDatabase(mdb.NewMemDatabase())
+ triedb := NewDatabase(rawdb.NewMemoryDatabase())
trie, _ := New(common.Hash{}, triedb)
// Fill it with some arbitrary data
@@ -88,13 +88,13 @@ func checkTrieConsistency(db *Database, root common.Hash) error {
// Tests that an empty trie is not scheduled for syncing.
func TestEmptySync(t *testing.T) {
- dbA := NewDatabase(mdb.NewMemDatabase())
- dbB := NewDatabase(mdb.NewMemDatabase())
+ dbA := NewDatabase(rawdb.NewMemoryDatabase())
+ dbB := NewDatabase(rawdb.NewMemoryDatabase())
emptyA, _ := New(common.Hash{}, dbA)
emptyB, _ := New(emptyRoot, dbB)
for i, trie := range []*Trie{emptyA, emptyB} {
- if req := NewSync(trie.Hash(), mdb.NewMemDatabase(), nil).Missing(1); len(req) != 0 {
+ if req := NewSync(trie.Hash(), rawdb.NewMemoryDatabase(), nil).Missing(1); len(req) != 0 {
t.Errorf("test %d: content requested for empty trie: %v", i, req)
}
}
@@ -110,7 +110,7 @@ func testIterativeSync(t *testing.T, batch int) {
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
@@ -143,7 +143,7 @@ func TestIterativeDelayedSync(t *testing.T) {
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
@@ -181,7 +181,7 @@ func testIterativeRandomSync(t *testing.T, batch int) {
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
@@ -222,7 +222,7 @@ func TestIterativeRandomDelayedSync(t *testing.T) {
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
@@ -269,7 +269,7 @@ func TestDuplicateAvoidanceSync(t *testing.T) {
srcDb, srcTrie, srcData := makeTestTrie()
// Create a destination trie and sync with the scheduler
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
@@ -309,7 +309,7 @@ func TestIncompleteSync(t *testing.T) {
srcDb, srcTrie, _ := makeTestTrie()
// Create a destination trie and sync with the scheduler
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
sched := NewSync(srcTrie.Hash(), diskdb, nil)
diff --git a/state/mtp/trie_test.go b/state/mtp/trie_test.go
index 819a0463..3a2c2a81 100644
--- a/state/mtp/trie_test.go
+++ b/state/mtp/trie_test.go
@@ -32,9 +32,9 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/crypto"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/utils/fdb"
ldb "github.com/fractalplatform/fractal/utils/fdb/leveldb"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/fractalplatform/fractal/utils/rlp"
)
@@ -45,7 +45,7 @@ func init() {
// Used for testing
func newEmpty() *Trie {
- trie, _ := New(common.Hash{}, NewDatabase(mdb.NewMemDatabase()))
+ trie, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
return trie
}
@@ -69,7 +69,7 @@ func TestNull(t *testing.T) {
}
func TestMissingRoot(t *testing.T) {
- trie, err := New(common.HexToHash("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"), NewDatabase(mdb.NewMemDatabase()))
+ trie, err := New(common.HexToHash("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"), NewDatabase(rawdb.NewMemoryDatabase()))
if trie != nil {
t.Error("New returned non-nil trie for invalid root")
}
@@ -82,7 +82,7 @@ func TestMissingNodeDisk(t *testing.T) { testMissingNode(t, false) }
func TestMissingNodeMemonly(t *testing.T) { testMissingNode(t, true) }
func testMissingNode(t *testing.T, memonly bool) {
- diskdb := mdb.NewMemDatabase()
+ diskdb := rawdb.NewMemoryDatabase()
triedb := NewDatabase(diskdb)
trie, _ := New(common.Hash{}, triedb)
@@ -413,7 +413,7 @@ func (randTest) Generate(r *rand.Rand, size int) reflect.Value {
}
func runRandTest(rt randTest) bool {
- triedb := NewDatabase(mdb.NewMemDatabase())
+ triedb := NewDatabase(rawdb.NewMemoryDatabase())
tr, _ := New(common.Hash{}, triedb)
values := make(map[string]string) // tracks content of the trie
@@ -597,7 +597,7 @@ func tempDB() (string, *Database) {
if err != nil {
panic(fmt.Sprintf("can't create temporary directory: %v", err))
}
- diskdb, err := ldb.NewLDBDatabase(dir, 256, 0)
+ diskdb, err := rawdb.NewLevelDBDatabase(dir, 256, 0)
if err != nil {
panic(fmt.Sprintf("can't create temporary database: %v", err))
}
diff --git a/state/statedb_test.go b/state/statedb_test.go
index cd27fdd0..5dd9a565 100644
--- a/state/statedb_test.go
+++ b/state/statedb_test.go
@@ -26,11 +26,10 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
func TestNew(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
cacheDb := NewDatabase(db)
rootHash := common.BytesToHash([]byte("not exist hash"))
@@ -47,7 +46,7 @@ func TestNew(t *testing.T) {
}
func TestReset(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
cacheDb := NewDatabase(db)
rootNullHash := common.Hash{}
@@ -91,7 +90,7 @@ func TestReset(t *testing.T) {
}
func TestRefund(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
cacheDb := NewDatabase(db)
rootNullHash := common.Hash{}
@@ -110,7 +109,7 @@ func TestRefund(t *testing.T) {
}
func TestPutAndGet(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
batch := db.NewBatch()
cachedb := NewDatabase(db)
prevRoot := common.Hash{}
@@ -167,7 +166,7 @@ func TestPutAndGet(t *testing.T) {
}
func TestSetAndGetState(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
batch := db.NewBatch()
cachedb := NewDatabase(db)
prevRoot := common.Hash{}
@@ -215,7 +214,7 @@ func TestSetAndGetState(t *testing.T) {
}
func TestLog(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
cachedb := NewDatabase(db)
prevRoot := common.Hash{}
currentBlockHash := common.BytesToHash([]byte("01"))
@@ -276,7 +275,7 @@ func TestLog(t *testing.T) {
}
func TestRevertSnap(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
cachedb := NewDatabase(db)
prevHash := common.Hash{}
state, _ := New(prevHash, cachedb)
@@ -377,7 +376,7 @@ func TestRevertSnap(t *testing.T) {
//element : 1->2->3
func TestTransToSpecBlock1(t *testing.T) {
- db := mdb.NewMemDatabase()
+ db := rawdb.NewMemoryDatabase()
batch := db.NewBatch()
cachedb := NewDatabase(db)
addr := "addr01"
@@ -423,7 +422,7 @@ func TestTransToSpecBlock1(t *testing.T) {
}
func TestStateDB_IntermediateRoot(t *testing.T) {
- state, err := New(common.Hash{}, NewDatabase(mdb.NewMemDatabase()))
+ state, err := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
if err != nil {
t.Error("New err")
}
diff --git a/txpool/handler_test.go b/txpool/handler_test.go
index 11336d1e..91e83321 100644
--- a/txpool/handler_test.go
+++ b/txpool/handler_test.go
@@ -26,9 +26,9 @@ import (
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/event"
"github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
const (
@@ -114,7 +114,7 @@ func TestBloom(t *testing.T) {
func TestP2PTxMsg(t *testing.T) {
var (
- statedb, _ = state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
manager, _ = am.NewAccountManager(statedb)
fname = common.Name("fromname")
tname = common.Name("totestname")
diff --git a/txpool/test_utils.go b/txpool/test_utils.go
index 01b08f49..ae14c536 100644
--- a/txpool/test_utils.go
+++ b/txpool/test_utils.go
@@ -29,9 +29,9 @@ import (
"github.com/fractalplatform/fractal/crypto"
"github.com/fractalplatform/fractal/event"
"github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- memdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
)
// testTxPoolConfig is a transaction pool configuration without stateful disk
@@ -109,7 +109,7 @@ func generateAccount(t *testing.T, name common.Name, managers ...*am.AccountMana
func setupTxPool(assetOwner common.Name) (*TxPool, *am.AccountManager) {
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(memdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
asset := asset.NewAsset(statedb)
asset.IssueAsset("ft", 0, 0, "zz", new(big.Int).SetUint64(params.Fractal), 10, assetOwner, assetOwner, big.NewInt(1000000), common.Name(""), "")
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)}
diff --git a/txpool/txpool_test.go b/txpool/txpool_test.go
index 268af6b7..d471fb38 100644
--- a/txpool/txpool_test.go
+++ b/txpool/txpool_test.go
@@ -32,9 +32,9 @@ import (
"github.com/fractalplatform/fractal/crypto"
"github.com/fractalplatform/fractal/event"
"github.com/fractalplatform/fractal/params"
+ "github.com/fractalplatform/fractal/rawdb"
"github.com/fractalplatform/fractal/state"
"github.com/fractalplatform/fractal/types"
- mdb "github.com/fractalplatform/fractal/utils/fdb/memdb"
"github.com/stretchr/testify/assert"
)
@@ -49,7 +49,7 @@ func TestConfigCheck(t *testing.T) {
// block head event that initiated the resetState().
func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
var (
- statedb, _ = state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
manager, _ = am.NewAccountManager(statedb)
fname = common.Name("fromname")
tname = common.Name("totestname")
@@ -263,7 +263,7 @@ func TestTransactionChainFork(t *testing.T) {
tkey := generateAccount(t, tname, manager)
resetAsset := func() {
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
newmanager, _ := am.NewAccountManager(statedb)
if err := newmanager.CreateAccount(common.Name("fractal"), fname, common.Name(""), 0, 0, common.BytesToPubKey(crypto.FromECDSAPub(&fkey.PublicKey)), ""); err != nil {
@@ -308,7 +308,7 @@ func TestTransactionDoubleNonce(t *testing.T) {
tkey := generateAccount(t, tname, manager)
resetAsset := func() {
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
newmanager, _ := am.NewAccountManager(statedb)
if err := newmanager.CreateAccount(common.Name("fractal"), fname, common.Name(""), 0, 0, common.BytesToPubKey(crypto.FromECDSAPub(&fkey.PublicKey)), ""); err != nil {
@@ -535,7 +535,7 @@ func TestTransactionDropping(t *testing.T) {
// postponed back into the future queue to prevent broadcasting them.
func TestTransactionPostponing(t *testing.T) {
// Create the pool to test the postponing with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)}
manager, _ := am.NewAccountManager(statedb)
assetID := uint64(0)
@@ -761,7 +761,7 @@ func TestTransactionQueueGlobalLimitingNoLocals(t *testing.T) {
func testTransactionQueueGlobalLimiting(t *testing.T, nolocals bool) {
// Create the pool to test the limit enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
config := testTxPoolConfig
@@ -862,7 +862,7 @@ func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) {
evictionInterval = time.Second
// Create the pool to test the non-expiration enforcement
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
config := testTxPoolConfig
@@ -977,7 +977,7 @@ func TestTransactionPendingLimiting(t *testing.T) {
// Note, local transactions are never allowed to be dropped.
func TestTransactionPoolRepricing(t *testing.T) {
// Create the pool to test the pricing enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
@@ -1107,7 +1107,7 @@ func TestTransactionPoolRepricing(t *testing.T) {
// remove local transactions.
func TestTransactionPoolRepricingKeepsLocals(t *testing.T) {
// Create the pool to test the pricing enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
pool := New(testTxPoolConfig, params.DefaultChainconfig, blockchain)
@@ -1178,7 +1178,7 @@ func TestTransactionPoolRepricingKeepsLocals(t *testing.T) {
// Note, local transactions are never allowed to be dropped.
func TestTransactionPoolUnderpricing(t *testing.T) {
// Create the pool to test the pricing enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
@@ -1292,7 +1292,7 @@ func TestTransactionPoolUnderpricing(t *testing.T) {
// back and forth between queued/pending.
func TestTransactionPoolStableUnderpricing(t *testing.T) {
// Create the pool to test the pricing enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
config := testTxPoolConfig
@@ -1367,7 +1367,7 @@ func TestTransactionPoolStableUnderpricing(t *testing.T) {
// price bump required.
func TestTransactionReplacement(t *testing.T) {
// Create the pool to test the pricing enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
pool := New(testTxPoolConfig, params.DefaultChainconfig, blockchain)
@@ -1452,7 +1452,7 @@ func TestTransactionReplacement(t *testing.T) {
func TestTransactionPendingGlobalLimiting(t *testing.T) {
// Create the pool to test the limit enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
config := testTxPoolConfig
@@ -1506,7 +1506,7 @@ func TestTransactionPendingGlobalLimiting(t *testing.T) {
// Tests that if transactions start being capped, transactions are also removed from 'all'
func TestTransactionCapClearsFromAll(t *testing.T) {
// Create the pool to test the limit enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
config := testTxPoolConfig
@@ -1544,7 +1544,7 @@ func TestTransactionCapClearsFromAll(t *testing.T) {
// the transactions are still kept.
func TestTransactionPendingMinimumAllowance(t *testing.T) {
// Create the pool to test the limit enforcement with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
@@ -1613,7 +1613,7 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
event.Reset()
// Create the original pool to inject transaction into the journal
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
config := testTxPoolConfig
@@ -1719,7 +1719,7 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
// pending status of individual transactions.
func TestTransactionStatusCheck(t *testing.T) {
// Create the pool to test the status retrievals with
- statedb, _ := state.New(common.Hash{}, state.NewDatabase(mdb.NewMemDatabase()))
+ statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
event.Reset()
pool := New(testTxPoolConfig, params.DefaultChainconfig, blockchain)
diff --git a/utils/fdb/memdb/memdb.go b/utils/fdb/memdb/memdb.go
index 14a822b7..5159d535 100644
--- a/utils/fdb/memdb/memdb.go
+++ b/utils/fdb/memdb/memdb.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-package fdb
+package memdb
import (
"errors"
diff --git a/utils/fdb/memdb/memdb_test.go b/utils/fdb/memdb/memdb_test.go
index 6662dc0b..e6e63b1e 100644
--- a/utils/fdb/memdb/memdb_test.go
+++ b/utils/fdb/memdb/memdb_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-package fdb
+package memdb
import (
"testing"