"os"
"testing"
- dbm "github.com/vapor/database/leveldb"
- "github.com/vapor/database/storage"
- "github.com/vapor/protocol/bc"
- "github.com/vapor/protocol/state"
- "github.com/vapor/testutil"
+ dbm "github.com/bytom/vapor/database/leveldb"
+ "github.com/bytom/vapor/database/storage"
+ "github.com/bytom/vapor/protocol/bc"
+ "github.com/bytom/vapor/protocol/state"
+ "github.com/bytom/vapor/testutil"
)
func TestSaveUtxoView(t *testing.T) {
func TestGetTransactionsUtxo(t *testing.T) {
testDB := dbm.NewDB("testdb", "leveldb", "temp")
- defer os.RemoveAll("temp")
+ defer func() {
+ testDB.Close()
+ os.RemoveAll("temp")
+ }()
batch := testDB.NewBatch()
inputView := state.NewUtxoViewpoint()
for i := 0; i <= 2; i++ {
inputView.Entries[bc.Hash{V0: uint64(i)}] = storage.NewUtxoEntry(storage.NormalUTXOType, uint64(i), false)
}
+ inputView.Entries[bc.Hash{V0: uint64(3)}] = storage.NewUtxoEntry(storage.CrosschainUTXOType, uint64(3), true)
+ inputView.Entries[bc.Hash{V0: uint64(4)}] = storage.NewUtxoEntry(storage.CoinbaseUTXOType, uint64(4), false)
+ inputView.Entries[bc.Hash{V0: uint64(5)}] = storage.NewUtxoEntry(storage.VoteUTXOType, uint64(5), false)
+
saveUtxoView(batch, inputView)
batch.Write()
{
txs: []*bc.Tx{
&bc.Tx{
+ MainchainOutputIDs: []bc.Hash{
+ bc.Hash{V0: 10},
+ bc.Hash{V0: 3},
+ },
+ },
+ },
+ inputView: state.NewUtxoViewpoint(),
+ fetchView: &state.UtxoViewpoint{
+ Entries: map[bc.Hash]*storage.UtxoEntry{
+ bc.Hash{V0: 10}: storage.NewUtxoEntry(storage.CrosschainUTXOType, 0, false),
+ bc.Hash{V0: 3}: storage.NewUtxoEntry(storage.CrosschainUTXOType, 3, true),
+ },
+ },
+ err: false,
+ },
+ {
+ txs: []*bc.Tx{
+ &bc.Tx{
+ SpentOutputIDs: []bc.Hash{
+ bc.Hash{V0: 4},
+ bc.Hash{V0: 5},
+ bc.Hash{V0: 6},//no spentOutputID store
+ },
+ },
+ },
+ inputView: state.NewUtxoViewpoint(),
+ fetchView: &state.UtxoViewpoint{
+ Entries: map[bc.Hash]*storage.UtxoEntry{
+ bc.Hash{V0: 4}: storage.NewUtxoEntry(storage.CoinbaseUTXOType, 4, false),
+ bc.Hash{V0: 5}: storage.NewUtxoEntry(storage.VoteUTXOType, 5, false),
+ },
+ },
+ err: false,
+ },
+ {
+ txs: []*bc.Tx{
+ &bc.Tx{
SpentOutputIDs: []bc.Hash{bc.Hash{V0: 0}},
},
},