diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-07-31 18:46:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-31 18:46:24 +0800 |
commit | 3778e956013cad171cd5954686831e2598de3045 (patch) | |
tree | f1d38286fc55dbf20def9a49a67449961ce89b44 /blockdb/level-db_test.go | |
parent | c9cf5953512e4503f4781d6a441404ff9dfe5660 (diff) | |
download | dexon-consensus-3778e956013cad171cd5954686831e2598de3045.tar dexon-consensus-3778e956013cad171cd5954686831e2598de3045.tar.gz dexon-consensus-3778e956013cad171cd5954686831e2598de3045.tar.bz2 dexon-consensus-3778e956013cad171cd5954686831e2598de3045.tar.lz dexon-consensus-3778e956013cad171cd5954686831e2598de3045.tar.xz dexon-consensus-3778e956013cad171cd5954686831e2598de3045.tar.zst dexon-consensus-3778e956013cad171cd5954686831e2598de3045.zip |
blockdb: allow to dump blocks to json-encoded file
- Allow to dump blockdb to a json file
- Compared to leveldb, a json file is easier to trace.
- Add interfaces block database:
- Close would be required by database that needs cleanup.
- BlockIterator is required when we need to access 'all' blocks,
adding a new method 'GetAll' as the constructor for iterators.
- Remove GetByValidatorAndHeight from blockdb.Reader
- This function is not used anywhere, to make interface
minimum, remove it.
- Fix typo: backend -> backed
Diffstat (limited to 'blockdb/level-db_test.go')
-rw-r--r-- | blockdb/level-db_test.go | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/blockdb/level-db_test.go b/blockdb/level-db_test.go index ef698f6..863adba 100644 --- a/blockdb/level-db_test.go +++ b/blockdb/level-db_test.go @@ -36,7 +36,7 @@ type LevelDBTestSuite struct { func (s *LevelDBTestSuite) TestBasicUsage() { dbName := fmt.Sprintf("test-db-%v.db", time.Now().UTC()) - db, err := NewLevelDBBackendBlockDB(dbName) + db, err := NewLevelDBBackedBlockDB(dbName) s.Require().Nil(err) defer func(dbName string) { err = db.Close() @@ -81,7 +81,7 @@ func (s *LevelDBTestSuite) TestBasicUsage() { s.Nil(err) // Try to get it back via ValidatorID and height. - queried, err = db.GetByValidatorAndHeight(block1.ProposerID, block1.Height) + queried, err = db.Get(block1.Hash) s.Nil(err) s.Equal(now, queried.Timestamps[queried.ProposerID]) @@ -89,7 +89,7 @@ func (s *LevelDBTestSuite) TestBasicUsage() { func (s *LevelDBTestSuite) TestSyncIndex() { dbName := fmt.Sprintf("test-db-%v-si.db", time.Now().UTC()) - db, err := NewLevelDBBackendBlockDB(dbName) + db, err := NewLevelDBBackedBlockDB(dbName) s.Require().Nil(err) defer func(dbName string) { err = db.Close() @@ -116,7 +116,7 @@ func (s *LevelDBTestSuite) TestSyncIndex() { s.Nil(err) // Load back blocks(syncIndex is called). - db, err = NewLevelDBBackendBlockDB(dbName) + db, err = NewLevelDBBackedBlockDB(dbName) s.Require().Nil(err) // Verify result. @@ -126,13 +126,6 @@ func (s *LevelDBTestSuite) TestSyncIndex() { s.Equal(block.ProposerID, queried.ProposerID) s.Equal(block.Height, queried.Height) } - - // Verify result using GetByValidatorAndHeight(). - for _, block := range blocks { - queried, err := db.GetByValidatorAndHeight(block.ProposerID, block.Height) - s.Nil(err) - s.Equal(block.Hash, queried.Hash) - } } func TestLevelDB(t *testing.T) { |