Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
5817fe0e
Commit
5817fe0e
authored
Jul 07, 2021
by
hezhengjun
Committed by
vipwzw
Jul 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct unpack ut and remove old ut files
parent
f84b1429
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
5 additions
and
2625 deletions
+5
-2625
api_test.go
plugin/dapp/evm/executor/abi/api_test.go
+5
-1
base_evm_test.go
plugin/dapp/evm/executor/tests/base_evm_test.go
+0
-130
evm_test.go
plugin/dapp/evm/executor/tests/evm_test.go
+0
-209
gen_test.go
plugin/dapp/evm/executor/tests/gen_test.go
+0
-130
json_struct.go
plugin/dapp/evm/executor/tests/json_struct.go
+0
-47
data_0.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_0.json
+0
-169
data_1.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_1.json
+0
-153
data_2.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_2.json
+0
-129
data_3.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_3.json
+0
-51
data_4.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_4.json
+0
-82
data_5.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_5.json
+0
-74
data_6.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_6.json
+0
-13
data_7.json
plugin/dapp/evm/executor/tests/testdata/mathTest/data_7.json
+0
-44
address.sol
...dapp/evm/executor/tests/testdata/mathTest/sol/address.sol
+0
-39
bitop.sol
...n/dapp/evm/executor/tests/testdata/mathTest/sol/bitop.sol
+0
-33
extern.sol
.../dapp/evm/executor/tests/testdata/mathTest/sol/extern.sol
+0
-76
log.sol
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/log.sol
+0
-20
logic1.sol
.../dapp/evm/executor/tests/testdata/mathTest/sol/logic1.sol
+0
-46
math0.sol
...n/dapp/evm/executor/tests/testdata/mathTest/sol/math0.sol
+0
-40
math1.sol
...n/dapp/evm/executor/tests/testdata/mathTest/sol/math1.sol
+0
-15
math2.sol
...n/dapp/evm/executor/tests/testdata/mathTest/sol/math2.sol
+0
-74
sha3.sol
...in/dapp/evm/executor/tests/testdata/mathTest/sol/sha3.sol
+0
-72
tpl_0.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_0.json
+0
-44
tpl_1.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_1.json
+0
-44
tpl_2.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_2.json
+0
-44
tpl_3.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_3.json
+0
-44
tpl_4.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_4.json
+0
-44
tpl_5.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_5.json
+0
-44
tpl_6.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_6.json
+0
-44
tpl_7.json
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_7.json
+0
-44
tester.go
plugin/dapp/evm/executor/tests/tester.go
+0
-103
util_test.go
plugin/dapp/evm/executor/tests/util_test.go
+0
-291
interpreter.go
plugin/dapp/evm/executor/vm/runtime/interpreter.go
+0
-4
evm.go
plugin/dapp/evm/types/evm.go
+0
-92
evm_test.go
plugin/dapp/evm/types/evm_test.go
+0
-107
tx.go
plugin/dapp/evm/types/tx.go
+0
-29
No files found.
plugin/dapp/evm/executor/abi/api_test.go
View file @
5817fe0e
...
@@ -2,6 +2,7 @@ package abi
...
@@ -2,6 +2,7 @@ package abi
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"fmt"
"fmt"
"reflect"
"reflect"
"testing"
"testing"
...
@@ -77,7 +78,10 @@ func TestABI_Unpack(t *testing.T) {
...
@@ -77,7 +78,10 @@ func TestABI_Unpack(t *testing.T) {
data
,
err
:=
Unpack
(
common
.
FromHex
(
test
.
input
),
test
.
method
,
abiData
)
data
,
err
:=
Unpack
(
common
.
FromHex
(
test
.
input
),
test
.
method
,
abiData
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
EqualValues
(
t
,
test
.
output
,
data
)
jsondata
,
err
:=
json
.
Marshal
(
data
)
assert
.
NoError
(
t
,
err
)
jsonStr
:=
string
(
jsondata
)
assert
.
EqualValues
(
t
,
test
.
output
,
jsonStr
)
}
}
}
}
...
...
plugin/dapp/evm/executor/tests/base_evm_test.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
tests
import
(
"encoding/hex"
"testing"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/model"
)
// 正常创建合约逻辑
func
TestCreateContract1
(
t
*
testing
.
T
)
{
deployCode
,
_
:=
hex
.
DecodeString
(
"608060405260358060116000396000f3006080604052600080fd00a165627a7a723058203f5c7a16b3fd4fb82c8b466dd5a3f43773e41cc9c0acb98f83640880a39a68080029"
)
execCode
,
_
:=
hex
.
DecodeString
(
"6080604052600080fd00a165627a7a723058203f5c7a16b3fd4fb82c8b466dd5a3f43773e41cc9c0acb98f83640880a39a68080029"
)
privKey
:=
getPrivKey
()
gas
:=
uint64
(
210000
)
gasLimit
:=
gas
tx
:=
createTx
(
privKey
,
deployCode
,
gas
,
10000000
)
mdb
:=
buildStateDB
(
getAddr
(
privKey
)
.
String
(),
500000000
)
ret
,
addr
,
leftGas
,
statedb
,
err
:=
createContract
(
mdb
,
tx
,
0
)
test
:=
NewTester
(
t
)
test
.
assertNil
(
err
)
test
.
assertEqualsB
(
ret
,
execCode
)
test
.
assertBigger
(
int
(
gasLimit
),
int
(
leftGas
))
test
.
assertNotEqualsI
(
addr
,
common
.
EmptyAddress
())
// 检查返回数据是否正确
test
.
assertEqualsV
(
statedb
.
GetLastSnapshot
()
.
GetID
(),
0
)
}
// 创建合约gas不足
func
TestCreateContract2
(
t
*
testing
.
T
)
{
deployCode
,
_
:=
hex
.
DecodeString
(
"60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a723058204bf1accefb2526a5077bcdfeaeb8020162814272245a9741cc2fddd89191af1c0029"
)
//execCode, _ := hex.DecodeString("6060604052600080fd00a165627a7a723058204bf1accefb2526a5077bcdfeaeb8020162814272245a9741cc2fddd89191af1c0029")
privKey
:=
getPrivKey
()
// 以上合约代码部署逻辑需要消耗61个Gas,存储代码需要消耗10600个Gas
gas
:=
uint64
(
30
)
tx
:=
createTx
(
privKey
,
deployCode
,
gas
,
0
)
mdb
:=
buildStateDB
(
getAddr
(
privKey
)
.
String
(),
100000000
)
ret
,
_
,
leftGas
,
_
,
err
:=
createContract
(
mdb
,
tx
,
0
)
test
:=
NewTester
(
t
)
// 创建时gas不足,应该返回空
test
.
assertNilB
(
ret
)
test
.
assertEqualsE
(
err
,
model
.
ErrOutOfGas
)
// gas不足时,应该是被扣光了
test
.
assertEqualsV
(
int
(
leftGas
),
0
)
}
// 存储合约gas不足
func
TestCreateContract3
(
t
*
testing
.
T
)
{
deployCode
,
_
:=
hex
.
DecodeString
(
"60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a723058204bf1accefb2526a5077bcdfeaeb8020162814272245a9741cc2fddd89191af1c0029"
)
execCode
,
_
:=
hex
.
DecodeString
(
"6060604052600080fd00a165627a7a723058204bf1accefb2526a5077bcdfeaeb8020162814272245a9741cc2fddd89191af1c0029"
)
privKey
:=
getPrivKey
()
// 以上合约代码部署逻辑需要消耗61个Gas,存储代码需要消耗10600个Gas
usedGas
:=
uint64
(
61
)
gas
:=
uint64
(
100
)
gasLimit
:=
gas
tx
:=
createTx
(
privKey
,
deployCode
,
gas
,
0
)
mdb
:=
buildStateDB
(
getAddr
(
privKey
)
.
String
(),
100000000
)
ret
,
_
,
leftGas
,
_
,
err
:=
createContract
(
mdb
,
tx
,
0
)
test
:=
NewTester
(
t
)
// 这是合约代码已经生成了,但是没有存储到StateDb
test
.
assertEqualsB
(
ret
,
execCode
)
//合约gas不足
test
.
assertEqualsE
(
err
,
model
.
ErrCodeStoreOutOfGas
)
// 合约计算是否正确
// Gas消耗了部署的61个,还应该剩下
test
.
assertEqualsV
(
int
(
leftGas
),
int
(
gasLimit
-
usedGas
))
}
// Gas充足,但是合约代码超大 (通过修改合约代码大小限制)
func
TestCreateContract4
(
t
*
testing
.
T
)
{
deployCode
,
_
:=
hex
.
DecodeString
(
"60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a723058204bf1accefb2526a5077bcdfeaeb8020162814272245a9741cc2fddd89191af1c0029"
)
execCode
,
_
:=
hex
.
DecodeString
(
"6060604052600080fd00a165627a7a723058204bf1accefb2526a5077bcdfeaeb8020162814272245a9741cc2fddd89191af1c0029"
)
privKey
:=
getPrivKey
()
// 以上合约代码部署逻辑需要消耗61个Gas,存储代码需要消耗10600个Gas
gas
:=
uint64
(
210000
)
gasLimit
:=
gas
tx
:=
createTx
(
privKey
,
deployCode
,
gas
,
0
)
mdb
:=
buildStateDB
(
getAddr
(
privKey
)
.
String
(),
100000000
)
ret
,
_
,
leftGas
,
_
,
err
:=
createContract
(
mdb
,
tx
,
50
)
test
:=
NewTester
(
t
)
// 合约代码正常返回
test
.
assertNotNil
(
ret
)
test
.
assertEqualsB
(
ret
,
execCode
)
test
.
assertBigger
(
int
(
gasLimit
),
int
(
leftGas
))
// 返回指定错误
test
.
assertNotNil
(
err
)
test
.
assertEqualsS
(
err
.
Error
(),
"evm: max code size exceeded"
)
}
// 下面测试合约调用时的合约代码
// 对应二进制:608060405234801561001057600080fd5b506298967f60008190555060df806100296000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a72305820b3ccec4d8cbe393844da31834b7464f23d3b81b24f36ce7e18bb09601f2eb8660029
//contract MyStore {
// uint value;
// constructor() public{
// value=9999999;
// }
// function set(uint x) public {
// value = x;
// }
//
// function get() public constant returns (uint){
// return value;
// }
//}
plugin/dapp/evm/executor/tests/evm_test.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
tests
import
(
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/types"
evm
"github.com/33cn/plugin/plugin/dapp/evm/executor"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common/crypto"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/runtime"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/state"
)
func
TestVM
(
t
*
testing
.
T
)
{
basePath
:=
"testdata/"
// 生成测试用例
genTestCase
(
basePath
)
t
.
Parallel
()
// 执行测试用例
runTestCase
(
t
,
basePath
)
//清空测试用例
defer
clearTestCase
(
basePath
)
}
func
TestTmp
(
t
*
testing
.
T
)
{
//addr := common.StringToAddress("19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj")
//fmt.Println(hex.EncodeToString(addr.Bytes()))
tt
:=
types
.
Now
()
.
Unix
()
fmt
.
Println
(
time
.
Unix
(
tt
,
0
)
.
String
())
}
type
CaseFilter
struct
{}
var
testCaseFilter
=
&
CaseFilter
{}
// 满足过滤条件的用例将被执行
func
(
filter
*
CaseFilter
)
filter
(
num
int
)
bool
{
return
num
>=
0
}
// 满足过滤条件的用例将被执行
func
(
filter
*
CaseFilter
)
filterCaseName
(
name
string
)
bool
{
//return name == "selfdestruct"
return
name
!=
""
}
func
runTestCase
(
t
*
testing
.
T
,
basePath
string
)
{
filepath
.
Walk
(
basePath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
path
==
basePath
||
!
info
.
IsDir
()
{
return
nil
}
runDir
(
t
,
path
)
return
nil
})
}
func
runDir
(
tt
*
testing
.
T
,
basePath
string
)
{
filepath
.
Walk
(
basePath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
info
.
IsDir
()
{
return
nil
}
baseName
:=
info
.
Name
()
if
baseName
[
:
5
]
==
"data_"
||
baseName
[
:
4
]
==
"tpl_"
||
filepath
.
Ext
(
path
)
!=
".json"
{
return
nil
}
raw
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
tt
.
FailNow
()
}
var
data
interface
{}
json
.
Unmarshal
(
raw
,
&
data
)
cases
:=
parseData
(
data
.
(
map
[
string
]
interface
{}))
for
_
,
c
:=
range
cases
{
// 每个测试用例,单独起子任务测试
tt
.
Run
(
c
.
name
,
func
(
t
*
testing
.
T
)
{
runCase
(
t
,
c
,
baseName
)
})
}
return
nil
})
}
func
runCase
(
tt
*
testing
.
T
,
c
VMCase
,
file
string
)
{
tt
.
Logf
(
"running test case:%s in file:%s"
,
c
.
name
,
file
)
// 1 构建预置环境 pre
inst
:=
evm
.
NewEVMExecutor
()
q
:=
queue
.
New
(
"channel"
)
q
.
SetConfig
(
chainTestCfg
)
api
,
_
:=
client
.
New
(
q
.
Client
(),
nil
)
inst
.
SetAPI
(
api
)
inst
.
SetEnv
(
c
.
env
.
currentNumber
,
c
.
env
.
currentTimestamp
,
uint64
(
c
.
env
.
currentDifficulty
))
inst
.
CheckInit
()
statedb
:=
inst
.
GetMStateDB
()
mdb
:=
createStateDB
(
statedb
,
c
)
statedb
.
StateDB
=
mdb
statedb
.
CoinsAccount
=
account
.
NewCoinsAccount
(
chainTestCfg
)
statedb
.
CoinsAccount
.
SetDB
(
statedb
.
StateDB
)
// 2 创建交易信息 create
vmcfg
:=
inst
.
GetVMConfig
()
msg
:=
buildMsg
(
c
)
context
:=
inst
.
NewEVMContext
(
msg
)
context
.
Coinbase
=
common
.
StringToAddress
(
c
.
env
.
currentCoinbase
)
// 3 调用执行逻辑 call
env
:=
runtime
.
NewEVM
(
context
,
statedb
,
*
vmcfg
,
api
.
GetConfig
())
var
(
ret
[]
byte
//addr common.Address
//leftGas uint64
err
error
)
if
len
(
c
.
exec
.
address
)
>
0
{
ret
,
_
,
_
,
err
=
env
.
Call
(
runtime
.
AccountRef
(
msg
.
From
()),
*
common
.
StringToAddress
(
c
.
exec
.
address
),
msg
.
Data
(),
msg
.
GasLimit
(),
msg
.
Value
())
}
else
{
addr
:=
crypto
.
RandomContractAddress
()
ret
,
_
,
_
,
err
=
env
.
Create
(
runtime
.
AccountRef
(
msg
.
From
()),
*
addr
,
msg
.
Data
(),
msg
.
GasLimit
(),
"testExecName"
,
""
,
0
)
}
if
err
!=
nil
{
// 合约执行出错的情况下,判断错误是否相同,如果相同,则返回,不判断post
if
len
(
c
.
err
)
>
0
&&
c
.
err
==
err
.
Error
()
{
return
}
// 非意料情况下的出错,视为错误
tt
.
Errorf
(
"test case:%s, failed:%s"
,
c
.
name
,
err
)
tt
.
Fail
()
return
}
// 4 检查执行结果 post (注意,这里不检查Gas具体扣费数额,因为计费规则不一样,值检查执行结果是否正确)
t
:=
NewTester
(
tt
)
// 4.1 返回结果
t
.
assertEqualsB
(
ret
,
getBin
(
c
.
out
))
// 4.2 账户余额以及数据
for
k
,
v
:=
range
c
.
post
{
addrStr
:=
(
*
common
.
StringToAddress
(
k
))
.
String
()
t
.
assertEqualsV
(
int
(
statedb
.
GetBalance
(
addrStr
)),
int
(
v
.
balance
))
t
.
assertEqualsB
(
statedb
.
GetCode
(
addrStr
),
getBin
(
v
.
code
))
for
a
,
b
:=
range
v
.
storage
{
if
len
(
a
)
<
1
||
len
(
b
)
<
1
{
continue
}
hashKey
:=
common
.
BytesToHash
(
getBin
(
a
))
hashVal
:=
common
.
BytesToHash
(
getBin
(
b
))
t
.
assertEqualsB
(
statedb
.
GetState
(
addrStr
,
hashKey
)
.
Bytes
(),
hashVal
.
Bytes
())
}
}
}
// 使用预先设置的数据构建测试环境数据库
func
createStateDB
(
msdb
*
state
.
MemoryStateDB
,
c
VMCase
)
*
db
.
GoMemDB
{
// 替换statedb中的数据库,获取测试需要的数据
mdb
,
_
:=
db
.
NewGoMemDB
(
"test"
,
""
,
0
)
// 构建预置的账户信息
for
k
,
v
:=
range
c
.
pre
{
// 写coins账户
ac
:=
&
types
.
Account
{
Addr
:
c
.
exec
.
caller
,
Balance
:
v
.
balance
}
addAccount
(
mdb
,
k
,
ac
)
// 写合约账户
addContractAccount
(
msdb
,
mdb
,
k
,
v
,
c
.
exec
.
caller
)
}
// 清空MemoryStateDB中的日志
msdb
.
ResetDatas
()
return
mdb
}
// 使用测试输入信息构建交易
func
buildMsg
(
c
VMCase
)
*
common
.
Message
{
code
,
_
:=
hex
.
DecodeString
(
c
.
exec
.
code
)
addr1
:=
common
.
StringToAddress
(
c
.
exec
.
caller
)
addr2
:=
common
.
StringToAddress
(
c
.
exec
.
address
)
gasLimit
:=
uint64
(
210000000
)
gasPrice
:=
c
.
exec
.
gasPrice
return
common
.
NewMessage
(
*
addr1
,
addr2
,
int64
(
1
),
uint64
(
c
.
exec
.
value
),
gasLimit
,
uint32
(
gasPrice
),
code
,
""
,
""
)
}
plugin/dapp/evm/executor/tests/gen_test.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
tests
import
(
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strconv"
"text/template"
)
type
TestData
struct
{
Name
string
Code
string
Out
string
Err
string
}
func
clearTestCase
(
basePath
string
)
{
filepath
.
Walk
(
basePath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
path
==
basePath
||
info
==
nil
{
return
nil
}
if
info
.
IsDir
()
{
clearTestCase
(
path
)
return
nil
}
baseName
:=
info
.
Name
()
if
filepath
.
Ext
(
path
)
==
".json"
&&
baseName
[
:
4
]
!=
"tpl_"
&&
baseName
[
:
5
]
!=
"data_"
{
os
.
Remove
(
path
)
}
return
nil
})
}
func
genTestCase
(
basePath
string
)
{
filepath
.
Walk
(
basePath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
!
info
.
IsDir
()
{
return
nil
}
if
path
==
basePath
{
return
nil
}
scanTestData
(
path
)
return
nil
})
}
func
scanTestData
(
basePath
string
)
{
var
testmap
=
make
(
map
[
string
]
string
)
filepath
.
Walk
(
basePath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
info
.
IsDir
()
{
return
nil
}
basename
:=
info
.
Name
()
// 生成模板文件和数据文件之间的关系
if
filepath
.
Ext
(
path
)
==
".json"
&&
basename
[
:
5
]
==
"data_"
{
re
:=
regexp
.
MustCompile
(
"([0-9]+)"
)
match
:=
re
.
FindStringSubmatch
(
basename
)
num
:=
match
[
1
]
number
,
_
:=
strconv
.
Atoi
(
num
)
if
!
testCaseFilter
.
filter
(
number
)
{
return
nil
}
key
:=
fmt
.
Sprintf
(
"tpl_%s.json"
,
num
)
value
:=
fmt
.
Sprintf
(
"data_%s.json"
,
num
)
keyFile
:=
basePath
+
string
(
filepath
.
Separator
)
+
key
dataFile
:=
basePath
+
string
(
filepath
.
Separator
)
+
value
// 检查两个文件是否都存在
if
_
,
err
:=
os
.
Stat
(
keyFile
);
os
.
IsNotExist
(
err
)
{
fmt
.
Println
(
fmt
.
Errorf
(
"test template file:%s, not exists"
,
keyFile
))
return
nil
}
if
_
,
err
:=
os
.
Stat
(
dataFile
);
os
.
IsNotExist
(
err
)
{
fmt
.
Println
(
fmt
.
Errorf
(
"test data file:%s, not exists"
,
dataFile
))
return
nil
}
testmap
[
keyFile
]
=
dataFile
}
return
nil
})
genTestFile
(
basePath
,
testmap
)
}
func
genTestFile
(
basePath
string
,
datas
map
[
string
]
string
)
{
for
k
,
v
:=
range
datas
{
tpldata
,
err
:=
ioutil
.
ReadFile
(
k
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
continue
}
testdata
,
err
:=
ioutil
.
ReadFile
(
v
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
continue
}
txt
:=
string
(
tpldata
)
tpl
:=
template
.
New
(
"gen test data"
)
tpl
.
Parse
(
txt
)
var
datas
[]
TestData
json
.
Unmarshal
(
testdata
,
&
datas
)
for
_
,
v
:=
range
datas
{
if
!
testCaseFilter
.
filterCaseName
(
v
.
Name
)
{
continue
}
fp
,
err
:=
os
.
Create
(
basePath
+
string
(
filepath
.
Separator
)
+
"generated_"
+
v
.
Name
+
".json"
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
continue
}
tpl
.
Execute
(
fp
,
v
)
}
}
}
plugin/dapp/evm/executor/tests/json_struct.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
tests
// VMCase 一个测试用例
type
VMCase
struct
{
name
string
env
EnvJSON
exec
ExecJSON
gas
int64
logs
string
out
string
err
string
pre
map
[
string
]
AccountJSON
post
map
[
string
]
AccountJSON
}
// EnvJSON 上下文信息
type
EnvJSON
struct
{
currentCoinbase
string
currentDifficulty
int64
currentGasLimit
int64
currentNumber
int64
currentTimestamp
int64
}
// ExecJSON 调用信息
type
ExecJSON
struct
{
address
string
caller
string
code
string
data
string
gas
int64
gasPrice
int64
origin
string
value
int64
}
// AccountJSON 账户信息
type
AccountJSON
struct
{
balance
int64
code
string
nonce
int64
storage
map
[
string
]
string
}
plugin/dapp/evm/executor/tests/testdata/mathTest/data_0.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"add1_2"
,
"Code"
:
"a5f3c23b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000002"
},
{
"Name"
:
"add1_1"
,
"Code"
:
"a5f3c23b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"add0_0"
,
"Code"
:
"a5f3c23b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"add3_-3"
,
"Code"
:
"a5f3c23b0000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"add_overflow"
,
"Code"
:
"a5f3c23bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
},
{
"Name"
:
"sub3_2"
,
"Code"
:
"adefc37b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"sub1_1"
,
"Code"
:
"adefc37b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"sub0_0"
,
"Code"
:
"adefc37b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"sub0_1"
,
"Code"
:
"adefc37b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"Name"
:
"sub3_-3"
,
"Code"
:
"adefc37b0000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000006"
},
{
"Name"
:
"multi1_1"
,
"Code"
:
"b1fd583800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"multi1_0"
,
"Code"
:
"b1fd583800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"multi0_0"
,
"Code"
:
"b1fd583800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"multi_overflow"
,
"Code"
:
"b1fd5838ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"multi2_-2"
,
"Code"
:
"b1fd58380000000000000000000000000000000000000000000000000000000000000002fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"
},
{
"Name"
:
"div1_1"
,
"Code"
:
"a391c15b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"div10_3"
,
"Code"
:
"a391c15b000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000003"
},
{
"Name"
:
"div1_2"
,
"Code"
:
"a391c15b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"div0_1"
,
"Code"
:
"a391c15b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"div3_0"
,
"Code"
:
"a391c15b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
,
"Err"
:
"invalid OpCode 0xfe"
},
{
"Name"
:
"div3_-1"
,
"Code"
:
"a391c15b0000000000000000000000000000000000000000000000000000000000000003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"mod10_3"
,
"Code"
:
"f43f523a000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"mod10_2"
,
"Code"
:
"f43f523a000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"mod0_3"
,
"Code"
:
"f43f523a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"mod3_3"
,
"Code"
:
"f43f523a00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"mod1_1"
,
"Code"
:
"f43f523a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"sdiv10_-3"
,
"Code"
:
"397b3a49000000000000000000000000000000000000000000000000000000000000000afffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb"
},
{
"Name"
:
"sdiv-6_-3"
,
"Code"
:
"397b3a49fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffafffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000002"
},
{
"Name"
:
"sdiv0_-1"
,
"Code"
:
"397b3a490000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"mod-10_3"
,
"Code"
:
"75df4bb9fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"Name"
:
"mod-10_-3"
,
"Code"
:
"75df4bb9fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"Name"
:
"mod10_3"
,
"Code"
:
"75df4bb9000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"mod-3_-3"
,
"Code"
:
"75df4bb9fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_1.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"exp_2_3"
,
"Code"
:
"f5f565f800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000008"
},
{
"Name"
:
"exp_2_0"
,
"Code"
:
"f5f565f800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"exp_2_1"
,
"Code"
:
"f5f565f800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000002"
},
{
"Name"
:
"exp_0_1"
,
"Code"
:
"f5f565f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"exp_0_0"
,
"Code"
:
"f5f565f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"exp_1_1"
,
"Code"
:
"f5f565f800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"less_3_5"
,
"Code"
:
"2d73896500000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000005"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"less_3_3"
,
"Code"
:
"2d73896500000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"less_5_3"
,
"Code"
:
"2d73896500000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"more_5_3"
,
"Code"
:
"ba7d2d9800000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"more_5_5"
,
"Code"
:
"ba7d2d9800000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000005"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"more_3_5"
,
"Code"
:
"ba7d2d9800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000005"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"sless_2_3"
,
"Code"
:
"af5a362b00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"sless_3_2"
,
"Code"
:
"af5a362b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"Name"
:
"sless_-2_3"
,
"Code"
:
"af5a362bfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"sless_2_-3"
,
"Code"
:
"af5a362b0000000000000000000000000000000000000000000000000000000000000002fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb"
},
{
"Name"
:
"sless_-3_-3"
,
"Code"
:
"af5a362bfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"smore_3_2"
,
"Code"
:
"6e28645a00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"smore_2_3"
,
"Code"
:
"6e28645a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"Name"
:
"smore_-3_2"
,
"Code"
:
"6e28645afffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd0000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb"
},
{
"Name"
:
"smore_3_-2"
,
"Code"
:
"6e28645a0000000000000000000000000000000000000000000000000000000000000003fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"equals_3_3"
,
"Code"
:
"bfb0f6bf00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"equals_0_0"
,
"Code"
:
"bfb0f6bf00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"equals_0_3"
,
"Code"
:
"bfb0f6bf00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"equals_0_-1"
,
"Code"
:
"bfb0f6bf0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"equals_-1_-1"
,
"Code"
:
"bfb0f6bfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"equals_-1_-3"
,
"Code"
:
"bfb0f6bffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"iszero_1"
,
"Code"
:
"319d54140000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"iszero_0"
,
"Code"
:
"319d54140000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"iszero_-1"
,
"Code"
:
"319d5414ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_2.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"bitnot_1"
,
"Code"
:
"79e433eb0000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
},
{
"Name"
:
"bitnot_0"
,
"Code"
:
"79e433eb0000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"Name"
:
"bitnot_-1"
,
"Code"
:
"79e433ebffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitand_1_1"
,
"Code"
:
"e919089500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitand_1_0"
,
"Code"
:
"e919089500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitand_0_0"
,
"Code"
:
"e919089500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitand_1_-1"
,
"Code"
:
"e91908950000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitor_1_1"
,
"Code"
:
"45d2def500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitor_0_0"
,
"Code"
:
"45d2def500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitor_0_1"
,
"Code"
:
"45d2def500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitxor_1_1"
,
"Code"
:
"df5dc68600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitxor_0_0"
,
"Code"
:
"df5dc68600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitxor_0_1"
,
"Code"
:
"df5dc68600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitnth_1"
,
"Code"
:
"07d1e68b0000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"3800000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitnth_0"
,
"Code"
:
"07d1e68b0000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"3800000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitnth_33"
,
"Code"
:
"07d1e68b0000000000000000000000000000000000000000000000000000000000000021"
,
"Out"
:
""
,
"Err"
:
"invalid OpCode 0xfe"
},
{
"Name"
:
"bitleft_1_10"
,
"Code"
:
"c5cee4300000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000400"
},
{
"Name"
:
"bitleft_1_1"
,
"Code"
:
"c5cee43000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000002"
},
{
"Name"
:
"bitleft_1_0"
,
"Code"
:
"c5cee43000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitleft_0_3"
,
"Code"
:
"c5cee43000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitleft_-1_2"
,
"Code"
:
"c5cee430ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"
},
{
"Name"
:
"bitright_1_2"
,
"Code"
:
"9a39d53000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"bitright_1024_6"
,
"Code"
:
"9a39d53000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000006"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000010"
},
{
"Name"
:
"bitright_1024_10"
,
"Code"
:
"9a39d5300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000a"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"bitright_-1024_10"
,
"Code"
:
"9a39d530fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00000000000000000000000000000000000000000000000000000000000000000a"
,
"Out"
:
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_3.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"addmodx_2_4_3"
,
"Code"
:
"d0a1703f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"addmodx_-2_2_3"
,
"Code"
:
"d0a1703ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"addmodx_2_2_0"
,
"Code"
:
"d0a1703f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
,
"err"
:
"invalid OpCode 0xfe"
},
{
"Name"
:
"addmodx_2_-4_3"
,
"Code"
:
"d0a1703f0000000000000000000000000000000000000000000000000000000000000002fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
},
{
"Name"
:
"mulmodx_1_2_3"
,
"Code"
:
"1774f30f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000002"
},
{
"Name"
:
"mulmodx_1_3_3"
,
"Code"
:
"1774f30f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
},
{
"Name"
:
"mulmodx_1_-2_3"
,
"Code"
:
"1774f30f0000000000000000000000000000000000000000000000000000000000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
},
{
"Name"
:
"mulmodx_2_2_0"
,
"Code"
:
"1774f30f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
,
"err"
:
"invalid OpCode 0xfe"
},
{
"Name"
:
"mulmodx_1_0_3"
,
"Code"
:
"1774f30f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000000"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_4.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"keccak256_testpackedArgs"
,
"Code"
:
"c8cf44bd"
,
"Out"
:
"true"
},
{
"Name"
:
"keccak256_hashwei"
,
"Code"
:
"d2f8cf24"
,
"Out"
:
"0x26700e13983fefbd9cf16da2ed70fa5c6798ac55062a4803121a869731e308d2"
},
{
"Name"
:
"keccak256_hashstring"
,
"Code"
:
"04d3c094"
,
"Out"
:
"0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb"
},
{
"Name"
:
"keccak256_hashpackArryay"
,
"Code"
:
"11b405c7"
,
"Out"
:
"0xe79a6745d2205095147fd735f329de58377b2f0b9f4b81ae23e010062127f2bc"
},
{
"Name"
:
"keccak256_hashMultipleArgs"
,
"Code"
:
"5087821a"
,
"Out"
:
"0xb5cafab5b83d18303877bb912b2d66ca18ab7390cfd9be8a2e66cc5096e0ea02"
},
{
"Name"
:
"keccak256_hashNegative"
,
"Code"
:
"114be584"
,
"Out"
:
"0xa9c584056064687e149968cbab758a3376d22aedc6a55823d1b3ecbee81b8fb9"
},
{
"Name"
:
"keccak256_hashInt"
,
"Code"
:
"5fdc7f65"
,
"Out"
:
"0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"
},
{
"Name"
:
"keccak256_hashHex"
,
"Code"
:
"5985b624"
,
"Out"
:
"0x0ef9d8f8804d174666011a394cab7901679a8944d24249fd148a6a36071151f8"
},
{
"Name"
:
"keccak256_hashEth"
,
"Code"
:
"e86783a7"
,
"Out"
:
"0xc7cc234d21c9cfbd4632749fd77669e7ae72f5241ce5895e410c45185a469273"
},
{
"Name"
:
"keccak256_hashArray"
,
"Code"
:
"4c9e7ca5"
,
"Out"
:
"0x374c0504f79c1d5e6e4ded17d488802b5656bd1d96b16a568d6c324e1c04c37b"
},
{
"Name"
:
"keccak256_hashaddress"
,
"Code"
:
"51193102"
,
"Out"
:
"0x229327de236bd04ccac2efc445f1a2b63afddf438b35874b9f6fd1e6c38b0198"
},
{
"Name"
:
"keccak256_hash8"
,
"Code"
:
"44d9385f"
,
"Out"
:
"0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2"
},
{
"Name"
:
"keccak256_hash32"
,
"Code"
:
"f74d8e32"
,
"Out"
:
"0x51f81bcdfc324a0dff2b5bec9d92e21cbebc4d5e29d3a3d30de3e03fbeab8d7f"
},
{
"Name"
:
"keccak256_hash256"
,
"Code"
:
"7781deba"
,
"Out"
:
"0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"
}
//
{
//
"Name"
:
"mload_abcdefg"
,
//
"Code"
:
"f23ac2f5000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000076162636465666700000000000000000000000000000000000000000000000000"
,
//
"Out"
:
"0xa82aec019867b7307551dc397acde18b541e742fa1a4e53df4ce3b02d462f524"
//
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_5.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"hashArray"
,
"Code"
:
"4c9e7ca5"
,
"Out"
:
"0x374c0504f79c1d5e6e4ded17d488802b5656bd1d96b16a568d6c324e1c04c37b"
},
{
"Name"
:
"hashPackedArray"
,
"Code"
:
"11b405c7"
,
"Out"
:
"0xe79a6745d2205095147fd735f329de58377b2f0b9f4b81ae23e010062127f2bc"
},
{
"Name"
:
"hashAddress"
,
"Code"
:
"51193102"
,
"Out"
:
"0x229327de236bd04ccac2efc445f1a2b63afddf438b35874b9f6fd1e6c38b0198"
},
{
"Name"
:
"testPackedArgs"
,
"Code"
:
"c8cf44bd"
,
"Out"
:
"0x0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"hashHex"
,
"Code"
:
"5985b624"
,
"Out"
:
"0x0ef9d8f8804d174666011a394cab7901679a8944d24249fd148a6a36071151f8"
},
{
"Name"
:
"hashInt"
,
"Code"
:
"5fdc7f65"
,
"Out"
:
"0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"
},
{
"Name"
:
"hashNegative"
,
"Code"
:
"114be584"
,
"Out"
:
"0xa9c584056064687e149968cbab758a3376d22aedc6a55823d1b3ecbee81b8fb9"
},
{
"Name"
:
"hash8"
,
"Code"
:
"44d9385f"
,
"Out"
:
"0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2"
},
{
"Name"
:
"hash32"
,
"Code"
:
"f74d8e32"
,
"Out"
:
"0x51f81bcdfc324a0dff2b5bec9d92e21cbebc4d5e29d3a3d30de3e03fbeab8d7f"
},
{
"Name"
:
"hash256"
,
"Code"
:
"7781deba"
,
"Out"
:
"0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"
},
{
"Name"
:
"hashEth"
,
"Code"
:
"e86783a7"
,
"Out"
:
"0xc7cc234d21c9cfbd4632749fd77669e7ae72f5241ce5895e410c45185a469273"
},
{
"Name"
:
"hashWei"
,
"Code"
:
"d2f8cf24"
,
"Out"
:
"0x26700e13983fefbd9cf16da2ed70fa5c6798ac55062a4803121a869731e308d2"
},
{
"Name"
:
"hashMultipleArgs"
,
"Code"
:
"5087821a"
,
"Out"
:
"0xb5cafab5b83d18303877bb912b2d66ca18ab7390cfd9be8a2e66cc5096e0ea02"
},
{
"Name"
:
"hashString"
,
"Code"
:
"04d3c094"
,
"Out"
:
"0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_6.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"returnContractAddress"
,
"Code"
:
"0589a27c"
,
"Out"
:
"0x000000000000000000000000a3f45359f6da99814ab4aac58fcac87a641a78cb"
},
{
"Name"
:
"getBalance"
,
"Code"
:
"12065fe0"
,
"Out"
:
"0000000000000000000000000000000000000000000000000000000000000064"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/data_7.json
deleted
100644 → 0
View file @
f84b1429
[
{
"Name"
:
"number"
,
"Code"
:
"0x624de725"
,
"Out"
:
"0x0000000000000000000000000000000000000000000000000000000000000005"
},
{
"Name"
:
"timestamp"
,
"Code"
:
"0xe6369e41"
,
"Out"
:
"0x0000000000000000000000000000000000000000000000000000000000000001"
},
{
"Name"
:
"coinbase"
,
"Code"
:
"0xa6ae0aac"
,
"Out"
:
"0x0000000000000000000000005f853051f1b72cb6825eb03b3dcdd076cd34d079"
},
{
"Name"
:
"difficult"
,
"Code"
:
"0xbdc572b5"
,
"Out"
:
"0x0000000000000000000000000000000000000000000000000000000000000100"
},
{
"Name"
:
"gas"
,
"Code"
:
"0x6ca7c216"
,
"Out"
:
"0x000000000000000000000000000000000000000000000000000000000c8457bd"
},
{
"Name"
:
"gaslimit"
,
"Code"
:
"0x2a722839"
,
"Out"
:
"0x000000000000000000000000000000000000000000000000000000000c845880"
},
{
"Name"
:
"gasprice"
,
"Code"
:
"0x6ec232d3"
,
"Out"
:
"0x00000000000000000000000000000000000000000000000000000000107a4000"
},
{
"Name"
:
"origin"
,
"Code"
:
"0x938b5f32"
,
"Out"
:
"0x000000000000000000000000b0700a4b01af69d625e5528944bcd167fbd9eeff"
}
]
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/address.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract LogicTest1 {
function returnContractAddress() constant returns (address) {
return this;
}
function getBalance(address addr) constant returns (uint){
return addr.balance;
}
}
pragma solidity ^0.4.0;
contract Person{
bytes fail;
function(){
fail = msg.data;
}
function getFail() returns (bytes){
return fail;
}
}
contract CallTest{
function callData(address addr) returns (bool){
return addr.call("abc", 256);
}
}
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/bitop.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract BitTest {
function bitnot(int256 x) pure public returns (int256) {
return ~x;
}
function bitand(int256 x, int256 y) pure public returns (int256) {
return x&y;
}
function bitor(int256 x, int256 y) pure public returns (int256) {
return x|y;
}
function bitxor(int256 x, int256 y) pure public returns (int256) {
return x^y;
}
function bitnth(uint8 x) pure public returns (bytes1) {
bytes memory bts = "8899aabbccddeef";
return bts[x];
}
function bitshiftleft(int256 x, uint256 y) pure public returns (int256) {
return x << y;
}
function bitshiftright(int256 x,uint256 y) pure public returns (int) {
return x>>y;
}
}
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/extern.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract Test{
function difficult() returns (uint){
return block.difficulty;
}
function coinbase() returns (address){
return block.coinbase;
}
function gaslimit() returns (uint){
return block.gaslimit;
}
function Number() returns (uint){
return block.number;
}
function Timestamp() returns (uint){
return block.timestamp;
}
function gas() returns (uint){
return msg.gas;
}
function origin() returns (address){
return tx.origin;
}
function gasprice() returns (uint){
return tx.gasprice;
}
function revert() returns(bytes){
return revert();
}
function selfdestruct() returns(address){
return selfdestruct();
}
}
// contract blockhashTest{
// function blockhash(uint blockNumber) returns (bytes32){
// return block.blockhash();
// }
// }
// contract Person{
// bytes fail;
// function(){
// fail = msg.data;
// }
// function getFail() returns (bytes){
// return fail;
// }
// }
// contract CallTest{
// function callData(address addr) returns (bool){
// return addr.call("abc", 256);
// }
// }
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/log.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract Transfer{
event transfer(address indexed _from, address indexed _to, uint indexed value);
function deposit() payable {
address current = this;
uint value = msg.value;
transfer(msg.sender, current, value);
}
function getBanlance() constant returns(uint) {
return this.balance;
}
/* fallback function */
function(){}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/logic1.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract LogicTest1 {
function exp(uint256 x, uint256 y) pure public returns (uint256) {
uint z = x**y;
return z;
}
function less(uint256 x, uint256 y) pure public returns (uint256) {
if(x < y)
return 1;
return 0;
}
function more(uint256 x, uint256 y) pure public returns (uint256) {
if(x > y)
return 1;
return 0;
}
function sless(int256 x, int256 y) pure public returns (int256) {
if(x < y)
return 1;
return y-x;
}
function smore(int256 x, int256 y) pure public returns (int256) {
if(x > y)
return 1;
return x-y;
}
function equals(int256 x, int256 y) pure public returns (int256) {
if(x == y)
return 1;
return 0;
}
function iszero(int256 x) pure public returns (int) {
if(x == 0)
return 1;
return 0;
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/math0.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract LogicTest {
function add(int x, int y) pure public returns (int) {
int z = x+y;
return z;
}
function sub(int x, int y) pure public returns (int) {
int z = x-y;
return z;
}
function multi(int x, int y) pure public returns (int) {
int z = x*y;
return z;
}
function div(uint x, uint y) pure public returns (uint) {
uint z = x/y;
return z;
}
function sdiv(int x, int y) pure public returns (int) {
int z = x/y;
return z;
}
function mod(uint x, uint y) pure public returns (uint) {
uint z = x%y;
return z;
}
function smod(int x, int y) pure public returns (int) {
int z = x%y;
return z;
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/math1.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract LogicTest1 {
function addmodx(int x, int y, int m) pure public returns (int) {
int z = (x + y) % m;
return z;
}
function mulmod(int x, int y, int m) pure public returns (int) {
int z = (x * y) % m;
return z;
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/math2.sol
deleted
100644 → 0
View file @
f84b1429
pragma solidity ^0.4.0;
contract LogicTest1 {
function hashArray() constant returns(bytes32) {
bytes8[] memory tickers = new bytes8[](4);
tickers[0] = bytes8('BTC');
tickers[1] = bytes8('ETH');
tickers[2] = bytes8('LTC');
tickers[3] = bytes8('DOGE');
return keccak256(tickers);
// 0x374c0504f79c1d5e6e4ded17d488802b5656bd1d96b16a568d6c324e1c04c37b
}
function hashPackedArray() constant returns(bytes32) {
bytes8 btc = bytes8('BTC');
bytes8 eth = bytes8('ETH');
bytes8 ltc = bytes8('LTC');
bytes8 doge = bytes8('DOGE');
return keccak256(btc, eth, ltc, doge);
// 0xe79a6745d2205095147fd735f329de58377b2f0b9f4b81ae23e010062127f2bc
}
function hashAddress() constant returns(bytes32) {
address account = 0x6779913e982688474f710b47e1c0506c5dca4634;
return keccak256(bytes20(account));
// 0x229327de236bd04ccac2efc445f1a2b63afddf438b35874b9f6fd1e6c38b0198
}
function testPackedArgs() constant returns (bool) {
return keccak256('ab') == keccak256('a', 'b');
}
function hashHex() constant returns (bytes32) {
return keccak256(0x0a);
// 0x0ef9d8f8804d174666011a394cab7901679a8944d24249fd148a6a36071151f8
}
function hashInt() constant returns (bytes32) {
return keccak256(int(1));
}
function hashNegative() constant returns (bytes32) {
return keccak256(int(-1));
}
function hash8() constant returns (bytes32) {
return keccak256(1);
}
function hash32() constant returns (bytes32) {
return keccak256(uint32(1));
}
function hash256() constant returns (bytes32) {
return keccak256(uint(1));
}
function hashEth() constant returns (bytes32) {
return keccak256(uint(100 ether));
}
function hashWei() constant returns (bytes32) {
return keccak256(uint(100));
}
function hashMultipleArgs() constant returns (bytes32) {
return keccak256('a', uint(1));
}
function hashString() constant returns (bytes32) {
return keccak256('a');
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/sol/sha3.sol
deleted
100644 → 0
View file @
f84b1429
contract Sha3 {
function hashArray() constant returns(bytes32) {
bytes8[] memory tickers = new bytes8[](4);
tickers[0] = bytes8('BTC');
tickers[1] = bytes8('ETH');
tickers[2] = bytes8('LTC');
tickers[3] = bytes8('DOGE');
return sha3(tickers);
// 0x374c0504f79c1d5e6e4ded17d488802b5656bd1d96b16a568d6c324e1c04c37b
}
function hashPackedArray() constant returns(bytes32) {
bytes8 btc = bytes8('BTC');
bytes8 eth = bytes8('ETH');
bytes8 ltc = bytes8('LTC');
bytes8 doge = bytes8('DOGE');
return sha3(btc, eth, ltc, doge);
// 0xe79a6745d2205095147fd735f329de58377b2f0b9f4b81ae23e010062127f2bc
}
function hashAddress() constant returns(bytes32) {
address account = 0x6779913e982688474f710b47e1c0506c5dca4634;
return sha3(bytes20(account));
// 0x229327de236bd04ccac2efc445f1a2b63afddf438b35874b9f6fd1e6c38b0198
}
function testPackedArgs() constant returns (bool) {
return sha3('ab') == sha3('a', 'b');
}
function hashHex() constant returns (bytes32) {
return sha3(0x0a);
// 0x0ef9d8f8804d174666011a394cab7901679a8944d24249fd148a6a36071151f8
}
function hashInt() constant returns (bytes32) {
return sha3(int(1));
}
function hashNegative() constant returns (bytes32) {
return sha3(int(-1));
}
function hash8() constant returns (bytes32) {
return sha3(1);
}
function hash32() constant returns (bytes32) {
return sha3(uint32(1));
}
function hash256() constant returns (bytes32) {
return sha3(uint(1));
}
function hashEth() constant returns (bytes32) {
return sha3(uint(100 ether));
}
function hashWei() constant returns (bytes32) {
return sha3(uint(100));
}
function hashMultipleArgs() constant returns (bytes32) {
return sha3('a', uint(1));
}
function hashString() constant returns (bytes32) {
return sha3('a');
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_0.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063397b3a491461008857806375df4bb9146100d3578063a391c15b1461011e578063a5f3c23b14610169578063adefc37b146101b4578063b1fd5838146101ff578063f43f523a1461024a575b600080fd5b34801561009457600080fd5b506100bd6004803603810190808035906020019092919080359060200190929190505050610295565b6040518082815260200191505060405180910390f35b3480156100df57600080fd5b5061010860048036038101908080359060200190929190803590602001909291905050506102b0565b6040518082815260200191505060405180910390f35b34801561012a57600080fd5b5061015360048036038101908080359060200190929190803590602001909291905050506102cb565b6040518082815260200191505060405180910390f35b34801561017557600080fd5b5061019e60048036038101908080359060200190929190803590602001909291905050506102e6565b6040518082815260200191505060405180910390f35b3480156101c057600080fd5b506101e960048036038101908080359060200190929190803590602001909291905050506102f8565b6040518082815260200191505060405180910390f35b34801561020b57600080fd5b50610234600480360381019080803590602001909291908035906020019092919050505061030a565b6040518082815260200191505060405180910390f35b34801561025657600080fd5b5061027f600480360381019080803590602001909291908035906020019092919050505061031c565b6040518082815260200191505060405180910390f35b60008082848115156102a357fe5b0590508091505092915050565b60008082848115156102be57fe5b0790508091505092915050565b60008082848115156102d957fe5b0490508091505092915050565b60008082840190508091505092915050565b60008082840390508091505092915050565b60008082840290508091505092915050565b600080828481151561032a57fe5b06905080915050929150505600a165627a7a72305820c06108d061192027b981266b15c3d6be5e2972324486000cb1e362177f26b6890029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063397b3a491461008857806375df4bb9146100d3578063a391c15b1461011e578063a5f3c23b14610169578063adefc37b146101b4578063b1fd5838146101ff578063f43f523a1461024a575b600080fd5b34801561009457600080fd5b506100bd6004803603810190808035906020019092919080359060200190929190505050610295565b6040518082815260200191505060405180910390f35b3480156100df57600080fd5b5061010860048036038101908080359060200190929190803590602001909291905050506102b0565b6040518082815260200191505060405180910390f35b34801561012a57600080fd5b5061015360048036038101908080359060200190929190803590602001909291905050506102cb565b6040518082815260200191505060405180910390f35b34801561017557600080fd5b5061019e60048036038101908080359060200190929190803590602001909291905050506102e6565b6040518082815260200191505060405180910390f35b3480156101c057600080fd5b506101e960048036038101908080359060200190929190803590602001909291905050506102f8565b6040518082815260200191505060405180910390f35b34801561020b57600080fd5b50610234600480360381019080803590602001909291908035906020019092919050505061030a565b6040518082815260200191505060405180910390f35b34801561025657600080fd5b5061027f600480360381019080803590602001909291908035906020019092919050505061031c565b6040518082815260200191505060405180910390f35b60008082848115156102a357fe5b0590508091505092915050565b60008082848115156102be57fe5b0790508091505092915050565b60008082848115156102d957fe5b0490508091505092915050565b60008082840190508091505092915050565b60008082840390508091505092915050565b60008082840290508091505092915050565b600080828481151561032a57fe5b06905080915050929150505600a165627a7a72305820c06108d061192027b981266b15c3d6be5e2972324486000cb1e362177f26b6890029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_1.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632d73896514610088578063319d5414146100d35780636e28645a14610114578063af5a362b1461015f578063ba7d2d98146101aa578063bfb0f6bf146101f5578063f5f565f814610240575b600080fd5b34801561009457600080fd5b506100bd600480360381019080803590602001909291908035906020019092919050505061028b565b6040518082815260200191505060405180910390f35b3480156100df57600080fd5b506100fe600480360381019080803590602001909291905050506102a9565b6040518082815260200191505060405180910390f35b34801561012057600080fd5b5061014960048036038101908080359060200190929190803590602001909291905050506102c6565b6040518082815260200191505060405180910390f35b34801561016b57600080fd5b5061019460048036038101908080359060200190929190803590602001909291905050506102e5565b6040518082815260200191505060405180910390f35b3480156101b657600080fd5b506101df6004803603810190808035906020019092919080359060200190929190505050610304565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b5061022a6004803603810190808035906020019092919080359060200190929190505050610322565b6040518082815260200191505060405180910390f35b34801561024c57600080fd5b506102756004803603810190808035906020019092919080359060200190929190505050610340565b6040518082815260200191505060405180910390f35b60008183101561029e57600190506102a3565b600090505b92915050565b6000808214156102bc57600190506102c1565b600090505b919050565b6000818313156102d957600190506102df565b81830390505b92915050565b6000818312156102f857600190506102fe565b82820390505b92915050565b600081831115610317576001905061031c565b600090505b92915050565b600081831415610335576001905061033a565b600090505b92915050565b60008082840a905080915050929150505600a165627a7a72305820eed7096a91470e58bf09a1645564d0bc48c98f831687f003d1cbaa64f87954360029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632d73896514610088578063319d5414146100d35780636e28645a14610114578063af5a362b1461015f578063ba7d2d98146101aa578063bfb0f6bf146101f5578063f5f565f814610240575b600080fd5b34801561009457600080fd5b506100bd600480360381019080803590602001909291908035906020019092919050505061028b565b6040518082815260200191505060405180910390f35b3480156100df57600080fd5b506100fe600480360381019080803590602001909291905050506102a9565b6040518082815260200191505060405180910390f35b34801561012057600080fd5b5061014960048036038101908080359060200190929190803590602001909291905050506102c6565b6040518082815260200191505060405180910390f35b34801561016b57600080fd5b5061019460048036038101908080359060200190929190803590602001909291905050506102e5565b6040518082815260200191505060405180910390f35b3480156101b657600080fd5b506101df6004803603810190808035906020019092919080359060200190929190505050610304565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b5061022a6004803603810190808035906020019092919080359060200190929190505050610322565b6040518082815260200191505060405180910390f35b34801561024c57600080fd5b506102756004803603810190808035906020019092919080359060200190929190505050610340565b6040518082815260200191505060405180910390f35b60008183101561029e57600190506102a3565b600090505b92915050565b6000808214156102bc57600190506102c1565b600090505b919050565b6000818313156102d957600190506102df565b81830390505b92915050565b6000818312156102f857600190506102fe565b82820390505b92915050565b600081831115610317576001905061031c565b600090505b92915050565b600081831415610335576001905061033a565b600090505b92915050565b60008082840a905080915050929150505600a165627a7a72305820eed7096a91470e58bf09a1645564d0bc48c98f831687f003d1cbaa64f87954360029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_2.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806307d1e68b1461008857806345d2def51461011057806379e433eb1461015b5780639a39d5301461019c578063c5cee430146101e7578063df5dc68614610232578063e91908951461027d575b600080fd5b34801561009457600080fd5b506100b6600480360381019080803560ff1690602001909291905050506102c8565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b34801561011c57600080fd5b506101456004803603810190808035906020019092919080359060200190929190505050610368565b6040518082815260200191505060405180910390f35b34801561016757600080fd5b5061018660048036038101908080359060200190929190505050610375565b6040518082815260200191505060405180910390f35b3480156101a857600080fd5b506101d16004803603810190808035906020019092919080359060200190929190505050610380565b6040518082815260200191505060405180910390f35b3480156101f357600080fd5b5061021c6004803603810190808035906020019092919080359060200190929190505050610392565b6040518082815260200191505060405180910390f35b34801561023e57600080fd5b5061026760048036038101908080359060200190929190803590602001909291905050506103a3565b6040518082815260200191505060405180910390f35b34801561028957600080fd5b506102b260048036038101908080359060200190929190803590602001909291905050506103b0565b6040518082815260200191505060405180910390f35b600060606040805190810160405280600f81526020017f38383939616162626363646465656600000000000000000000000000000000008152509050808360ff1681518110151561031557fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002915050919050565b6000818317905092915050565b600081199050919050565b600081839060020a9005905092915050565b600081839060020a02905092915050565b6000818318905092915050565b60008183169050929150505600a165627a7a72305820bf9b444f2c2a52e1dad8d4dd9b3eb1dfd6728513da2c151c6457b9e7e8d56e4b0029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806307d1e68b1461008857806345d2def51461011057806379e433eb1461015b5780639a39d5301461019c578063c5cee430146101e7578063df5dc68614610232578063e91908951461027d575b600080fd5b34801561009457600080fd5b506100b6600480360381019080803560ff1690602001909291905050506102c8565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b34801561011c57600080fd5b506101456004803603810190808035906020019092919080359060200190929190505050610368565b6040518082815260200191505060405180910390f35b34801561016757600080fd5b5061018660048036038101908080359060200190929190505050610375565b6040518082815260200191505060405180910390f35b3480156101a857600080fd5b506101d16004803603810190808035906020019092919080359060200190929190505050610380565b6040518082815260200191505060405180910390f35b3480156101f357600080fd5b5061021c6004803603810190808035906020019092919080359060200190929190505050610392565b6040518082815260200191505060405180910390f35b34801561023e57600080fd5b5061026760048036038101908080359060200190929190803590602001909291905050506103a3565b6040518082815260200191505060405180910390f35b34801561028957600080fd5b506102b260048036038101908080359060200190929190803590602001909291905050506103b0565b6040518082815260200191505060405180910390f35b600060606040805190810160405280600f81526020017f38383939616162626363646465656600000000000000000000000000000000008152509050808360ff1681518110151561031557fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002915050919050565b6000818317905092915050565b600081199050919050565b600081839060020a9005905092915050565b600081839060020a02905092915050565b6000818318905092915050565b60008183169050929150505600a165627a7a72305820bf9b444f2c2a52e1dad8d4dd9b3eb1dfd6728513da2c151c6457b9e7e8d56e4b0029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_3.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631774f30f14610051578063d0a1703f146100a6575b600080fd5b34801561005d57600080fd5b506100906004803603810190808035906020019092919080359060200190929190803590602001909291905050506100fb565b6040518082815260200191505060405180910390f35b3480156100b257600080fd5b506100e5600480360381019080803590602001909291908035906020019092919080359060200190929190505050610119565b6040518082815260200191505060405180910390f35b6000808284860281151561010b57fe5b079050809150509392505050565b6000808284860181151561012957fe5b0790508091505093925050505600a165627a7a723058206443f02e2fa7652f7f1fe7df536744b14736b8c86656786bda15478d5b91b0e50029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631774f30f14610051578063d0a1703f146100a6575b600080fd5b34801561005d57600080fd5b506100906004803603810190808035906020019092919080359060200190929190803590602001909291905050506100fb565b6040518082815260200191505060405180910390f35b3480156100b257600080fd5b506100e5600480360381019080803590602001909291908035906020019092919080359060200190929190505050610119565b6040518082815260200191505060405180910390f35b6000808284860281151561010b57fe5b079050809150509392505050565b6000808284860181151561012957fe5b0790508091505093925050505600a165627a7a723058206443f02e2fa7652f7f1fe7df536744b14736b8c86656786bda15478d5b91b0e50029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_4.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x60600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304d3c094146100d5578063114be5841461010857806311b405c71461013b57806344d9385f1461016e5780634c9e7ca5146101a15780635087821a146101d457806351193102146102075780635985b6241461023a5780635fdc7f651461026d5780637781deba146102a0578063c8cf44bd146102d3578063d2f8cf2414610302578063e86783a714610335578063f74d8e3214610368575b600080fd5b3480156100e157600080fd5b506100ea61039b565b60405180826000191660001916815260200191505060405180910390f35b34801561011457600080fd5b5061011d6103d8565b60405180826000191660001916815260200191505060405180910390f35b34801561014757600080fd5b50610150610415565b60405180826000191660001916815260200191505060405180910390f35b34801561017a57600080fd5b506101836105b8565b60405180826000191660001916815260200191505060405180910390f35b3480156101ad57600080fd5b506101b66105fb565b60405180826000191660001916815260200191505060405180910390f35b3480156101e057600080fd5b506101e9610853565b60405180826000191660001916815260200191505060405180910390f35b34801561021357600080fd5b5061021c610899565b60405180826000191660001916815260200191505060405180910390f35b34801561024657600080fd5b5061024f6108fc565b60405180826000191660001916815260200191505060405180910390f35b34801561027957600080fd5b5061028261093f565b60405180826000191660001916815260200191505060405180910390f35b3480156102ac57600080fd5b506102b561095d565b60405180826000191660001916815260200191505060405180910390f35b3480156102df57600080fd5b506102e861097b565b604051808215151515815260200191505060405180910390f35b34801561030e57600080fd5b50610317610a1f565b60405180826000191660001916815260200191505060405180910390f35b34801561034157600080fd5b5061034a610a3d565b60405180826000191660001916815260200191505060405180910390f35b34801561037457600080fd5b5061037d610a63565b60405180826000191660001916815260200191505060405180910390f35b600060405180807f610000000000000000000000000000000000000000000000000000000000000081525060010190506040518091039020905090565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff604051808281526020019150506040518091039020905090565b60008060008060007f425443000000000000000000000000000000000000000000000000000000000093507f455448000000000000000000000000000000000000000000000000000000000092507f4c5443000000000000000000000000000000000000000000000000000000000091507f444f474500000000000000000000000000000000000000000000000000000000905083838383604051808577ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018477ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018377ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018277ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff19168152600801945050505050604051809103902094505050505090565b60006001604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006060600460405190808252806020026020018201604052801561062f5781602001602082028038833980820191505090505b5090507f425443000000000000000000000000000000000000000000000000000000000081600081518110151561066257fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f45544800000000000000000000000000000000000000000000000000000000008160018151811015156106d857fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f4c5443000000000000000000000000000000000000000000000000000000000081600281518110151561074e57fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f444f4745000000000000000000000000000000000000000000000000000000008160038151811015156107c457fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508060405180828051906020019060200280838360005b8381101561083b578082015181840152602081019050610820565b50505050905001915050604051809103902091505090565b6000600160405180807f61000000000000000000000000000000000000000000000000000000000000008152506001018281526020019150506040518091039020905090565b600080736779913e982688474f710b47e1c0506c5dca46349050806c010000000000000000000000000260405180826bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152601401915050604051809103902091505090565b6000600a604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b600060405180807f6100000000000000000000000000000000000000000000000000000000000000815250600101807f6200000000000000000000000000000000000000000000000000000000000000815250600101905060405180910390206000191660405180807f6162000000000000000000000000000000000000000000000000000000000000815250600201905060405180910390206000191614905090565b60006064604051808281526020019150506040518091039020905090565b600068056bc75e2d63100000604051808281526020019150506040518091039020905090565b60006001604051808263ffffffff1663ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040191505060405180910390209050905600a165627a7a72305820e36daa8a02ea2ee3869e04f85728f94b5983abfb19fb9819811fce0339f105760029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x60600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304d3c094146100d5578063114be5841461010857806311b405c71461013b57806344d9385f1461016e5780634c9e7ca5146101a15780635087821a146101d457806351193102146102075780635985b6241461023a5780635fdc7f651461026d5780637781deba146102a0578063c8cf44bd146102d3578063d2f8cf2414610302578063e86783a714610335578063f74d8e3214610368575b600080fd5b3480156100e157600080fd5b506100ea61039b565b60405180826000191660001916815260200191505060405180910390f35b34801561011457600080fd5b5061011d6103d8565b60405180826000191660001916815260200191505060405180910390f35b34801561014757600080fd5b50610150610415565b60405180826000191660001916815260200191505060405180910390f35b34801561017a57600080fd5b506101836105b8565b60405180826000191660001916815260200191505060405180910390f35b3480156101ad57600080fd5b506101b66105fb565b60405180826000191660001916815260200191505060405180910390f35b3480156101e057600080fd5b506101e9610853565b60405180826000191660001916815260200191505060405180910390f35b34801561021357600080fd5b5061021c610899565b60405180826000191660001916815260200191505060405180910390f35b34801561024657600080fd5b5061024f6108fc565b60405180826000191660001916815260200191505060405180910390f35b34801561027957600080fd5b5061028261093f565b60405180826000191660001916815260200191505060405180910390f35b3480156102ac57600080fd5b506102b561095d565b60405180826000191660001916815260200191505060405180910390f35b3480156102df57600080fd5b506102e861097b565b604051808215151515815260200191505060405180910390f35b34801561030e57600080fd5b50610317610a1f565b60405180826000191660001916815260200191505060405180910390f35b34801561034157600080fd5b5061034a610a3d565b60405180826000191660001916815260200191505060405180910390f35b34801561037457600080fd5b5061037d610a63565b60405180826000191660001916815260200191505060405180910390f35b600060405180807f610000000000000000000000000000000000000000000000000000000000000081525060010190506040518091039020905090565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff604051808281526020019150506040518091039020905090565b60008060008060007f425443000000000000000000000000000000000000000000000000000000000093507f455448000000000000000000000000000000000000000000000000000000000092507f4c5443000000000000000000000000000000000000000000000000000000000091507f444f474500000000000000000000000000000000000000000000000000000000905083838383604051808577ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018477ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018377ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018277ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff19168152600801945050505050604051809103902094505050505090565b60006001604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006060600460405190808252806020026020018201604052801561062f5781602001602082028038833980820191505090505b5090507f425443000000000000000000000000000000000000000000000000000000000081600081518110151561066257fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f45544800000000000000000000000000000000000000000000000000000000008160018151811015156106d857fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f4c5443000000000000000000000000000000000000000000000000000000000081600281518110151561074e57fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f444f4745000000000000000000000000000000000000000000000000000000008160038151811015156107c457fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508060405180828051906020019060200280838360005b8381101561083b578082015181840152602081019050610820565b50505050905001915050604051809103902091505090565b6000600160405180807f61000000000000000000000000000000000000000000000000000000000000008152506001018281526020019150506040518091039020905090565b600080736779913e982688474f710b47e1c0506c5dca46349050806c010000000000000000000000000260405180826bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152601401915050604051809103902091505090565b6000600a604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b600060405180807f6100000000000000000000000000000000000000000000000000000000000000815250600101807f6200000000000000000000000000000000000000000000000000000000000000815250600101905060405180910390206000191660405180807f6162000000000000000000000000000000000000000000000000000000000000815250600201905060405180910390206000191614905090565b60006064604051808281526020019150506040518091039020905090565b600068056bc75e2d63100000604051808281526020019150506040518091039020905090565b60006001604051808263ffffffff1663ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040191505060405180910390209050905600a165627a7a72305820e36daa8a02ea2ee3869e04f85728f94b5983abfb19fb9819811fce0339f105760029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_5.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304d3c094146100d5578063114be5841461010857806311b405c71461013b57806344d9385f1461016e5780634c9e7ca5146101a15780635087821a146101d457806351193102146102075780635985b6241461023a5780635fdc7f651461026d5780637781deba146102a0578063c8cf44bd146102d3578063d2f8cf2414610302578063e86783a714610335578063f74d8e3214610368575b600080fd5b3480156100e157600080fd5b506100ea61039b565b60405180826000191660001916815260200191505060405180910390f35b34801561011457600080fd5b5061011d6103d8565b60405180826000191660001916815260200191505060405180910390f35b34801561014757600080fd5b50610150610415565b60405180826000191660001916815260200191505060405180910390f35b34801561017a57600080fd5b506101836105b8565b60405180826000191660001916815260200191505060405180910390f35b3480156101ad57600080fd5b506101b66105fb565b60405180826000191660001916815260200191505060405180910390f35b3480156101e057600080fd5b506101e9610853565b60405180826000191660001916815260200191505060405180910390f35b34801561021357600080fd5b5061021c610899565b60405180826000191660001916815260200191505060405180910390f35b34801561024657600080fd5b5061024f6108fc565b60405180826000191660001916815260200191505060405180910390f35b34801561027957600080fd5b5061028261093f565b60405180826000191660001916815260200191505060405180910390f35b3480156102ac57600080fd5b506102b561095d565b60405180826000191660001916815260200191505060405180910390f35b3480156102df57600080fd5b506102e861097b565b604051808215151515815260200191505060405180910390f35b34801561030e57600080fd5b50610317610a1f565b60405180826000191660001916815260200191505060405180910390f35b34801561034157600080fd5b5061034a610a3d565b60405180826000191660001916815260200191505060405180910390f35b34801561037457600080fd5b5061037d610a63565b60405180826000191660001916815260200191505060405180910390f35b600060405180807f610000000000000000000000000000000000000000000000000000000000000081525060010190506040518091039020905090565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff604051808281526020019150506040518091039020905090565b60008060008060007f425443000000000000000000000000000000000000000000000000000000000093507f455448000000000000000000000000000000000000000000000000000000000092507f4c5443000000000000000000000000000000000000000000000000000000000091507f444f474500000000000000000000000000000000000000000000000000000000905083838383604051808577ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018477ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018377ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018277ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff19168152600801945050505050604051809103902094505050505090565b60006001604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006060600460405190808252806020026020018201604052801561062f5781602001602082028038833980820191505090505b5090507f425443000000000000000000000000000000000000000000000000000000000081600081518110151561066257fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f45544800000000000000000000000000000000000000000000000000000000008160018151811015156106d857fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f4c5443000000000000000000000000000000000000000000000000000000000081600281518110151561074e57fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f444f4745000000000000000000000000000000000000000000000000000000008160038151811015156107c457fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508060405180828051906020019060200280838360005b8381101561083b578082015181840152602081019050610820565b50505050905001915050604051809103902091505090565b6000600160405180807f61000000000000000000000000000000000000000000000000000000000000008152506001018281526020019150506040518091039020905090565b600080736779913e982688474f710b47e1c0506c5dca46349050806c010000000000000000000000000260405180826bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152601401915050604051809103902091505090565b6000600a604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b600060405180807f6100000000000000000000000000000000000000000000000000000000000000815250600101807f6200000000000000000000000000000000000000000000000000000000000000815250600101905060405180910390206000191660405180807f6162000000000000000000000000000000000000000000000000000000000000815250600201905060405180910390206000191614905090565b60006064604051808281526020019150506040518091039020905090565b600068056bc75e2d63100000604051808281526020019150506040518091039020905090565b60006001604051808263ffffffff1663ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040191505060405180910390209050905600a165627a7a72305820c978adfa82073b60b730d9d174cfc11b141f0521f175850d4414f7980c7386a00029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806304d3c094146100d5578063114be5841461010857806311b405c71461013b57806344d9385f1461016e5780634c9e7ca5146101a15780635087821a146101d457806351193102146102075780635985b6241461023a5780635fdc7f651461026d5780637781deba146102a0578063c8cf44bd146102d3578063d2f8cf2414610302578063e86783a714610335578063f74d8e3214610368575b600080fd5b3480156100e157600080fd5b506100ea61039b565b60405180826000191660001916815260200191505060405180910390f35b34801561011457600080fd5b5061011d6103d8565b60405180826000191660001916815260200191505060405180910390f35b34801561014757600080fd5b50610150610415565b60405180826000191660001916815260200191505060405180910390f35b34801561017a57600080fd5b506101836105b8565b60405180826000191660001916815260200191505060405180910390f35b3480156101ad57600080fd5b506101b66105fb565b60405180826000191660001916815260200191505060405180910390f35b3480156101e057600080fd5b506101e9610853565b60405180826000191660001916815260200191505060405180910390f35b34801561021357600080fd5b5061021c610899565b60405180826000191660001916815260200191505060405180910390f35b34801561024657600080fd5b5061024f6108fc565b60405180826000191660001916815260200191505060405180910390f35b34801561027957600080fd5b5061028261093f565b60405180826000191660001916815260200191505060405180910390f35b3480156102ac57600080fd5b506102b561095d565b60405180826000191660001916815260200191505060405180910390f35b3480156102df57600080fd5b506102e861097b565b604051808215151515815260200191505060405180910390f35b34801561030e57600080fd5b50610317610a1f565b60405180826000191660001916815260200191505060405180910390f35b34801561034157600080fd5b5061034a610a3d565b60405180826000191660001916815260200191505060405180910390f35b34801561037457600080fd5b5061037d610a63565b60405180826000191660001916815260200191505060405180910390f35b600060405180807f610000000000000000000000000000000000000000000000000000000000000081525060010190506040518091039020905090565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff604051808281526020019150506040518091039020905090565b60008060008060007f425443000000000000000000000000000000000000000000000000000000000093507f455448000000000000000000000000000000000000000000000000000000000092507f4c5443000000000000000000000000000000000000000000000000000000000091507f444f474500000000000000000000000000000000000000000000000000000000905083838383604051808577ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018477ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018377ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff191681526008018277ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff19168152600801945050505050604051809103902094505050505090565b60006001604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006060600460405190808252806020026020018201604052801561062f5781602001602082028038833980820191505090505b5090507f425443000000000000000000000000000000000000000000000000000000000081600081518110151561066257fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f45544800000000000000000000000000000000000000000000000000000000008160018151811015156106d857fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f4c5443000000000000000000000000000000000000000000000000000000000081600281518110151561074e57fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250507f444f4745000000000000000000000000000000000000000000000000000000008160038151811015156107c457fe5b9060200190602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508060405180828051906020019060200280838360005b8381101561083b578082015181840152602081019050610820565b50505050905001915050604051809103902091505090565b6000600160405180807f61000000000000000000000000000000000000000000000000000000000000008152506001018281526020019150506040518091039020905090565b600080736779913e982688474f710b47e1c0506c5dca46349050806c010000000000000000000000000260405180826bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152601401915050604051809103902091505090565b6000600a604051808260ff167f01000000000000000000000000000000000000000000000000000000000000000281526001019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b60006001604051808281526020019150506040518091039020905090565b600060405180807f6100000000000000000000000000000000000000000000000000000000000000815250600101807f6200000000000000000000000000000000000000000000000000000000000000815250600101905060405180910390206000191660405180807f6162000000000000000000000000000000000000000000000000000000000000815250600201905060405180910390206000191614905090565b60006064604051808281526020019150506040518091039020905090565b600068056bc75e2d63100000604051808281526020019150506040518091039020905090565b60006001604051808263ffffffff1663ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040191505060405180910390209050905600a165627a7a72305820c978adfa82073b60b730d9d174cfc11b141f0521f175850d4414f7980c7386a00029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_6.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x00"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x2540BE400"
,
"code"
:
"0x6080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630589a27c14604e57806312065fe01460a2575b600080fd5b348015605957600080fd5b50606060ca565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801560ad57600080fd5b5060b460d2565b6040518082815260200191505060405180910390f35b600030905090565b60003073ffffffffffffffffffffffffffffffffffffffff16319050905600a165627a7a72305820c3a6b3a9c24cd8bb8d10622c61909561937d99f9ceaaec09055ed12b5f02dacc0029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x2540BE400"
,
"code"
:
"0x6080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630589a27c14604e57806312065fe01460a2575b600080fd5b348015605957600080fd5b50606060ca565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801560ad57600080fd5b5060b460d2565b6040518082815260200191505060405180910390f35b600030905090565b60003073ffffffffffffffffffffffffffffffffffffffff16319050905600a165627a7a72305820c3a6b3a9c24cd8bb8d10622c61909561937d99f9ceaaec09055ed12b5f02dacc0029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/testdata/mathTest/tpl_7.json
deleted
100644 → 0
View file @
f84b1429
{
"{{.Name}}"
:
{
"env"
:
{
"currentCoinbase"
:
"19i4kLkSrAr4ssvk1pLwjkFAnoXeJgvGvj"
,
"currentDifficulty"
:
"0x0100"
,
"currentGasLimit"
:
"0x0f4240"
,
"currentNumber"
:
"0x05"
,
"currentTimestamp"
:
"0x01"
},
"exec"
:
{
"address"
:
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
,
"caller"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"code"
:
"{{.Code}}"
,
"data"
:
"0x"
,
"gas"
:
"0x0186a0"
,
"gasPrice"
:
"0x5af3107a4000"
,
"origin"
:
"1H5v9TEEvYUyMt2HsG7vgkF2LWdnfu8mvd"
,
"value"
:
"0x0"
},
"gas"
:
""
,
"logs"
:
""
,
"out"
:
"{{.Out}}"
,
"err"
:
"{{.Err}}"
,
"post"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x6080604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a722839146100a9578063624de725146100d4578063679d38e0146100ff5780636ca7c216146101565780636ec232d3146101815780637da3c3ab146101ac578063938b5f321461023c578063a6ae0aac14610293578063bdc572b5146102ea578063e6369e4114610315575b600080fd5b3480156100b557600080fd5b506100be610340565b6040518082815260200191505060405180910390f35b3480156100e057600080fd5b506100e9610348565b6040518082815260200191505060405180910390f35b34801561010b57600080fd5b50610114610350565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016257600080fd5b5061016b61035f565b6040518082815260200191505060405180910390f35b34801561018d57600080fd5b50610196610367565b6040518082815260200191505060405180910390f35b3480156101b857600080fd5b506101c161036f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102015780820151818401526020810190506101e6565b50505050905090810190601f16801561022e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561024857600080fd5b5061025161037e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029f57600080fd5b506102a8610386565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102f657600080fd5b506102ff61038e565b6040518082815260200191505060405180910390f35b34801561032157600080fd5b5061032a610396565b6040518082815260200191505060405180910390f35b600045905090565b600043905090565b600061035a610350565b905090565b60005a905090565b60003a905090565b606061037961036f565b905090565b600032905090565b600041905090565b600044905090565b6000429050905600a165627a7a723058200f8fccee8a33264994d0d02326ba44a8e782f4a0d061496d6c7e14f6e19c85c90029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
},
"pre"
:
{
"1FwuqJsLH1c4LRBGYPHvKtspEYmS8ag2kf"
:
{
"balance"
:
"0x0de0b6b3a7640000"
,
"code"
:
"0x6080604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a722839146100a9578063624de725146100d4578063679d38e0146100ff5780636ca7c216146101565780636ec232d3146101815780637da3c3ab146101ac578063938b5f321461023c578063a6ae0aac14610293578063bdc572b5146102ea578063e6369e4114610315575b600080fd5b3480156100b557600080fd5b506100be610340565b6040518082815260200191505060405180910390f35b3480156100e057600080fd5b506100e9610348565b6040518082815260200191505060405180910390f35b34801561010b57600080fd5b50610114610350565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016257600080fd5b5061016b61035f565b6040518082815260200191505060405180910390f35b34801561018d57600080fd5b50610196610367565b6040518082815260200191505060405180910390f35b3480156101b857600080fd5b506101c161036f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102015780820151818401526020810190506101e6565b50505050905090810190601f16801561022e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561024857600080fd5b5061025161037e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029f57600080fd5b506102a8610386565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102f657600080fd5b506102ff61038e565b6040518082815260200191505060405180910390f35b34801561032157600080fd5b5061032a610396565b6040518082815260200191505060405180910390f35b600045905090565b600043905090565b600061035a610350565b905090565b60005a905090565b60003a905090565b606061037961036f565b905090565b600032905090565b600041905090565b600044905090565b6000429050905600a165627a7a723058200f8fccee8a33264994d0d02326ba44a8e782f4a0d061496d6c7e14f6e19c85c90029"
,
"nonce"
:
"0x00"
,
"storage"
:
{
}
}
}
}
}
\ No newline at end of file
plugin/dapp/evm/executor/tests/tester.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
tests
import
(
"testing"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
)
// Tester 测试执行对象
type
Tester
struct
{
t
*
testing
.
T
}
// NewTester 新创建测试执行对象
func
NewTester
(
t
*
testing
.
T
)
*
Tester
{
return
&
Tester
{
t
:
t
}
}
func
(
t
*
Tester
)
assertNil
(
val
interface
{})
{
if
val
!=
nil
{
t
.
t
.
Errorf
(
"value {%s} is not nil"
,
val
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertNilB
(
val
[]
byte
)
{
if
val
!=
nil
{
t
.
t
.
Errorf
(
"value {%s} is not nil"
,
common
.
Bytes2Hex
(
val
))
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertNotNil
(
val
interface
{})
{
if
val
==
nil
{
t
.
t
.
Errorf
(
"value {%s} is nil"
,
val
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertEquals
(
val1
,
val2
struct
{})
{
if
val1
!=
val2
{
t
.
t
.
Errorf
(
"value {%s} is not equals to {%s}"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertEqualsS
(
val1
,
val2
string
)
{
if
val1
!=
val2
{
t
.
t
.
Errorf
(
"value %v is not equals to %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertEqualsV
(
val1
,
val2
int
)
{
if
val1
!=
val2
{
t
.
t
.
Errorf
(
"value %v is not equals to %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertEqualsE
(
val1
,
val2
error
)
{
if
val1
!=
val2
{
t
.
t
.
Errorf
(
"value %v is not equals to %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertEqualsB
(
val1
,
val2
[]
byte
)
{
if
string
(
val1
)
!=
string
(
val2
)
{
t
.
t
.
Errorf
(
"value %v is not equals to %v"
,
common
.
Bytes2Hex
(
val1
),
common
.
Bytes2Hex
(
val2
))
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertBigger
(
val1
,
val2
int
)
{
if
val1
<
val2
{
t
.
t
.
Errorf
(
"value %v is less than %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertNotEquals
(
val1
,
val2
struct
{})
{
if
val1
==
val2
{
t
.
t
.
Errorf
(
"value %v is equals to %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertNotEqualsI
(
val1
,
val2
interface
{})
{
if
val1
==
val2
{
t
.
t
.
Errorf
(
"value %v is equals to %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
func
(
t
*
Tester
)
assertNotEqualsV
(
val1
,
val2
int
)
{
if
val1
==
val2
{
t
.
t
.
Errorf
(
"value %v is equals to %v"
,
val1
,
val2
)
t
.
t
.
Fail
()
}
}
plugin/dapp/evm/executor/tests/util_test.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
tests
import
(
"encoding/hex"
"fmt"
"strconv"
"strings"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/types"
evm
"github.com/33cn/plugin/plugin/dapp/evm/executor"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
crypto2
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common/crypto"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/runtime"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/state"
evmtypes
"github.com/33cn/plugin/plugin/dapp/evm/types"
)
var
chainTestCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
chain33
\"
"
,
1
))
func
init
()
{
evm
.
Init
(
evmtypes
.
ExecutorName
,
chainTestCfg
,
nil
)
}
func
getBin
(
data
string
)
(
ret
[]
byte
)
{
ret
,
err
:=
hex
.
DecodeString
(
data
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
return
}
func
parseData
(
data
map
[
string
]
interface
{})
(
cases
[]
VMCase
)
{
for
k
,
v
:=
range
data
{
ut
:=
VMCase
{
name
:
k
}
parseVMCase
(
v
,
&
ut
)
cases
=
append
(
cases
,
ut
)
}
return
}
func
parseVMCase
(
data
interface
{},
ut
*
VMCase
)
{
m
:=
data
.
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
m
{
switch
k
{
case
"env"
:
ut
.
env
=
parseEnv
(
v
)
case
"exec"
:
ut
.
exec
=
parseExec
(
v
)
case
"pre"
:
ut
.
pre
=
parseAccount
(
v
)
case
"post"
:
ut
.
post
=
parseAccount
(
v
)
case
"gas"
:
ut
.
gas
=
toint64
(
unpre
(
v
.
(
string
)))
case
"logs"
:
ut
.
logs
=
unpre
(
v
.
(
string
))
case
"out"
:
ut
.
out
=
unpre
(
v
.
(
string
))
case
"err"
:
ut
.
err
=
v
.
(
string
)
if
ut
.
err
==
"{{.Err}}"
{
ut
.
err
=
""
}
default
:
//fmt.Println(k, "is of a type I don't know how to handle")
}
}
}
func
parseEnv
(
data
interface
{})
EnvJSON
{
m
:=
data
.
(
map
[
string
]
interface
{})
ut
:=
EnvJSON
{}
for
k
,
v
:=
range
m
{
switch
k
{
case
"currentCoinbase"
:
ut
.
currentCoinbase
=
unpre
(
v
.
(
string
))
case
"currentDifficulty"
:
ut
.
currentDifficulty
=
toint64
(
unpre
(
v
.
(
string
)))
case
"currentGasLimit"
:
ut
.
currentGasLimit
=
toint64
(
unpre
(
v
.
(
string
)))
case
"currentNumber"
:
ut
.
currentNumber
=
toint64
(
unpre
(
v
.
(
string
)))
case
"currentTimestamp"
:
ut
.
currentTimestamp
=
toint64
(
unpre
(
v
.
(
string
)))
default
:
fmt
.
Println
(
k
,
"is of a type I don't know how to handle"
)
}
}
return
ut
}
func
parseExec
(
data
interface
{})
ExecJSON
{
m
:=
data
.
(
map
[
string
]
interface
{})
ut
:=
ExecJSON
{}
for
k
,
v
:=
range
m
{
switch
k
{
case
"address"
:
ut
.
address
=
unpre
(
v
.
(
string
))
case
"caller"
:
ut
.
caller
=
unpre
(
v
.
(
string
))
case
"code"
:
ut
.
code
=
unpre
(
v
.
(
string
))
case
"data"
:
ut
.
data
=
unpre
(
v
.
(
string
))
case
"gas"
:
ut
.
gas
=
toint64
(
unpre
(
v
.
(
string
)))
case
"gasPrice"
:
ut
.
gasPrice
=
toint64
(
unpre
(
v
.
(
string
)))
case
"origin"
:
ut
.
origin
=
unpre
(
v
.
(
string
))
case
"value"
:
ut
.
value
=
toint64
(
unpre
(
v
.
(
string
)))
/
100000000
default
:
fmt
.
Println
(
k
,
"is of a type I don't know how to handle"
)
}
}
return
ut
}
func
parseAccount
(
data
interface
{})
map
[
string
]
AccountJSON
{
ret
:=
make
(
map
[
string
]
AccountJSON
)
m
:=
data
.
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
m
{
ret
[
unpre
(
k
)]
=
parseAccount2
(
v
)
}
return
ret
}
func
parseAccount2
(
data
interface
{})
AccountJSON
{
m
:=
data
.
(
map
[
string
]
interface
{})
ut
:=
AccountJSON
{}
for
k
,
v
:=
range
m
{
switch
k
{
case
"balance"
:
ut
.
balance
=
toint64
(
unpre
(
v
.
(
string
)))
/
100000000
case
"code"
:
ut
.
code
=
unpre
(
v
.
(
string
))
case
"nonce"
:
ut
.
nonce
=
toint64
(
unpre
(
v
.
(
string
)))
case
"storage"
:
ut
.
storage
=
parseStorage
(
v
)
default
:
fmt
.
Println
(
k
,
"is of a type I don't know how to handle"
)
}
}
return
ut
}
func
parseStorage
(
data
interface
{})
map
[
string
]
string
{
ret
:=
make
(
map
[
string
]
string
)
m
:=
data
.
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
m
{
ret
[
unpre
(
k
)]
=
unpre
(
v
.
(
string
))
}
return
ret
}
func
toint64
(
data
string
)
int64
{
if
len
(
data
)
==
0
{
return
0
}
val
,
err
:=
strconv
.
ParseInt
(
data
,
16
,
64
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
0
}
return
val
}
// 去掉十六进制字符串前面的0x
func
unpre
(
data
string
)
string
{
if
len
(
data
)
>
1
&&
data
[
:
2
]
==
"0x"
{
return
data
[
2
:
]
}
return
data
}
func
getPrivKey
()
crypto
.
PrivKey
{
c
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
if
err
!=
nil
{
return
nil
}
key
,
err
:=
c
.
GenKey
()
if
err
!=
nil
{
return
nil
}
return
key
}
func
getAddr
(
privKey
crypto
.
PrivKey
)
*
address
.
Address
{
return
address
.
PubKeyToAddress
(
privKey
.
PubKey
()
.
Bytes
())
}
func
createTx
(
privKey
crypto
.
PrivKey
,
code
[]
byte
,
fee
uint64
,
amount
uint64
)
types
.
Transaction
{
action
:=
evmtypes
.
EVMContractAction
{
Amount
:
amount
,
Code
:
code
}
tx
:=
types
.
Transaction
{
Execer
:
[]
byte
(
"evm"
),
Payload
:
types
.
Encode
(
&
action
),
Fee
:
int64
(
fee
),
To
:
address
.
ExecAddress
(
"evm"
)}
tx
.
Sign
(
types
.
SECP256K1
,
privKey
)
return
tx
}
func
addAccount
(
mdb
*
db
.
GoMemDB
,
execAddr
string
,
acc1
*
types
.
Account
)
{
acc
:=
account
.
NewCoinsAccount
(
chainTestCfg
)
var
set
[]
*
types
.
KeyValue
if
len
(
execAddr
)
>
0
{
set
=
acc
.
GetExecKVSet
(
execAddr
,
acc1
)
}
else
{
set
=
acc
.
GetKVSet
(
acc1
)
}
for
i
:=
0
;
i
<
len
(
set
);
i
++
{
mdb
.
Set
(
set
[
i
]
.
GetKey
(),
set
[
i
]
.
Value
)
}
}
func
addContractAccount
(
db
*
state
.
MemoryStateDB
,
mdb
*
db
.
GoMemDB
,
addr
string
,
a
AccountJSON
,
creator
string
)
{
acc
:=
state
.
NewContractAccount
(
addr
,
db
)
acc
.
SetCreator
(
creator
)
code
,
err
:=
hex
.
DecodeString
(
a
.
code
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
acc
.
SetCode
(
code
)
acc
.
SetNonce
(
uint64
(
a
.
nonce
))
for
k
,
v
:=
range
a
.
storage
{
key
,
_
:=
hex
.
DecodeString
(
k
)
value
,
_
:=
hex
.
DecodeString
(
v
)
acc
.
SetState
(
common
.
BytesToHash
(
key
),
common
.
BytesToHash
(
value
))
}
set
:=
acc
.
GetDataKV
()
set
=
append
(
set
,
acc
.
GetStateKV
()
...
)
for
i
:=
0
;
i
<
len
(
set
);
i
++
{
mdb
.
Set
(
set
[
i
]
.
GetKey
(),
set
[
i
]
.
Value
)
}
}
func
buildStateDB
(
addr
string
,
balance
int64
)
*
db
.
GoMemDB
{
// 替换statedb中的数据库,获取测试需要的数据
mdb
,
_
:=
db
.
NewGoMemDB
(
"test"
,
""
,
0
)
// 将调用者账户设置进去,并给予金额,方便发起合约调用
ac
:=
&
types
.
Account
{
Addr
:
addr
,
Balance
:
balance
}
addAccount
(
mdb
,
""
,
ac
)
return
mdb
}
func
createContract
(
mdb
*
db
.
GoMemDB
,
tx
types
.
Transaction
,
maxCodeSize
int
)
(
ret
[]
byte
,
contractAddr
common
.
Address
,
leftOverGas
uint64
,
statedb
*
state
.
MemoryStateDB
,
err
error
)
{
inst
:=
evm
.
NewEVMExecutor
()
q
:=
queue
.
New
(
"channel"
)
q
.
SetConfig
(
chainTestCfg
)
api
,
_
:=
client
.
New
(
q
.
Client
(),
nil
)
inst
.
SetAPI
(
api
)
inst
.
CheckInit
()
msg
,
_
:=
inst
.
GetMessage
(
&
tx
,
0
)
inst
.
SetEnv
(
10
,
0
,
uint64
(
10
))
statedb
=
inst
.
GetMStateDB
()
statedb
.
StateDB
=
mdb
statedb
.
CoinsAccount
=
account
.
NewCoinsAccount
(
chainTestCfg
)
statedb
.
CoinsAccount
.
SetDB
(
statedb
.
StateDB
)
vmcfg
:=
inst
.
GetVMConfig
()
context
:=
inst
.
NewEVMContext
(
msg
)
// 创建EVM运行时对象
env
:=
runtime
.
NewEVM
(
context
,
statedb
,
*
vmcfg
,
q
.
GetConfig
())
if
maxCodeSize
!=
0
{
env
.
SetMaxCodeSize
(
maxCodeSize
)
}
addr
:=
*
crypto2
.
RandomContractAddress
()
ret
,
_
,
leftGas
,
err
:=
env
.
Create
(
runtime
.
AccountRef
(
msg
.
From
()),
addr
,
msg
.
Data
(),
msg
.
GasLimit
(),
fmt
.
Sprintf
(
"%s%s"
,
evmtypes
.
EvmPrefix
,
common
.
BytesToHash
(
tx
.
Hash
())
.
Hex
()),
""
,
""
)
return
ret
,
addr
,
leftGas
,
statedb
,
err
}
plugin/dapp/evm/executor/vm/runtime/interpreter.go
View file @
5817fe0e
...
@@ -199,14 +199,10 @@ func (in *Interpreter) Run(contract *Contract, input []byte, readOnly bool) (ret
...
@@ -199,14 +199,10 @@ func (in *Interpreter) Run(contract *Contract, input []byte, readOnly bool) (ret
var
dynamicCost
uint64
var
dynamicCost
uint64
dynamicCost
,
err
=
operation
.
dynamicGas
(
in
.
evm
,
contract
,
stack
,
mem
,
memorySize
)
dynamicCost
,
err
=
operation
.
dynamicGas
(
in
.
evm
,
contract
,
stack
,
mem
,
memorySize
)
cost
+=
dynamicCost
// total cost, for debug tracing
cost
+=
dynamicCost
// total cost, for debug tracing
log15
.
Info
(
"(in *Interpreter) Run"
,
"op="
,
op
.
String
(),
"contract.Gas"
,
contract
.
Gas
,
"dynamicCost"
,
dynamicCost
,
"err"
,
err
)
if
err
!=
nil
||
!
contract
.
UseGas
(
dynamicCost
)
{
if
err
!=
nil
||
!
contract
.
UseGas
(
dynamicCost
)
{
log15
.
Error
(
"Run:outOfGas"
,
"op="
,
op
.
String
(),
"contract addr="
,
contract
.
self
.
Address
()
.
String
(),
log15
.
Error
(
"Run:outOfGas"
,
"op="
,
op
.
String
(),
"contract addr="
,
contract
.
self
.
Address
()
.
String
(),
"CallerAddress="
,
contract
.
CallerAddress
.
String
(),
"CallerAddress="
,
contract
.
CallerAddress
.
String
(),
"caller="
,
contract
.
caller
.
Address
()
.
String
())
"caller="
,
contract
.
caller
.
Address
()
.
String
())
panic
(
"Run:outOfGas:__line__:207"
)
return
nil
,
ErrOutOfGas
return
nil
,
ErrOutOfGas
}
}
}
}
...
...
plugin/dapp/evm/types/evm.go
View file @
5817fe0e
...
@@ -5,15 +5,11 @@
...
@@ -5,15 +5,11 @@
package
types
package
types
import
(
import
(
"encoding/json"
"errors"
"strings"
"strings"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
log
"github.com/33cn/chain33/common/log/log15"
log
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/golang/protobuf/proto"
)
)
var
(
var
(
...
@@ -110,95 +106,7 @@ func (evm EvmType) Amount(tx *types.Transaction) (int64, error) {
...
@@ -110,95 +106,7 @@ func (evm EvmType) Amount(tx *types.Transaction) (int64, error) {
return
0
,
nil
return
0
,
nil
}
}
// CreateTx 创建交易对象
func
(
evm
EvmType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
elog
.
Debug
(
"evm.CreateTx"
,
"action"
,
action
)
if
action
==
"CreateCall"
{
var
param
CreateCallTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
elog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
createEvmTx
(
evm
.
GetConfig
(),
&
param
)
}
return
nil
,
types
.
ErrNotSupport
}
// GetLogMap 获取日志类型映射
// GetLogMap 获取日志类型映射
func
(
evm
*
EvmType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
evm
*
EvmType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
logInfo
return
logInfo
}
}
func
createEvmTx
(
cfg
*
types
.
Chain33Config
,
param
*
CreateCallTx
)
(
*
types
.
Transaction
,
error
)
{
if
param
==
nil
{
elog
.
Error
(
"createEvmTx"
,
"param"
,
param
)
return
nil
,
types
.
ErrInvalidParam
}
// 调用格式判断规则:
// 十六进制格式默认使用原方式调用,其它格式,使用ABI方式调用
// 为了方便区分,在ABI格式前加0x00000000
action
:=
&
EVMContractAction
{
Amount
:
param
.
Amount
,
GasLimit
:
param
.
GasLimit
,
GasPrice
:
param
.
GasPrice
,
Note
:
param
.
Note
,
Alias
:
param
.
Alias
,
}
if
len
(
param
.
Code
)
>
0
{
bCode
,
err
:=
common
.
FromHex
(
param
.
Code
)
if
err
!=
nil
{
elog
.
Error
(
"create evm Tx error, code is invalid"
,
"param.Code"
,
param
.
Code
)
return
nil
,
err
}
action
.
Code
=
bCode
}
if
len
(
param
.
Para
)
>
0
{
para
,
err
:=
common
.
FromHex
(
param
.
Para
)
if
err
!=
nil
{
elog
.
Error
(
"create evm Tx error, code is invalid"
,
"param.Code"
,
param
.
Code
)
return
nil
,
err
}
action
.
Para
=
para
}
if
param
.
IsCreate
{
if
len
(
action
.
Code
)
==
0
{
elog
.
Error
(
"create evm Tx error, code is empty"
)
return
nil
,
errors
.
New
(
"code must be set in create tx"
)
}
return
createRawTx
(
cfg
,
action
,
""
,
param
.
Fee
)
}
return
createRawTx
(
cfg
,
action
,
param
.
Name
,
param
.
Fee
)
}
func
createRawTx
(
cfg
*
types
.
Chain33Config
,
action
proto
.
Message
,
name
string
,
fee
int64
)
(
*
types
.
Transaction
,
error
)
{
tx
:=
&
types
.
Transaction
{}
if
len
(
name
)
==
0
{
tx
=
&
types
.
Transaction
{
Execer
:
[]
byte
(
cfg
.
ExecName
(
ExecutorName
)),
Payload
:
types
.
Encode
(
action
),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
ExecutorName
)),
}
}
else
{
tx
=
&
types
.
Transaction
{
Execer
:
[]
byte
(
cfg
.
ExecName
(
name
)),
Payload
:
types
.
Encode
(
action
),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
name
)),
}
}
tx
,
err
:=
types
.
FormatTx
(
cfg
,
string
(
tx
.
Execer
),
tx
)
if
err
!=
nil
{
return
nil
,
err
}
if
tx
.
Fee
<
fee
{
tx
.
Fee
=
fee
}
return
tx
,
nil
}
plugin/dapp/evm/types/evm_test.go
deleted
100644 → 0
View file @
f84b1429
package
types
import
(
"encoding/hex"
"encoding/json"
"testing"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
)
// TestEvmType_CreateTx 测试RPC创建交易逻辑
func
TestEvmType_CreateTx
(
t
*
testing
.
T
)
{
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
evm
:=
&
EvmType
{}
evm
.
SetConfig
(
cfg
)
errMap
:=
map
[
int
]
string
{
2
:
"code must be set in create tx"
,
4
:
"encoding/hex: invalid byte: U+0078 'x'"
}
for
idx
,
test
:=
range
[]
CreateCallTx
{
{
Code
:
"abddee"
,
Abi
:
"[{}]"
,
IsCreate
:
true
,
Name
:
"user.evm.xxx"
,
Note
:
"test"
,
Alias
:
"mycon"
,
Fee
:
5000000
,
Amount
:
100000000
,
},
{
Code
:
"abddee"
,
Abi
:
""
,
IsCreate
:
true
,
Name
:
"user.evm.xxx"
,
Note
:
"test"
,
Alias
:
"mycon"
,
Fee
:
5000000
,
Amount
:
100000000
,
},
{
Code
:
""
,
Abi
:
"[{}]"
,
IsCreate
:
true
,
Name
:
"user.evm.xxx"
,
Note
:
"test"
,
Alias
:
"mycon"
,
Fee
:
5000000
,
Amount
:
100000000
,
},
{
Code
:
"abccdd"
,
Abi
:
"[{}]"
,
IsCreate
:
false
,
Name
:
"user.evm.xxx"
,
Note
:
"test"
,
Alias
:
"mycon"
,
Fee
:
0
,
Amount
:
100000000
,
},
{
Code
:
"xyz"
,
Abi
:
"[{}]"
,
IsCreate
:
true
,
Name
:
"user.evm.xxx"
,
Note
:
"test"
,
Alias
:
"mycon"
,
Fee
:
5000000
,
Amount
:
100000000
,
},
}
{
data
,
err
:=
json
.
Marshal
(
&
test
)
assert
.
NoError
(
t
,
err
)
tx
,
err
:=
evm
.
CreateTx
(
"CreateCall"
,
data
)
if
er
,
ok
:=
errMap
[
idx
];
ok
{
assert
.
EqualError
(
t
,
err
,
er
)
continue
}
else
{
assert
.
NoError
(
t
,
err
)
}
var
action
EVMContractAction
types
.
Decode
(
tx
.
Payload
,
&
action
)
assert
.
EqualValues
(
t
,
test
.
Amount
,
action
.
Amount
)
assert
.
EqualValues
(
t
,
test
.
Abi
,
action
.
Abi
)
assert
.
EqualValues
(
t
,
test
.
Alias
,
action
.
Alias
)
assert
.
EqualValues
(
t
,
test
.
Note
,
action
.
Note
)
if
tx
.
Fee
<
test
.
Fee
{
assert
.
Fail
(
t
,
"tx fee low"
)
}
if
len
(
test
.
Code
)
>
0
{
bcode
,
err
:=
hex
.
DecodeString
(
test
.
Code
)
assert
.
NoError
(
t
,
err
)
assert
.
EqualValues
(
t
,
bcode
,
action
.
Code
)
}
if
test
.
IsCreate
{
assert
.
EqualValues
(
t
,
address
.
ExecAddress
(
cfg
.
ExecName
(
ExecutorName
)),
tx
.
To
)
}
else
{
assert
.
EqualValues
(
t
,
address
.
ExecAddress
(
cfg
.
ExecName
(
test
.
Name
)),
tx
.
To
)
}
}
}
plugin/dapp/evm/types/tx.go
deleted
100644 → 0
View file @
f84b1429
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
types
// CreateCallTx 创建或调用合约交易结构
type
CreateCallTx
struct
{
// Amount 金额
Amount
uint64
`json:"amount"`
// Code 合约代码
Code
string
`json:"code"`
// GasLimit gas限制
GasLimit
uint64
`json:"gasLimit"`
// GasPrice gas定价
GasPrice
uint32
`json:"gasPrice"`
// Note 备注
Note
string
`json:"note"`
// Alias 合约别名
Alias
string
`json:"alias"`
// Fee 交易手续费
Fee
int64
`json:"fee"`
// Name 交易名称
Name
string
`json:"name"`
// IsCreate 是否创建合约
IsCreate
bool
`json:"isCreate"`
// 调用参数
Para
string
`json:"para"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment