2018-03-21 16:11:04 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
2018-03-21 16:11:04 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2018-04-16 20:15:30 +00:00
|
|
|
func TestDecodeEncodeUnspentCoinState(t *testing.T) {
|
2018-03-21 16:11:04 +00:00
|
|
|
unspent := &UnspentCoinState{
|
2019-11-28 16:06:09 +00:00
|
|
|
states: []state.Coin{
|
|
|
|
state.CoinConfirmed,
|
|
|
|
state.CoinSpent,
|
|
|
|
state.CoinSpent,
|
|
|
|
state.CoinSpent,
|
|
|
|
state.CoinConfirmed,
|
2018-03-21 16:11:04 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-09-16 09:18:13 +00:00
|
|
|
buf := io.NewBufBinWriter()
|
2019-09-16 16:31:49 +00:00
|
|
|
unspent.EncodeBinary(buf.BinWriter)
|
|
|
|
assert.Nil(t, buf.Err)
|
2018-03-21 16:11:04 +00:00
|
|
|
unspentDecode := &UnspentCoinState{}
|
2019-09-16 16:31:49 +00:00
|
|
|
r := io.NewBinReaderFromBuf(buf.Bytes())
|
|
|
|
unspentDecode.DecodeBinary(r)
|
|
|
|
assert.Nil(t, r.Err)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|