aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/benchmarks_test.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2016-12-02 03:09:22 +0800
committerFelix Lange <fjl@twurst.com>2016-12-02 03:09:22 +0800
commit2dcf75a722f193ef5528f5af8fb4fd7c5824fded (patch)
treea30e617df7e75bc8afd3d38cf3388b2bb986479a /whisper/whisperv5/benchmarks_test.go
parent671fd94e256fb33761dc3b0ae2b8b6374d1d9576 (diff)
downloadgo-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar
go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.gz
go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.bz2
go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.lz
go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.xz
go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.zst
go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.zip
whisper/shhapi, whisper/whisperv5: refactoring (#3364)
* Filter refactoring * API tests added + bugfix * fixed the error logs * FilterID fixed * test cases fixed * key generation updated * POW updated * got rid of redundant stuff
Diffstat (limited to 'whisper/whisperv5/benchmarks_test.go')
-rw-r--r--whisper/whisperv5/benchmarks_test.go57
1 files changed, 19 insertions, 38 deletions
diff --git a/whisper/whisperv5/benchmarks_test.go b/whisper/whisperv5/benchmarks_test.go
index 8bb6c0574..f2eef3c47 100644
--- a/whisper/whisperv5/benchmarks_test.go
+++ b/whisper/whisperv5/benchmarks_test.go
@@ -40,8 +40,7 @@ func BenchmarkEncryptionSym(b *testing.B) {
params, err := generateMessageParams()
if err != nil {
- b.Errorf("failed generateMessageParams with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
}
for i := 0; i < b.N; i++ {
@@ -60,13 +59,11 @@ func BenchmarkEncryptionAsym(b *testing.B) {
params, err := generateMessageParams()
if err != nil {
- b.Errorf("failed generateMessageParams with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
}
key, err := crypto.GenerateKey()
if err != nil {
- b.Errorf("failed GenerateKey with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
}
params.KeySym = nil
params.Dst = &key.PublicKey
@@ -75,8 +72,7 @@ func BenchmarkEncryptionAsym(b *testing.B) {
msg := NewSentMessage(params)
_, err := msg.Wrap(params)
if err != nil {
- b.Errorf("failed Wrap with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
}
}
@@ -86,22 +82,19 @@ func BenchmarkDecryptionSymValid(b *testing.B) {
params, err := generateMessageParams()
if err != nil {
- b.Errorf("failed generateMessageParams with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
}
msg := NewSentMessage(params)
env, err := msg.Wrap(params)
if err != nil {
- b.Errorf("failed Wrap with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
f := Filter{KeySym: params.KeySym}
for i := 0; i < b.N; i++ {
msg := env.Open(&f)
if msg == nil {
- b.Errorf("failed to open with seed %d.", seed)
- return
+ b.Fatalf("failed to open with seed %d.", seed)
}
}
}
@@ -111,22 +104,19 @@ func BenchmarkDecryptionSymInvalid(b *testing.B) {
params, err := generateMessageParams()
if err != nil {
- b.Errorf("failed generateMessageParams with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
}
msg := NewSentMessage(params)
env, err := msg.Wrap(params)
if err != nil {
- b.Errorf("failed Wrap with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
f := Filter{KeySym: []byte("arbitrary stuff here")}
for i := 0; i < b.N; i++ {
msg := env.Open(&f)
if msg != nil {
- b.Errorf("opened envelope with invalid key, seed: %d.", seed)
- return
+ b.Fatalf("opened envelope with invalid key, seed: %d.", seed)
}
}
}
@@ -136,13 +126,11 @@ func BenchmarkDecryptionAsymValid(b *testing.B) {
params, err := generateMessageParams()
if err != nil {
- b.Errorf("failed generateMessageParams with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
}
key, err := crypto.GenerateKey()
if err != nil {
- b.Errorf("failed GenerateKey with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
}
f := Filter{KeyAsym: key}
params.KeySym = nil
@@ -150,15 +138,13 @@ func BenchmarkDecryptionAsymValid(b *testing.B) {
msg := NewSentMessage(params)
env, err := msg.Wrap(params)
if err != nil {
- b.Errorf("failed Wrap with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
for i := 0; i < b.N; i++ {
msg := env.Open(&f)
if msg == nil {
- b.Errorf("fail to open, seed: %d.", seed)
- return
+ b.Fatalf("fail to open, seed: %d.", seed)
}
}
}
@@ -168,35 +154,30 @@ func BenchmarkDecryptionAsymInvalid(b *testing.B) {
params, err := generateMessageParams()
if err != nil {
- b.Errorf("failed generateMessageParams with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
}
key, err := crypto.GenerateKey()
if err != nil {
- b.Errorf("failed GenerateKey with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
}
params.KeySym = nil
params.Dst = &key.PublicKey
msg := NewSentMessage(params)
env, err := msg.Wrap(params)
if err != nil {
- b.Errorf("failed Wrap with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
key, err = crypto.GenerateKey()
if err != nil {
- b.Errorf("failed GenerateKey with seed %d: %s.", seed, err)
- return
+ b.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
}
f := Filter{KeyAsym: key}
for i := 0; i < b.N; i++ {
msg := env.Open(&f)
if msg != nil {
- b.Errorf("opened envelope with invalid key, seed: %d.", seed)
- return
+ b.Fatalf("opened envelope with invalid key, seed: %d.", seed)
}
}
}