OSDN Git Service

modify utxo pending number and consensus node vote restrict (#285)
[bytom/vapor.git] / protocol / state / utxo_view_test.go
index e2697fa..3cd4f4a 100644 (file)
@@ -19,6 +19,24 @@ var defaultEntry = map[bc.Hash]bc.Entry{
        },
 }
 
+var coinbaseEntry = map[bc.Hash]bc.Entry{
+       bc.Hash{V0: 0}: &bc.IntraChainOutput{
+               Source: &bc.ValueSource{
+                       Value: &bc.AssetAmount{
+                               AssetId: consensus.BTMAssetID,
+                       },
+               },
+       },
+       bc.Hash{V0: 1}: &bc.IntraChainOutput{
+               Source: &bc.ValueSource{
+                       Value: &bc.AssetAmount{
+                               AssetId: consensus.BTMAssetID,
+                               Amount:  uint64(100),
+                       },
+               },
+       },
+}
+
 var voteEntry = map[bc.Hash]bc.Entry{
        bc.Hash{V0: 0}: &bc.VoteOutput{
                Source: &bc.ValueSource{
@@ -148,7 +166,7 @@ func TestApplyBlock(t *testing.T) {
                {
                        block: &bc.Block{
                                BlockHeader: &bc.BlockHeader{
-                                       Height:            101,
+                                       Height:            consensus.MainNetParams.CoinbasePendingBlockNumber + 1,
                                        TransactionStatus: bc.NewTransactionStatus(),
                                },
                                Transactions: []*bc.Tx{
@@ -216,17 +234,18 @@ func TestApplyBlock(t *testing.T) {
                                                TxHeader: &bc.TxHeader{
                                                        ResultIds: []*bc.Hash{
                                                                &bc.Hash{V0: 0},
+                                                               &bc.Hash{V0: 1},
                                                        },
                                                },
                                                SpentOutputIDs: []bc.Hash{},
-                                               Entries:        defaultEntry,
+                                               Entries:        coinbaseEntry,
                                        },
                                },
                        },
                        inputView: NewUtxoViewpoint(),
                        fetchView: &UtxoViewpoint{
                                Entries: map[bc.Hash]*storage.UtxoEntry{
-                                       bc.Hash{V0: 0}: storage.NewUtxoEntry(storage.CoinbaseUTXOType, 0, false),
+                                       bc.Hash{V0: 1}: storage.NewUtxoEntry(storage.CoinbaseUTXOType, 0, false),
                                },
                        },
                        err: false,
@@ -285,11 +304,7 @@ func TestApplyBlock(t *testing.T) {
                                },
                        },
                        inputView: NewUtxoViewpoint(),
-                       fetchView: &UtxoViewpoint{
-                               Entries: map[bc.Hash]*storage.UtxoEntry{
-                                       bc.Hash{V1: 0}: storage.NewUtxoEntry(storage.CoinbaseUTXOType, 0, false),
-                               },
-                       },
+                       fetchView: NewUtxoViewpoint(),
                        gasOnlyTx: true,
                        err:       false,
                },
@@ -325,7 +340,7 @@ func TestApplyBlock(t *testing.T) {
                {
                        block: &bc.Block{
                                BlockHeader: &bc.BlockHeader{
-                                       Height:            10001,
+                                       Height:            consensus.MainNetParams.VotePendingBlockNumber + 1,
                                        TransactionStatus: bc.NewTransactionStatus(),
                                },
                                Transactions: []*bc.Tx{
@@ -411,17 +426,22 @@ func TestDetachBlock(t *testing.T) {
                                                TxHeader: &bc.TxHeader{
                                                        ResultIds: []*bc.Hash{
                                                                &bc.Hash{V0: 0},
+                                                               &bc.Hash{V0: 1},
                                                        },
                                                },
                                                SpentOutputIDs: []bc.Hash{},
-                                               Entries:        defaultEntry,
+                                               Entries:        coinbaseEntry,
                                        },
                                },
                        },
-                       inputView: NewUtxoViewpoint(),
+                       inputView: &UtxoViewpoint{
+                               Entries: map[bc.Hash]*storage.UtxoEntry{
+                                       bc.Hash{V0: 1}: storage.NewUtxoEntry(storage.NormalUTXOType, 0, false),
+                               },
+                       },
                        fetchView: &UtxoViewpoint{
                                Entries: map[bc.Hash]*storage.UtxoEntry{
-                                       bc.Hash{V0: 0}: storage.NewUtxoEntry(storage.NormalUTXOType, 0, true),
+                                       bc.Hash{V0: 1}: storage.NewUtxoEntry(storage.NormalUTXOType, 0, true),
                                },
                        },
                        err: false,
@@ -531,11 +551,7 @@ func TestDetachBlock(t *testing.T) {
                                },
                        },
                        inputView: NewUtxoViewpoint(),
-                       fetchView: &UtxoViewpoint{
-                               Entries: map[bc.Hash]*storage.UtxoEntry{
-                                       bc.Hash{V1: 0}: storage.NewUtxoEntry(storage.NormalUTXOType, 0, true),
-                               },
-                       },
+                       fetchView: NewUtxoViewpoint(),
                        gasOnlyTx: true,
                        err:       false,
                },