OSDN Git Service

final code review (#484)
[bytom/vapor.git] / application / mov / mov_core_test.go
index 54a6f7e..9c0b354 100644 (file)
@@ -121,11 +121,11 @@ func TestApplyBlock(t *testing.T) {
                                Transactions: []*types.Tx{
                                        mock.Eos2EtcMakerTxs[0],
                                        mock.Btc2EthMakerTxs[0],
+                                       mock.Eth2BtcMakerTxs[1],
                                        mock.MatchedTxs[4],
                                        mock.Eth2EosMakerTxs[0],
-                                       mock.Eth2BtcMakerTxs[1],
-                                       mock.MatchedTxs[5],
                                        mock.Etc2EosMakerTxs[0],
+                                       mock.MatchedTxs[5],
                                },
                        },
                        blockFunc:  applyBlock,
@@ -137,6 +137,23 @@ func TestApplyBlock(t *testing.T) {
                        wantDBState: &common.MovDatabaseState{Height: 2, Hash: hashPtr(testutil.MustDecodeHash("88dbcde57bb2b53b107d7494f20f1f1a892307a019705980c3510890449c0020"))},
                },
                {
+                       desc: "apply block has partial matched transaction chain",
+                       block: &types.Block{
+                               BlockHeader: types.BlockHeader{Height: 2, PreviousBlockHash: initBlockHeader.Hash()},
+                               Transactions: []*types.Tx{
+                                       mock.Btc2EthMakerTxs[0],
+                                       mock.Eth2BtcMakerTxs[1],
+                                       mock.MatchedTxs[4],
+                                       mock.Eth2BtcMakerTxs[0],
+                                       mock.MatchedTxs[7],
+                               },
+                       },
+                       blockFunc:   applyBlock,
+                       initOrders:  []*common.Order{},
+                       wantOrders:  []*common.Order{mock.MustNewOrderFromOutput(mock.MatchedTxs[7], 2)},
+                       wantDBState: &common.MovDatabaseState{Height: 2, Hash: hashPtr(testutil.MustDecodeHash("88dbcde57bb2b53b107d7494f20f1f1a892307a019705980c3510890449c0020"))},
+               },
+               {
                        desc: "detach block has pending order transaction",
                        block: &types.Block{
                                BlockHeader: *initBlockHeader,