}
}
-func TestCalcMergeGas(t *testing.T) {
- chainTxUtxoNum = 10
- cases := []struct {
- utxoNum int
- gas uint64
- }{
- {
- utxoNum: 0,
- gas: 0,
- },
- {
- utxoNum: 1,
- gas: 0,
- },
- {
- utxoNum: 9,
- gas: chainTxMergeGas,
- },
- {
- utxoNum: 10,
- gas: chainTxMergeGas,
- },
- {
- utxoNum: 11,
- gas: chainTxMergeGas * 2,
- },
- {
- utxoNum: 20,
- gas: chainTxMergeGas * 3,
- },
- {
- utxoNum: 21,
- gas: chainTxMergeGas * 3,
- },
- {
- utxoNum: 74,
- gas: chainTxMergeGas * 9,
- },
- }
-
- for i, c := range cases {
- gas := calcMergeGas(c.utxoNum)
- if gas != c.gas {
- t.Fatalf("case %d got %d want %d", i, gas, c.gas)
- }
- }
-}
-
func TestReserveBtmUtxoChain(t *testing.T) {
chainTxUtxoNum = 3
+ chainTxMergeGas = uint64(10000000)
+
utxos := []*UTXO{}
m := mockAccountManager(t)
for i := uint64(1); i <= 20; i++ {
var (
//chainTxUtxoNum maximum utxo quantity in a tx
chainTxUtxoNum = 5
- //chainTxMergeGas chain tx gas
- chainTxMergeGas = uint64(10000000)
)
func TestBuildBtmTxChain(t *testing.T) {
inputUtxo: []uint64{5},
wantInput: [][]uint64{},
wantOutput: [][]uint64{},
- wantUtxo: 5 * chainTxMergeGas,
+ wantUtxo: 5,
},
{
inputUtxo: []uint64{5, 4},
[]uint64{5, 4},
},
wantOutput: [][]uint64{
- []uint64{8},
+ []uint64{9},
},
- wantUtxo: 8 * chainTxMergeGas,
+ wantUtxo: 9,
},
{
inputUtxo: []uint64{5, 4, 1, 1},
[]uint64{1, 9},
},
wantOutput: [][]uint64{
+ []uint64{11},
[]uint64{10},
- []uint64{9},
},
- wantUtxo: 10 * chainTxMergeGas,
+ wantUtxo: 11,
},
{
inputUtxo: []uint64{22, 123, 53, 234, 23, 4, 2423, 24, 23, 43, 34, 234, 234, 24, 11, 16, 33, 59, 73, 89, 66},
wantInput: [][]uint64{
[]uint64{22, 123, 53, 234, 23, 4, 2423, 24, 23, 43, 34, 234, 234, 24, 11, 16, 33, 59, 73, 89},
- []uint64{66, 3778},
+ []uint64{66, 3779},
},
wantOutput: [][]uint64{
- []uint64{3778},
- []uint64{3843},
+ []uint64{3779},
+ []uint64{3845},
},
- wantUtxo: 3843 * chainTxMergeGas,
+ wantUtxo: 3845,
},
}
utxos := []*acc.UTXO{}
for _, amount := range c.inputUtxo {
utxos = append(utxos, &acc.UTXO{
- Amount: amount * chainTxMergeGas,
+ Amount: amount,
AssetID: *consensus.BTMAssetID,
Address: acp.Address,
ControlProgram: acp.ControlProgram,
for i, tpl := range tpls {
gotInput := []uint64{}
for _, input := range tpl.Transaction.Inputs {
- gotInput = append(gotInput, input.Amount()/chainTxMergeGas)
+ gotInput = append(gotInput, input.Amount())
}
gotOutput := []uint64{}
for _, output := range tpl.Transaction.Outputs {
- gotOutput = append(gotOutput, output.AssetAmount().Amount/chainTxMergeGas)
+ gotOutput = append(gotOutput, output.AssetAmount().Amount)
}
if !testutil.DeepEqual(c.wantInput[i], gotInput) {