Rename sizedDataTransaction to sizedTx

This commit is contained in:
Quentin Mc Gaw 2025-02-18 14:17:12 +01:00
parent 76f79b339d
commit a31e1acade
No known key found for this signature in database
GPG Key ID: 6B26BAFFE648CAFB
1 changed files with 6 additions and 6 deletions

View File

@ -1217,22 +1217,22 @@ func TestAllowedTxSize(t *testing.T) {
gasLimit := pool.currentHead.Load().GasLimit
// Try adding a transaction with maximal allowed size
tx := sizedDataTransaction(t, txMaxSize, 0, gasLimit, key)
tx := sizedTx(t, txMaxSize, 0, gasLimit, key)
if err := pool.addRemoteSync(tx); err != nil {
t.Fatalf("failed to add transaction of size %d, close to maximal: %v", int(tx.Size()), err)
}
// Try adding a transaction with random allowed size
tx = sizedDataTransaction(t, txMaxSize/2, 1, gasLimit, key)
tx = sizedTx(t, txMaxSize/2, 1, gasLimit, key)
if err := pool.addRemoteSync(tx); err != nil {
t.Fatalf("failed to add transaction of random allowed size: %v", err)
}
// Try adding a transaction above maximum size by one
tx = sizedDataTransaction(t, txMaxSize+1, 2, gasLimit, key)
tx = sizedTx(t, txMaxSize+1, 2, gasLimit, key)
if err := pool.addRemoteSync(tx); err == nil {
t.Fatalf("expected rejection on slightly oversize transaction")
}
// Try adding a transaction above maximum size by two
tx = sizedDataTransaction(t, txMaxSize+2, 2, gasLimit, key)
tx = sizedTx(t, txMaxSize+2, 2, gasLimit, key)
if err := pool.addRemoteSync(tx); err == nil {
t.Fatalf("expected rejection on oversize transaction")
}
@ -1249,10 +1249,10 @@ func TestAllowedTxSize(t *testing.T) {
}
}
// sizedDataTransaction generates a transaction with the size matching the `targetSize` given
// sizedTx generates a transaction with the size matching the `targetSize` given
// as argument. It uses the nonce, gasLimit and key given as arguments to generate the transaction.
// Note around 1% of all possible sizes under [txMaxSize] cannot be generated by this function.
func sizedDataTransaction(t *testing.T, targetSize, nonce, gasLimit uint64, key *ecdsa.PrivateKey) (
func sizedTx(t *testing.T, targetSize, nonce, gasLimit uint64, key *ecdsa.PrivateKey) (
tx *types.Transaction) {
t.Helper()
gasPrice := big.NewInt(1)