File: generatexid_test.go

package info (click to toggle)
golang-github-d2g-dhcp4client 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 120 kB
  • sloc: makefile: 3
file content (29 lines) | stat: -rw-r--r-- 640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package dhcp4client_test

import (
	"bytes"
	"math/rand"
	"testing"

	"github.com/d2g/dhcp4client"
)

func Test_GenerateXID(t *testing.T) {
	//Set the math seed so we always get the same result.
	rand.Seed(1)

	crypto_messageid := make([]byte, 4)
	dhcp4client.CryptoGenerateXID(crypto_messageid)

	t.Logf("Crypto Token: %v", crypto_messageid)

	math_messageid := make([]byte, 4)
	dhcp4client.MathGenerateXID(math_messageid)

	//Math token shouldn't change as we don't seed it.
	if !bytes.Equal(math_messageid, []byte{82, 253, 252, 7}) {
		t.Errorf("Math Token was %v, expected %v", math_messageid, []byte{82, 253, 252, 7})
		t.Fail()
	}

}