github.com/annchain/OG@v0.0.9/vm/vm_test/create_contract_test.go (about)

     1  package vm_test
     2  
     3  import (
     4  	"github.com/annchain/OG/common"
     5  	"github.com/annchain/OG/common/math"
     6  	"github.com/annchain/OG/vm/eth/core/vm"
     7  	"github.com/annchain/OG/vm/ovm"
     8  	"github.com/stretchr/testify/assert"
     9  	"testing"
    10  )
    11  
    12  func TestContractCreation(t *testing.T) {
    13  	from := common.HexToAddress("0xABCDEF88")
    14  	coinBase := common.HexToAddress("0x1234567812345678AABBCCDDEEFF998877665544")
    15  
    16  	tracer := vm.NewStructLogger(&vm.LogConfig{
    17  		Debug: true,
    18  	})
    19  	ldb := DefaultLDB(from, coinBase)
    20  
    21  	rt := &Runtime{
    22  		Tracer:    tracer,
    23  		VmContext: ovm.NewOVMContext(&ovm.DefaultChainContext{}, &coinBase, ldb),
    24  		TxContext: &ovm.TxContext{
    25  			From:       common.HexToAddress("0xABCDEF88"),
    26  			Value:      math.NewBigInt(0),
    27  			GasPrice:   math.NewBigInt(1),
    28  			GasLimit:   DefaultGasLimit,
    29  			Coinbase:   coinBase,
    30  			SequenceID: 0,
    31  		},
    32  	}
    33  
    34  	_, contractAddr, _, err := DeployContract("C.bin", from, coinBase, rt, nil)
    35  	assert.NoError(t, err)
    36  
    37  	// Use C to create D
    38  	{
    39  		params := EncodeParams([]interface{}{55, 66})
    40  		ret, leftGas, err := CallContract(contractAddr, from, coinBase, rt, math.NewBigInt(66), "8dcd64cc", params)
    41  		dump(t, ldb, ret, leftGas, err)
    42  	}
    43  
    44  	//vm.WriteTrace(os.Stdout, tracer.Logs)
    45  }