@@ -27,7 +27,6 @@ import (
27
27
"github.com/ethereum/go-ethereum/common/mclock"
28
28
"github.com/ethereum/go-ethereum/core/txpool"
29
29
"github.com/ethereum/go-ethereum/core/types"
30
- "github.com/ethereum/go-ethereum/params"
31
30
)
32
31
33
32
var (
@@ -994,14 +993,15 @@ func TestTransactionFetcherTimeoutTimerResets(t *testing.T) {
994
993
})
995
994
}
996
995
997
- // Tests that if thousands of transactions are announced , only a small
996
+ // Tests that if thousands of transactions are announces , only a small
998
997
// number of them will be requested at a time.
999
998
func TestTransactionFetcherRateLimiting (t * testing.T ) {
1000
- // Create a slew of transactions and announce them
999
+ // Create a slew of transactions and to announce them
1001
1000
var hashes []common.Hash
1002
1001
for i := 0 ; i < maxTxAnnounces ; i ++ {
1003
1002
hashes = append (hashes , common.Hash {byte (i / 256 ), byte (i % 256 )})
1004
1003
}
1004
+
1005
1005
testTransactionFetcherParallel (t , txFetcherTest {
1006
1006
init : func () * TxFetcher {
1007
1007
return NewTxFetcher (
@@ -1029,68 +1029,6 @@ func TestTransactionFetcherRateLimiting(t *testing.T) {
1029
1029
})
1030
1030
}
1031
1031
1032
- // Tests that if huge transactions are announced, only a small number of them will
1033
- // be requested at a time, to keep the responses below a resonable level.
1034
- func TestTransactionFetcherBandwidthLimiting (t * testing.T ) {
1035
- testTransactionFetcherParallel (t , txFetcherTest {
1036
- init : func () * TxFetcher {
1037
- return NewTxFetcher (
1038
- func (common.Hash ) bool { return false },
1039
- nil ,
1040
- func (string , []common.Hash ) error { return nil },
1041
- nil ,
1042
- )
1043
- },
1044
- steps : []interface {}{
1045
- // Announce mid size transactions from A to verify that multiple
1046
- // ones can be piled into a single request.
1047
- doTxNotify {peer : "A" ,
1048
- hashes : []common.Hash {{0x01 }, {0x02 }, {0x03 }, {0x04 }},
1049
- types : []byte {types .LegacyTxType , types .LegacyTxType , types .LegacyTxType , types .LegacyTxType },
1050
- sizes : []uint32 {48 * 1024 , 48 * 1024 , 48 * 1024 , 48 * 1024 },
1051
- },
1052
- // Announce exactly on the limit transactions to see that only one
1053
- // gets requested
1054
- doTxNotify {peer : "B" ,
1055
- hashes : []common.Hash {{0x05 }, {0x06 }},
1056
- types : []byte {types .LegacyTxType , types .LegacyTxType },
1057
- sizes : []uint32 {maxTxRetrievalSize , maxTxRetrievalSize },
1058
- },
1059
- // Announce oversized blob transactions to see that overflows are ok
1060
- doTxNotify {peer : "C" ,
1061
- hashes : []common.Hash {{0x07 }, {0x08 }},
1062
- types : []byte {types .BlobTxType , types .BlobTxType },
1063
- sizes : []uint32 {params .MaxBlobGasPerBlock , params .MaxBlobGasPerBlock },
1064
- },
1065
- doWait {time : txArriveTimeout , step : true },
1066
- isWaiting (nil ),
1067
- isScheduledWithMeta {
1068
- tracking : map [string ][]announce {
1069
- "A" : {
1070
- {common.Hash {0x01 }, typeptr (types .LegacyTxType ), sizeptr (48 * 1024 )},
1071
- {common.Hash {0x02 }, typeptr (types .LegacyTxType ), sizeptr (48 * 1024 )},
1072
- {common.Hash {0x03 }, typeptr (types .LegacyTxType ), sizeptr (48 * 1024 )},
1073
- {common.Hash {0x04 }, typeptr (types .LegacyTxType ), sizeptr (48 * 1024 )},
1074
- },
1075
- "B" : {
1076
- {common.Hash {0x05 }, typeptr (types .LegacyTxType ), sizeptr (maxTxRetrievalSize )},
1077
- {common.Hash {0x06 }, typeptr (types .LegacyTxType ), sizeptr (maxTxRetrievalSize )},
1078
- },
1079
- "C" : {
1080
- {common.Hash {0x07 }, typeptr (types .BlobTxType ), sizeptr (params .MaxBlobGasPerBlock )},
1081
- {common.Hash {0x08 }, typeptr (types .BlobTxType ), sizeptr (params .MaxBlobGasPerBlock )},
1082
- },
1083
- },
1084
- fetching : map [string ][]common.Hash {
1085
- "A" : {{0x02 }, {0x03 }, {0x04 }},
1086
- "B" : {{0x06 }},
1087
- "C" : {{0x08 }},
1088
- },
1089
- },
1090
- },
1091
- })
1092
- }
1093
-
1094
1032
// Tests that then number of transactions a peer is allowed to announce and/or
1095
1033
// request at the same time is hard capped.
1096
1034
func TestTransactionFetcherDoSProtection (t * testing.T ) {
@@ -1726,7 +1664,7 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
1726
1664
if (meta == nil && (ann .kind != nil || ann .size != nil )) ||
1727
1665
(meta != nil && (ann .kind == nil || ann .size == nil )) ||
1728
1666
(meta != nil && (meta .kind != * ann .kind || meta .size != * ann .size )) {
1729
- t .Errorf ("step %d, peer %s, hash %x: waitslot metadata mismatch: want %v, have %v/%v" , i , peer , ann .hash , meta , * ann .kind , * ann .size )
1667
+ t .Errorf ("step %d, peer %s, hash %x: waitslot metadata mismatch: want %v, have %v/%v" , i , peer , ann .hash , meta , ann .kind , ann .size )
1730
1668
}
1731
1669
}
1732
1670
}
@@ -1795,7 +1733,7 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
1795
1733
if (meta == nil && (ann .kind != nil || ann .size != nil )) ||
1796
1734
(meta != nil && (ann .kind == nil || ann .size == nil )) ||
1797
1735
(meta != nil && (meta .kind != * ann .kind || meta .size != * ann .size )) {
1798
- t .Errorf ("step %d, peer %s, hash %x: announce metadata mismatch: want %v, have %v/%v" , i , peer , ann .hash , meta , * ann .kind , * ann .size )
1736
+ t .Errorf ("step %d, peer %s, hash %x: announce metadata mismatch: want %v, have %v/%v" , i , peer , ann .hash , meta , ann .kind , ann .size )
1799
1737
}
1800
1738
}
1801
1739
}
0 commit comments