github.com/amnezia-vpn/amnezia-wg@v0.1.8/device/util_test.go (about)

     1  package device
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"testing"
     7  )
     8  
     9  func Test_randomJunktWithSize(t *testing.T) {
    10  	junk, err := randomJunkWithSize(30)
    11  	fmt.Println(string(junk), len(junk), err)
    12  }
    13  
    14  func Test_appendJunk(t *testing.T) {
    15  	t.Run("", func(t *testing.T) {
    16  		s := "apple"
    17  		buffer := bytes.NewBuffer([]byte(s))
    18  		err := appendJunk(buffer, 30)
    19  		if err != nil &&
    20  			buffer.Len() != len(s)+30 {
    21  			t.Errorf("appendWithJunk() size don't match")
    22  		}
    23  		read := make([]byte, 50)
    24  		buffer.Read(read)
    25  		fmt.Println(string(read))
    26  	})
    27  }