From 528a53f7f76f08af5902f4cfa8235380b3434ba0 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Mon, 25 Apr 2022 00:43:06 +0200 Subject: drafty types refactor with simple ascii package types.go compiles but that is about it, here be dragons. Pushing so that we can get an idea of what this refactor would roughly look like. --- pkg/types/crypto_test.go | 64 ------------------------------------------------ 1 file changed, 64 deletions(-) delete mode 100644 pkg/types/crypto_test.go (limited to 'pkg/types/crypto_test.go') diff --git a/pkg/types/crypto_test.go b/pkg/types/crypto_test.go deleted file mode 100644 index d95d5fa..0000000 --- a/pkg/types/crypto_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package types - -import ( - "crypto" - "crypto/ed25519" - "crypto/rand" - "io" - "testing" -) - -type testSigner struct { - PublicKey PublicKey - Signature Signature - Error error -} - -func (ts *testSigner) Public() crypto.PublicKey { - return ed25519.PublicKey(ts.PublicKey[:]) -} - -func (ts *testSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) { - return ts.Signature[:], ts.Error -} - -func newKeyPair(t *testing.T) (crypto.Signer, PublicKey) { - vk, sk, err := ed25519.GenerateKey(rand.Reader) - if err != nil { - t.Fatal(err) - } - - var pub PublicKey - copy(pub[:], vk[:]) - return sk, pub -} - -func newHashBufferInc(t *testing.T) *Hash { - t.Helper() - - var buf Hash - for i := 0; i < len(buf); i++ { - buf[i] = byte(i) - } - return &buf -} - -func newSigBufferInc(t *testing.T) *Signature { - t.Helper() - - var buf Signature - for i := 0; i < len(buf); i++ { - buf[i] = byte(i) - } - return &buf -} - -func newPubBufferInc(t *testing.T) *PublicKey { - t.Helper() - - var buf PublicKey - for i := 0; i < len(buf); i++ { - buf[i] = byte(i) - } - return &buf -} -- cgit v1.2.3