2020-03-09 13:56:37 +00:00
|
|
|
package state
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-03-09 15:56:24 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
2020-03-26 14:43:24 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
2020-03-09 15:56:24 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-03-09 13:56:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDecodeEncodeUnspentCoin(t *testing.T) {
|
|
|
|
unspent := &UnspentCoin{
|
2020-03-09 15:56:24 +00:00
|
|
|
Height: 100500,
|
|
|
|
States: []OutputState{
|
|
|
|
{
|
|
|
|
Output: transaction.Output{
|
|
|
|
AssetID: random.Uint256(),
|
|
|
|
Amount: util.Fixed8(42),
|
|
|
|
ScriptHash: random.Uint160(),
|
|
|
|
},
|
|
|
|
SpendHeight: 201000,
|
|
|
|
State: CoinSpent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Output: transaction.Output{
|
|
|
|
AssetID: random.Uint256(),
|
|
|
|
Amount: util.Fixed8(420),
|
|
|
|
ScriptHash: random.Uint160(),
|
|
|
|
},
|
|
|
|
SpendHeight: 0,
|
|
|
|
State: CoinConfirmed,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Output: transaction.Output{
|
|
|
|
AssetID: random.Uint256(),
|
|
|
|
Amount: util.Fixed8(4200),
|
|
|
|
ScriptHash: random.Uint160(),
|
|
|
|
},
|
|
|
|
SpendHeight: 111000,
|
|
|
|
State: CoinSpent & CoinClaimed,
|
|
|
|
},
|
2020-03-09 13:56:37 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-03-26 14:43:24 +00:00
|
|
|
testserdes.EncodeDecodeBinary(t, unspent, new(UnspentCoin))
|
2020-03-09 13:56:37 +00:00
|
|
|
}
|