github.com/cheng762/platon-go@v1.8.17-0.20190529111256-7deff2d7be26/core/vm/interpreter_life_test_util.go (about)

     1  package vm
     2  
     3  import (
     4  	"github.com/PlatONnetwork/PlatON-Go/common"
     5  	"github.com/PlatONnetwork/PlatON-Go/life/utils"
     6  	"github.com/PlatONnetwork/PlatON-Go/rlp"
     7  	"bytes"
     8  	"encoding/binary"
     9  	"fmt"
    10  	"math/big"
    11  )
    12  
    13  type ContractRefSelf struct {
    14  }
    15  
    16  func (c ContractRefSelf) Address() common.Address {
    17  	return common.BigToAddress(big.NewInt(66666))
    18  }
    19  
    20  type ContractRefCaller struct {
    21  }
    22  
    23  func (c ContractRefCaller) Address() common.Address {
    24  	return common.BigToAddress(big.NewInt(77777))
    25  }
    26  
    27  func genInput() []byte {
    28  	var input [][]byte
    29  	input = make([][]byte, 0)
    30  	input = append(input, utils.Int64ToBytes(1))
    31  	input = append(input, []byte("transfer"))
    32  	input = append(input, []byte("0x0000000000000000000000000000000000000001"))
    33  	input = append(input, []byte("0x0000000000000000000000000000000000000002"))
    34  	input = append(input, utils.Int64ToBytes(100))
    35  
    36  	buffer := new(bytes.Buffer)
    37  	err := rlp.Encode(buffer, input)
    38  	if err != nil {
    39  		fmt.Println("geninput fail.", err)
    40  	}
    41  	return buffer.Bytes()
    42  }
    43  
    44  type StateDBTest struct {
    45  }
    46  
    47  func bytes2int64(byt []byte) int64 {
    48  	bytesBuf := bytes.NewBuffer(byt)
    49  	var tmp int64
    50  	binary.Read(bytesBuf, binary.BigEndian, &tmp)
    51  	return tmp
    52  }