neo-go/pkg/vm/slot_test.go
Roman Khimov 0d93b353e6 vm: count initial Null slot variables as well
Match C# behavior. Thanks to @ixje for finding this.
2022-05-16 17:42:57 +03:00

27 lines
565 B
Go

package vm
import (
"math/big"
"testing"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/stretchr/testify/require"
)
func TestSlot_Get(t *testing.T) {
rc := newRefCounter()
var s slot
require.Panics(t, func() { s.Size() })
s.init(3, rc)
require.Equal(t, 3, s.Size())
require.Equal(t, 3, int(*rc))
// Null is the default
item := s.Get(2)
require.Equal(t, stackitem.Null{}, item)
s.Set(1, stackitem.NewBigInteger(big.NewInt(42)), rc)
require.Equal(t, stackitem.NewBigInteger(big.NewInt(42)), s.Get(1))
require.Equal(t, 3, int(*rc))
}