native: add Oracle.finish reentrancy test
This commit is contained in:
parent
da2db74bc9
commit
8d170a1eb8
5 changed files with 31 additions and 2 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -151,6 +152,15 @@ func TestOracle_Request(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
require.True(t, strings.Contains(err.Error(), "oracle tx points to invalid request"))
|
||||
})
|
||||
t.Run("Reentrant", func(t *testing.T) {
|
||||
putOracleRequest(t, helperValidatorInvoker, "url", nil, "handleRecursive", []byte{}, gasForResponse)
|
||||
tx := prepareResponseTx(t, 2)
|
||||
e.AddNewBlock(t, tx)
|
||||
// e.CheckFault(t, tx.Hash(), "")
|
||||
aer, err := e.Chain.GetAppExecResults(tx.Hash(), trigger.Application)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, len(aer[0].Events)) // OracleResponse + Invocation
|
||||
})
|
||||
t.Run("BadRequest", func(t *testing.T) {
|
||||
t.Run("non-UTF8 url", func(t *testing.T) {
|
||||
putOracleRequest(t, helperValidatorInvoker, "\xff", nil, "", []byte{1, 2}, gasForResponse, "invalid value: not UTF-8")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue