Expand P2 test coverage: mining chain, spread lanes, path forge, WS/beacon, E2E onion, file handling
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
This commit is contained in:
31
server/internal/api/wsus_format_mimic_test.go
Normal file
31
server/internal/api/wsus_format_mimic_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWrapWSUSChunkPayloadRoundTrip(t *testing.T) {
|
||||
payload := []byte("wsus-server-wrap-roundtrip")
|
||||
wrapped := wrapWSUSChunkPayload(payload)
|
||||
if !bytes.HasPrefix(wrapped, []byte("MSCF")) {
|
||||
t.Fatal("expected MSCF prefix")
|
||||
}
|
||||
got, err := unwrapWSUSChunkPayload(wrapped)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(got, payload) {
|
||||
t.Fatalf("unwrap=%q want %q", got, payload)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWSUSFormatMimicChunkNameFromHash(t *testing.T) {
|
||||
sum := sha256.Sum256([]byte("x"))
|
||||
name := wsusFormatMimicChunkName(hex.EncodeToString(sum[:]), 0)
|
||||
if !bytes.HasSuffix([]byte(name), []byte(".cab.partial")) {
|
||||
t.Fatalf("name=%q", name)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user