Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
97b8b24c
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,发现更多精彩内容 >>
提交
97b8b24c
编写于
1月 09, 2018
作者:
C
Ciju John
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for contracts publication and sending messages.
上级
0aad7186
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
210 addition
and
40 deletion
+210
-40
tests/eosd_run_test.py
tests/eosd_run_test.py
+81
-10
tests/testUtils.py
tests/testUtils.py
+129
-30
未找到文件。
tests/eosd_run_test.py
浏览文件 @
97b8b24c
...
@@ -338,17 +338,88 @@ try:
...
@@ -338,17 +338,88 @@ try:
if
codeHash
is
None
:
if
codeHash
is
None
:
cmdError
(
"eosc get code currency"
)
cmdError
(
"eosc get code currency"
)
errorExit
(
"Failed to get code hash for account %s"
%
(
currencyAccount
.
name
))
errorExit
(
"Failed to get code hash for account %s"
%
(
currencyAccount
.
name
))
nonZero
=
codeHash
.
replace
(
'0'
,
''
)
hashNum
=
int
(
codeHash
,
16
)
if
nonZero
!=
""
:
if
hashNum
!=
0
:
errorExit
(
"FAILURE - get transactions testera failed"
,
raw
=
True
)
errorExit
(
"FAILURE - get code currency failed"
,
raw
=
True
)
wastFile
=
"contracts/currency/currency.wast"
abiFile
=
"contracts/currency/currency.abi"
Print
(
"Publish contract"
)
trans
=
node
.
publishContract
(
currencyAccount
.
name
,
wastFile
,
abiFile
,
waitForTransBlock
=
True
)
if
trans
is
None
:
cmdError
(
"eosc set contract currency"
)
errorExit
(
"Failed to publish contract."
)
# wastFile="contracts/currency/currency.wast"
Print
(
"Get code hash for account %s"
%
(
currencyAccount
.
name
))
# abiFile="contracts/currency/currency.abi"
codeHash
=
node
.
getAccountCodeHash
(
currencyAccount
.
name
)
# Print("Publish contract")
if
codeHash
is
None
:
# transId=node.publishContract(currencyAccount.name, wastFile, abiFile, waitForTransBlock=True)
cmdError
(
"eosc get code currency"
)
# if transId is None:
errorExit
(
"Failed to get code hash for account %s"
%
(
currencyAccount
.
name
))
# cmdError("eosc set contract currency")
hashNum
=
int
(
codeHash
,
16
)
# errorExit("Failed to publish contract.")
if
hashNum
==
0
:
errorExit
(
"FAILURE - get code currency failed"
,
raw
=
True
)
Print
(
"Verify currency contract has proper initial balance"
)
contract
=
"currency"
table
=
"account"
row0
=
node
.
getTableRow
(
currencyAccount
.
name
,
contract
,
table
,
0
)
if
row0
is
None
:
cmdError
(
"eosc get table currency account"
)
errorExit
(
"Failed to retrieve contract %s table %s"
%
(
contract
,
table
))
balanceKey
=
"balance"
keyKey
=
"key"
if
row0
[
balanceKey
]
!=
1000000000
or
row0
[
keyKey
]
!=
"account"
:
errorExit
(
"FAILURE - get table currency account failed"
,
raw
=
True
)
Print
(
"push message to currency contract"
)
contract
=
"currency"
action
=
"transfer"
data
=
"{
\"
from
\"
:
\"
currency
\"
,
\"
to
\"
:
\"
inita
\"
,
\"
quantity
\"
:50}"
opts
=
"--scope currency,inita --permission currency@active"
trans
=
node
.
pushMessage
(
contract
,
action
,
data
,
opts
)
if
trans
is
None
:
cmdError
(
"eosc push message currency transfer"
)
errorExit
(
"Failed to push message to currency contract"
)
transId
=
testUtils
.
Node
.
getTransId
(
trans
)
Print
(
"verify transaction exists"
)
if
not
node
.
waitForTransIdOnNode
(
transId
):
cmdError
(
"eosc get transaction trans_id"
)
errorExit
(
"Failed to verify push message transaction id."
)
Print
(
"read current contract balance"
)
contract
=
"currency"
table
=
"account"
row0
=
node
.
getTableRow
(
initaAccount
.
name
,
contract
,
table
,
0
)
if
row0
is
None
:
cmdError
(
"eosc get table currency account"
)
errorExit
(
"Failed to retrieve contract %s table %s"
%
(
contract
,
table
))
balanceKey
=
"balance"
keyKey
=
"key"
if
row0
[
balanceKey
]
!=
50
:
errorExit
(
"FAILURE - get table currency account failed"
,
raw
=
True
)
row0
=
node
.
getTableRow
(
currencyAccount
.
name
,
contract
,
table
,
0
)
if
row0
is
None
:
cmdError
(
"eosc get table currency account"
)
errorExit
(
"Failed to retrieve contract %s table %s"
%
(
contract
,
table
))
if
row0
[
balanceKey
]
!=
999999950
:
errorExit
(
"FAILURE - get table currency account failed"
,
raw
=
True
)
Print
(
"Exchange Contract Tests"
)
Print
(
"upload exchange contract"
)
wastFile
=
"contracts/exchange/exchange.wast"
abiFile
=
"contracts/exchange/exchange.abi"
Print
(
"Publish contract"
)
trans
=
node
.
publishContract
(
exchangeAccount
.
name
,
wastFile
,
abiFile
,
waitForTransBlock
=
True
)
if
trans
is
None
:
cmdError
(
"eosc set contract exchange"
)
errorExit
(
"Failed to publish contract."
)
testSuccessful
=
True
testSuccessful
=
True
Print
(
"END"
)
Print
(
"END"
)
...
...
tests/testUtils.py
浏览文件 @
97b8b24c
...
@@ -14,6 +14,7 @@ import inspect
...
@@ -14,6 +14,7 @@ import inspect
import
sys
import
sys
import
random
import
random
import
io
import
io
import
json
###########################################################################################
###########################################################################################
class
Utils
:
class
Utils
:
...
@@ -51,6 +52,13 @@ class Utils:
...
@@ -51,6 +52,13 @@ class Utils:
return
chainSyncStrategies
return
chainSyncStrategies
###########################################################################################
class
Table
(
object
):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
keys
=
[]
self
.
data
=
[]
###########################################################################################
###########################################################################################
class
Transaction
(
object
):
class
Transaction
(
object
):
def
__init__
(
self
,
transId
):
def
__init__
(
self
,
transId
):
...
@@ -135,7 +143,7 @@ class Node(object):
...
@@ -135,7 +143,7 @@ class Node(object):
transId
=
m
.
group
(
1
)
transId
=
m
.
group
(
1
)
# Utils.Print("Transaction num: %s" % (transId))
# Utils.Print("Transaction num: %s" % (transId))
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during account creation. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during account creation. %s"
%
(
msg
))
return
None
return
None
...
@@ -155,7 +163,7 @@ class Node(object):
...
@@ -155,7 +163,7 @@ class Node(object):
if
m
is
None
:
if
m
is
None
:
Utils
.
Print
(
"ERROR: Failed to verify account creation."
,
account
.
name
)
Utils
.
Print
(
"ERROR: Failed to verify account creation."
,
account
.
name
)
return
False
return
False
except
Exception
as
es
:
except
subprocess
.
CalledProcessError
as
es
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during account verification. %s"
,
msg
)
Utils
.
Print
(
"ERROR: Exception during account verification. %s"
,
msg
)
return
False
return
False
...
@@ -201,7 +209,7 @@ class Node(object):
...
@@ -201,7 +209,7 @@ class Node(object):
s
=
m
.
group
(
1
)
s
=
m
.
group
(
1
)
num
=
int
(
s
)
num
=
int
(
s
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during block number retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during block number retrieval. %s"
%
(
msg
))
return
-
1
return
-
1
...
@@ -247,7 +255,7 @@ class Node(object):
...
@@ -247,7 +255,7 @@ class Node(object):
transId
=
m
.
group
(
1
)
transId
=
m
.
group
(
1
)
#MyPrint("Transaction block num: %s" % (blockNum))
#MyPrint("Transaction block num: %s" % (blockNum))
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during funds transfer. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during funds transfer. %s"
%
(
msg
))
return
None
return
None
...
@@ -291,7 +299,7 @@ class Node(object):
...
@@ -291,7 +299,7 @@ class Node(object):
raise
Exception
(
msg
)
raise
Exception
(
msg
)
return
m
return
m
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during accounts by key retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during accounts by key retrieval. %s"
%
(
msg
))
raise
raise
...
@@ -310,7 +318,7 @@ class Node(object):
...
@@ -310,7 +318,7 @@ class Node(object):
raise
Exception
(
msg
)
raise
Exception
(
msg
)
return
m
return
m
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during servants retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during servants retrieval. %s"
%
(
msg
))
raise
raise
...
@@ -335,7 +343,7 @@ class Node(object):
...
@@ -335,7 +343,7 @@ class Node(object):
account
.
balance
=
int
(
balance
)
account
.
balance
=
int
(
balance
)
return
account
return
account
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during account by name retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during account by name retrieval. %s"
%
(
msg
))
raise
raise
...
@@ -375,7 +383,7 @@ class Node(object):
...
@@ -375,7 +383,7 @@ class Node(object):
transaction
.
amount
=
amount
transaction
.
amount
=
amount
return
transaction
return
transaction
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during account by transaction retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during account by transaction retrieval. %s"
%
(
msg
))
raise
raise
...
@@ -399,7 +407,7 @@ class Node(object):
...
@@ -399,7 +407,7 @@ class Node(object):
transaction
=
Transaction
(
id
)
transaction
=
Transaction
(
id
)
transactions
.
append
(
transaction
)
transactions
.
append
(
transaction
)
return
transactions
return
transactions
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during transactions by account retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during transactions by account retrieval. %s"
%
(
msg
))
raise
raise
...
@@ -409,7 +417,7 @@ class Node(object):
...
@@ -409,7 +417,7 @@ class Node(object):
cmd
=
"programs/eosc/eosc %s get code %s"
%
(
self
.
endpointArgs
,
account
)
cmd
=
"programs/eosc/eosc %s get code %s"
%
(
self
.
endpointArgs
,
account
)
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
retStr
=
subprocess
.
check_output
(
cmd
.
split
()).
decode
(
"utf-8"
)
retStr
=
subprocess
.
check_output
(
cmd
.
split
()).
decode
(
"utf-8"
)
#Utils.Print ("get
AccountDetails
> %s"% retStr)
#Utils.Print ("get
code
> %s"% retStr)
p
=
re
.
compile
(
'code\shash: (\w+)
\n
'
,
re
.
MULTILINE
)
p
=
re
.
compile
(
'code\shash: (\w+)
\n
'
,
re
.
MULTILINE
)
m
=
p
.
search
(
retStr
)
m
=
p
.
search
(
retStr
)
if
m
is
None
:
if
m
is
None
:
...
@@ -418,33 +426,123 @@ class Node(object):
...
@@ -418,33 +426,123 @@ class Node(object):
raise
Exception
(
msg
)
raise
Exception
(
msg
)
return
m
.
group
(
1
)
return
m
.
group
(
1
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during code hash retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during code hash retrieval. %s"
%
(
msg
))
raise
raise
# def publishContract(self, account, wastFile, abiFile, waitForTransBlock=False):
# transId=None
# p = re.compile('\n\s+\"transaction_id\":\s+\"(\w+)\",\n', re.MULTILINE)
# cmd="programs/eosc/eosc %s set contract %s %s %s" % (self.endpointArgs, account, wastFile, abiFile)
# Utils.Debug and Utils.Print("cmd: %s" % (cmd))
# try:
# retStr=subprocess.check_output(cmd.split()).decode("utf-8")
# #Utils.Print ("getAccountDetails> %s"% retStr)
# m=p.search(retStr)
# if m is None:
# Utils.Print("ERROR: transaction id parser failure")
# return None
# transId=m.group(1)
# except subprocess.CalledProcessError as ex:
# msg=ex.output.decode("utf-8")
# Utils.Print("ERROR: Exception during code hash retrieval. %s" % (msg))
# return None
# if waitForTransBlock and not self.waitForTransIdOnNode(transId):
# return None
# return transId
@
staticmethod
def
filterJsonObject
(
data
):
firstIdx
=
data
.
find
(
'{'
)
lastIdx
=
data
.
rfind
(
'}'
)
retStr
=
data
[
firstIdx
:
lastIdx
+
1
]
return
retStr
def
publishContract
(
self
,
account
,
wastFile
,
abiFile
,
waitForTransBlock
=
False
):
def
publishContract
(
self
,
account
,
wastFile
,
abiFile
,
waitForTransBlock
=
False
):
transId
=
None
p
=
re
.
compile
(
'
\n
\s+
\"
transaction_id
\"
:\s+
\"
(\w+)
\"
,
\n
'
,
re
.
MULTILINE
)
cmd
=
"programs/eosc/eosc %s set contract %s %s %s"
%
(
self
.
endpointArgs
,
account
,
wastFile
,
abiFile
)
cmd
=
"programs/eosc/eosc %s set contract %s %s %s"
%
(
self
.
endpointArgs
,
account
,
wastFile
,
abiFile
)
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
trans
=
None
try
:
try
:
retStr
=
subprocess
.
check_output
(
cmd
.
split
()).
decode
(
"utf-8"
)
retStr
=
Node
.
__checkOutput
(
cmd
.
split
())
Utils
.
Print
(
"getAccountDetails> %s"
%
retStr
)
jStr
=
Node
.
filterJsonObject
(
retStr
)
m
=
p
.
search
(
retStr
)
#Utils.Print ("publishContract> %s"% retStr)
if
m
is
None
:
trans
=
jsonData
=
json
.
loads
(
jStr
)
Utils
.
Print
(
"ERROR: transaction id parser failure"
)
transId
=
Node
.
getTransId
(
jsonData
)
return
None
except
subprocess
.
CalledProcessError
as
ex
:
transId
=
m
.
group
(
1
)
except
Exception
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during code hash retrieval. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during code hash retrieval. %s"
%
(
msg
))
return
None
return
None
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
return
None
return
None
return
transId
return
trans
@
staticmethod
def
__checkOutput
(
cmd
):
#retStr=subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8")
retStr
=
subprocess
.
check_output
(
cmd
).
decode
(
"utf-8"
)
return
retStr
def
getTable
(
self
,
account
,
contract
,
table
):
try
:
cmd
=
"programs/eosc/eosc %s get table %s %s %s"
%
(
self
.
endpointArgs
,
account
,
contract
,
table
)
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
retStr
=
Node
.
__checkOutput
(
cmd
.
split
())
#Utils.Print ("getAccountDetails> %s"% retStr)
jsonData
=
json
.
loads
(
retStr
)
return
jsonData
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during table retrieval. %s"
%
(
msg
))
raise
def
getTableRows
(
self
,
account
,
contract
,
table
):
jsonData
=
self
.
getTable
(
account
,
contract
,
table
)
rows
=
jsonData
[
"rows"
]
return
rows
def
getTableRow
(
self
,
account
,
contract
,
table
,
idx
):
if
idx
<
0
:
Utils
.
Print
(
"ERROR: Table index cannot be negative. idx: %d"
%
(
idx
))
return
None
rows
=
self
.
getTableRows
(
account
,
contract
,
table
)
if
idx
>=
len
(
rows
):
Utils
.
Print
(
"ERROR: Requested table index(%d) larger than table length(%d)."
%
(
idx
,
len
(
rows
)))
return
None
row
=
rows
[
idx
]
return
row
def
getTableColumns
(
self
,
account
,
contract
,
table
):
row
=
self
.
getTableRow
(
account
,
contract
,
table
,
0
)
keys
=
list
(
row
.
keys
())
return
keys
def
pushMessage
(
self
,
contract
,
action
,
data
,
opts
):
try
:
cmd
=
"programs/eosc/eosc %s push message %s %s"
%
(
self
.
endpointArgs
,
contract
,
action
)
cmdArgs
=
cmd
.
split
()
if
data
is
not
None
:
cmdArgs
.
append
(
data
)
if
opts
is
not
None
:
cmdArgs
+=
opts
.
split
()
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmdArgs
))
retStr
=
Node
.
__checkOutput
(
cmdArgs
)
#Utils.Print ("getAccountDetails> %s"% retStr)
jsonData
=
json
.
loads
(
retStr
)
return
jsonData
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during push message. %s"
%
(
msg
))
raise
@
staticmethod
def
getTransId
(
trans
):
transIdKey
=
"transaction_id"
transId
=
trans
[
transIdKey
]
return
transId
###########################################################################################
###########################################################################################
Wallet
=
namedtuple
(
"Wallet"
,
"name password host port"
)
Wallet
=
namedtuple
(
"Wallet"
,
"name password host port"
)
...
@@ -509,7 +607,7 @@ class WalletMgr(object):
...
@@ -509,7 +607,7 @@ class WalletMgr(object):
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
try
:
try
:
retStr
=
subprocess
.
check_output
(
cmd
.
split
(),
stderr
=
subprocess
.
STDOUT
).
decode
(
"utf-8"
)
retStr
=
subprocess
.
check_output
(
cmd
.
split
(),
stderr
=
subprocess
.
STDOUT
).
decode
(
"utf-8"
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
if
warningMsg
in
msg
:
if
warningMsg
in
msg
:
Utils
.
Print
(
"WARNING: This key is already imported into the wallet."
)
Utils
.
Print
(
"WARNING: This key is already imported into the wallet."
)
...
@@ -525,7 +623,7 @@ class WalletMgr(object):
...
@@ -525,7 +623,7 @@ class WalletMgr(object):
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
Utils
.
Debug
and
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
try
:
try
:
retStr
=
subprocess
.
check_output
(
cmd
.
split
(),
stderr
=
subprocess
.
STDOUT
).
decode
(
"utf-8"
)
retStr
=
subprocess
.
check_output
(
cmd
.
split
(),
stderr
=
subprocess
.
STDOUT
).
decode
(
"utf-8"
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
if
warningMsg
in
msg
:
if
warningMsg
in
msg
:
Utils
.
Print
(
"WARNING: This key is already imported into the wallet."
)
Utils
.
Print
(
"WARNING: This key is already imported into the wallet."
)
...
@@ -627,6 +725,7 @@ class WalletMgr(object):
...
@@ -627,6 +725,7 @@ class WalletMgr(object):
shutil
.
copyfileobj
(
Cluster
.
__walletLogFile
,
sys
.
stdout
)
shutil
.
copyfileobj
(
Cluster
.
__walletLogFile
,
sys
.
stdout
)
def
killall
(
self
):
def
killall
(
self
):
#Utils.Print("Wallet pid: %s" % "None" if self.__walletPid is None else str(self.__walletPid))
if
self
.
__walletPid
is
not
None
:
if
self
.
__walletPid
is
not
None
:
os
.
kill
(
self
.
__walletPid
,
signal
.
SIGKILL
)
os
.
kill
(
self
.
__walletPid
,
signal
.
SIGKILL
)
...
@@ -790,7 +889,7 @@ class Cluster(object):
...
@@ -790,7 +889,7 @@ class Cluster(object):
account
.
activePublicKey
=
activePublic
account
.
activePublicKey
=
activePublic
accounts
.
append
(
account
)
accounts
.
append
(
account
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
msg
=
ex
.
output
.
decode
(
"utf-8"
)
msg
=
ex
.
output
.
decode
(
"utf-8"
)
Utils
.
Print
(
"ERROR: Exception during key creation. %s"
%
(
msg
))
Utils
.
Print
(
"ERROR: Exception during key creation. %s"
%
(
msg
))
break
break
...
@@ -1050,7 +1149,7 @@ class Cluster(object):
...
@@ -1050,7 +1149,7 @@ class Cluster(object):
instance
.
setWalletEndpointArgs
(
self
.
walletEndpointArgs
)
instance
.
setWalletEndpointArgs
(
self
.
walletEndpointArgs
)
Utils
.
Debug
and
Utils
.
Print
(
"Node:"
,
instance
)
Utils
.
Debug
and
Utils
.
Print
(
"Node:"
,
instance
)
nodes
.
append
(
instance
)
nodes
.
append
(
instance
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
Utils
.
Print
(
"ERROR: Exception during Nodes creation:"
,
ex
)
Utils
.
Print
(
"ERROR: Exception during Nodes creation:"
,
ex
)
raise
raise
...
@@ -1064,7 +1163,7 @@ class Cluster(object):
...
@@ -1064,7 +1163,7 @@ class Cluster(object):
running
=
True
running
=
True
try
:
try
:
os
.
kill
(
node
.
pid
,
0
)
os
.
kill
(
node
.
pid
,
0
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
running
=
False
running
=
False
if
running
!=
node
.
alive
:
if
running
!=
node
.
alive
:
self
.
nodes
[
i
].
alive
=
running
self
.
nodes
[
i
].
alive
=
running
...
@@ -1081,7 +1180,7 @@ class Cluster(object):
...
@@ -1081,7 +1180,7 @@ class Cluster(object):
for
node
in
reversed
(
self
.
nodes
):
for
node
in
reversed
(
self
.
nodes
):
try
:
try
:
os
.
kill
(
node
.
pid
,
killSignal
)
os
.
kill
(
node
.
pid
,
killSignal
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
Utils
.
Print
(
"ERROR: Failed to kill process pid %d."
%
(
node
.
pid
),
ex
)
Utils
.
Print
(
"ERROR: Failed to kill process pid %d."
%
(
node
.
pid
),
ex
)
return
False
return
False
killedCount
+=
1
killedCount
+=
1
...
@@ -1100,7 +1199,7 @@ class Cluster(object):
...
@@ -1100,7 +1199,7 @@ class Cluster(object):
running
=
True
running
=
True
try
:
try
:
os
.
kill
(
node
.
pid
,
0
)
#check if instance is running
os
.
kill
(
node
.
pid
,
0
)
#check if instance is running
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
running
=
False
running
=
False
if
running
is
False
:
if
running
is
False
:
...
@@ -1136,7 +1235,7 @@ class Cluster(object):
...
@@ -1136,7 +1235,7 @@ class Cluster(object):
for
node
in
self
.
nodes
:
for
node
in
self
.
nodes
:
try
:
try
:
os
.
kill
(
node
.
pid
,
signal
.
SIGKILL
)
os
.
kill
(
node
.
pid
,
signal
.
SIGKILL
)
except
Exception
as
ex
:
except
subprocess
.
CalledProcessError
as
ex
:
pass
pass
def
waitForNextBlock
(
self
,
timeout
=
60
):
def
waitForNextBlock
(
self
,
timeout
=
60
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录