},
{
input: &GasState{
+ GasLeft: consensus.DefaultGasCredit,
+ GasUsed: 0,
+ BTMValue: 0,
+ },
+ output: &GasState{
+ GasLeft: 200000,
+ GasUsed: 0,
+ BTMValue: math.MaxInt64,
+ },
+ f: func(input *GasState) error {
+ return input.setGas(math.MaxInt64, 0)
+ },
+ err: nil,
+ },
+ {
+ input: &GasState{
GasLeft: 10000,
GasUsed: 0,
BTMValue: 0,
},
{
input: &GasState{
+ GasLeft: -10000,
+ GasUsed: 0,
+ BTMValue: 0,
+ },
+ output: &GasState{
+ GasLeft: -10000,
+ GasUsed: 0,
+ BTMValue: 0,
+ },
+ f: func(input *GasState) error {
+ return input.updateUsage(math.MaxInt64)
+ },
+ err: ErrGasCalculate,
+ },
+ {
+ input: &GasState{
GasLeft: 1000,
GasUsed: 10,
StorageGas: 1000,
block: &bc.Block{
BlockHeader: &bc.BlockHeader{Version: 1},
Transactions: []*bc.Tx{
- &bc.Tx{TxHeader: &bc.TxHeader{Version: 2}},
+ {TxHeader: &bc.TxHeader{Version: 2}},
},
},
err: ErrTxVersion,
block: &bc.Block{
BlockHeader: &bc.BlockHeader{Version: 1},
Transactions: []*bc.Tx{
- &bc.Tx{TxHeader: &bc.TxHeader{Version: 0}},
+ {TxHeader: &bc.TxHeader{Version: 0}},
},
},
err: ErrTxVersion,
block: &bc.Block{
BlockHeader: &bc.BlockHeader{Version: 1},
Transactions: []*bc.Tx{
- &bc.Tx{TxHeader: &bc.TxHeader{Version: math.MaxUint64}},
+ {TxHeader: &bc.TxHeader{Version: math.MaxUint64}},
},
},
err: ErrTxVersion,
result.issuanceProg = bc.Program{VmVersion: 1, Code: prog}
}
if len(result.issuanceArgs) == 0 {
- result.issuanceArgs = [][]byte{[]byte{2}, []byte{3}}
+ result.issuanceArgs = [][]byte{{2}, {3}}
}
if len(result.assetDef) == 0 {
result.assetDef = []byte{2}
if err != nil {
tb.Fatal(err)
}
- args1 := [][]byte{[]byte{4}, []byte{5}}
+ args1 := [][]byte{{4}, {5}}
cp2, err := vm.Assemble("ADD 13 NUMEQUAL")
if err != nil {
tb.Fatal(err)
}
- args2 := [][]byte{[]byte{6}, []byte{7}}
+ args2 := [][]byte{{6}, {7}}
result.txInputs = []*types.TxInput{
types.NewIssuanceInput([]byte{3}, 10, result.issuanceProg.Code, result.issuanceArgs, result.assetDef),