Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
81b0aa0c
Unverified
Commit
81b0aa0c
authored
Mar 20, 2023
by
Marius van der Wijden
Committed by
GitHub
Mar 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trie: reduce unit test time (#26918)
parent
ee8e83fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
+23
-9
proof_test.go
trie/proof_test.go
+19
-6
sync_test.go
trie/sync_test.go
+1
-0
trie_test.go
trie/trie_test.go
+3
-3
No files found.
trie/proof_test.go
View file @
81b0aa0c
...
...
@@ -20,6 +20,7 @@ import (
"bytes"
crand
"crypto/rand"
"encoding/binary"
"fmt"
mrand
"math/rand"
"sort"
"testing"
...
...
@@ -30,6 +31,24 @@ import (
"github.com/ethereum/go-ethereum/ethdb/memorydb"
)
// Prng is a pseudo random number generator seeded by strong randomness.
// The randomness is printed on startup in order to make failures reproducible.
var
prng
=
initRnd
()
func
initRnd
()
*
mrand
.
Rand
{
var
seed
[
8
]
byte
crand
.
Read
(
seed
[
:
])
rnd
:=
mrand
.
New
(
mrand
.
NewSource
(
int64
(
binary
.
LittleEndian
.
Uint64
(
seed
[
:
]))))
fmt
.
Printf
(
"Seed: %x
\n
"
,
seed
)
return
rnd
}
func
randBytes
(
n
int
)
[]
byte
{
r
:=
make
([]
byte
,
n
)
prng
.
Read
(
r
)
return
r
}
// makeProvers creates Merkle trie provers based on different implementations to
// test all variations.
func
makeProvers
(
trie
*
Trie
)
[]
func
(
key
[]
byte
)
*
memorydb
.
Database
{
...
...
@@ -1041,12 +1060,6 @@ func randomTrie(n int) (*Trie, map[string]*kv) {
return
trie
,
vals
}
func
randBytes
(
n
int
)
[]
byte
{
r
:=
make
([]
byte
,
n
)
crand
.
Read
(
r
)
return
r
}
func
nonRandomTrie
(
n
int
)
(
*
Trie
,
map
[
string
]
*
kv
)
{
trie
:=
NewEmpty
(
NewDatabase
(
rawdb
.
NewMemoryDatabase
()))
vals
:=
make
(
map
[
string
]
*
kv
)
...
...
trie/sync_test.go
View file @
81b0aa0c
...
...
@@ -434,6 +434,7 @@ func TestDuplicateAvoidanceSync(t *testing.T) {
// Tests that at any point in time during a sync, only complete sub-tries are in
// the database.
func
TestIncompleteSync
(
t
*
testing
.
T
)
{
t
.
Parallel
()
// Create a random trie to copy
srcDb
,
srcTrie
,
_
:=
makeTestTrie
()
...
...
trie/trie_test.go
View file @
81b0aa0c
...
...
@@ -18,7 +18,6 @@ package trie
import
(
"bytes"
crand
"crypto/rand"
"encoding/binary"
"errors"
"fmt"
...
...
@@ -1146,13 +1145,14 @@ func deleteString(trie *Trie, k string) {
func
TestDecodeNode
(
t
*
testing
.
T
)
{
t
.
Parallel
()
var
(
hash
=
make
([]
byte
,
20
)
elems
=
make
([]
byte
,
20
)
)
for
i
:=
0
;
i
<
5000000
;
i
++
{
crand
.
Read
(
hash
)
crand
.
Read
(
elems
)
prng
.
Read
(
hash
)
prng
.
Read
(
elems
)
decodeNode
(
hash
,
elems
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment