mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 05:53:46 +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 {
|
for dataLength > 0 {
|
||||||
txWithData := types.NewTransaction(nonce, common.Address{}, big.NewInt(0), gasLimit, gasPrice, data)
|
txWithData := types.NewTransaction(nonce, common.Address{}, big.NewInt(0), gasLimit, gasPrice, data)
|
||||||
signedTx, err := types.SignTx(txWithData, types.HomesteadSigner{}, key)
|
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
|
// try again with other data to get a signature of the desired length
|
||||||
for i := range data {
|
for i := range data {
|
||||||
data[i]++
|
data[i]++
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case err != nil:
|
|
||||||
require.NoError(t, err, "signing transaction")
|
|
||||||
case signedTx.Size() == targetSize:
|
case signedTx.Size() == targetSize:
|
||||||
return signedTx
|
return signedTx
|
||||||
case signedTx.Size() < targetSize:
|
case signedTx.Size() < targetSize:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue