neo-go/pkg/vm/slot_test.go

26 lines
513 B
Go
Raw Normal View History

2020-05-07 08:45:24 +00:00
package vm
import (
"math/big"
"testing"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
2020-05-07 08:45:24 +00:00
"github.com/stretchr/testify/require"
)
func TestSlot_Get(t *testing.T) {
s := newSlot(newRefCounter())
2020-05-07 08:45:24 +00:00
require.NotNil(t, s)
require.Panics(t, func() { s.Size() })
s.init(3)
2020-05-07 08:45:24 +00:00
require.Equal(t, 3, s.Size())
// Null is the default
2020-05-07 08:45:24 +00:00
item := s.Get(2)
require.Equal(t, stackitem.Null{}, item)
2020-05-07 08:45:24 +00:00
s.Set(1, stackitem.NewBigInteger(big.NewInt(42)))
require.Equal(t, stackitem.NewBigInteger(big.NewInt(42)), s.Get(1))
2020-05-07 08:45:24 +00:00
}