• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版07dd42e9d149fb33db5179d57a54726496cbc969 (tree)
时间2020-02-13 11:59:38
作者shenao78 <shenao.78@163....>
Commitershenao78

Log Message

Supplementary unit tests

更改概述

差异

--- a/application/mov/mock/mock.go
+++ b/application/mov/mock/mock.go
@@ -172,6 +172,12 @@ var (
172172 Inputs: []*types.TxInput{types.NewSpendInput([][]byte{{}, {}, vm.Int64Bytes(2)}, *Btc2EthOrders[0].Utxo.SourceID, *Btc2EthOrders[0].FromAssetID, Btc2EthOrders[0].Utxo.Amount, Btc2EthOrders[0].Utxo.SourcePos, Btc2EthOrders[0].Utxo.ControlProgram)},
173173 Outputs: []*types.TxOutput{types.NewIntraChainOutput(*Btc2EthOrders[0].FromAssetID, Btc2EthOrders[0].Utxo.Amount, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251"))},
174174 }),
175+
176+ // output 2 of MatchedTxs[2]
177+ types.NewTx(types.TxData{
178+ Inputs: []*types.TxInput{types.NewSpendInput([][]byte{{}, {}, vm.Int64Bytes(2)}, *MustNewOrderFromOutput(MatchedTxs[2], 2).Utxo.SourceID, *Eth2BtcOrders[2].FromAssetID, 270, 2, Eth2BtcOrders[2].Utxo.ControlProgram)},
179+ Outputs: []*types.TxOutput{types.NewIntraChainOutput(*Eth2BtcOrders[2].FromAssetID, Eth2BtcOrders[2].Utxo.Amount, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19255"))},
180+ }),
175181 }
176182
177183 Btc2EthMakerTxs = []*types.Tx{
@@ -379,6 +385,19 @@ var (
379385 types.NewIntraChainOutput(*Etc2EosOrders[0].ToAssetID, 100, testutil.MustDecodeHexString("0014df7a97e53bbe278e4e44810b0a760fb472daa9a3")),
380386 },
381387 }),
388+
389+ // full matched transaction from Btc2EthOrders[0], Eth2BtcMakerTxs[0]
390+ types.NewTx(types.TxData{
391+ Inputs: []*types.TxInput{
392+ types.NewSpendInput([][]byte{vm.Int64Bytes(0), vm.Int64Bytes(1)}, *Btc2EthOrders[0].Utxo.SourceID, *Btc2EthOrders[0].FromAssetID, Btc2EthOrders[0].Utxo.Amount, Btc2EthOrders[0].Utxo.SourcePos, Btc2EthOrders[0].Utxo.ControlProgram),
393+ types.NewSpendInput([][]byte{vm.Int64Bytes(1), vm.Int64Bytes(1)}, *MustNewOrderFromOutput(Eth2BtcMakerTxs[0], 0).Utxo.SourceID, *Eth2BtcOrders[0].FromAssetID, Eth2BtcOrders[0].Utxo.Amount, 0, Eth2BtcOrders[0].Utxo.ControlProgram),
394+ },
395+ Outputs: []*types.TxOutput{
396+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 500, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19251")),
397+ types.NewIntraChainOutput(*Eth2BtcOrders[0].ToAssetID, 10, testutil.MustDecodeHexString("0014f928b723999312df4ed51cb275a2644336c19253")),
398+ types.NewIntraChainOutput(*Btc2EthOrders[0].ToAssetID, 10, NodeProgram),
399+ },
400+ }),
382401 }
383402 )
384403
--- a/application/mov/mov_core_test.go
+++ b/application/mov/mov_core_test.go
@@ -628,6 +628,18 @@ func TestValidateMatchedTxSequence(t *testing.T) {
628628 wantError: nil,
629629 },
630630 {
631+ desc: "package matched tx, one order from db, and the another order from transactions",
632+ initOrders: []*common.Order{mock.Btc2EthOrders[0]},
633+ transactions: []*types.Tx{mock.Eth2BtcMakerTxs[0], mock.MatchedTxs[10]},
634+ wantError: nil,
635+ },
636+ {
637+ desc: "two matched txs use the same orders",
638+ initOrders: []*common.Order{mock.Btc2EthOrders[0], mock.Eth2BtcOrders[0]},
639+ transactions: []*types.Tx{mock.MatchedTxs[1], mock.MatchedTxs[1]},
640+ wantError: errNotMatchedOrder,
641+ },
642+ {
631643 desc: "existing two matched orders in db, and only one corresponding matched tx in transactions",
632644 initOrders: []*common.Order{
633645 mock.Btc2EthOrders[3], mock.Eth2BtcOrders[2],
@@ -646,7 +658,7 @@ func TestValidateMatchedTxSequence(t *testing.T) {
646658 wantError: errSpendOutputIDIsIncorrect,
647659 },
648660 {
649- desc: "package full matched tx from maker tx",
661+ desc: "matched tx and orders from packaged transactions",
650662 initOrders: []*common.Order{},
651663 transactions: []*types.Tx{mock.Btc2EthMakerTxs[0], mock.Eth2BtcMakerTxs[1], mock.MatchedTxs[4]},
652664 wantError: nil,
@@ -688,11 +700,17 @@ func TestValidateMatchedTxSequence(t *testing.T) {
688700 wantError: nil,
689701 },
690702 {
691- desc: "package partial matched tx from db orders",
703+ desc: "package partial match tx from db orders, and the re-pending order continue to match",
692704 initOrders: []*common.Order{mock.Btc2EthOrders[0], mock.Btc2EthOrders[1], mock.Eth2BtcOrders[2]},
693705 transactions: []*types.Tx{mock.MatchedTxs[2], mock.MatchedTxs[3]},
694706 wantError: nil,
695707 },
708+ {
709+ desc: "cancel the re-pending order",
710+ initOrders: []*common.Order{mock.Btc2EthOrders[0], mock.Btc2EthOrders[1], mock.Eth2BtcOrders[2]},
711+ transactions: []*types.Tx{mock.MatchedTxs[2], mock.Btc2EthCancelTxs[1], mock.MatchedTxs[3]},
712+ wantError: errNotMatchedOrder,
713+ },
696714 }
697715
698716 for i, c := range cases {
Show on old repository browser