From 7b88aedb2772a0c39d84628c957b034287140c04 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 9 Jun 2022 13:43:00 +0300 Subject: [PATCH] transaction: add fuzz-test, refs. #2374 --- pkg/core/transaction/fuzz_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 pkg/core/transaction/fuzz_test.go diff --git a/pkg/core/transaction/fuzz_test.go b/pkg/core/transaction/fuzz_test.go new file mode 100644 index 000000000..adfb99521 --- /dev/null +++ b/pkg/core/transaction/fuzz_test.go @@ -0,0 +1,27 @@ +//go:build go1.18 +// +build go1.18 + +package transaction + +import ( + "encoding/base64" + "testing" + + "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/stretchr/testify/require" +) + +func FuzzNewTransactionFromBytes(f *testing.F) { + b, err := base64.StdEncoding.DecodeString(rawInvocationTX) + require.NoError(f, err) + f.Add(b) + tx := New([]byte{0x51}, 1) + tx.Signers = []Signer{{Account: util.Uint160{1, 2, 3}}} + tx.Scripts = []Witness{{InvocationScript: []byte{}, VerificationScript: []byte{}}} + f.Add(tx.Bytes()) + f.Fuzz(func(t *testing.T, b []byte) { + require.NotPanics(t, func() { + _, _ = NewTransactionFromBytes(b) + }) + }) +}