@@ -1346,7 +1346,7 @@ func createTestTransactions(t *testing.T, count int) []*types.Transaction {
1346
1346
)
1347
1347
1348
1348
var transactions []* types.Transaction
1349
- for i := 0 ; i < count ; i ++ {
1349
+ for i := range count {
1350
1350
tx , _ := types .SignTx (types .NewTx (& types.LegacyTx {
1351
1351
Nonce : uint64 (i ),
1352
1352
To : & testAddr ,
@@ -1361,27 +1361,6 @@ func createTestTransactions(t *testing.T, count int) []*types.Transaction {
1361
1361
return transactions
1362
1362
}
1363
1363
1364
- // createSingleTransaction creates a single transaction for testing
1365
- func createSingleTransaction (t * testing.T , nonce uint64 , value * big.Int , gasLimit uint64 , data []byte ) * types.Transaction {
1366
- t .Helper ()
1367
-
1368
- var (
1369
- key , _ = crypto .HexToECDSA ("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291" )
1370
- testAddr = common .HexToAddress ("0x7217d81b76bdd8707601e959454e3d776aee5f43" )
1371
- )
1372
-
1373
- tx , _ := types .SignTx (types .NewTx (& types.LegacyTx {
1374
- Nonce : nonce ,
1375
- To : & testAddr ,
1376
- Value : value ,
1377
- Gas : gasLimit ,
1378
- GasPrice : big .NewInt (1000000000 ),
1379
- Data : data ,
1380
- }), types.HomesteadSigner {}, key )
1381
-
1382
- return tx
1383
- }
1384
-
1385
1364
// setupBadBlock creates a bad block and stores it in the database for testing
1386
1365
func setupBadBlock (t * testing.T , backend * testBackend , transactions []* types.Transaction ) (* types.Block , []common.Hash ) {
1387
1366
t .Helper ()
@@ -1392,23 +1371,23 @@ func setupBadBlock(t *testing.T, backend *testBackend, transactions []*types.Tra
1392
1371
}
1393
1372
1394
1373
// Get the latest block from the test chain as the parent
1395
- latestBlock := backend .chain .CurrentBlock ()
1396
- parentHash := latestBlock .Hash ()
1397
- parentNumber := latestBlock .Number .Uint64 ()
1374
+ parentBlock := backend .chain .CurrentBlock ()
1375
+ parentHash := parentBlock .Hash ()
1376
+ parentNumber := parentBlock .Number .Uint64 ()
1398
1377
1399
1378
// Create a bad block header that references the existing parent
1400
1379
badHeader := & types.Header {
1401
1380
Number : big .NewInt (int64 (parentNumber + 1 )),
1402
- Time : latestBlock .Time + 1 ,
1381
+ Time : parentBlock .Time + 1 ,
1403
1382
Extra : []byte ("bad block for testing" ),
1404
- GasLimit : latestBlock .GasLimit ,
1383
+ GasLimit : parentBlock .GasLimit ,
1405
1384
GasUsed : uint64 (len (transactions ) * 21000 ),
1406
1385
Difficulty : big .NewInt (1000 ),
1407
1386
UncleHash : types .EmptyUncleHash ,
1408
1387
TxHash : types .DeriveSha (types .Transactions (transactions ), trie .NewStackTrie (nil )),
1409
1388
ReceiptHash : types .EmptyReceiptsHash ,
1410
1389
ParentHash : parentHash ,
1411
- BaseFee : latestBlock .BaseFee , // Copy base fee to avoid nil pointer
1390
+ BaseFee : parentBlock .BaseFee , // Copy base fee to avoid nil pointer
1412
1391
}
1413
1392
1414
1393
// Create the bad block
@@ -1438,7 +1417,6 @@ func TestStandardTraceBadBlockToFile(t *testing.T) {
1438
1417
testAddr := common .HexToAddress ("0x7217d81b76bdd8707601e959454e3d776aee5f43" )
1439
1418
testCode := []byte {byte (vm .PUSH1 ), 0x42 , byte (vm .POP ), byte (vm .STOP )}
1440
1419
1441
- // Create test backend with proper accounts
1442
1420
genesis := & core.Genesis {
1443
1421
Config : params .TestChainConfig ,
1444
1422
Alloc : types.GenesisAlloc {
@@ -1562,7 +1540,6 @@ func TestStandardTraceBadBlockToFile(t *testing.T) {
1562
1540
t .Fatalf ("Expected %d trace files, got %d" , len (tc .expectedTraces ), len (files ))
1563
1541
}
1564
1542
1565
- // Verify trace content if files are expected
1566
1543
for i , fileName := range files {
1567
1544
data , err := os .ReadFile (fileName )
1568
1545
if err != nil {
0 commit comments