Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
11fb4046
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,发现更多精彩内容 >>
提交
11fb4046
编写于
9月 08, 2017
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Currency Contract interaction #372
上级
9414234e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
106 addition
and
17 deletion
+106
-17
tests/eosd_run_test.sh
tests/eosd_run_test.sh
+106
-17
未找到文件。
tests/eosd_run_test.sh
浏览文件 @
11fb4046
#!/bin/bash
# prevent bc from adding \ at end of large hex values
export
BC_LINE_LENGTH
=
9999
# $1 - error message
error
()
{
(>
&2
echo
$1
)
...
...
@@ -11,7 +15,7 @@ verifyErrorCode()
{
rc
=
$?
if
[[
$rc
!=
0
]]
;
then
error
"
$1
returned error code
$rc
"
error
"
FAILURE -
$1
returned error code
$rc
"
fi
}
...
...
@@ -27,6 +31,16 @@ cleanup()
rm
-rf
test_wallet_0
}
# $1 - string that contains "transaction_id": "<trans id>", in it
# result <trans id> stored in TRANS_ID
getTransactionId
()
{
TRANS_ID
=
"
$(
echo
"
$1
"
|
awk
'/transaction_id/ {print $2}'
)
"
# remove leading/trailing quotes
TRANS_ID
=
${
TRANS_ID
#\
"}
TRANS_ID=
${
TRANS_ID
%\
",}
}
# result stored in HEAD_BLOCK_NUM
getHeadBlockNum()
{
...
...
@@ -84,6 +98,10 @@ if [ -z "$PRV_KEY1" ] || [ -z "$PRV_KEY2" ] || [ -z "$PRV_KEY3" ] || [ -z "$PUB_
error "
FAILURE
- create keys
"
fi
#
# Wallet Tests
#
# walletd
programs/eos-walletd/eos-walletd --data-dir test_wallet_0 --http-server-endpoint=127.0.0.1:8899 > test_walletd_output.log 2>&1 &
verifyErrorCode "
eos
-walletd
"
...
...
@@ -165,6 +183,10 @@ if [[ $count == 0 ]]; then
error "
FAILURE
- wallet keys did not include
$INITA_PRV_KEY
"
fi
#
# Account and Transfer Tests
#
# create new account
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 create account inita testera
$PUB_KEY1
$PUB_KEY3
)
"
verifyErrorCode "
eosc
create account
"
...
...
@@ -190,13 +212,11 @@ if [ $count == 0 ]; then
fi
# create another new account via initb
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 create account initb
testerb
$PUB_KEY2
$PUB_KEY3
)
"
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 create account initb
currency
$PUB_KEY2
$PUB_KEY3
)
"
verifyErrorCode "
eosc
create account
"
waitForNextBlock
#
# now transfer from testera to testerb using keys from testera
#
## now transfer from testera to currency using keys from testera
# lock via lock_all
programs/eosc/eosc --wallet-port 8899 wallet lock_all
...
...
@@ -207,18 +227,14 @@ echo $PASSWORD | programs/eosc/eosc --wallet-port 8899 wallet unlock --name test
verifyErrorCode "
eosc
wallet unlock
"
# transfer
TRANSFER_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 transfer testera
testerb
975311
"test transfer a->b"
)
"
TRANSFER_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 transfer testera
currency
975311
"test transfer a->b"
)
"
verifyErrorCode "
eosc
transfer
"
TRANS_ID="
$(
echo
"
$TRANSFER_INFO
"
|
awk
'/transaction_id/ {print $2}'
)
"
waitForNextBlock
# remove leading/trailing quotes
TRANS_ID=
${
TRANS_ID
#\
"}
TRANS_ID=
${
TRANS_ID
%\
",}
getTransactionId "
$TRANSFER_INFO
"
# verify transfer
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get account
testerb
)
"
verifyErrorCode "
eosc
get account
testerb
"
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get account
currency
)
"
verifyErrorCode "
eosc
get account
currency
"
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"97.5311"
`
if [
$count
== 0 ]; then
error "
FAILURE
- transfer failed
:
$ACCOUNT_INFO
"
...
...
@@ -231,7 +247,7 @@ count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [
$count
== 0 ]; then
error "
FAILURE
- get accounts failed
:
$ACCOUNT_INFO
"
fi
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"
testerb
"
`
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"
currency
"
`
if [
$count
== 0 ]; then
error "
FAILURE
- get accounts failed
:
$ACCOUNT_INFO
"
fi
...
...
@@ -241,7 +257,7 @@ count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [
$count
== 0 ]; then
error "
FAILURE
- get accounts failed
:
$ACCOUNT_INFO
"
fi
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"
testerb
"
`
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"
currency
"
`
if [
$count
!= 0 ]; then
error "
FAILURE
- get accounts failed
:
$ACCOUNT_INFO
"
fi
...
...
@@ -253,7 +269,7 @@ count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [
$count
== 0 ]; then
error "
FAILURE
- get servants failed
:
$ACCOUNT_INFO
"
fi
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"
testerb
"
`
count=
`
echo
$ACCOUNT_INFO
|
grep
-c
"
currency
"
`
if [
$count
!= 0 ]; then
error "
FAILURE
- get servants failed
:
$ACCOUNT_INFO
"
fi
...
...
@@ -266,7 +282,7 @@ fi
# get transaction
TRANS_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get transaction
$TRANS_ID
)
"
verifyErrorCode "
eosc
get transaction trans_id
"
verifyErrorCode "
eosc
get transaction trans_id
of
$TRANS_INFO
"
count=
`
echo
$TRANS_INFO
|
grep
-c
"transfer"
`
if [
$count
== 0 ]; then
error "
FAILURE
- get transaction trans_id failed
:
$TRANS_INFO
"
...
...
@@ -284,6 +300,79 @@ if [ $count == 0 ]; then
error "
FAILURE
- get transactions testera failed
:
$TRANS_INFO
"
fi
#
# Currency Contract Tests
#
# verify no contract in place
CODE_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get code currency
)
"
verifyErrorCode "
eosc
get code currency
"
# convert to num
CODE_HASH="
$(
echo
"
$CODE_INFO
"
|
awk
'/code hash/ {print $3}'
)
"
CODE_HASH="
$(
echo
$CODE_HASH
|
awk
'{print toupper($0)}'
)
"
CODE_HASH="
$(
echo
"ibase=16;
$CODE_HASH
"
| bc
)
"
if [
$CODE_HASH
!= 0 ]; then
error "
FAILURE
- get code currency failed
:
$CODE_INFO
"
fi
# upload a contract
INFO="
$(
programs/eosc/eosc
--wallet-port
8899
set
contract currency contracts/currency/currency.wast contracts/currency/currency.abi
)
"
verifyErrorCode "
eosc
set contract testera
"
count=
`
echo
$INFO
|
grep
-c
"processed"
`
if [
$count
== 0 ]; then
error "
FAILURE
- set contract failed
:
$INFO
"
fi
getTransactionId "
$INFO
"
waitForNextBlock
# verify transaction exists
TRANS_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get transaction
$TRANS_ID
)
"
verifyErrorCode "
eosc
get transaction trans_id of
$TRANS_INFO
"
# verify code is set
CODE_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get code currency
)
"
verifyErrorCode "
eosc
get code currency
"
# convert to num
CODE_HASH="
$(
echo
"
$CODE_INFO
"
|
awk
'/code hash/ {print $3}'
)
"
CODE_HASH="
$(
echo
$CODE_HASH
|
awk
'{print toupper($0)}'
)
"
CODE_HASH="
$(
echo
"ibase=16;
$CODE_HASH
"
| bc
)
"
if [
$CODE_HASH
== 0 ]; then
error "
FAILURE
- get code currency failed
:
$CODE_INFO
"
fi
# verify currency contract has proper initial balance
INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get table currency currency account
)
"
verifyErrorCode "
eosc
get table currency account
"
count=
`
echo
$INFO
|
grep
-c
"1000000000"
`
if [
$count
== 0 ]; then
error "
FAILURE
- get table currency account failed
:
$INFO
"
fi
# push message to currency contract
INFO="
$(
programs/eosc/eosc
--wallet-port
8899 push message currency transfer
'{"from":"currency","to":"inita","amount":50}'
--scope
currency,inita
--permission
currency@active
)
"
verifyErrorCode "
eosc
push message currency transfer
"
getTransactionId "
$INFO
"
# verify transaction exists
waitForNextBlock
TRANS_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get transaction
$TRANS_ID
)
"
verifyErrorCode "
eosc
get transaction trans_id of
$TRANS_INFO
"
# read current contract balance
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get table inita currency account
)
"
verifyErrorCode "
eosc
get table currency account
"
count=
`
echo
$ACCOUNT_INFO
|
grep
"balance"
|
grep
-c
"50"
`
if [
$count
== 0 ]; then
error "
FAILURE
- get table inita account failed
:
$ACCOUNT_INFO
"
fi
ACCOUNT_INFO="
$(
programs/eosc/eosc
--wallet-port
8899 get table currency currency account
)
"
verifyErrorCode "
eosc
get table currency account
"
count=
`
echo
$ACCOUNT_INFO
|
grep
"balance"
|
grep
-c
"999999950"
`
if [
$count
== 0 ]; then
error "
FAILURE
- get table currency account failed
:
$ACCOUNT_INFO
"
fi
# should be able to get every block from beginning to end
getHeadBlockNum
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录