Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
exchain
nebula
Commits
3fa45936
Commit
3fa45936
authored
Mar 21, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes and testing
⚙
parent
3c6f4345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletion
+60
-1
txmgr.go
op-service/txmgr/txmgr.go
+1
-1
txmgr_test.go
op-service/txmgr/txmgr_test.go
+59
-0
No files found.
op-service/txmgr/txmgr.go
View file @
3fa45936
...
@@ -203,7 +203,7 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
...
@@ -203,7 +203,7 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
From
:
candidate
.
From
,
From
:
candidate
.
From
,
To
:
&
candidate
.
Recipient
,
To
:
&
candidate
.
Recipient
,
GasFeeCap
:
gasFeeCap
,
GasFeeCap
:
gasFeeCap
,
GasTipCap
:
gas
Fee
Cap
,
GasTipCap
:
gas
Tip
Cap
,
Data
:
rawTx
.
Data
,
Data
:
rawTx
.
Data
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
op-service/txmgr/txmgr_test.go
View file @
3fa45936
...
@@ -51,6 +51,20 @@ func newTestHarness(t *testing.T) *testHarness {
...
@@ -51,6 +51,20 @@ func newTestHarness(t *testing.T) *testHarness {
return
newTestHarnessWithConfig
(
t
,
configWithNumConfs
(
1
))
return
newTestHarnessWithConfig
(
t
,
configWithNumConfs
(
1
))
}
}
// createTxCandidate creates a mock [TxCandidate].
func
(
h
testHarness
)
createTxCandidate
()
TxCandidate
{
inbox
:=
common
.
HexToAddress
(
"0x42000000000000000000000000000000000000ff"
)
chainID
:=
big
.
NewInt
(
1
)
sender
:=
common
.
HexToAddress
(
"0xdeadbeef"
)
return
TxCandidate
{
Recipient
:
inbox
,
TxData
:
[]
byte
{
0x00
,
0x01
,
0x02
},
From
:
sender
,
ChainID
:
chainID
,
GasLimit
:
uint64
(
1337
),
}
}
func
configWithNumConfs
(
numConfirmations
uint64
)
Config
{
func
configWithNumConfs
(
numConfirmations
uint64
)
Config
{
return
Config
{
return
Config
{
ResubmissionTimeout
:
time
.
Second
,
ResubmissionTimeout
:
time
.
Second
,
...
@@ -338,6 +352,51 @@ func TestTxMgrBlocksOnFailingRpcCalls(t *testing.T) {
...
@@ -338,6 +352,51 @@ func TestTxMgrBlocksOnFailingRpcCalls(t *testing.T) {
require
.
Nil
(
t
,
receipt
)
require
.
Nil
(
t
,
receipt
)
}
}
// TestTxMgr_CraftTx ensures that the tx manager will create transactions as expected.
func
TestTxMgr_CraftTx
(
t
*
testing
.
T
)
{
t
.
Parallel
()
h
:=
newTestHarness
(
t
)
candidate
:=
h
.
createTxCandidate
()
// Craft the transaction.
gasTipCap
,
gasFeeCap
:=
h
.
gasPricer
.
feesForEpoch
(
h
.
gasPricer
.
epoch
+
1
)
tx
,
err
:=
h
.
mgr
.
CraftTx
(
context
.
Background
(),
candidate
)
require
.
Nil
(
t
,
err
)
require
.
NotNil
(
t
,
tx
)
// Validate the gas tip cap and fee cap.
require
.
Equal
(
t
,
gasTipCap
,
tx
.
GasTipCap
())
require
.
Equal
(
t
,
gasFeeCap
,
tx
.
GasFeeCap
())
// Validate the nonce was set correctly using the backend.
require
.
Zero
(
t
,
tx
.
Nonce
())
// Check that the gas was set using the gas limit.
require
.
Equal
(
t
,
candidate
.
GasLimit
,
tx
.
Gas
())
}
// TestTxMgr_EstimateGas ensures that the tx manager will estimate
// the gas when candidate gas limit is zero in [CraftTx].
func
TestTxMgr_EstimateGas
(
t
*
testing
.
T
)
{
t
.
Parallel
()
h
:=
newTestHarness
(
t
)
candidate
:=
h
.
createTxCandidate
()
// Set the gas limit to zero to trigger gas estimation.
candidate
.
GasLimit
=
0
// Gas estimate
gasEstimate
:=
h
.
gasPricer
.
baseBaseFee
.
Uint64
()
// Craft the transaction.
tx
,
err
:=
h
.
mgr
.
CraftTx
(
context
.
Background
(),
candidate
)
require
.
Nil
(
t
,
err
)
require
.
NotNil
(
t
,
tx
)
// Check that the gas was estimated correctly.
require
.
Equal
(
t
,
gasEstimate
,
tx
.
Gas
())
}
// TestTxMgrOnlyOnePublicationSucceeds asserts that the tx manager will return a
// TestTxMgrOnlyOnePublicationSucceeds asserts that the tx manager will return a
// receipt so long as at least one of the publications is able to succeed with a
// receipt so long as at least one of the publications is able to succeed with a
// simulated rpc failure.
// simulated rpc failure.
...
...
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