Skip to content

Commit

Permalink
core/vdf: unit tests for routines leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
Zergity committed Sep 7, 2019
1 parent 1700658 commit ba10817
Show file tree
Hide file tree
Showing 8 changed files with 578 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/vdf/delayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/fortytw2/leaktest"
)

func TestOutput(t *testing.T) {
Expand Down Expand Up @@ -251,3 +252,23 @@ func TestRequestGo(t *testing.T) {
NoCLI()
TestRequest(t)
}

func TestLeakage(t *testing.T) {
defer leaktest.Check(t)()
delayer := NewDelayer(32)
for i := uint64(1); i < iteration0/1000; i++ {
output := delayer.Get(input0, i)
if output != nil {
if delayer.Verify(input0, output, i) {
t.Log("success", "output", common.Bytes2Hex(output))
} else {
t.Error("failed", "output", common.Bytes2Hex(output))
}
}
}
}

func TestLeakageGo(t *testing.T) {
NoCLI()
TestLeakage(t)
}
21 changes: 21 additions & 0 deletions core/vdf/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,24 @@ func TestInterruptedGeneratorGo(t *testing.T) {
NoCLI()
TestInterruptedGenerator(t)
}

func TestLeak(t *testing.T) {
for i := uint64(1); i < iteration0/300; i++ {
output, err := Instance().Generate(input0, i, 127, nil)
if err != nil {
t.Error("error", "err", err)
}
if output != nil {
if Instance().Verify(input0, output, i, 127) {
t.Log("success", "output", common.Bytes2Hex(output))
} else {
t.Error("failed", "output", common.Bytes2Hex(output))
}
}
}
}

func TestLeakGo(t *testing.T) {
NoCLI()
TestLeak(t)
}
16 changes: 16 additions & 0 deletions vendor/github.com/fortytw2/leaktest/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/fortytw2/leaktest/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions vendor/github.com/fortytw2/leaktest/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 171 additions & 0 deletions vendor/github.com/fortytw2/leaktest/leaktest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ba10817

Please sign in to comment.