mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
emit: allow to emit Null
This commit is contained in:
parent
e5d973d3a4
commit
a3f419f8df
2 changed files with 7 additions and 3 deletions
|
@ -79,8 +79,11 @@ func Array(w *io.BinWriter, es ...interface{}) {
|
|||
case bool:
|
||||
Bool(w, e)
|
||||
default:
|
||||
w.Err = errors.New("unsupported type")
|
||||
return
|
||||
if es[i] != nil {
|
||||
w.Err = errors.New("unsupported type")
|
||||
return
|
||||
}
|
||||
Opcode(w, opcode.PUSHNULL)
|
||||
}
|
||||
}
|
||||
Int(w, int64(len(es)))
|
||||
|
|
|
@ -142,7 +142,7 @@ func TestBytes(t *testing.T) {
|
|||
func TestEmitArray(t *testing.T) {
|
||||
t.Run("good", func(t *testing.T) {
|
||||
buf := io.NewBufBinWriter()
|
||||
Array(buf.BinWriter, int64(1), "str", true, []byte{0xCA, 0xFE})
|
||||
Array(buf.BinWriter, nil, int64(1), "str", true, []byte{0xCA, 0xFE})
|
||||
require.NoError(t, buf.Err)
|
||||
|
||||
res := buf.Bytes()
|
||||
|
@ -154,6 +154,7 @@ func TestEmitArray(t *testing.T) {
|
|||
assert.EqualValues(t, 3, res[6])
|
||||
assert.EqualValues(t, []byte("str"), res[7:10])
|
||||
assert.EqualValues(t, opcode.PUSH1, res[10])
|
||||
assert.EqualValues(t, opcode.PUSHNULL, res[11])
|
||||
})
|
||||
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue