github.com/annchain/OG@v0.0.9/vm/vm_test/assert_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 TestAsserts(t *testing.T) { 13 from := common.HexToAddress("0xABCDEF88") 14 from2 := common.HexToAddress("0xABCDEF87") 15 coinBase := common.HexToAddress("0x1234567812345678AABBCCDDEEFF998877665544") 16 17 tracer := vm.NewStructLogger(&vm.LogConfig{ 18 Debug: true, 19 }) 20 ldb := DefaultLDB(from, coinBase) 21 ldb.CreateAccount(from2) 22 ldb.AddBalance(from2, math.NewBigInt(10000000)) 23 24 rt := &Runtime{ 25 Tracer: tracer, 26 VmContext: ovm.NewOVMContext(&ovm.DefaultChainContext{}, &coinBase, ldb), 27 TxContext: &ovm.TxContext{ 28 From: common.HexToAddress("0xABCDEF88"), 29 Value: math.NewBigInt(0), 30 GasPrice: math.NewBigInt(1), 31 GasLimit: DefaultGasLimit, 32 Coinbase: coinBase, 33 SequenceID: 0, 34 }, 35 } 36 37 _, contractAddr, _, err := DeployContract("asserts.bin", from, coinBase, rt, nil) 38 assert.NoError(t, err) 39 40 { 41 // op jumps to 0xfe and then raise a non-existing op 42 ret, leftGas, err := CallContract(contractAddr, from, coinBase, rt, math.NewBigInt(3), "2911e7b2", nil) 43 dump(t, ldb, ret, leftGas, err) 44 } 45 //vm.WriteTrace(os.Stdout, tracer.Logs) 46 { 47 ret, leftGas, err := CallContract(contractAddr, from2, coinBase, rt, math.NewBigInt(3), "0d43aaf2", nil) 48 dump(t, ldb, ret, leftGas, err) 49 } 50 //vm.WriteTrace(os.Stdout, tracer.Logs) 51 }