forked from okx/xlayer-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Etherman optionally readonly. (0xPolygonHermez#1321)
Closes: 0xPolygonHermez#1227 This PR implements the option to set Etherman to be read only (a.k.a. without an account). This is useful for nodes that don't send transactions. The behavior is controlled by the new ReadOnly field in the Etherman config (false by default). Methods accessing the account are now safeguarded by a check on the readOnly field in the Etherman struct. Bonus: added the Etherman test cases in config/config_test.go Includes: * No need to supply RPC with account (0xPolygonHermez#1337) Co-authored-by: Konrad Iturbe <[email protected]>
- Loading branch information
Showing
14 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,39 @@ | ||
package ethtxmanager | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"testing" | ||
|
||
ethman "github.com/0xPolygonHermez/zkevm-node/etherman" | ||
ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIncreaseGasLimit(t *testing.T) { | ||
actual := increaseGasLimit(100, 1) | ||
assert.Equal(t, uint64(101), actual) | ||
} | ||
|
||
func TestIncreaseGasPrice(t *testing.T) { | ||
actual := increaseGasPrice(big.NewInt(100), 1) | ||
assert.Equal(t, big.NewInt(101), actual) | ||
} | ||
|
||
func TestIncreaseGasLimit(t *testing.T) { | ||
actual := increaseGasLimit(100, 1) | ||
assert.Equal(t, uint64(101), actual) | ||
func TestSequenceBatchesWithROEthman(t *testing.T) { | ||
ethManRO, _, _, _, _ := ethman.NewSimulatedEtherman(ethman.Config{}, nil) | ||
txMan := New(Config{MaxSendBatchTxRetries: 2}, ethManRO) // 3 executions in total | ||
|
||
err := txMan.SequenceBatches(context.Background(), []ethmanTypes.Sequence{}) | ||
|
||
assert.ErrorIs(t, err, ethman.ErrIsReadOnlyMode) | ||
} | ||
|
||
func TestVerifyBatchWithROEthman(t *testing.T) { | ||
ethManRO, _, _, _, _ := ethman.NewSimulatedEtherman(ethman.Config{}, nil) | ||
txMan := New(Config{MaxVerifyBatchTxRetries: 2}, ethManRO) // 3 executions in total | ||
|
||
err := txMan.VerifyBatch(context.Background(), 42, nil) | ||
|
||
assert.ErrorIs(t, err, ethman.ErrIsReadOnlyMode) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters