forked from TrueCloudLab/neoneo-go
vm: add fuzz test for ParseMultiSigContract
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
affe1ecb4f
commit
db977ce38d
1 changed files with 31 additions and 0 deletions
|
@ -5,6 +5,8 @@ package vm
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -35,6 +37,35 @@ func FuzzIsScriptCorrect(f *testing.F) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FuzzParseMultiSigContract(f *testing.F) {
|
||||||
|
pubs := make(keys.PublicKeys, 10)
|
||||||
|
for i := range pubs {
|
||||||
|
p, _ := keys.NewPrivateKey()
|
||||||
|
pubs[i] = p.PublicKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
s, _ := smartcontract.CreateMultiSigRedeemScript(1, pubs[:1])
|
||||||
|
f.Add(s)
|
||||||
|
|
||||||
|
s, _ = smartcontract.CreateMultiSigRedeemScript(3, pubs[:6])
|
||||||
|
f.Add(s)
|
||||||
|
|
||||||
|
s, _ = smartcontract.CreateMultiSigRedeemScript(1, pubs)
|
||||||
|
f.Add(s)
|
||||||
|
|
||||||
|
f.Fuzz(func(t *testing.T, script []byte) {
|
||||||
|
var b [][]byte
|
||||||
|
var ok bool
|
||||||
|
var n int
|
||||||
|
require.NotPanics(t, func() {
|
||||||
|
n, b, ok = ParseMultiSigContract(script)
|
||||||
|
})
|
||||||
|
if ok {
|
||||||
|
require.True(t, n <= len(b))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func FuzzVMDontPanic(f *testing.F) {
|
func FuzzVMDontPanic(f *testing.F) {
|
||||||
for _, s := range fuzzSeedValidScripts {
|
for _, s := range fuzzSeedValidScripts {
|
||||||
f.Add(s)
|
f.Add(s)
|
||||||
|
|
Loading…
Reference in a new issue