|
|
@ -51,8 +51,9 @@ func init() { |
|
|
|
func Fuzz(input []byte) int { |
|
|
|
func Fuzz(input []byte) int { |
|
|
|
// Don't generate insanely large test cases, not much value in them
|
|
|
|
// Don't generate insanely large test cases, not much value in them
|
|
|
|
if len(input) > 16*1024 { |
|
|
|
if len(input) > 16*1024 { |
|
|
|
return -1 |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
verbose := false |
|
|
|
r := bytes.NewReader(input) |
|
|
|
r := bytes.NewReader(input) |
|
|
|
|
|
|
|
|
|
|
|
// Reduce the problem space for certain fuzz runs. Small tx space is better
|
|
|
|
// Reduce the problem space for certain fuzz runs. Small tx space is better
|
|
|
@ -124,7 +125,9 @@ func Fuzz(input []byte) int { |
|
|
|
announceIdxs[i] = (int(annBuf[0])*256 + int(annBuf[1])) % len(txs) |
|
|
|
announceIdxs[i] = (int(annBuf[0])*256 + int(annBuf[1])) % len(txs) |
|
|
|
announces[i] = txs[announceIdxs[i]].Hash() |
|
|
|
announces[i] = txs[announceIdxs[i]].Hash() |
|
|
|
} |
|
|
|
} |
|
|
|
fmt.Println("Notify", peer, announceIdxs) |
|
|
|
if verbose { |
|
|
|
|
|
|
|
fmt.Println("Notify", peer, announceIdxs) |
|
|
|
|
|
|
|
} |
|
|
|
if err := f.Notify(peer, announces); err != nil { |
|
|
|
if err := f.Notify(peer, announces); err != nil { |
|
|
|
panic(err) |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
} |
|
|
@ -163,8 +166,9 @@ func Fuzz(input []byte) int { |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
direct := (directFlag % 2) == 0 |
|
|
|
direct := (directFlag % 2) == 0 |
|
|
|
|
|
|
|
if verbose { |
|
|
|
fmt.Println("Enqueue", peer, deliverIdxs, direct) |
|
|
|
fmt.Println("Enqueue", peer, deliverIdxs, direct) |
|
|
|
|
|
|
|
} |
|
|
|
if err := f.Enqueue(peer, deliveries, direct); err != nil { |
|
|
|
if err := f.Enqueue(peer, deliveries, direct); err != nil { |
|
|
|
panic(err) |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
} |
|
|
@ -177,8 +181,9 @@ func Fuzz(input []byte) int { |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
peer := peers[int(peerIdx)%len(peers)] |
|
|
|
peer := peers[int(peerIdx)%len(peers)] |
|
|
|
|
|
|
|
if verbose { |
|
|
|
fmt.Println("Drop", peer) |
|
|
|
fmt.Println("Drop", peer) |
|
|
|
|
|
|
|
} |
|
|
|
if err := f.Drop(peer); err != nil { |
|
|
|
if err := f.Drop(peer); err != nil { |
|
|
|
panic(err) |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
} |
|
|
@ -191,8 +196,9 @@ func Fuzz(input []byte) int { |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
tick := time.Duration(tickCnt) * 100 * time.Millisecond |
|
|
|
tick := time.Duration(tickCnt) * 100 * time.Millisecond |
|
|
|
|
|
|
|
if verbose { |
|
|
|
fmt.Println("Sleep", tick) |
|
|
|
fmt.Println("Sleep", tick) |
|
|
|
|
|
|
|
} |
|
|
|
clock.Run(tick) |
|
|
|
clock.Run(tick) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|