Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
ce5c3c2b
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,发现更多精彩内容 >>
未验证
提交
ce5c3c2b
编写于
7月 25, 2018
作者:
K
Kevin Heifner
提交者:
GitHub
7月 25, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4866 from brianjohnson5972/4864-script-cleanup
Script Cleanup
上级
df36dc89
48caac89
变更
15
展开全部
显示空白变更内容
内联
并排
Showing
15 changed file
with
261 addition
and
412 deletion
+261
-412
tests/Cluster.py
tests/Cluster.py
+12
-12
tests/Node.py
tests/Node.py
+200
-208
tests/WalletMgr.py
tests/WalletMgr.py
+5
-1
tests/consensus-validation-malicious-producers.py
tests/consensus-validation-malicious-producers.py
+3
-13
tests/distributed-transactions-remote-test.py
tests/distributed-transactions-remote-test.py
+1
-4
tests/distributed-transactions-test.py
tests/distributed-transactions-test.py
+1
-4
tests/nodeos_run_remote_test.py
tests/nodeos_run_remote_test.py
+1
-4
tests/nodeos_run_test.py
tests/nodeos_run_test.py
+16
-68
tests/nodeos_under_min_avail_ram.py
tests/nodeos_under_min_avail_ram.py
+6
-33
tests/nodeos_voting_test.py
tests/nodeos_voting_test.py
+6
-34
tests/p2p_network_test.py
tests/p2p_network_test.py
+2
-10
tests/p2p_stress.py
tests/p2p_stress.py
+2
-2
tests/restart-scenarios-test.py
tests/restart-scenarios-test.py
+1
-8
tests/testUtils.py
tests/testUtils.py
+4
-5
tests/validate-dirty-db.py
tests/validate-dirty-db.py
+1
-6
未找到文件。
tests/Cluster.py
浏览文件 @
ce5c3c2b
...
...
@@ -244,7 +244,7 @@ class Cluster(object):
node
.
setWalletEndpointArgs
(
self
.
walletEndpointArgs
)
if
Utils
.
Debug
:
Utils
.
Print
(
"Node: %s"
,
str
(
node
))
node
.
checkPulse
()
node
.
checkPulse
(
exitOnError
=
True
)
self
.
nodes
=
[
node
]
if
defproduceraPrvtKey
is
not
None
:
...
...
@@ -284,7 +284,7 @@ class Cluster(object):
node
.
setWalletEndpointArgs
(
self
.
walletEndpointArgs
)
if
Utils
.
Debug
:
Utils
.
Print
(
"Node:"
,
node
)
node
.
checkPulse
()
node
.
checkPulse
(
exitOnError
=
True
)
nodes
.
append
(
node
)
self
.
nodes
=
nodes
...
...
@@ -313,7 +313,6 @@ class Cluster(object):
for
node
in
nodes
:
try
:
if
(
not
node
.
killed
)
and
(
not
node
.
isBlockPresent
(
targetBlockNum
)):
#if (not node.killed) and (not node.isBlockFinalized(targetBlockNum)):
return
False
except
(
TypeError
)
as
_
:
# This can happen if client connects before server is listening
...
...
@@ -430,7 +429,13 @@ class Cluster(object):
self
.
accounts
=
accounts
return
True
def
getNode
(
self
,
nodeId
=
0
):
def
getNode
(
self
,
nodeId
=
0
,
exitOnError
=
True
):
if
exitOnError
and
nodeId
>=
len
(
self
.
nodes
):
Utils
.
cmdError
(
"cluster never created node %d"
%
(
nodeId
))
errorExit
(
"Failed to retrieve node %d"
%
(
nodeId
))
if
exitOnError
and
self
.
nodes
[
nodeId
]
is
None
:
Utils
.
cmdError
(
"cluster has None value for node %d"
%
(
nodeId
))
errorExit
(
"Failed to retrieve node %d"
%
(
nodeId
))
return
self
.
nodes
[
nodeId
]
def
getNodes
(
self
):
...
...
@@ -455,7 +460,6 @@ class Cluster(object):
Utils
.
Print
(
"Transfer %s units from account %s to %s on eos server port %d"
%
(
transferAmountStr
,
fromm
.
name
,
to
.
name
,
node
.
port
))
trans
=
node
.
transferFunds
(
fromm
,
to
,
transferAmountStr
)
assert
(
trans
)
transId
=
Node
.
getTransId
(
trans
)
if
transId
is
None
:
return
False
...
...
@@ -571,8 +575,7 @@ class Cluster(object):
"""create account, verify account and return transaction id"""
assert
(
len
(
self
.
nodes
)
>
0
)
node
=
self
.
nodes
[
0
]
trans
=
node
.
createInitializeAccount
(
account
,
creator
,
stakedDeposit
,
stakeNet
=
stakeNet
,
stakeCPU
=
stakeCPU
,
buyRAM
=
buyRAM
)
assert
(
trans
)
trans
=
node
.
createInitializeAccount
(
account
,
creator
,
stakedDeposit
,
stakeNet
=
stakeNet
,
stakeCPU
=
stakeCPU
,
buyRAM
=
buyRAM
,
exitOnError
=
True
)
assert
(
node
.
verifyAccount
(
account
))
return
trans
...
...
@@ -589,7 +592,7 @@ class Cluster(object):
# return transId
# return None
def
createInitializeAccount
(
self
,
account
,
creatorAccount
,
stakedDeposit
=
1000
,
waitForTransBlock
=
False
,
stakeNet
=
100
,
stakeCPU
=
100
,
buyRAM
=
100
):
def
createInitializeAccount
(
self
,
account
,
creatorAccount
,
stakedDeposit
=
1000
,
waitForTransBlock
=
False
,
stakeNet
=
100
,
stakeCPU
=
100
,
buyRAM
=
100
,
exitOnError
=
False
):
assert
(
len
(
self
.
nodes
)
>
0
)
node
=
self
.
nodes
[
0
]
trans
=
node
.
createInitializeAccount
(
account
,
creatorAccount
,
stakedDeposit
,
waitForTransBlock
,
stakeNet
=
stakeNet
,
stakeCPU
=
stakeCPU
,
buyRAM
=
buyRAM
)
...
...
@@ -707,9 +710,6 @@ class Cluster(object):
try
:
ignWallet
=
walletMgr
.
create
(
"ignition"
)
if
ignWallet
is
None
:
Utils
.
Print
(
"ERROR: Failed to create ignition wallet."
)
return
False
eosioName
=
"eosio"
eosioKeys
=
producerKeys
[
eosioName
]
...
...
@@ -807,7 +807,7 @@ class Cluster(object):
return
False
# wait for block production handover (essentially a block produced by anyone but eosio).
lam
=
lambda
:
biosNode
.
getInfo
()[
"head_block_producer"
]
!=
"eosio"
lam
=
lambda
:
biosNode
.
getInfo
(
exitOnError
=
True
)[
"head_block_producer"
]
!=
"eosio"
ret
=
Utils
.
waitForBool
(
lam
)
if
not
ret
:
Utils
.
Print
(
"ERROR: Block production handover failed."
)
...
...
tests/Node.py
浏览文件 @
ce5c3c2b
此差异已折叠。
点击以展开。
tests/WalletMgr.py
浏览文件 @
ce5c3c2b
...
...
@@ -47,7 +47,7 @@ class WalletMgr(object):
time
.
sleep
(
1
)
return
True
def
create
(
self
,
name
,
accounts
=
None
):
def
create
(
self
,
name
,
accounts
=
None
,
exitOnError
=
True
):
wallet
=
self
.
wallets
.
get
(
name
)
if
wallet
is
not
None
:
if
Utils
.
Debug
:
Utils
.
Print
(
"Wallet
\"
%s
\"
already exists. Returning same."
%
name
)
...
...
@@ -59,6 +59,10 @@ class WalletMgr(object):
#Utils.Print("create: %s" % (retStr))
m
=
p
.
search
(
retStr
)
if
m
is
None
:
if
exitOnError
:
Utils
.
cmdError
(
"could not create wallet %s"
%
(
name
))
errorExit
(
"Failed to create wallet %s"
%
(
name
))
Utils
.
Print
(
"ERROR: wallet password parser failure"
)
return
None
p
=
m
.
group
(
1
)
...
...
tests/consensus-validation-malicious-producers.py
浏览文件 @
ce5c3c2b
...
...
@@ -21,6 +21,7 @@ import shutil
Print
=
testUtils
.
Utils
.
Print
errorExit
=
Utils
.
errorExit
StagedNodeInfo
=
namedtuple
(
"StagedNodeInfo"
,
"config logging"
)
...
...
@@ -192,11 +193,6 @@ def stageScenario(stagedNodeInfos):
def
cleanStaging
():
os
.
path
.
exists
(
stagingDir
)
and
shutil
.
rmtree
(
stagingDir
)
def
errorExit
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
exit
(
errorCode
)
def
error
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
...
...
@@ -269,9 +265,6 @@ def myTest(transWillEnterBlock):
testWalletName
=
"test"
Print
(
"Creating wallet
\"
%s
\"
."
%
(
testWalletName
))
testWallet
=
walletMgr
.
create
(
testWalletName
)
if
testWallet
is
None
:
error
(
"Failed to create wallet %s."
%
(
testWalletName
))
return
False
for
account
in
accounts
:
Print
(
"Importing keys for account %s into wallet %s."
%
(
account
.
name
,
testWallet
.
name
))
...
...
@@ -281,9 +274,6 @@ def myTest(transWillEnterBlock):
node
=
cluster
.
getNode
(
0
)
node2
=
cluster
.
getNode
(
1
)
if
node
is
None
or
node2
is
None
:
error
(
"Cluster in bad state, received None node"
)
return
False
defproduceraAccount
=
testUtils
.
Cluster
.
defproduceraAccount
...
...
@@ -338,14 +328,14 @@ def myTest(transWillEnterBlock):
return
False
Print
(
"Get details for transaction %s"
%
(
transId
))
transaction
=
node2
.
getTransaction
(
transId
)
transaction
=
node2
.
getTransaction
(
transId
,
exitOnError
=
True
)
signature
=
transaction
[
"transaction"
][
"signatures"
][
0
]
blockNum
=
int
(
transaction
[
"transaction"
][
"ref_block_num"
])
blockNum
+=
1
Print
(
"Our transaction is in block %d"
%
(
blockNum
))
block
=
node2
.
getBlock
(
blockNum
)
block
=
node2
.
getBlock
(
blockNum
,
exitOnError
=
True
)
cycles
=
block
[
"cycles"
]
if
len
(
cycles
)
>
0
:
blockTransSignature
=
cycles
[
0
][
0
][
"user_input"
][
0
][
"signatures"
][
0
]
...
...
tests/distributed-transactions-remote-test.py
浏览文件 @
ce5c3c2b
...
...
@@ -15,10 +15,7 @@ import os
###############################################################
Print
=
Utils
.
Print
def
errorExit
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
exit
(
errorCode
)
errorExit
=
Utils
.
errorExit
args
=
TestHelper
.
parse_args
({
"-p"
,
"--dump-error-details"
,
"-v"
,
"--leave-running"
,
"--clean-run"
})
pnodes
=
args
.
p
...
...
tests/distributed-transactions-test.py
浏览文件 @
ce5c3c2b
...
...
@@ -8,10 +8,7 @@ from TestHelper import TestHelper
import
random
Print
=
Utils
.
Print
def
errorExit
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
exit
(
errorCode
)
errorExit
=
Utils
.
errorExit
args
=
TestHelper
.
parse_args
({
"-p"
,
"-n"
,
"-d"
,
"-s"
,
"--nodes-file"
,
"--seed"
,
"--dump-error-details"
,
"-v"
,
"--leave-running"
,
"--clean-run"
})
...
...
tests/nodeos_run_remote_test.py
浏览文件 @
ce5c3c2b
...
...
@@ -13,10 +13,7 @@ import subprocess
###############################################################
Print
=
Utils
.
Print
def
errorExit
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
exit
(
errorCode
)
errorExit
=
Utils
.
errorExit
args
=
TestHelper
.
parse_args
({
"--dump-error-details"
,
"-v"
,
"--leave-running"
,
"--only-bios"
,
"--clean-run"
})
debug
=
args
.
v
...
...
tests/nodeos_run_test.py
浏览文件 @
ce5c3c2b
...
...
@@ -17,16 +17,9 @@ import re
Print
=
Utils
.
Print
errorExit
=
Utils
.
errorExit
cmdError
=
Utils
.
cmdError
from
core_symbol
import
CORE_SYMBOL
def
cmdError
(
name
,
cmdCode
=
0
,
exitNow
=
False
):
msg
=
"FAILURE - %s%s"
%
(
name
,
(
""
if
cmdCode
==
0
else
(
" returned error code %d"
%
cmdCode
)))
if
exitNow
:
errorExit
(
msg
,
True
)
else
:
Print
(
msg
)
args
=
TestHelper
.
parse_args
({
"--host"
,
"--port"
,
"--prod-count"
,
"--defproducera_prvt_key"
,
"--defproducerb_prvt_key"
,
"--mongodb"
,
"--dump-error-details"
,
"--dont-launch"
,
"--keep-logs"
,
"-v"
,
"--leave-running"
,
"--only-bios"
,
"--clean-run"
,
"--sanity-test"
})
...
...
@@ -121,9 +114,6 @@ try:
testWalletName
=
"test"
Print
(
"Creating wallet
\"
%s
\"
."
%
(
testWalletName
))
testWallet
=
walletMgr
.
create
(
testWalletName
,
[
cluster
.
eosioAccount
,
cluster
.
defproduceraAccount
,
cluster
.
defproducerbAccount
])
if
testWallet
is
None
:
cmdError
(
"eos wallet create"
)
errorExit
(
"Failed to create wallet %s."
%
(
testWalletName
))
Print
(
"Wallet
\"
%s
\"
password=%s."
%
(
testWalletName
,
testWallet
.
password
.
encode
(
"utf-8"
)))
...
...
@@ -136,9 +126,6 @@ try:
defproduceraWalletName
=
"defproducera"
Print
(
"Creating wallet
\"
%s
\"
."
%
(
defproduceraWalletName
))
defproduceraWallet
=
walletMgr
.
create
(
defproduceraWalletName
)
if
defproduceraWallet
is
None
:
cmdError
(
"eos wallet create"
)
errorExit
(
"Failed to create wallet %s."
%
(
defproduceraWalletName
))
Print
(
"Wallet
\"
%s
\"
password=%s."
%
(
defproduceraWalletName
,
defproduceraWallet
.
password
.
encode
(
"utf-8"
)))
...
...
@@ -209,30 +196,19 @@ try:
errorExit
(
"FAILURE - wallet keys did not include %s"
%
(
noMatch
),
raw
=
True
)
node
=
cluster
.
getNode
(
0
)
if
node
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
Print
(
"Validating accounts before user accounts creation"
)
cluster
.
validateAccounts
(
None
)
# create accounts via eosio as otherwise a bid is needed
Print
(
"Create new account %s via %s"
%
(
testeraAccount
.
name
,
cluster
.
eosioAccount
.
name
))
transId
=
node
.
createInitializeAccount
(
testeraAccount
,
cluster
.
eosioAccount
,
stakedDeposit
=
0
,
waitForTransBlock
=
False
)
if
transId
is
None
:
cmdError
(
"%s create account"
%
(
testeraAccount
.
name
))
errorExit
(
"Failed to create account %s"
%
(
testeraAccount
.
name
))
transId
=
node
.
createInitializeAccount
(
testeraAccount
,
cluster
.
eosioAccount
,
stakedDeposit
=
0
,
waitForTransBlock
=
False
,
exitOnError
=
True
)
Print
(
"Create new account %s via %s"
%
(
currencyAccount
.
name
,
cluster
.
eosioAccount
.
name
))
transId
=
node
.
createInitializeAccount
(
currencyAccount
,
cluster
.
eosioAccount
,
stakedDeposit
=
5000
)
if
transId
is
None
:
cmdError
(
"%s create account"
%
(
ClientName
))
errorExit
(
"Failed to create account %s"
%
(
currencyAccount
.
name
))
transId
=
node
.
createInitializeAccount
(
currencyAccount
,
cluster
.
eosioAccount
,
stakedDeposit
=
5000
,
exitOnError
=
True
)
Print
(
"Create new account %s via %s"
%
(
exchangeAccount
.
name
,
cluster
.
eosioAccount
.
name
))
transId
=
node
.
createInitializeAccount
(
exchangeAccount
,
cluster
.
eosioAccount
,
waitForTransBlock
=
True
)
if
transId
is
None
:
cmdError
(
"%s create account"
%
(
ClientName
))
errorExit
(
"Failed to create account %s"
%
(
exchangeAccount
.
name
))
transId
=
node
.
createInitializeAccount
(
exchangeAccount
,
cluster
.
eosioAccount
,
waitForTransBlock
=
True
,
exitOnError
=
True
)
Print
(
"Validating accounts after user accounts creation"
)
accounts
=
[
testeraAccount
,
currencyAccount
,
exchangeAccount
]
...
...
@@ -244,10 +220,7 @@ try:
transferAmount
=
"97.5321 {0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
if
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
)
is
None
:
cmdError
(
"%s transfer"
%
(
ClientName
))
errorExit
(
"Failed to transfer funds %d from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
)
expectedAmount
=
transferAmount
Print
(
"Verify transfer, Expected: %s"
%
(
expectedAmount
))
...
...
@@ -259,10 +232,7 @@ try:
transferAmount
=
"0.0100 {0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Force transfer funds %s from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
if
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
,
force
=
True
)
is
None
:
cmdError
(
"%s transfer"
%
(
ClientName
))
errorExit
(
"Failed to force transfer funds %d from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
,
force
=
True
)
expectedAmount
=
"97.5421 {0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Verify transfer, Expected: %s"
%
(
expectedAmount
))
...
...
@@ -289,10 +259,6 @@ try:
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
testeraAccount
.
name
,
currencyAccount
.
name
))
trans
=
node
.
transferFunds
(
testeraAccount
,
currencyAccount
,
transferAmount
,
"test transfer a->b"
)
if
trans
is
None
:
cmdError
(
"%s transfer"
%
(
ClientName
))
errorExit
(
"Failed to transfer funds %d from account %s to %s"
%
(
transferAmount
,
testeraAccount
.
name
,
currencyAccount
.
name
))
transId
=
Node
.
getTransId
(
trans
)
expectedAmount
=
"98.0311 {0}"
.
format
(
CORE_SYMBOL
)
# 5000 initial deposit
...
...
@@ -303,8 +269,7 @@ try:
errorExit
(
"Transfer verification failed. Excepted %s, actual: %s"
%
(
expectedAmount
,
actualAmount
))
Print
(
"Validate last action for account %s"
%
(
testeraAccount
.
name
))
actions
=
node
.
getActions
(
testeraAccount
,
-
1
,
-
1
)
assert
(
actions
)
actions
=
node
.
getActions
(
testeraAccount
,
-
1
,
-
1
,
exitOnError
=
True
)
try
:
if
not
enableMongo
:
assert
(
actions
[
"actions"
][
0
][
"action_trace"
][
"act"
][
"name"
]
==
"transfer"
)
...
...
@@ -316,14 +281,10 @@ try:
node
.
waitForTransInBlock
(
transId
)
transaction
=
node
.
getTransaction
(
transId
)
if
transaction
is
None
:
cmdError
(
"%s get transaction trans_id"
%
(
ClientName
))
errorExit
(
"Failed to retrieve transaction details %s"
%
(
transId
))
transaction
=
node
.
getTransaction
(
transId
,
exitOnError
=
True
)
typeVal
=
None
amountVal
=
None
assert
(
transaction
)
key
=
""
try
:
if
not
enableMongo
:
...
...
@@ -428,9 +389,8 @@ try:
errorExit
(
"FAILURE - currency1111 balance check failed. Expected: %s, Recieved %s"
%
(
expected
,
actual
),
raw
=
True
)
Print
(
"Verify currency1111 contract has proper total supply of CUR (via get currency1111 stats)"
)
res
=
node
.
getCurrencyStats
(
contract
,
"CUR"
)
res
=
node
.
getCurrencyStats
(
contract
,
"CUR"
,
exitOnError
=
True
)
try
:
assert
(
res
)
assert
(
res
[
"CUR"
][
"supply"
]
==
"100000.0000 CUR"
)
except
(
AssertionError
,
KeyError
)
as
_
:
Print
(
"ERROR: Failed get currecy stats assertion. %s"
%
(
res
))
...
...
@@ -508,8 +468,8 @@ try:
Print
(
"Test for block decoded packed transaction (issue 2932)"
)
blockId
=
node
.
getBlockIdByTransId
(
transId
)
assert
(
blockId
)
block
=
node
.
getBlock
(
blockId
)
assert
(
block
)
block
=
node
.
getBlock
(
blockId
,
exitOnError
=
True
)
transactions
=
None
try
:
if
not
enableMongo
:
...
...
@@ -669,17 +629,11 @@ try:
code
=
"currency1111"
pType
=
"transfer"
requirement
=
"active"
trans
=
node
.
setPermission
(
testeraAccount
.
name
,
code
,
pType
,
requirement
,
waitForTransBlock
=
True
)
if
trans
is
None
:
cmdError
(
"%s set action permission set"
%
(
ClientName
))
errorExit
(
"Failed to set permission"
)
trans
=
node
.
setPermission
(
testeraAccount
.
name
,
code
,
pType
,
requirement
,
waitForTransBlock
=
True
,
exitOnError
=
True
)
Print
(
"remove permission"
)
requirement
=
"null"
trans
=
node
.
setPermission
(
testeraAccount
.
name
,
code
,
pType
,
requirement
,
waitForTransBlock
=
True
)
if
trans
is
None
:
cmdError
(
"%s set action permission set"
%
(
ClientName
))
errorExit
(
"Failed to remove permission"
)
trans
=
node
.
setPermission
(
testeraAccount
.
name
,
code
,
pType
,
requirement
,
waitForTransBlock
=
True
,
exitOnError
=
True
)
Print
(
"Locking all wallets."
)
if
not
walletMgr
.
lockAllWallets
():
...
...
@@ -692,10 +646,7 @@ try:
errorExit
(
"Failed to unlock wallet %s"
%
(
defproduceraWallet
.
name
))
Print
(
"Get account defproducera"
)
account
=
node
.
getEosAccount
(
defproduceraAccount
.
name
)
if
account
is
None
:
cmdError
(
"%s get account"
%
(
ClientName
))
errorExit
(
"Failed to get account %s"
%
(
defproduceraAccount
.
name
))
account
=
node
.
getEosAccount
(
defproduceraAccount
.
name
,
exitOnError
=
True
)
Print
(
"Unlocking wallet
\"
%s
\"
."
%
(
defproduceraWallet
.
name
))
if
not
walletMgr
.
unlockWallet
(
testWallet
):
...
...
@@ -711,14 +662,11 @@ try:
if
enableMongo
:
start
=
2
# block 1 (genesis block) is not signaled to the plugins, so not available in DB
for
blockNum
in
range
(
start
,
currentBlockNum
+
1
):
block
=
node
.
getBlock
(
blockNum
,
silentErrors
=
False
)
if
block
is
None
:
cmdError
(
"%s get block"
%
(
ClientName
))
errorExit
(
"get block by num %d"
%
blockNum
)
block
=
node
.
getBlock
(
blockNum
,
silentErrors
=
False
,
exitOnError
=
True
)
if
enableMongo
:
blockId
=
block
[
"block_id"
]
block2
=
node
.
getBlockById
(
blockId
)
block2
=
node
.
getBlockById
Mdb
(
blockId
)
if
block2
is
None
:
errorExit
(
"mongo get block by id %s"
%
blockId
)
...
...
tests/nodeos_under_min_avail_ram.py
浏览文件 @
ce5c3c2b
...
...
@@ -102,9 +102,6 @@ try:
errorExit
(
"Failed to stand up eos walletd."
)
testWallet
=
walletMgr
.
create
(
testWalletName
,
[
cluster
.
eosioAccount
])
if
testWallet
is
None
:
Utils
.
cmdError
(
"eos wallet create"
)
errorExit
(
"Failed to create wallet %s."
%
(
testWalletName
))
for
_
,
account
in
cluster
.
defProducerAccounts
.
items
():
walletMgr
.
importKey
(
account
,
testWallet
,
ignoreDupKeyWarning
=
True
)
...
...
@@ -113,17 +110,9 @@ try:
nodes
=
[]
nodes
.
append
(
cluster
.
getNode
(
0
))
if
nodes
[
0
]
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
nodes
.
append
(
cluster
.
getNode
(
1
))
if
nodes
[
1
]
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
nodes
.
append
(
cluster
.
getNode
(
2
))
if
nodes
[
2
]
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
nodes
.
append
(
cluster
.
getNode
(
3
))
if
nodes
[
3
]
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
for
account
in
accounts
:
...
...
@@ -132,37 +121,21 @@ try:
# create accounts via eosio as otherwise a bid is needed
for
account
in
accounts
:
Print
(
"Create new account %s via %s"
%
(
account
.
name
,
cluster
.
eosioAccount
.
name
))
trans
=
nodes
[
0
].
createInitializeAccount
(
account
,
cluster
.
eosioAccount
,
stakedDeposit
=
500000
,
waitForTransBlock
=
False
,
stakeNet
=
50000
,
stakeCPU
=
50000
,
buyRAM
=
50000
)
if
trans
is
None
:
Utils
.
cmdError
(
"%s create account"
%
(
account
.
name
))
errorExit
(
"Failed to create account %s"
%
(
account
.
name
))
trans
=
nodes
[
0
].
createInitializeAccount
(
account
,
cluster
.
eosioAccount
,
stakedDeposit
=
500000
,
waitForTransBlock
=
False
,
stakeNet
=
50000
,
stakeCPU
=
50000
,
buyRAM
=
50000
,
exitOnError
=
True
)
transferAmount
=
"70000000.0000 {0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
cluster
.
eosioAccount
.
name
,
account
.
name
))
if
nodes
[
0
].
transferFunds
(
cluster
.
eosioAccount
,
account
,
transferAmount
,
"test transfer"
)
is
None
:
errorExit
(
"Failed to transfer funds %d from account %s to %s"
%
(
transferAmount
,
cluster
.
eosioAccount
.
name
,
account
.
name
))
trans
=
nodes
[
0
].
delegatebw
(
account
,
1000000.0000
,
68000000.0000
)
if
trans
is
None
:
Utils
.
cmdError
(
"delegate bandwidth for %s"
%
(
account
.
name
))
errorExit
(
"Failed to delegate bandwidth for %s"
%
(
account
.
name
))
nodes
[
0
].
transferFunds
(
cluster
.
eosioAccount
,
account
,
transferAmount
,
"test transfer"
)
trans
=
nodes
[
0
].
delegatebw
(
account
,
1000000.0000
,
68000000.0000
,
exitOnError
=
True
)
contractAccount
=
cluster
.
createAccountKeys
(
1
)[
0
]
contractAccount
.
name
=
"contracttest"
walletMgr
.
importKey
(
contractAccount
,
testWallet
)
Print
(
"Create new account %s via %s"
%
(
contractAccount
.
name
,
cluster
.
eosioAccount
.
name
))
trans
=
nodes
[
0
].
createInitializeAccount
(
contractAccount
,
cluster
.
eosioAccount
,
stakedDeposit
=
500000
,
waitForTransBlock
=
False
,
stakeNet
=
50000
,
stakeCPU
=
50000
,
buyRAM
=
50000
)
if
trans
is
None
:
Utils
.
cmdError
(
"%s create account"
%
(
contractAccount
.
name
))
errorExit
(
"Failed to create account %s"
%
(
contractAccount
.
name
))
trans
=
nodes
[
0
].
createInitializeAccount
(
contractAccount
,
cluster
.
eosioAccount
,
stakedDeposit
=
500000
,
waitForTransBlock
=
False
,
stakeNet
=
50000
,
stakeCPU
=
50000
,
buyRAM
=
50000
,
exitOnError
=
True
)
transferAmount
=
"90000000.0000 {0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
cluster
.
eosioAccount
.
name
,
contractAccount
.
name
))
if
nodes
[
0
].
transferFunds
(
cluster
.
eosioAccount
,
contractAccount
,
transferAmount
,
"test transfer"
)
is
None
:
errorExit
(
"Failed to transfer funds %d from account %s to %s"
%
(
transferAmount
,
cluster
.
eosioAccount
.
name
,
contractAccount
.
name
))
trans
=
nodes
[
0
].
delegatebw
(
contractAccount
,
1000000.0000
,
88000000.0000
)
if
trans
is
None
:
Utils
.
cmdError
(
"delegate bandwidth for %s"
%
(
contractAccount
.
name
))
errorExit
(
"Failed to delegate bandwidth for %s"
%
(
contractAccount
.
name
))
nodes
[
0
].
transferFunds
(
cluster
.
eosioAccount
,
contractAccount
,
transferAmount
,
"test transfer"
)
trans
=
nodes
[
0
].
delegatebw
(
contractAccount
,
1000000.0000
,
88000000.0000
,
exitOnError
=
True
)
contractDir
=
"contracts/integration_test"
wastFile
=
"contracts/integration_test/integration_test.wast"
...
...
tests/nodeos_voting_test.py
浏览文件 @
ce5c3c2b
...
...
@@ -27,18 +27,12 @@ class ProducerToNode:
def
vote
(
node
,
account
,
producers
):
Print
(
"Votes for %s"
%
(
account
.
name
))
trans
=
node
.
vote
(
account
,
producers
,
waitForTransBlock
=
False
)
if
trans
is
None
:
Utils
.
cmdError
(
"voting with %s"
%
(
account
.
name
))
errorExit
(
"Failed to vote with account %s"
%
(
account
.
name
))
trans
=
node
.
vote
(
account
,
producers
,
waitForTransBlock
=
False
,
exitOnError
=
True
)
return
trans
def
getBlockProducer
(
node
,
blockNum
):
node
.
waitForBlock
(
blockNum
)
block
=
node
.
getBlock
(
blockNum
)
if
block
is
None
:
Utils
.
cmdError
(
"could not get block number %s"
%
(
blockNum
))
errorExit
(
"Failed to get block"
)
block
=
node
.
getBlock
(
blockNum
,
exitOnError
=
True
)
blockProducer
=
block
[
"producer"
]
if
blockProducer
is
None
:
Utils
.
cmdError
(
"could not get producer for block number %s"
%
(
blockNum
))
...
...
@@ -240,9 +234,6 @@ try:
errorExit
(
"Failed to stand up eos walletd."
)
testWallet
=
walletMgr
.
create
(
testWalletName
,
[
cluster
.
eosioAccount
,
accounts
[
0
],
accounts
[
1
],
accounts
[
2
],
accounts
[
3
],
accounts
[
4
]])
if
testWallet
is
None
:
Utils
.
cmdError
(
"eos wallet create"
)
errorExit
(
"Failed to create wallet %s."
%
(
testWalletName
))
for
_
,
account
in
cluster
.
defProducerAccounts
.
items
():
walletMgr
.
importKey
(
account
,
testWallet
,
ignoreDupKeyWarning
=
True
)
...
...
@@ -253,41 +244,22 @@ try:
node
=
cluster
.
getNode
(
i
)
node
.
producers
=
Cluster
.
parseProducers
(
i
)
for
prod
in
node
.
producers
:
trans
=
node
.
regproducer
(
cluster
.
defProducerAccounts
[
prod
],
"http::/mysite.com"
,
0
,
waitForTransBlock
=
False
)
if
trans
is
None
:
Utils
.
cmdError
(
"registering producer %s"
%
(
prod
.
name
))
errorExit
(
"Failed registering producer %s"
%
(
prod
.
name
))
trans
=
node
.
regproducer
(
cluster
.
defProducerAccounts
[
prod
],
"http::/mysite.com"
,
0
,
waitForTransBlock
=
False
,
exitOnError
=
True
)
node0
=
cluster
.
getNode
(
0
)
if
node0
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
node1
=
cluster
.
getNode
(
1
)
if
node1
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
node2
=
cluster
.
getNode
(
2
)
if
node2
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
node3
=
cluster
.
getNode
(
3
)
if
node3
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
node
=
node0
# create accounts via eosio as otherwise a bid is needed
for
account
in
accounts
:
Print
(
"Create new account %s via %s"
%
(
account
.
name
,
cluster
.
eosioAccount
.
name
))
trans
=
node
.
createInitializeAccount
(
account
,
cluster
.
eosioAccount
,
stakedDeposit
=
0
,
waitForTransBlock
=
False
,
stakeNet
=
1000
,
stakeCPU
=
1000
,
buyRAM
=
1000
)
if
trans
is
None
:
Utils
.
cmdError
(
"%s create account"
%
(
account
.
name
))
errorExit
(
"Failed to create account %s"
%
(
account
.
name
))
trans
=
node
.
createInitializeAccount
(
account
,
cluster
.
eosioAccount
,
stakedDeposit
=
0
,
waitForTransBlock
=
False
,
stakeNet
=
1000
,
stakeCPU
=
1000
,
buyRAM
=
1000
,
exitOnError
=
True
)
transferAmount
=
"100000000.0000 {0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
cluster
.
eosioAccount
.
name
,
account
.
name
))
if
node
.
transferFunds
(
cluster
.
eosioAccount
,
account
,
transferAmount
,
"test transfer"
)
is
None
:
errorExit
(
"Failed to transfer funds %d from account %s to %s"
%
(
transferAmount
,
cluster
.
eosioAccount
.
name
,
account
.
name
))
trans
=
node
.
delegatebw
(
account
,
20000000.0000
,
20000000.0000
)
if
trans
is
None
:
Utils
.
cmdError
(
"delegate bandwidth for %s"
%
(
account
.
name
))
errorExit
(
"Failed to delegate bandwidth for %s"
%
(
account
.
name
))
node
.
transferFunds
(
cluster
.
eosioAccount
,
account
,
transferAmount
,
"test transfer"
)
trans
=
node
.
delegatebw
(
account
,
20000000.0000
,
20000000.0000
,
exitOnError
=
True
)
# containers for tracking producers
prodsActive
=
{}
...
...
tests/p2p_network_test.py
浏览文件 @
ce5c3c2b
...
...
@@ -23,7 +23,7 @@ DEFAULT_PORT=ports[0]
parser
=
argparse
.
ArgumentParser
(
add_help
=
False
)
Print
=
testUtils
.
Utils
.
Print
errorExit
=
testUtils
.
Utils
.
errorExit
errorExit
=
Utils
.
errorExit
# Override default help argument so that only --help (and not -h) can call help
parser
.
add_argument
(
'-?'
,
action
=
'help'
,
default
=
argparse
.
SUPPRESS
,
...
...
@@ -111,9 +111,6 @@ if walletMgr.launch() is False:
testWalletName
=
"test"
Print
(
"Creating wallet
\"
%s
\"
."
%
(
testWalletName
))
testWallet
=
walletMgr
.
create
(
testWalletName
)
if
testWallet
is
None
:
cmdError
(
"eos wallet create"
)
errorExit
(
"Failed to create wallet %s."
%
(
testWalletName
))
for
account
in
accounts
:
Print
(
"Importing keys for account %s into wallet %s."
%
(
account
.
name
,
testWallet
.
name
))
...
...
@@ -124,9 +121,6 @@ for account in accounts:
defproduceraWalletName
=
"defproducera"
Print
(
"Creating wallet
\"
%s
\"
."
%
(
defproduceraWalletName
))
defproduceraWallet
=
walletMgr
.
create
(
defproduceraWalletName
)
if
defproduceraWallet
is
None
:
cmdError
(
"eos wallet create"
)
errorExit
(
"Failed to create wallet %s."
%
(
defproduceraWalletName
))
defproduceraAccount
=
testUtils
.
Cluster
.
defproduceraAccount
# defproducerbAccount=testUtils.Cluster.defproducerbAccount
...
...
@@ -137,8 +131,6 @@ if not walletMgr.importKey(defproduceraAccount, defproduceraWallet):
errorExit
(
"Failed to import key for account %s"
%
(
defproduceraAccount
.
name
))
node0
=
cluster
.
getNode
(
0
)
if
node0
is
None
:
errorExit
(
"cluster in bad state, received None node"
)
# eosio should have the same key as defproducera
eosio
=
copy
.
copy
(
defproduceraAccount
)
...
...
@@ -146,7 +138,7 @@ eosio.name = "eosio"
Print
(
"Info of each node:"
)
for
i
in
range
(
len
(
hosts
)):
node
=
cluster
.
getNode
(
0
)
node
=
node0
cmd
=
"%s %s get info"
%
(
testUtils
.
Utils
.
EosClientPath
,
node
.
endpointArgs
)
trans
=
node
.
runCmdReturnJson
(
cmd
)
Print
(
"host %s: %s"
%
(
hosts
[
i
],
trans
))
...
...
tests/p2p_stress.py
浏览文件 @
ce5c3c2b
...
...
@@ -34,7 +34,7 @@ class StressNetwork:
ta
.
name
=
self
.
randAcctName
()
acc1
=
copy
.
copy
(
ta
)
print
(
"creating new account %s"
%
(
ta
.
name
))
tr
=
node
.
createAccount
(
ta
,
eosio
,
stakedDeposit
=
0
,
waitForTransBlock
=
True
)
tr
=
node
.
createAccount
(
ta
,
eosio
,
stakedDeposit
=
0
,
waitForTransBlock
=
True
,
exitOnError
=
True
)
trid
=
node
.
getTransId
(
tr
)
if
trid
is
None
:
return
([],
""
,
0.0
,
"failed to create account"
)
...
...
@@ -43,7 +43,7 @@ class StressNetwork:
ta
.
name
=
self
.
randAcctName
()
acc2
=
copy
.
copy
(
ta
)
print
(
"creating new account %s"
%
(
ta
.
name
))
tr
=
node
.
createAccount
(
ta
,
eosio
,
stakedDeposit
=
0
,
waitForTransBlock
=
True
)
tr
=
node
.
createAccount
(
ta
,
eosio
,
stakedDeposit
=
0
,
waitForTransBlock
=
True
,
exitOnError
=
True
)
trid
=
node
.
getTransId
(
tr
)
if
trid
is
None
:
return
([],
""
,
0.0
,
"failed to create account"
)
...
...
tests/restart-scenarios-test.py
浏览文件 @
ce5c3c2b
...
...
@@ -6,7 +6,6 @@ from WalletMgr import WalletMgr
from
TestHelper
import
TestHelper
import
random
import
traceback
###############################################################
# Test for different nodes restart scenarios.
...
...
@@ -25,11 +24,7 @@ import traceback
Print
=
Utils
.
Print
def
errorExit
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
traceback
.
print_stack
(
limit
=-
1
)
exit
(
errorCode
)
errorExit
=
Utils
.
errorExit
args
=
TestHelper
.
parse_args
({
"-p"
,
"-d"
,
"-s"
,
"-c"
,
"--kill-sig"
,
"--kill-count"
,
"--keep-logs"
,
"--p2p-plugin"
,
"--dump-error-details"
,
"-v"
,
"--leave-running"
,
"--clean-run"
})
...
...
@@ -88,8 +83,6 @@ try:
walletName
=
"MyWallet"
Print
(
"Creating wallet %s if one doesn't already exist."
%
walletName
)
wallet
=
walletMgr
.
create
(
walletName
,
[
cluster
.
eosioAccount
,
cluster
.
defproduceraAccount
,
cluster
.
defproducerbAccount
])
if
wallet
is
None
:
errorExit
(
"Failed to create wallet %s"
%
(
walletName
))
Print
(
"Populate wallet with %d accounts."
%
(
accountsCount
))
if
not
cluster
.
populateWallet
(
accountsCount
,
wallet
):
...
...
tests/testUtils.py
浏览文件 @
ce5c3c2b
...
...
@@ -6,6 +6,7 @@ import inspect
import
json
import
shlex
from
sys
import
stdout
import
traceback
###########################################################################################
class
Utils
:
...
...
@@ -81,14 +82,12 @@ class Utils:
@
staticmethod
def
errorExit
(
msg
=
""
,
raw
=
False
,
errorCode
=
1
):
Utils
.
Print
(
"ERROR:"
if
not
raw
else
""
,
msg
)
traceback
.
print_stack
(
limit
=-
1
)
exit
(
errorCode
)
@
staticmethod
def
cmdError
(
name
,
cmdCode
=
0
,
exitNow
=
False
):
def
cmdError
(
name
,
cmdCode
=
0
):
msg
=
"FAILURE - %s%s"
%
(
name
,
(
""
if
cmdCode
==
0
else
(
" returned error code %d"
%
cmdCode
)))
if
exitNow
:
Utils
.
errorExit
(
msg
,
True
)
else
:
Utils
.
Print
(
msg
)
@
staticmethod
...
...
tests/validate-dirty-db.py
浏览文件 @
ce5c3c2b
...
...
@@ -14,10 +14,7 @@ import signal
Print
=
Utils
.
Print
def
errorExit
(
msg
=
""
,
errorCode
=
1
):
Print
(
"ERROR:"
,
msg
)
exit
(
errorCode
)
errorExit
=
Utils
.
errorExit
args
=
TestHelper
.
parse_args
({
"--keep-logs"
,
"--dump-error-details"
,
"-v"
,
"--leave-running"
,
"--clean-run"
})
debug
=
args
.
v
...
...
@@ -81,8 +78,6 @@ try:
errorExit
(
"Failed to stand up eos cluster."
)
node
=
cluster
.
getNode
(
0
)
if
node
is
None
:
errorExit
(
"Cluster in bad state, received None node"
)
Print
(
"Kill cluster nodes."
)
cluster
.
killall
(
allInstances
=
killAll
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录