good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Erigon
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
a
Erigon
Commits
677d2f88
Unverified
Commit
677d2f88
authored
3 years ago
by
Enrique Jose Avila Asapche
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test tha produces an error for decoding incarnation (#2742)
parent
3f10758f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/types/accounts/account.go
+0
-1
0 additions, 1 deletion
core/types/accounts/account.go
core/types/accounts/account_test.go
+31
-12
31 additions, 12 deletions
core/types/accounts/account_test.go
with
31 additions
and
13 deletions
core/types/accounts/account.go
+
0
−
1
View file @
677d2f88
...
...
@@ -528,7 +528,6 @@ func (a *Account) DecodeForStorage(enc []byte) error {
}
func
DecodeIncarnationFromStorage
(
enc
[]
byte
)
(
uint64
,
error
)
{
if
len
(
enc
)
==
0
{
return
0
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
core/types/accounts/account_test.go
+
31
−
12
View file @
677d2f88
...
...
@@ -190,7 +190,7 @@ func isAccountsEqual(t *testing.T, src, dst Account) {
}
}
func
t
estIncarnationForEmptyAccount
(
t
*
testing
.
T
)
{
func
T
estIncarnationForEmptyAccount
(
t
*
testing
.
T
)
{
a
:=
Account
{
Initialised
:
true
,
Nonce
:
100
,
...
...
@@ -202,34 +202,39 @@ func testIncarnationForEmptyAccount(t *testing.T) {
encodedAccount
:=
make
([]
byte
,
a
.
EncodingLengthForStorage
())
a
.
EncodeForStorage
(
encodedAccount
)
var
decodedIncarnation
uint64
if
_
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
);
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
decodedIncarnation
,
_
=
DecodeIncarnationFromStorage
(
encodedAccount
)
decodedIncarnation
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
)
if
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
isIncarnationEqual
(
t
,
a
.
Incarnation
,
decodedIncarnation
)
}
func
t
estEmptyIncarnationForEmptyAccount2
(
t
*
testing
.
T
)
{
func
T
estEmptyIncarnationForEmptyAccount2
(
t
*
testing
.
T
)
{
a
:=
Account
{}
encodedAccount
:=
make
([]
byte
,
a
.
EncodingLengthForStorage
())
a
.
EncodeForStorage
(
encodedAccount
)
var
decodedIncarnation
uint64
if
_
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
);
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
decodedIncarnation
,
_
=
DecodeIncarnationFromStorage
(
encodedAccount
)
decodedIncarnation
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
)
if
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
isIncarnationEqual
(
t
,
a
.
Incarnation
,
decodedIncarnation
)
}
func
t
estIncarnationWithNonEmptyAccount
(
t
*
testing
.
T
)
{
func
T
estIncarnationWithNonEmptyAccount
(
t
*
testing
.
T
)
{
a
:=
Account
{
Initialised
:
true
,
Nonce
:
2
,
...
...
@@ -242,18 +247,20 @@ func testIncarnationWithNonEmptyAccount(t *testing.T) {
encodedAccount
:=
make
([]
byte
,
a
.
EncodingLengthForStorage
())
a
.
EncodeForStorage
(
encodedAccount
)
var
decodedIncarnation
uint64
if
_
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
);
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
decodedIncarnation
,
_
=
DecodeIncarnationFromStorage
(
encodedAccount
)
decodedIncarnation
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
)
if
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
isIncarnationEqual
(
t
,
a
.
Incarnation
,
decodedIncarnation
)
}
func
t
estIncarnationWithNoIncarnation
(
t
*
testing
.
T
)
{
func
T
estIncarnationWithNoIncarnation
(
t
*
testing
.
T
)
{
a
:=
Account
{
Initialised
:
true
,
Nonce
:
2
,
...
...
@@ -266,17 +273,29 @@ func testIncarnationWithNoIncarnation(t *testing.T) {
encodedAccount
:=
make
([]
byte
,
a
.
EncodingLengthForStorage
())
a
.
EncodeForStorage
(
encodedAccount
)
var
decodedIncarnation
uint64
if
_
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
);
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
decodedIncarnation
,
_
=
DecodeIncarnationFromStorage
(
encodedAccount
)
decodedIncarnation
,
err
:=
DecodeIncarnationFromStorage
(
encodedAccount
)
if
err
!=
nil
{
t
.
Fatal
(
"Can't decode the incarnation"
,
err
,
encodedAccount
)
}
isIncarnationEqual
(
t
,
a
.
Incarnation
,
decodedIncarnation
)
}
func
TestIncarnationWithInvalidEncodedAccount
(
t
*
testing
.
T
)
{
var
failingSlice
=
[]
byte
{
1
,
12
}
if
incarnation
,
err
:=
DecodeIncarnationFromStorage
(
failingSlice
);
err
==
nil
{
t
.
Fatal
(
"decoded the incarnation"
,
incarnation
,
failingSlice
)
}
}
func
isIncarnationEqual
(
t
*
testing
.
T
,
initialIncarnation
uint64
,
decodedIncarnation
uint64
)
{
if
initialIncarnation
!=
decodedIncarnation
{
t
.
Fatal
(
"Can't decode the incarnation"
,
initialIncarnation
,
decodedIncarnation
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment