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
426f62f1
Commit
426f62f1
authored
6 years ago
by
kimmylin
Committed by
Felix Lange
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: improve test for TransactionPriceNonceSort (#16413)
parent
7677ec1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
22 deletions
+7
-22
transaction_test.go
core/types/transaction_test.go
+7
-22
No files found.
core/types/transaction_test.go
View file @
426f62f1
...
...
@@ -165,28 +165,13 @@ func TestTransactionPriceNonceSort(t *testing.T) {
t
.
Errorf
(
"invalid nonce ordering: tx #%d (A=%x N=%v) < tx #%d (A=%x N=%v)"
,
i
,
fromi
[
:
4
],
txi
.
Nonce
(),
i
+
j
,
fromj
[
:
4
],
txj
.
Nonce
())
}
}
// Find the previous and next nonce of this account
prev
,
next
:=
i
-
1
,
i
+
1
for
j
:=
i
-
1
;
j
>=
0
;
j
--
{
if
fromj
,
_
:=
Sender
(
signer
,
txs
[
j
]);
fromi
==
fromj
{
prev
=
j
break
}
}
for
j
:=
i
+
1
;
j
<
len
(
txs
);
j
++
{
if
fromj
,
_
:=
Sender
(
signer
,
txs
[
j
]);
fromi
==
fromj
{
next
=
j
break
}
}
// Make sure that in between the neighbor nonces, the transaction is correctly positioned price wise
for
j
:=
prev
+
1
;
j
<
next
;
j
++
{
fromj
,
_
:=
Sender
(
signer
,
txs
[
j
])
if
j
<
i
&&
txs
[
j
]
.
GasPrice
()
.
Cmp
(
txi
.
GasPrice
())
<
0
{
t
.
Errorf
(
"invalid gasprice ordering: tx #%d (A=%x P=%v) < tx #%d (A=%x P=%v)"
,
j
,
fromj
[
:
4
],
txs
[
j
]
.
GasPrice
(),
i
,
fromi
[
:
4
],
txi
.
GasPrice
())
}
if
j
>
i
&&
txs
[
j
]
.
GasPrice
()
.
Cmp
(
txi
.
GasPrice
())
>
0
{
t
.
Errorf
(
"invalid gasprice ordering: tx #%d (A=%x P=%v) > tx #%d (A=%x P=%v)"
,
j
,
fromj
[
:
4
],
txs
[
j
]
.
GasPrice
(),
i
,
fromi
[
:
4
],
txi
.
GasPrice
())
// If the next tx has different from account, the price must be lower than the current one
if
i
+
1
<
len
(
txs
)
{
next
:=
txs
[
i
+
1
]
fromNext
,
_
:=
Sender
(
signer
,
next
)
if
fromi
!=
fromNext
&&
txi
.
GasPrice
()
.
Cmp
(
next
.
GasPrice
())
<
0
{
t
.
Errorf
(
"invalid gasprice ordering: tx #%d (A=%x P=%v) < tx #%d (A=%x P=%v)"
,
i
,
fromi
[
:
4
],
txi
.
GasPrice
(),
i
+
1
,
fromNext
[
:
4
],
next
.
GasPrice
())
}
}
}
...
...
This diff is collapsed.
Click to expand it.
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