github.com/decred/dcrlnd@v0.7.6/fuzz/brontide/static_actone.go (about)

     1  //go:build gofuzz
     2  // +build gofuzz
     3  
     4  package brontidefuzz
     5  
     6  import (
     7  	"github.com/decred/dcrlnd/brontide"
     8  )
     9  
    10  // Fuzz_static_actone is a go-fuzz harness for ActOne in the brontide
    11  // handshake.
    12  func Fuzz_static_actone(data []byte) int {
    13  	// Check if data is large enough.
    14  	if len(data) < brontide.ActOneSize {
    15  		return 1
    16  	}
    17  
    18  	// This will return brontide machines with static keys.
    19  	_, responder := getStaticBrontideMachines()
    20  
    21  	// Copy data into [ActOneSize]byte.
    22  	var actOne [brontide.ActOneSize]byte
    23  	copy(actOne[:], data)
    24  
    25  	// Responder receives ActOne, should fail.
    26  	if err := responder.RecvActOne(actOne); err == nil {
    27  		nilAndPanic(nil, responder, nil)
    28  	}
    29  
    30  	return 1
    31  }