2016-01-19 07:43:02 +03:00
|
|
|
package elkrem
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-05-15 17:17:44 +03:00
|
|
|
"github.com/roasbeef/btcd/wire"
|
2016-01-19 07:43:02 +03:00
|
|
|
)
|
|
|
|
|
2016-06-30 02:54:24 +03:00
|
|
|
// TestElkremBig tries 10K hashes
|
2016-01-19 07:43:02 +03:00
|
|
|
func TestElkremBig(t *testing.T) {
|
2016-06-30 02:54:24 +03:00
|
|
|
var rcv ElkremReceiver
|
2016-07-26 02:16:56 +03:00
|
|
|
|
|
|
|
sndr := NewElkremSender(wire.DoubleSha256SH([]byte("elktest")))
|
|
|
|
|
2016-01-19 07:43:02 +03:00
|
|
|
for n := uint64(0); n < 10000; n++ {
|
2016-06-30 02:54:24 +03:00
|
|
|
sha, err := sndr.AtIndex(n)
|
2016-01-19 07:43:02 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2016-07-26 02:16:56 +03:00
|
|
|
|
|
|
|
if err = rcv.AddNext(sha); err != nil {
|
2016-01-19 07:43:02 +03:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2016-07-26 02:16:56 +03:00
|
|
|
|
2016-01-19 10:28:14 +03:00
|
|
|
ReceiverSerdesTest(t, &rcv)
|
2016-07-26 02:16:56 +03:00
|
|
|
|
2016-01-19 07:43:02 +03:00
|
|
|
for n := uint64(0); n < 10000; n += 500 {
|
2016-07-26 02:16:56 +03:00
|
|
|
if _, err := rcv.AtIndex(n); err != nil {
|
2016-01-19 07:43:02 +03:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 02:54:24 +03:00
|
|
|
// TestElkremLess tries 10K hashes
|
|
|
|
func TestElkremLess(t *testing.T) {
|
|
|
|
var rcv ElkremReceiver
|
2016-07-26 02:16:56 +03:00
|
|
|
|
|
|
|
sndr := NewElkremSender(wire.DoubleSha256SH([]byte("elktest2")))
|
|
|
|
|
2016-01-19 07:43:02 +03:00
|
|
|
for n := uint64(0); n < 5000; n++ {
|
2016-06-30 02:54:24 +03:00
|
|
|
sha, err := sndr.AtIndex(n)
|
2016-01-19 07:43:02 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2016-07-26 02:16:56 +03:00
|
|
|
|
|
|
|
if err = rcv.AddNext(sha); err != nil {
|
2016-01-19 07:43:02 +03:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2016-07-26 02:16:56 +03:00
|
|
|
|
2016-01-19 07:43:02 +03:00
|
|
|
for n := uint64(0); n < 5000; n += 500 {
|
2016-07-26 02:16:56 +03:00
|
|
|
if _, err := rcv.AtIndex(n); err != nil {
|
2016-01-19 07:43:02 +03:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|