github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/execution/evm/testdata_test.go (about)

     1  package evm
     2  
     3  import (
     4  	"math/big"
     5  
     6  	"github.com/ethereum/go-ethereum/common"
     7  	"github.com/ethereum/go-ethereum/core/types"
     8  	"github.com/iotexproject/go-pkgs/hash"
     9  )
    10  
    11  type (
    12  	// test vector for Contract
    13  	set struct {
    14  		k     hash.Hash256
    15  		v     []byte
    16  		cause error
    17  	}
    18  	cntrTest struct {
    19  		contract Contract
    20  		codes    []code
    21  		states   []set
    22  	}
    23  	// test vector for StateDBAdapter
    24  	bal struct {
    25  		addr common.Address
    26  		v    *big.Int
    27  	}
    28  	code struct {
    29  		addr common.Address
    30  		v    []byte
    31  	}
    32  	evmSet struct {
    33  		addr common.Address
    34  		k    common.Hash
    35  		v    common.Hash
    36  	}
    37  	sui struct {
    38  		amount      *big.Int
    39  		beneficiary common.Address
    40  		addr        common.Address
    41  		suicide     bool
    42  		exist       bool
    43  	}
    44  	image struct {
    45  		hash common.Hash
    46  		v    []byte
    47  	}
    48  	access struct {
    49  		addr  common.Address
    50  		slots []common.Hash
    51  		nx    []common.Hash
    52  		exist bool
    53  	}
    54  	stateDBTest struct {
    55  		balance                       []bal
    56  		codes                         []code
    57  		states                        []evmSet
    58  		refund                        uint64
    59  		suicide                       []sui
    60  		preimage                      []image
    61  		accessList                    []access
    62  		logs                          []*types.Log
    63  		logSize, txLogSize            int
    64  		logAddr, txSender, txReceiver string
    65  	}
    66  )
    67  
    68  var (
    69  	_bytecode = []byte("test contract creation")
    70  
    71  	_addr1 = common.HexToAddress("02ae2a956d21e8d481c3a69e146633470cf625ec")
    72  	_c1    = common.HexToAddress("01fc246633470cf62ae2a956d21e8d481c3a69e1")
    73  	_c2    = common.HexToAddress("3470cf62ae2a956d38d481c3a69e121e01fc2466")
    74  	_c3    = common.HexToAddress("956d21e8d481c3a6901fc246633470cf62ae2ae1")
    75  	_c4    = common.HexToAddress("121e01fc24663470cf62ae2a956d38d481c3a69e")
    76  
    77  	_k1b = hash.Hash256b([]byte("cat"))
    78  	_v1b = hash.Hash256b([]byte("cat"))
    79  	_k2b = hash.Hash256b([]byte("dog"))
    80  	_v2b = hash.Hash256b([]byte("dog"))
    81  	_k3b = hash.Hash256b([]byte("hen"))
    82  	_v3b = hash.Hash256b([]byte("hen"))
    83  	_k4b = hash.Hash256b([]byte("fox"))
    84  	_v4b = hash.Hash256b([]byte("fox"))
    85  	_k1  = common.BytesToHash(_k1b[:])
    86  	_v1  = common.BytesToHash(_v1b[:])
    87  	_k2  = common.BytesToHash(_k2b[:])
    88  	_v2  = common.BytesToHash(_v2b[:])
    89  	_k3  = common.BytesToHash(_k3b[:])
    90  	_v3  = common.BytesToHash(_v3b[:])
    91  	_k4  = common.BytesToHash(_k4b[:])
    92  	_v4  = common.BytesToHash(_v4b[:])
    93  )
    94  
    95  func newTestLog(addr common.Address) *types.Log {
    96  	return &types.Log{
    97  		Address: addr,
    98  		Topics:  []common.Hash{_k1},
    99  	}
   100  }