diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-10-04 01:05:10 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-10-06 19:41:06 +0900 |
| commit | a7383510fb05abc98b992240cb76ad4b6c598956 (patch) | |
| tree | 90881e9d6952e050128f1378d66452c7d733d012 /test/sandbox/testdata/sum.go | |
| parent | b452e1047ccd3e1826da16416430e6638270155b (diff) | |
test/sandbox: migrate tests
This significantly improves performance, removing overhead of nix,
python, and virtualisation. Running this in an unprivileged container
required patching the kernel, but since special runner setup was already
needed, that was an acceptable tradeoff.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/sandbox/testdata/sum.go')
| -rw-r--r-- | test/sandbox/testdata/sum.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/sandbox/testdata/sum.go b/test/sandbox/testdata/sum.go new file mode 100644 index 00000000..e4e8643a --- /dev/null +++ b/test/sandbox/testdata/sum.go @@ -0,0 +1,22 @@ +//go:build testsuite || tester + +package testdata + +import ( + "crypto/sha512" + "encoding/base64" + "strconv" +) + +// sum decodes s as [base64.StdEncoding] and panics if it is invalid or +// unexpectedly sized. +func sum(s string) [sha512.Size]byte { + p, err := base64.StdEncoding.DecodeString(s) + if err != nil { + panic(err) + } + if len(p) != sha512.Size { + panic("unexpected checksum sized " + strconv.Itoa(len(p))) + } + return ([sha512.Size]byte)(p) +} |
