2020-05-07 08:45:24 +00:00
|
|
|
package vm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/big"
|
|
|
|
"testing"
|
|
|
|
|
2020-06-03 12:55:06 +00:00
|
|
|
"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) {
|
2021-11-30 12:03:01 +00:00
|
|
|
rc := newRefCounter()
|
|
|
|
var s slot
|
2020-07-24 08:54:12 +00:00
|
|
|
require.Panics(t, func() { s.Size() })
|
|
|
|
|
2022-05-16 14:42:57 +00:00
|
|
|
s.init(3, rc)
|
2020-05-07 08:45:24 +00:00
|
|
|
require.Equal(t, 3, s.Size())
|
2022-05-16 14:42:57 +00:00
|
|
|
require.Equal(t, 3, int(*rc))
|
2020-05-07 08:45:24 +00:00
|
|
|
|
2020-06-03 12:55:06 +00:00
|
|
|
// Null is the default
|
2020-05-07 08:45:24 +00:00
|
|
|
item := s.Get(2)
|
2020-06-03 12:55:06 +00:00
|
|
|
require.Equal(t, stackitem.Null{}, item)
|
2020-05-07 08:45:24 +00:00
|
|
|
|
2021-11-30 12:03:01 +00:00
|
|
|
s.Set(1, stackitem.NewBigInteger(big.NewInt(42)), rc)
|
2020-06-03 12:55:06 +00:00
|
|
|
require.Equal(t, stackitem.NewBigInteger(big.NewInt(42)), s.Get(1))
|
2022-05-16 14:42:57 +00:00
|
|
|
require.Equal(t, 3, int(*rc))
|
2020-05-07 08:45:24 +00:00
|
|
|
}
|