Skip to content

Commit d9b512e

Browse files
Parameterize values in transfer tests (#4144)
1 parent 6947e4c commit d9b512e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/load/tests.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ func NewRandomTest(
7676
// writes, or computes) for a test that supports repeated operations.
7777
// This value is arbitrary but kept constant to ensure test reproducibility.
7878
count = big.NewInt(5)
79+
// value specifies the amount to send in a transfer test
80+
value = big.NewInt(1)
7981
)
8082

8183
weightedTests := []WeightedTest{
8284
{
83-
Test: ZeroTransferTest{},
85+
Test: TransferTest{Value: value},
8486
Weight: weight,
8587
},
8688
{
@@ -227,9 +229,11 @@ type WeightedTest struct {
227229
Weight uint64
228230
}
229231

230-
type ZeroTransferTest struct{}
232+
type TransferTest struct {
233+
Value *big.Int
234+
}
231235

232-
func (ZeroTransferTest) Run(
236+
func (t TransferTest) Run(
233237
tc tests.TestContext,
234238
ctx context.Context,
235239
wallet *Wallet,
@@ -241,16 +245,21 @@ func (ZeroTransferTest) Run(
241245
bigGwei := big.NewInt(params.GWei)
242246
gasTipCap := new(big.Int).Mul(bigGwei, big.NewInt(1))
243247
gasFeeCap := new(big.Int).Mul(bigGwei, maxFeeCap)
244-
senderAddress := crypto.PubkeyToAddress(wallet.privKey.PublicKey)
248+
249+
// Generate non-existent account address
250+
pk, err := crypto.GenerateKey()
251+
require.NoError(err)
252+
recipient := crypto.PubkeyToAddress(pk.PublicKey)
253+
245254
tx, err := types.SignNewTx(wallet.privKey, wallet.signer, &types.DynamicFeeTx{
246255
ChainID: wallet.chainID,
247256
Nonce: wallet.nonce,
248257
GasTipCap: gasTipCap,
249258
GasFeeCap: gasFeeCap,
250259
Gas: params.TxGas,
251-
To: &senderAddress,
260+
To: &recipient,
252261
Data: nil,
253-
Value: common.Big0,
262+
Value: t.Value,
254263
})
255264
require.NoError(err)
256265

0 commit comments

Comments
 (0)