Test 1: Encryption and decryption.
(t *testing.T)
| 28 | |
| 29 | // Test 1: Encryption and decryption. |
| 30 | func TestCipheringBasic(t *testing.T) { |
| 31 | privkey, _, err := asymmetric.GenSecp256k1KeyPair() |
| 32 | if err != nil { |
| 33 | t.Fatal("failed to generate private key") |
| 34 | } |
| 35 | |
| 36 | in := []byte("Hey there dude. How are you doing? This is a test.") |
| 37 | |
| 38 | out, err := EncryptAndSign(privkey.PubKey(), in) |
| 39 | if err != nil { |
| 40 | t.Fatal("failed to encrypt:", err) |
| 41 | } |
| 42 | |
| 43 | dec, err := DecryptAndCheck(privkey, out) |
| 44 | if err != nil { |
| 45 | t.Fatal("failed to decrypt:", err) |
| 46 | } |
| 47 | |
| 48 | if !bytes.Equal(in, dec) { |
| 49 | t.Error("decrypted data doesn't match original") |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestCipheringErrors(t *testing.T) { |
| 54 | privkey, _, err := asymmetric.GenSecp256k1KeyPair() |
nothing calls this directly
no test coverage detected