Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
582bb057
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
582bb057
编写于
2月 09, 2018
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update for bios
上级
5f4a7e35
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
23 deletion
+96
-23
tests/eosiod_run_test.py
tests/eosiod_run_test.py
+18
-10
tests/testUtils.py
tests/testUtils.py
+78
-13
未找到文件。
tests/eosiod_run_test.py
浏览文件 @
582bb057
...
...
@@ -2,6 +2,7 @@
import
testUtils
import
decimal
import
argparse
import
random
import
re
...
...
@@ -222,8 +223,11 @@ try:
if
node
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
Print
(
"Create initial accounts"
)
node
.
createInitAccounts
()
Print
(
"Create new account %s via %s"
%
(
testeraAccount
.
name
,
initaAccount
.
name
))
transId
=
node
.
createAccount
(
testeraAccount
,
initaAccount
,
waitForTransBlock
=
True
)
transId
=
node
.
createAccount
(
testeraAccount
,
initaAccount
,
stakedDeposit
=
0
,
waitForTransBlock
=
True
)
if
transId
is
None
:
cmdError
(
"%s create account"
%
(
ClientName
))
errorExit
(
"Failed to create account %s"
%
(
testeraAccount
.
name
))
...
...
@@ -293,7 +297,7 @@ try:
transferAmount
,
initaAccount
.
name
,
testeraAccount
.
name
))
transId
=
testUtils
.
Node
.
getTransId
(
trans
)
expectedAmount
=
975311
expectedAmount
=
975311
+
5000
# 5000 initial deposit
Print
(
"Verify transfer, Expected: %d"
%
(
expectedAmount
))
actualAmount
=
node
.
getAccountBalance
(
currencyAccount
.
name
)
if
actualAmount
is
None
:
...
...
@@ -363,9 +367,11 @@ try:
typeVal
=
None
amountVal
=
None
if
amINoon
:
debug
and
Print
(
"Transaction:"
,
transaction
)
if
not
enableMongo
:
typeVal
=
transaction
[
"transaction"
][
"actions"
][
1
][
"name"
]
amountVal
=
transaction
[
"transaction"
][
"actions"
][
1
][
"data"
][
"amount"
]
typeVal
=
transaction
[
"transaction"
][
"data"
][
"actions"
][
0
][
"name"
]
amountVal
=
transaction
[
"transaction"
][
"data"
][
"actions"
][
0
][
"data"
][
"quantity"
]
amountVal
=
int
(
decimal
.
Decimal
(
amountVal
.
split
()[
0
])
*
10000
)
else
:
typeVal
=
transaction
[
"name"
]
amountVal
=
transaction
[
"data"
][
"amount"
]
...
...
@@ -378,7 +384,7 @@ try:
amountVal
=
transaction
[
"data"
][
"amount"
]
if
typeVal
!=
"transfer"
or
amountVal
!=
975311
:
errorExit
(
"FAILURE - get transaction trans_id failed: %s
"
%
(
transId
),
raw
=
True
)
errorExit
(
"FAILURE - get transaction trans_id failed: %s
%s %s"
%
(
transId
,
typeVal
,
amountVal
),
raw
=
True
)
Print
(
"Get transactions for account %s"
%
(
testeraAccount
.
name
))
actualTransactions
=
node
.
getTransactionsArrByAccount
(
testeraAccount
.
name
)
...
...
@@ -512,11 +518,13 @@ try:
else
:
Print
(
"Test successful, %s returned error code: %d"
%
(
ClientName
,
retMap
[
"returncode"
]))
Print
(
"Producer tests"
)
trans
=
node
.
createProducer
(
testeraAccount
.
name
,
testeraAccount
.
ownerPublicKey
,
waitForTransBlock
=
False
)
if
trans
is
None
:
cmdError
(
"%s create producer"
%
(
ClientName
))
errorExit
(
"Failed to create producer %s"
%
(
testeraAccount
.
name
))
# TODO Currently unable to set producer
if
not
amINoon
:
Print
(
"Producer tests"
)
trans
=
node
.
createProducer
(
testeraAccount
.
name
,
testeraAccount
.
ownerPublicKey
,
waitForTransBlock
=
False
)
if
trans
is
None
:
cmdError
(
"%s create producer"
%
(
ClientName
))
errorExit
(
"Failed to create producer %s"
%
(
testeraAccount
.
name
))
Print
(
"set permission"
)
code
=
"currency"
...
...
tests/testUtils.py
浏览文件 @
582bb057
import
copy
import
decimal
import
subprocess
import
time
import
glob
...
...
@@ -149,6 +151,12 @@ class Node(object):
jsonData
=
json
.
loads
(
jStr
)
return
jsonData
@
staticmethod
def
runCmdReturnStr
(
cmd
,
trace
=
False
):
retStr
=
Node
.
__checkOutput
(
cmd
.
split
())
trace
and
Utils
.
Print
(
"RAW > %s"
%
retStr
)
return
retStr
@
staticmethod
def
filterJsonObject
(
data
):
firstIdx
=
data
.
find
(
'{'
)
...
...
@@ -387,13 +395,46 @@ class Node(object):
else
:
return
False
def
createInitAccounts
(
self
):
eosio
=
copy
.
copy
(
Cluster
.
initaAccount
)
eosio
.
name
=
"eosio"
# publish system contract
wastFile
=
"contracts/eosio.system/eosio.system.wast"
abiFile
=
"contracts/eosio.system/eosio.system.abi"
Utils
.
Print
(
"Publish eosio.system contract"
)
trans
=
self
.
publishContract
(
eosio
.
name
,
wastFile
,
abiFile
,
waitForTransBlock
=
True
)
if
trans
is
None
:
errorExit
(
"Failed to publish oesio.system."
)
Utils
.
Print
(
"push issue action to eosio contract"
)
contract
=
eosio
.
name
action
=
"issue"
data
=
"{
\"
to
\"
:
\"
eosio
\"
,
\"
quantity
\"
:
\"
1000000000.0000 EOS
\"
}"
opts
=
"--permission eosio@active"
trans
=
self
.
pushMessage
(
contract
,
action
,
data
,
opts
)
transId
=
Node
.
getTransId
(
trans
)
self
.
waitForTransIdOnNode
(
transId
)
initx
=
copy
.
copy
(
Cluster
.
initaAccount
)
self
.
createAccount
(
Cluster
.
initaAccount
,
eosio
,
0
)
for
i
in
range
(
2
,
21
):
initx
.
name
=
"init"
+
chr
(
ord
(
'a'
)
+
i
)
self
.
createAccount
(
initx
,
eosio
,
0
)
self
.
createAccount
(
Cluster
.
initbAccount
,
eosio
,
0
,
True
)
for
i
in
range
(
0
,
21
):
initx
.
name
=
"init"
+
chr
(
ord
(
'a'
)
+
i
)
trans
=
self
.
transferFunds
(
eosio
,
initx
,
10000000000
,
"init"
)
transId
=
Node
.
getTransId
(
trans
)
self
.
waitForTransIdOnNode
(
transId
)
# Create account and return creation transactions. Return transaction json object
# waitForTransBlock: wait on creation transaction id to appear in a block
def
createAccount
(
self
,
account
,
creatorAccount
,
stakedDeposit
=
1000
,
waitForTransBlock
=
False
):
cmd
=
None
if
Utils
.
amINoon
:
cmd
=
"%s %s create account
--staked-deposit %d
%s %s %s %s"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
stakedDeposit
,
creatorAccount
.
name
,
account
.
name
,
cmd
=
"%s %s create account %s %s %s %s"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
creatorAccount
.
name
,
account
.
name
,
account
.
ownerPublicKey
,
account
.
activePublicKey
)
else
:
cmd
=
"%s %s create account %s %s %s %s"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
...
...
@@ -410,6 +451,13 @@ class Node(object):
Utils
.
Print
(
"ERROR: Exception during account creation. %s"
%
(
msg
))
return
None
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
return
None
if
stakedDeposit
>
0
:
trans
=
self
.
transferFunds
(
creatorAccount
,
account
,
stakedDeposit
,
"init"
)
transId
=
Node
.
getTransId
(
trans
)
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
return
None
return
trans
...
...
@@ -438,13 +486,24 @@ class Node(object):
return
None
def
getEosCurrencyBalance
(
self
,
name
):
cmd
=
"%s %s get currency balance eosio %s EOS"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
name
)
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
try
:
trans
=
Node
.
runCmdReturnStr
(
cmd
)
return
trans
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during get currency balance. %s"
%
(
msg
))
return
None
# Verifies account. Returns "get account" json return object
def
verifyAccount
(
self
,
account
):
if
not
self
.
enableMongo
:
ret
=
self
.
getEosAccount
(
account
.
name
)
if
ret
is
not
None
:
stakedBalance
=
ret
[
"staked_balanc
e"
]
if
stakedBalanc
e
is
None
:
account_name
=
ret
[
"account_nam
e"
]
if
account_nam
e
is
None
:
Utils
.
Print
(
"ERROR: Failed to verify account creation."
,
account
.
name
)
return
None
return
ret
...
...
@@ -452,8 +511,8 @@ class Node(object):
for
i
in
range
(
2
):
ret
=
self
.
getEosAccountFromDb
(
account
.
name
)
if
ret
is
not
None
:
stakedBalance
=
ret
[
"staked_balanc
e"
]
if
stakedBalanc
e
is
None
:
account_name
=
ret
[
"account_nam
e"
]
if
account_nam
e
is
None
:
Utils
.
Print
(
"ERROR: Failed to verify account creation."
,
account
.
name
)
return
None
return
ret
...
...
@@ -506,7 +565,7 @@ class Node(object):
# Trasfer funds. Returns "transfer" json return object
def
transferFunds
(
self
,
source
,
destination
,
amount
,
memo
=
"memo"
,
force
=
False
):
cmd
=
"%s %s transfer %s %s %d"
%
(
cmd
=
"%s %s
-v
transfer %s %s %d"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
source
.
name
,
destination
.
name
,
amount
)
cmdArr
=
cmd
.
split
()
cmdArr
.
append
(
memo
)
...
...
@@ -581,10 +640,10 @@ class Node(object):
def
getAccountBalance
(
self
,
name
):
if
not
self
.
enableMongo
:
a
ccount
=
self
.
getEosAccount
(
name
)
field
=
account
[
"eos_balance"
]
balanceStr
=
field
.
split
()[
0
]
balance
=
int
(
float
(
balanceStr
)
*
10000
)
a
mount
=
self
.
getEosCurrencyBalance
(
name
)
Utils
.
Debug
and
Utils
.
Print
(
"getEosCurrencyBalance"
,
name
,
amount
)
balanceStr
=
amount
.
split
()[
0
]
balance
=
int
(
decimal
.
Decimal
(
balanceStr
[
1
:]
)
*
10000
)
return
balance
else
:
if
self
.
mongoSyncTime
is
not
None
:
...
...
@@ -644,7 +703,7 @@ class Node(object):
# publish contract and return transaction as json object
def
publishContract
(
self
,
account
,
wastFile
,
abiFile
,
waitForTransBlock
=
False
,
shouldFail
=
False
):
cmd
=
"%s %s set contract %s %s %s"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
account
,
wastFile
,
abiFile
)
cmd
=
"%s %s
-v
set contract %s %s %s"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
account
,
wastFile
,
abiFile
)
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
trans
=
None
try
:
...
...
@@ -673,7 +732,7 @@ class Node(object):
return
None
return
trans
# create producer and ret
ru
n transaction as json object
# create producer and ret
ur
n transaction as json object
def
createProducer
(
self
,
account
,
ownerPublicKey
,
waitForTransBlock
=
False
):
cmd
=
"%s %s create producer %s %s"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
account
,
ownerPublicKey
)
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
...
...
@@ -988,8 +1047,14 @@ class Cluster(object):
# init accounts
initaAccount
=
Account
(
"inita"
)
initaAccount
.
ownerPrivateKey
=
"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
;
initaAccount
.
ownerPublicKey
=
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
;
initaAccount
.
activePrivateKey
=
"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
;
initaAccount
.
activePublicKey
=
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
;
initbAccount
=
Account
(
"initb"
)
initbAccount
.
ownerPrivateKey
=
"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
;
initbAccount
.
ownerPublicKey
=
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
;
initbAccount
.
activePrivateKey
=
"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
;
initbAccount
.
activePublicKey
=
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
;
# walletd [True|False] Is walletd running. If not load the wallet plugin
def
__init__
(
self
,
walletd
=
False
,
localCluster
=
True
,
host
=
"localhost"
,
port
=
8888
,
walletHost
=
"localhost"
,
walletPort
=
8899
,
enableMongo
=
False
,
mongoHost
=
"localhost"
,
mongoPort
=
27017
,
mongoDb
=
"EOStest"
,
initaPrvtKey
=
initaAccount
.
ownerPrivateKey
,
initbPrvtKey
=
initbAccount
.
ownerPrivateKey
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录