Commit eb7ced13 authored by harrylee's avatar harrylee Committed by 33cn

fix a bug for test

parent 96cd55dd
This diff is collapsed.
...@@ -21,10 +21,8 @@ import ( ...@@ -21,10 +21,8 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/holiman/uint256"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common" "github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/davecgh/go-spew/spew"
) )
// typeWithoutStringer is a alias for the Type type which simply doesn't implement // typeWithoutStringer is a alias for the Type type which simply doesn't implement
...@@ -213,10 +211,11 @@ func TestTypeCheck(t *testing.T) { ...@@ -213,10 +211,11 @@ func TestTypeCheck(t *testing.T) {
{"uint16[3]", nil, [4]uint16{1, 2, 3}, "abi: cannot use [4]uint16 as type [3]uint16 as argument"}, {"uint16[3]", nil, [4]uint16{1, 2, 3}, "abi: cannot use [4]uint16 as type [3]uint16 as argument"},
{"uint16[3]", nil, []uint16{1, 2, 3}, ""}, {"uint16[3]", nil, []uint16{1, 2, 3}, ""},
{"uint16[3]", nil, []uint16{1, 2, 3, 4}, "abi: cannot use [4]uint16 as type [3]uint16 as argument"}, {"uint16[3]", nil, []uint16{1, 2, 3, 4}, "abi: cannot use [4]uint16 as type [3]uint16 as argument"},
{"address[]", nil, []common.Address{common.Uint256ToAddress(uint256.NewInt().SetUint64(1))}, ""}, //转化为chain33中evm下Hash160Address 合约地址
{"address[1]", nil, []common.Address{common.Uint256ToAddress(uint256.NewInt().SetUint64(1))}, ""}, {"address[]", nil, []common.Hash160Address{{1}}, ""},
{"address[1]", nil, [1]common.Address{common.Uint256ToAddress(uint256.NewInt().SetUint64(1))}, ""}, {"address[1]", nil, []common.Hash160Address{{1}}, ""},
{"address[2]", nil, [1]common.Address{common.Uint256ToAddress(uint256.NewInt().SetUint64(1))}, "abi: cannot use [1]array as type [2]array as argument"}, {"address[1]", nil, [1]common.Hash160Address{{1}}, ""},
{"address[2]", nil, [1]common.Hash160Address{{1}}, "abi: cannot use [1]array as type [2]array as argument"},
{"bytes32", nil, [32]byte{}, ""}, {"bytes32", nil, [32]byte{}, ""},
{"bytes31", nil, [31]byte{}, ""}, {"bytes31", nil, [31]byte{}, ""},
{"bytes30", nil, [30]byte{}, ""}, {"bytes30", nil, [30]byte{}, ""},
...@@ -261,9 +260,10 @@ func TestTypeCheck(t *testing.T) { ...@@ -261,9 +260,10 @@ func TestTypeCheck(t *testing.T) {
{"string", nil, []byte{}, "abi: cannot use slice as type string as argument"}, {"string", nil, []byte{}, "abi: cannot use slice as type string as argument"},
{"bytes32[]", nil, [][32]byte{{}}, ""}, {"bytes32[]", nil, [][32]byte{{}}, ""},
{"function", nil, [24]byte{}, ""}, {"function", nil, [24]byte{}, ""},
{"bytes20", nil, common.Address{}, ""}, //转化为chain33中evm下Hash160Address 合约地址
{"bytes20", nil, common.Hash160Address{}, ""},
{"address", nil, [20]byte{}, ""}, {"address", nil, [20]byte{}, ""},
{"address", nil, common.Address{}, ""}, {"address", nil, common.Hash160Address{}, ""},
{"bytes32[]]", nil, "", "invalid arg type in abi"}, {"bytes32[]]", nil, "", "invalid arg type in abi"},
{"invalidType", nil, "", "unsupported arg type: invalidType"}, {"invalidType", nil, "", "unsupported arg type: invalidType"},
{"invalidSlice[]", nil, "", "unsupported arg type: invalidSlice"}, {"invalidSlice[]", nil, "", "unsupported arg type: invalidSlice"},
......
...@@ -235,7 +235,7 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) { ...@@ -235,7 +235,7 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
case BoolTy: case BoolTy:
return readBool(returnOutput) return readBool(returnOutput)
case AddressTy: case AddressTy:
return common.BytesToAddress(returnOutput), nil return common.BytesToHash160Address(returnOutput), nil
case HashTy: case HashTy:
return common.BytesToHash(returnOutput), nil return common.BytesToHash(returnOutput), nil
case BytesTy: case BytesTy:
......
This diff is collapsed.
...@@ -458,7 +458,6 @@ func opBlockhash(pc *uint64, evm *EVM, callContext *callCtx) ([]byte, error) { ...@@ -458,7 +458,6 @@ func opBlockhash(pc *uint64, evm *EVM, callContext *callCtx) ([]byte, error) {
// 获取区块打包者地址 // 获取区块打包者地址
func opCoinbase(pc *uint64, evm *EVM, callContext *callCtx) ([]byte, error) { func opCoinbase(pc *uint64, evm *EVM, callContext *callCtx) ([]byte, error) {
// 需要注意coinbase可能为空的情况,这时将返回合约的创建者作为coinbase // 需要注意coinbase可能为空的情况,这时将返回合约的创建者作为coinbase
callContext.stack.Push(new(uint256.Int).SetBytes(evm.Coinbase.Bytes()))
if evm.Coinbase == nil { if evm.Coinbase == nil {
callContext.stack.Push(new(uint256.Int).SetBytes(callContext.contract.CallerAddress.Bytes())) callContext.stack.Push(new(uint256.Int).SetBytes(callContext.contract.CallerAddress.Bytes()))
} else { } else {
......
...@@ -96,6 +96,14 @@ func NewYoloV1InstructionSet() JumpTable { ...@@ -96,6 +96,14 @@ func NewYoloV1InstructionSet() JumpTable {
} }
// create2 不支持 // create2 不支持
// chainID 不支持 // chainID 不支持
//PUSH1 指令变更
instructionSet[PUSH1] = Operation{
Execute: opPush1,
GasCost: gas.Push,
ValidateStack: mm.MakeStackFunc(0, 1),
Valid: true,
}
return instructionSet return instructionSet
} }
...@@ -519,7 +527,7 @@ func NewFrontierInstructionSet() [256]Operation { ...@@ -519,7 +527,7 @@ func NewFrontierInstructionSet() [256]Operation {
Valid: true, Valid: true,
}, },
PUSH1: { PUSH1: {
Execute: opPush1, Execute: makePush(1,1),
GasCost: gas.Push, GasCost: gas.Push,
ValidateStack: mm.MakeStackFunc(0, 1), ValidateStack: mm.MakeStackFunc(0, 1),
Valid: true, Valid: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment