aboutsummaryrefslogtreecommitdiffstats
path: root/integration_test
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-12-13 09:55:14 +0800
committerGitHub <noreply@github.com>2018-12-13 09:55:14 +0800
commit06693fc13b451835ac460688903c7abb660710fb (patch)
tree22d1bfde3b023395cfe00c6df8a1edaebb0f7cce /integration_test
parent338bf8676563a103cc78bbacef75fbaaac4293d7 (diff)
downloaddexon-consensus-06693fc13b451835ac460688903c7abb660710fb.tar
dexon-consensus-06693fc13b451835ac460688903c7abb660710fb.tar.gz
dexon-consensus-06693fc13b451835ac460688903c7abb660710fb.tar.bz2
dexon-consensus-06693fc13b451835ac460688903c7abb660710fb.tar.lz
dexon-consensus-06693fc13b451835ac460688903c7abb660710fb.tar.xz
dexon-consensus-06693fc13b451835ac460688903c7abb660710fb.tar.zst
dexon-consensus-06693fc13b451835ac460688903c7abb660710fb.zip
db: rename blockdb to db (#367)
* Rename blockdb package to db * Rename 'BlockDB' to 'DB' * Make all methods in db specific for ''block'. * Rename db.BlockDatabase to db.Database * Rename revealer to block-revealer * Rename test.Revealer to test.BlockRevealer
Diffstat (limited to 'integration_test')
-rw-r--r--integration_test/consensus_test.go18
-rw-r--r--integration_test/node.go16
-rw-r--r--integration_test/utils.go8
3 files changed, 21 insertions, 21 deletions
diff --git a/integration_test/consensus_test.go b/integration_test/consensus_test.go
index 6d693c8..698305c 100644
--- a/integration_test/consensus_test.go
+++ b/integration_test/consensus_test.go
@@ -26,8 +26,8 @@ import (
"github.com/dexon-foundation/dexon-consensus/common"
"github.com/dexon-foundation/dexon-consensus/core"
- "github.com/dexon-foundation/dexon-consensus/core/blockdb"
"github.com/dexon-foundation/dexon-consensus/core/crypto"
+ "github.com/dexon-foundation/dexon-consensus/core/db"
"github.com/dexon-foundation/dexon-consensus/core/syncer"
"github.com/dexon-foundation/dexon-consensus/core/test"
"github.com/dexon-foundation/dexon-consensus/core/types"
@@ -46,7 +46,7 @@ type node struct {
con *core.Consensus
app *test.App
gov *test.Governance
- db blockdb.BlockDatabase
+ db db.Database
network *test.Network
}
@@ -65,7 +65,7 @@ func (s *ConsensusTestSuite) setupNodes(
nodes := make(map[types.NodeID]*node)
wg.Add(len(prvKeys))
for _, k := range prvKeys {
- db, err := blockdb.NewMemBackedBlockDB()
+ dbInst, err := db.NewMemBackedDB()
s.Require().NoError(err)
// Prepare essential modules: app, gov, db.
networkModule := test.NewNetwork(
@@ -83,12 +83,12 @@ func (s *ConsensusTestSuite) setupNodes(
dMoment,
app,
gov,
- db,
+ dbInst,
networkModule,
k,
&common.NullLogger{},
)
- nodes[con.ID] = &node{con.ID, con, app, gov, db, networkModule}
+ nodes[con.ID] = &node{con.ID, con, app, gov, dbInst, networkModule}
go func() {
defer wg.Done()
s.Require().NoError(networkModule.Setup(serverChannel))
@@ -121,11 +121,11 @@ func (s *ConsensusTestSuite) syncBlocksWithSomeNode(
syncerHeight = nextSyncHeight
// Setup revealer.
- DBAll, err := sourceNode.db.GetAll()
+ DBAll, err := sourceNode.db.GetAllBlocks()
if err != nil {
return
}
- r, err := test.NewCompactionChainRevealer(DBAll, nextSyncHeight)
+ r, err := test.NewCompactionChainBlockRevealer(DBAll, nextSyncHeight)
if err != nil {
return
}
@@ -153,9 +153,9 @@ func (s *ConsensusTestSuite) syncBlocksWithSomeNode(
}
for {
var b types.Block
- b, err = r.Next()
+ b, err = r.NextBlock()
if err != nil {
- if err == blockdb.ErrIterationFinished {
+ if err == db.ErrIterationFinished {
err = nil
if syncBlocks() {
break
diff --git a/integration_test/node.go b/integration_test/node.go
index aa3a703..511b5fd 100644
--- a/integration_test/node.go
+++ b/integration_test/node.go
@@ -23,8 +23,8 @@ import (
"github.com/dexon-foundation/dexon-consensus/common"
"github.com/dexon-foundation/dexon-consensus/core"
- "github.com/dexon-foundation/dexon-consensus/core/blockdb"
"github.com/dexon-foundation/dexon-consensus/core/crypto"
+ "github.com/dexon-foundation/dexon-consensus/core/db"
"github.com/dexon-foundation/dexon-consensus/core/test"
"github.com/dexon-foundation/dexon-consensus/core/types"
"github.com/dexon-foundation/dexon-consensus/core/utils"
@@ -76,7 +76,7 @@ type Node struct {
appModule *test.App
stateModule *test.State
govModule *test.Governance
- dbModule blockdb.BlockDatabase
+ dbModule db.Database
broadcastTargets map[types.NodeID]struct{}
networkLatency test.LatencyModel
proposingLatency test.LatencyModel
@@ -99,8 +99,8 @@ func newNode(
// Load all configs prepared in core.Governance into core.Lattice.
copiedGov := gov.Clone()
configs := loadAllConfigs(copiedGov)
- // Setup blockdb.
- db, err := blockdb.NewMemBackedBlockDB()
+ // Setup db.
+ dbInst, err := db.NewMemBackedDB()
if err != nil {
return nil, err
}
@@ -114,7 +114,7 @@ func newNode(
core.NewAuthenticator(privateKey),
app,
app,
- db,
+ dbInst,
&common.NullLogger{})
n := &Node{
ID: types.NewNodeID(privateKey.PublicKey()),
@@ -125,7 +125,7 @@ func newNode(
proposingLatency: proposingLatency,
appModule: app,
stateModule: copiedGov.State(),
- dbModule: db,
+ dbModule: dbInst,
govModule: copiedGov,
lattice: lattice,
latticeMaxNumChains: configs[0].NumChains,
@@ -254,7 +254,7 @@ func (n *Node) processBlock(b *types.Block) (events []*test.Event, err error) {
}
// Deliver blocks.
for _, b = range delivered {
- if err = n.dbModule.Put(*b); err != nil {
+ if err = n.dbModule.PutBlock(*b); err != nil {
panic(err)
}
b.Finalization.Height = n.prevFinalHeight + 1
@@ -349,7 +349,7 @@ func (n *Node) app() *test.App {
return n.appModule
}
-func (n *Node) db() blockdb.BlockDatabase {
+func (n *Node) db() db.Database {
return n.dbModule
}
diff --git a/integration_test/utils.go b/integration_test/utils.go
index a6cc139..2fbfa1a 100644
--- a/integration_test/utils.go
+++ b/integration_test/utils.go
@@ -22,8 +22,8 @@ import (
"time"
"github.com/dexon-foundation/dexon-consensus/core"
- "github.com/dexon-foundation/dexon-consensus/core/blockdb"
"github.com/dexon-foundation/dexon-consensus/core/crypto"
+ "github.com/dexon-foundation/dexon-consensus/core/db"
"github.com/dexon-foundation/dexon-consensus/core/test"
"github.com/dexon-foundation/dexon-consensus/core/types"
)
@@ -125,13 +125,13 @@ func VerifyApps(apps map[types.NodeID]*test.App) (err error) {
return
}
-// CollectAppAndDBFromNodes collects test.App and blockdb.BlockDatabase
+// CollectAppAndDBFromNodes collects test.App and db.Database
// from nodes.
func CollectAppAndDBFromNodes(nodes map[types.NodeID]*Node) (
apps map[types.NodeID]*test.App,
- dbs map[types.NodeID]blockdb.BlockDatabase) {
+ dbs map[types.NodeID]db.Database) {
apps = make(map[types.NodeID]*test.App)
- dbs = make(map[types.NodeID]blockdb.BlockDatabase)
+ dbs = make(map[types.NodeID]db.Database)
for nID, node := range nodes {
apps[nID] = node.app()
dbs[nID] = node.db()