core,vm: implement System.Runtime.GasLeft syscall

This commit is contained in:
Evgenii Stratonikov 2020-06-16 12:04:08 +03:00
parent a7d4fff897
commit a4e4439967
5 changed files with 31 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import (
"testing"
"github.com/nspcc-dev/dbft/crypto"
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
@ -197,3 +198,13 @@ func TestContractCreateAccount(t *testing.T) {
require.Error(t, contractCreateStandardAccount(ic, v))
})
}
func TestRuntimeGasLeft(t *testing.T) {
v, ic, chain := createVM(t)
defer chain.Close()
v.GasLimit = 100
v.AddGas(58)
require.NoError(t, runtime.GasLeft(ic, v))
require.EqualValues(t, 42, v.Estack().Pop().BigInt().Int64())
}