• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revisãodc2431976febfc912a71b26490d26f4a8b9211a4 (tree)
Hora2019-10-15 11:10:59
Autoryahtoo <yahtoo.ma@gmai...>
CommiterPaladz

Mensagem de Log

Set chain Tx Gas 0 (#409)

* Set chain Tx Gas 0

* Fix test file err

* Revert test file modify

Mudança Sumário

Diff

--- a/account/builder.go
+++ b/account/builder.go
@@ -20,7 +20,7 @@ var (
2020 //chainTxUtxoNum maximum utxo quantity in a tx
2121 chainTxUtxoNum = 20
2222 //chainTxMergeGas chain tx gas
23- chainTxMergeGas = uint64(10000000)
23+ chainTxMergeGas = uint64(0)
2424 )
2525
2626 //DecodeSpendAction unmarshal JSON-encoded data of spend action
--- a/account/builder_test.go
+++ b/account/builder_test.go
@@ -354,56 +354,10 @@ func TestMergeSpendAction(t *testing.T) {
354354 }
355355 }
356356
357-func TestCalcMergeGas(t *testing.T) {
358- chainTxUtxoNum = 10
359- cases := []struct {
360- utxoNum int
361- gas uint64
362- }{
363- {
364- utxoNum: 0,
365- gas: 0,
366- },
367- {
368- utxoNum: 1,
369- gas: 0,
370- },
371- {
372- utxoNum: 9,
373- gas: chainTxMergeGas,
374- },
375- {
376- utxoNum: 10,
377- gas: chainTxMergeGas,
378- },
379- {
380- utxoNum: 11,
381- gas: chainTxMergeGas * 2,
382- },
383- {
384- utxoNum: 20,
385- gas: chainTxMergeGas * 3,
386- },
387- {
388- utxoNum: 21,
389- gas: chainTxMergeGas * 3,
390- },
391- {
392- utxoNum: 74,
393- gas: chainTxMergeGas * 9,
394- },
395- }
396-
397- for i, c := range cases {
398- gas := calcMergeGas(c.utxoNum)
399- if gas != c.gas {
400- t.Fatalf("case %d got %d want %d", i, gas, c.gas)
401- }
402- }
403-}
404-
405357 func TestReserveBtmUtxoChain(t *testing.T) {
406358 chainTxUtxoNum = 3
359+ chainTxMergeGas = uint64(10000000)
360+
407361 utxos := []*UTXO{}
408362 m := mockAccountManager(t)
409363 for i := uint64(1); i <= 20; i++ {
--- a/test/builder_test.go
+++ b/test/builder_test.go
@@ -13,8 +13,6 @@ import (
1313 var (
1414 //chainTxUtxoNum maximum utxo quantity in a tx
1515 chainTxUtxoNum = 5
16- //chainTxMergeGas chain tx gas
17- chainTxMergeGas = uint64(10000000)
1816 )
1917
2018 func TestBuildBtmTxChain(t *testing.T) {
@@ -30,7 +28,7 @@ func TestBuildBtmTxChain(t *testing.T) {
3028 inputUtxo: []uint64{5},
3129 wantInput: [][]uint64{},
3230 wantOutput: [][]uint64{},
33- wantUtxo: 5 * chainTxMergeGas,
31+ wantUtxo: 5,
3432 },
3533 {
3634 inputUtxo: []uint64{5, 4},
@@ -38,9 +36,9 @@ func TestBuildBtmTxChain(t *testing.T) {
3836 []uint64{5, 4},
3937 },
4038 wantOutput: [][]uint64{
41- []uint64{8},
39+ []uint64{9},
4240 },
43- wantUtxo: 8 * chainTxMergeGas,
41+ wantUtxo: 9,
4442 },
4543 {
4644 inputUtxo: []uint64{5, 4, 1, 1},
@@ -49,22 +47,22 @@ func TestBuildBtmTxChain(t *testing.T) {
4947 []uint64{1, 9},
5048 },
5149 wantOutput: [][]uint64{
50+ []uint64{11},
5251 []uint64{10},
53- []uint64{9},
5452 },
55- wantUtxo: 10 * chainTxMergeGas,
53+ wantUtxo: 11,
5654 },
5755 {
5856 inputUtxo: []uint64{22, 123, 53, 234, 23, 4, 2423, 24, 23, 43, 34, 234, 234, 24, 11, 16, 33, 59, 73, 89, 66},
5957 wantInput: [][]uint64{
6058 []uint64{22, 123, 53, 234, 23, 4, 2423, 24, 23, 43, 34, 234, 234, 24, 11, 16, 33, 59, 73, 89},
61- []uint64{66, 3778},
59+ []uint64{66, 3779},
6260 },
6361 wantOutput: [][]uint64{
64- []uint64{3778},
65- []uint64{3843},
62+ []uint64{3779},
63+ []uint64{3845},
6664 },
67- wantUtxo: 3843 * chainTxMergeGas,
65+ wantUtxo: 3845,
6866 },
6967 }
7068
@@ -82,7 +80,7 @@ func TestBuildBtmTxChain(t *testing.T) {
8280 utxos := []*acc.UTXO{}
8381 for _, amount := range c.inputUtxo {
8482 utxos = append(utxos, &acc.UTXO{
85- Amount: amount * chainTxMergeGas,
83+ Amount: amount,
8684 AssetID: *consensus.BTMAssetID,
8785 Address: acp.Address,
8886 ControlProgram: acp.ControlProgram,
@@ -97,12 +95,12 @@ func TestBuildBtmTxChain(t *testing.T) {
9795 for i, tpl := range tpls {
9896 gotInput := []uint64{}
9997 for _, input := range tpl.Transaction.Inputs {
100- gotInput = append(gotInput, input.Amount()/chainTxMergeGas)
98+ gotInput = append(gotInput, input.Amount())
10199 }
102100
103101 gotOutput := []uint64{}
104102 for _, output := range tpl.Transaction.Outputs {
105- gotOutput = append(gotOutput, output.AssetAmount().Amount/chainTxMergeGas)
103+ gotOutput = append(gotOutput, output.AssetAmount().Amount)
106104 }
107105
108106 if !testutil.DeepEqual(c.wantInput[i], gotInput) {
Show on old repository browser