From 76f79b339db219505c9d00a43defa7f7e7b910e8 Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Tue, 18 Feb 2025 14:16:52 +0100 Subject: [PATCH] Simplify swith case logic in sizedDataTransaction --- core/txpool/legacypool/legacypool_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/txpool/legacypool/legacypool_test.go b/core/txpool/legacypool/legacypool_test.go index 3dc11a8e09..6e6fd1ec5f 100644 --- a/core/txpool/legacypool/legacypool_test.go +++ b/core/txpool/legacypool/legacypool_test.go @@ -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: