mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
test: add test
This commit is contained in:
parent
242f3f9334
commit
b093aa69a0
2 changed files with 21 additions and 1 deletions
|
|
@ -883,7 +883,7 @@ func (f *TxFetcher) rescheduleWait(timer *mclock.Timer, trigger chan struct{}) {
|
|||
// This method is a bit "flaky" "by design". In theory the timeout timer only ever
|
||||
// should be rescheduled if some request is pending. In practice, a timeout will
|
||||
// cause the timer to be rescheduled every 5 secs (until the peer comes through or
|
||||
// disconnects). This is a limitation of the fetcher code because we don't trac
|
||||
// disconnects). This is a limitation of the fetcher code because we don't track
|
||||
// pending requests and timed out requests separately. Without double tracking, if
|
||||
// we simply didn't reschedule the timer on all-timeout then the timer would never
|
||||
// be set again since len(request) > 0 => something's running.
|
||||
|
|
|
|||
|
|
@ -502,11 +502,15 @@ func TestTransactionFetcherFailedRescheduling(t *testing.T) {
|
|||
steps: []interface{}{
|
||||
// Push an initial announcement through to the scheduled stage
|
||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
||||
doTxNotify{peer: "C", hashes: []common.Hash{{0x03}}, types: []byte{types.LegacyTxType}, sizes: []uint32{333}},
|
||||
isWaiting(map[string][]announce{
|
||||
"A": {
|
||||
{common.Hash{0x01}, types.LegacyTxType, 111},
|
||||
{common.Hash{0x02}, types.LegacyTxType, 222},
|
||||
},
|
||||
"C": {
|
||||
{common.Hash{0x03}, types.LegacyTxType, 333},
|
||||
},
|
||||
}),
|
||||
isScheduled{tracking: nil, fetching: nil},
|
||||
|
||||
|
|
@ -518,9 +522,13 @@ func TestTransactionFetcherFailedRescheduling(t *testing.T) {
|
|||
{common.Hash{0x01}, types.LegacyTxType, 111},
|
||||
{common.Hash{0x02}, types.LegacyTxType, 222},
|
||||
},
|
||||
"C": {
|
||||
{common.Hash{0x03}, types.LegacyTxType, 333},
|
||||
},
|
||||
},
|
||||
fetching: map[string][]common.Hash{
|
||||
"A": {{0x01}, {0x02}},
|
||||
"C": {{0x03}},
|
||||
},
|
||||
},
|
||||
// While the original peer is stuck in the request, push in an second
|
||||
|
|
@ -536,9 +544,13 @@ func TestTransactionFetcherFailedRescheduling(t *testing.T) {
|
|||
"B": {
|
||||
{common.Hash{0x02}, types.LegacyTxType, 222},
|
||||
},
|
||||
"C": {
|
||||
{common.Hash{0x03}, types.LegacyTxType, 333},
|
||||
},
|
||||
},
|
||||
fetching: map[string][]common.Hash{
|
||||
"A": {{0x01}, {0x02}},
|
||||
"C": {{0x03}},
|
||||
},
|
||||
},
|
||||
// Wait until the original request fails and check that transactions
|
||||
|
|
@ -553,15 +565,23 @@ func TestTransactionFetcherFailedRescheduling(t *testing.T) {
|
|||
"B": {
|
||||
{common.Hash{0x02}, types.LegacyTxType, 222},
|
||||
},
|
||||
"C": {
|
||||
{common.Hash{0x03}, types.LegacyTxType, 333},
|
||||
},
|
||||
},
|
||||
fetching: map[string][]common.Hash{
|
||||
"B": {{0x02}},
|
||||
"C": {{0x03}},
|
||||
},
|
||||
},
|
||||
doFunc(func() {
|
||||
proceed <- struct{}{} // Allow peer B to return the failure
|
||||
}),
|
||||
doWait{time: 0, step: true},
|
||||
doFunc(func() {
|
||||
proceed <- struct{}{} // Allow peer B to return the failure
|
||||
}),
|
||||
doWait{time: 0, step: true},
|
||||
isWaiting(nil),
|
||||
isScheduled{nil, nil, nil},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue