github.com/ZuluSpl0it/Sia@v1.3.7/crypto/discard_test.go (about)

     1  package crypto
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  )
     7  
     8  // TestUnitSecureWipe tests that the SecureWipe function sets all the elements
     9  // in a byte slice to 0.
    10  func TestUnitSecureWipe(t *testing.T) {
    11  	s := []byte{1, 2, 3, 4}
    12  	SecureWipe(s)
    13  	if !bytes.Equal(s, make([]byte, len(s))) {
    14  		t.Error("some bytes not set to 0")
    15  	}
    16  }
    17  
    18  // TestUnitSecureWipeEdgeCases tests that SecureWipe doesn't panic on nil or
    19  // empty slices.
    20  func TestUnitSecureWipeEdgeCases(t *testing.T) {
    21  	SecureWipe(nil)
    22  	SecureWipe([]byte{})
    23  }