all: get rid of error when creating memory database (#16716)

* all: get rid of error when create mdb

* core: clean up variables definition

* all: inline mdb definition
This commit is contained in:
gary rong
2018-05-09 20:24:25 +08:00
committed by Péter Szilágyi
parent 5dbd8b42a9
commit 7beccb29be
48 changed files with 172 additions and 230 deletions

View File

@ -36,7 +36,7 @@ func TestProof(t *testing.T) {
trie, vals := randomTrie(500)
root := trie.Hash()
for _, kv := range vals {
proofs, _ := ethdb.NewMemDatabase()
proofs := ethdb.NewMemDatabase()
if trie.Prove(kv.k, 0, proofs) != nil {
t.Fatalf("missing key %x while constructing proof", kv.k)
}
@ -53,7 +53,7 @@ func TestProof(t *testing.T) {
func TestOneElementProof(t *testing.T) {
trie := new(Trie)
updateString(trie, "k", "v")
proofs, _ := ethdb.NewMemDatabase()
proofs := ethdb.NewMemDatabase()
trie.Prove([]byte("k"), 0, proofs)
if len(proofs.Keys()) != 1 {
t.Error("proof should have one element")
@ -71,7 +71,7 @@ func TestVerifyBadProof(t *testing.T) {
trie, vals := randomTrie(800)
root := trie.Hash()
for _, kv := range vals {
proofs, _ := ethdb.NewMemDatabase()
proofs := ethdb.NewMemDatabase()
trie.Prove(kv.k, 0, proofs)
if len(proofs.Keys()) == 0 {
t.Fatal("zero length proof")
@ -109,7 +109,7 @@ func BenchmarkProve(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
kv := vals[keys[i%len(keys)]]
proofs, _ := ethdb.NewMemDatabase()
proofs := ethdb.NewMemDatabase()
if trie.Prove(kv.k, 0, proofs); len(proofs.Keys()) == 0 {
b.Fatalf("zero length proof for %x", kv.k)
}
@ -123,7 +123,7 @@ func BenchmarkVerifyProof(b *testing.B) {
var proofs []*ethdb.MemDatabase
for k := range vals {
keys = append(keys, k)
proof, _ := ethdb.NewMemDatabase()
proof := ethdb.NewMemDatabase()
trie.Prove([]byte(k), 0, proof)
proofs = append(proofs, proof)
}