mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
Simplify swith case logic in sizedDataTransaction
This commit is contained in:
parent
399949cfa2
commit
76f79b339d
1 changed files with 4 additions and 5 deletions
|
|
@ -1273,16 +1273,15 @@ func sizedDataTransaction(t *testing.T, targetSize, nonce, gasLimit uint64, key
|
|||
for dataLength > 0 {
|
||||
txWithData := types.NewTransaction(nonce, common.Address{}, big.NewInt(0), gasLimit, gasPrice, data)
|
||||
signedTx, err := types.SignTx(txWithData, types.HomesteadSigner{}, key)
|
||||
if txSignatureLen(signedTx) != targetSignatureLength {
|
||||
switch {
|
||||
case err != nil:
|
||||
require.NoError(t, err, "signing transaction")
|
||||
case txSignatureLen(signedTx) != targetSignatureLength:
|
||||
// try again with other data to get a signature of the desired length
|
||||
for i := range data {
|
||||
data[i]++
|
||||
}
|
||||
continue
|
||||
}
|
||||
switch {
|
||||
case err != nil:
|
||||
require.NoError(t, err, "signing transaction")
|
||||
case signedTx.Size() == targetSize:
|
||||
return signedTx
|
||||
case signedTx.Size() < targetSize:
|
||||
|
|
|
|||
Loading…
Reference in a new issue