forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gasLimit: error on gas limit too high for queue origin sequencer txs (e…
…thereum#180) * gasLimit: prevent txs with too high of gas limit * gasLimit: fixes + test * test: fix * send tx: use >=
- Loading branch information
Showing
3 changed files
with
57 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package eth | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
) | ||
|
||
func TestGasLimit(t *testing.T) { | ||
backend := &EthAPIBackend{ | ||
extRPCEnabled: false, | ||
eth: nil, | ||
gpo: nil, | ||
verifier: false, | ||
DisableTransfers: false, | ||
GasLimit: 0, | ||
UsingOVM: true, | ||
} | ||
|
||
nonce := uint64(0) | ||
to := common.HexToAddress("0x5A0b54D5dc17e0AadC383d2db43B0a0D3E029c4c") | ||
value := big.NewInt(0) | ||
gasPrice := big.NewInt(0) | ||
data := []byte{} | ||
qo := types.QueueOriginSequencer | ||
sighash := types.SighashEIP155 | ||
|
||
// Set the gas limit to 1 so that the transaction will not be | ||
// able to be added. | ||
gasLimit := uint64(1) | ||
tx := types.NewTransaction(nonce, to, value, gasLimit, gasPrice, data, nil, nil, qo, sighash) | ||
|
||
err := backend.SendTx(context.Background(), tx) | ||
if err == nil { | ||
t.Fatal("Transaction with too large of gas limit accepted") | ||
} | ||
if err.Error() != fmt.Sprintf("Transaction gasLimit (%d) is greater than max gasLimit (%d)", gasLimit, backend.GasLimit) { | ||
t.Fatalf("Unexpected error type: %s", err) | ||
} | ||
} |
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