Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
26e338f4
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,发现更多精彩内容 >>
提交
26e338f4
编写于
5月 18, 2018
作者:
M
Matias Romeo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add cmake configuration parameter to set the CORE symbol. (CORE_SYMBOL_NAME)
上级
eeed07b0
变更
27
展开全部
隐藏空白更改
内联
并排
Showing
27 changed file
with
629 addition
and
580 deletion
+629
-580
CMakeLists.txt
CMakeLists.txt
+12
-0
contracts/dice/dice.cpp
contracts/dice/dice.cpp
+1
-1
contracts/eosio.system/delegate_bandwidth.cpp
contracts/eosio.system/delegate_bandwidth.cpp
+5
-5
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+4
-4
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+1
-1
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+1
-1
contracts/eosiolib/CMakeLists.txt
contracts/eosiolib/CMakeLists.txt
+3
-2
contracts/eosiolib/asset.hpp
contracts/eosiolib/asset.hpp
+2
-102
contracts/eosiolib/core_symbol.hpp.in
contracts/eosiolib/core_symbol.hpp.in
+7
-0
contracts/eosiolib/symbol.hpp
contracts/eosiolib/symbol.hpp
+112
-0
libraries/chain/CMakeLists.txt
libraries/chain/CMakeLists.txt
+2
-0
libraries/chain/include/eosio/chain/asset.hpp
libraries/chain/include/eosio/chain/asset.hpp
+1
-8
libraries/chain/include/eosio/chain/core_symbol.hpp.in
libraries/chain/include/eosio/chain/core_symbol.hpp.in
+8
-0
libraries/chain/include/eosio/chain/symbol.hpp
libraries/chain/include/eosio/chain/symbol.hpp
+2
-1
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+2
-0
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+4
-0
tests/CMakeLists.txt
tests/CMakeLists.txt
+3
-0
tests/core_symbol.py.in
tests/core_symbol.py.in
+1
-0
tests/nodeos_run_test.py
tests/nodeos_run_test.py
+6
-5
tests/p2p_stress.py
tests/p2p_stress.py
+3
-1
tests/testUtils.py
tests/testUtils.py
+11
-8
unittests/bootseq_tests.cpp
unittests/bootseq_tests.cpp
+7
-7
unittests/currency_tests.cpp
unittests/currency_tests.cpp
+7
-7
unittests/dice_tests.cpp
unittests/dice_tests.cpp
+40
-40
unittests/eosio.system_tests.cpp
unittests/eosio.system_tests.cpp
+359
-359
unittests/forked_tests.cpp
unittests/forked_tests.cpp
+2
-2
unittests/multisig_tests.cpp
unittests/multisig_tests.cpp
+23
-26
未找到文件。
CMakeLists.txt
浏览文件 @
26e338f4
...
@@ -180,6 +180,18 @@ endif()
...
@@ -180,6 +180,18 @@ endif()
add_subdirectory
(
externals
)
add_subdirectory
(
externals
)
if
(
"
${
CORE_SYMBOL_NAME
}
"
STREQUAL
""
)
set
(
CORE_SYMBOL_NAME
"SYS"
)
endif
()
string
(
TOUPPER
${
CORE_SYMBOL_NAME
}
CORE_SYMBOL_NAME
)
string
(
LENGTH
${
CORE_SYMBOL_NAME
}
CORE_SYMBOL_NAME_LENGTH
)
if
(
CORE_SYMBOL_NAME_LENGTH GREATER 7
)
message
(
FATAL_ERROR
"CORE_SYMBOL_NAME lenght must be a between 1 and 7 characters"
)
endif
()
message
(
STATUS
"Using
${
CORE_SYMBOL_NAME
}
as CORE symbol name"
)
include
(
wasm
)
include
(
wasm
)
add_subdirectory
(
libraries
)
add_subdirectory
(
libraries
)
...
...
contracts/dice/dice.cpp
浏览文件 @
26e338f4
...
@@ -35,7 +35,7 @@ class dice : public eosio::contract {
...
@@ -35,7 +35,7 @@ class dice : public eosio::contract {
//@abi action
//@abi action
void
offerbet
(
const
asset
&
bet
,
const
account_name
player
,
const
checksum256
&
commitment
)
{
void
offerbet
(
const
asset
&
bet
,
const
account_name
player
,
const
checksum256
&
commitment
)
{
eosio_assert
(
bet
.
symbol
==
S
(
4
,
SYS
)
,
"only SYS
token allowed"
);
eosio_assert
(
bet
.
symbol
==
CORE_SYMBOL
,
"only core
token allowed"
);
eosio_assert
(
bet
.
is_valid
(),
"invalid bet"
);
eosio_assert
(
bet
.
is_valid
(),
"invalid bet"
);
eosio_assert
(
bet
.
amount
>
0
,
"must bet positive quantity"
);
eosio_assert
(
bet
.
amount
>
0
,
"must bet positive quantity"
);
...
...
contracts/eosio.system/delegate_bandwidth.cpp
浏览文件 @
26e338f4
...
@@ -119,9 +119,9 @@ namespace eosiosystem {
...
@@ -119,9 +119,9 @@ namespace eosiosystem {
* This action will buy an exact amount of ram and bill the payer the current market price.
* This action will buy an exact amount of ram and bill the payer the current market price.
*/
*/
void
system_contract
::
buyrambytes
(
account_name
payer
,
account_name
receiver
,
uint32_t
bytes
)
{
void
system_contract
::
buyrambytes
(
account_name
payer
,
account_name
receiver
,
uint32_t
bytes
)
{
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
SYS
));
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
CORE
));
auto
tmp
=
*
itr
;
auto
tmp
=
*
itr
;
auto
eosout
=
tmp
.
convert
(
asset
(
bytes
,
S
(
0
,
RAM
)),
S
(
4
,
SYS
)
);
auto
eosout
=
tmp
.
convert
(
asset
(
bytes
,
S
(
0
,
RAM
)),
CORE_SYMBOL
);
buyram
(
payer
,
receiver
,
eosout
);
buyram
(
payer
,
receiver
,
eosout
);
}
}
...
@@ -148,7 +148,7 @@ namespace eosiosystem {
...
@@ -148,7 +148,7 @@ namespace eosiosystem {
int64_t
bytes_out
;
int64_t
bytes_out
;
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
SYS
));
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
CORE
));
_rammarket
.
modify
(
itr
,
0
,
[
&
](
auto
&
es
)
{
_rammarket
.
modify
(
itr
,
0
,
[
&
](
auto
&
es
)
{
bytes_out
=
es
.
convert
(
quant
,
S
(
0
,
RAM
)
).
amount
;
bytes_out
=
es
.
convert
(
quant
,
S
(
0
,
RAM
)
).
amount
;
});
});
...
@@ -190,10 +190,10 @@ namespace eosiosystem {
...
@@ -190,10 +190,10 @@ namespace eosiosystem {
eosio_assert
(
res_itr
->
ram_bytes
>=
bytes
,
"insufficient quota"
);
eosio_assert
(
res_itr
->
ram_bytes
>=
bytes
,
"insufficient quota"
);
asset
tokens_out
;
asset
tokens_out
;
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
SYS
));
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
CORE
));
_rammarket
.
modify
(
itr
,
0
,
[
&
](
auto
&
es
)
{
_rammarket
.
modify
(
itr
,
0
,
[
&
](
auto
&
es
)
{
/// the cast to int64_t of bytes is safe because we certify bytes is <= quota which is limited by prior purchases
/// the cast to int64_t of bytes is safe because we certify bytes is <= quota which is limited by prior purchases
tokens_out
=
es
.
convert
(
asset
(
bytes
,
S
(
0
,
RAM
)),
S
(
4
,
SYS
)
);
tokens_out
=
es
.
convert
(
asset
(
bytes
,
S
(
0
,
RAM
)),
CORE_SYMBOL
);
});
});
_gstate
.
total_ram_bytes_reserved
-=
bytes
;
_gstate
.
total_ram_bytes_reserved
-=
bytes
;
...
...
contracts/eosio.system/eosio.system.cpp
浏览文件 @
26e338f4
...
@@ -19,18 +19,18 @@ namespace eosiosystem {
...
@@ -19,18 +19,18 @@ namespace eosiosystem {
//print( "construct system\n" );
//print( "construct system\n" );
_gstate
=
_global
.
exists
()
?
_global
.
get
()
:
get_default_parameters
();
_gstate
=
_global
.
exists
()
?
_global
.
get
()
:
get_default_parameters
();
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
SYS
));
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
CORE
));
if
(
itr
==
_rammarket
.
end
()
)
{
if
(
itr
==
_rammarket
.
end
()
)
{
auto
system_token_supply
=
eosio
::
token
(
N
(
eosio
.
token
)).
get_supply
(
eosio
::
symbol_type
(
system_token_symbol
).
name
()).
amount
;
auto
system_token_supply
=
eosio
::
token
(
N
(
eosio
.
token
)).
get_supply
(
eosio
::
symbol_type
(
system_token_symbol
).
name
()).
amount
;
if
(
system_token_supply
>
0
)
{
if
(
system_token_supply
>
0
)
{
itr
=
_rammarket
.
emplace
(
_self
,
[
&
](
auto
&
m
)
{
itr
=
_rammarket
.
emplace
(
_self
,
[
&
](
auto
&
m
)
{
m
.
supply
.
amount
=
100000000000000ll
;
m
.
supply
.
amount
=
100000000000000ll
;
m
.
supply
.
symbol
=
S
(
4
,
RAM
SYS
);
m
.
supply
.
symbol
=
S
(
4
,
RAM
CORE
);
m
.
base
.
balance
.
amount
=
int64_t
(
_gstate
.
free_ram
());
m
.
base
.
balance
.
amount
=
int64_t
(
_gstate
.
free_ram
());
m
.
base
.
balance
.
symbol
=
S
(
0
,
RAM
);
m
.
base
.
balance
.
symbol
=
S
(
0
,
RAM
);
m
.
quote
.
balance
.
amount
=
system_token_supply
/
1000
;
m
.
quote
.
balance
.
amount
=
system_token_supply
/
1000
;
m
.
quote
.
balance
.
symbol
=
S
(
4
,
SYS
)
;
m
.
quote
.
balance
.
symbol
=
CORE_SYMBOL
;
});
});
}
}
}
else
{
}
else
{
...
@@ -58,7 +58,7 @@ namespace eosiosystem {
...
@@ -58,7 +58,7 @@ namespace eosiosystem {
eosio_assert
(
max_ram_size
>
_gstate
.
total_ram_bytes_reserved
,
"attempt to set max below reserved"
);
eosio_assert
(
max_ram_size
>
_gstate
.
total_ram_bytes_reserved
,
"attempt to set max below reserved"
);
auto
delta
=
int64_t
(
max_ram_size
)
-
int64_t
(
_gstate
.
max_ram_size
);
auto
delta
=
int64_t
(
max_ram_size
)
-
int64_t
(
_gstate
.
max_ram_size
);
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
SYS
));
auto
itr
=
_rammarket
.
find
(
S
(
4
,
RAM
CORE
));
/**
/**
* Increase or decrease the amount of ram for sale based upon the change in max
* Increase or decrease the amount of ram for sale based upon the change in max
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
26e338f4
...
@@ -113,7 +113,7 @@ namespace eosiosystem {
...
@@ -113,7 +113,7 @@ namespace eosiosystem {
// static constexpr uint32_t max_inflation_rate = 5; // 5% annual inflation
// static constexpr uint32_t max_inflation_rate = 5; // 5% annual inflation
static
constexpr
uint32_t
seconds_per_day
=
24
*
3600
;
static
constexpr
uint32_t
seconds_per_day
=
24
*
3600
;
static
constexpr
uint64_t
system_token_symbol
=
S
(
4
,
SYS
)
;
static
constexpr
uint64_t
system_token_symbol
=
CORE_SYMBOL
;
class
system_contract
:
public
native
{
class
system_contract
:
public
native
{
private:
private:
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
26e338f4
...
@@ -131,7 +131,7 @@ namespace eosiosystem {
...
@@ -131,7 +131,7 @@ namespace eosiosystem {
* @pre if proxy is set then proxy account must exist and be registered as a proxy
* @pre if proxy is set then proxy account must exist and be registered as a proxy
* @pre every listed producer or proxy must have been previously registered
* @pre every listed producer or proxy must have been previously registered
* @pre voter must authorize this action
* @pre voter must authorize this action
* @pre voter must have previously staked some
SY
S for voting
* @pre voter must have previously staked some
EO
S for voting
* @pre voter->staked must be up to date
* @pre voter->staked must be up to date
*
*
* @post every producer previously voted for will have vote reduced by previous vote weight
* @post every producer previously voted for will have vote reduced by previous vote weight
...
...
contracts/eosiolib/CMakeLists.txt
浏览文件 @
26e338f4
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/core_symbol.hpp.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/core_symbol.hpp
)
add_wast_library
(
TARGET eosiolib
add_wast_library
(
TARGET eosiolib
INCLUDE_FOLDERS
"
${
STANDARD_INCLUDE_FOLDERS
}
"
${
CMAKE_SOURCE_DIR
}
/externals/magic_get/include
INCLUDE_FOLDERS
"
${
STANDARD_INCLUDE_FOLDERS
}
"
${
CMAKE_SOURCE_DIR
}
/externals/magic_get/include
DESTINATION_FOLDER
${
CMAKE_CURRENT_BINARY_DIR
}
DESTINATION_FOLDER
${
CMAKE_CURRENT_BINARY_DIR
}
)
)
\ No newline at end of file
contracts/eosiolib/asset.hpp
浏览文件 @
26e338f4
...
@@ -2,119 +2,19 @@
...
@@ -2,119 +2,19 @@
#include <eosiolib/serialize.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/system.h>
#include <eosiolib/system.h>
#include <eosiolib/symbol.hpp>
#include <tuple>
#include <tuple>
#include <limits>
#include <limits>
namespace
eosio
{
namespace
eosio
{
static
constexpr
uint64_t
string_to_symbol
(
uint8_t
precision
,
const
char
*
str
)
{
uint32_t
len
=
0
;
while
(
str
[
len
]
)
++
len
;
uint64_t
result
=
0
;
for
(
uint32_t
i
=
0
;
i
<
len
;
++
i
)
{
if
(
str
[
i
]
<
'A'
||
str
[
i
]
>
'Z'
)
{
/// ERRORS?
}
else
{
result
|=
(
uint64_t
(
str
[
i
])
<<
(
8
*
(
1
+
i
)));
}
}
result
|=
uint64_t
(
precision
);
return
result
;
}
#define S(P,X) ::eosio::string_to_symbol(P,#X)
typedef
uint64_t
symbol_name
;
static
constexpr
bool
is_valid_symbol
(
symbol_name
sym
)
{
sym
>>=
8
;
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
char
c
=
(
char
)(
sym
&
0xff
);
if
(
!
(
'A'
<=
c
&&
c
<=
'Z'
)
)
return
false
;
sym
>>=
8
;
if
(
!
(
sym
&
0xff
)
)
{
do
{
sym
>>=
8
;
if
(
(
sym
&
0xff
)
)
return
false
;
++
i
;
}
while
(
i
<
7
);
}
}
return
true
;
}
static
constexpr
uint32_t
symbol_name_length
(
symbol_name
tmp
)
{
tmp
>>=
8
;
/// skip precision
uint32_t
length
=
0
;
while
(
tmp
&
0xff
&&
length
<=
7
)
{
++
length
;
tmp
>>=
8
;
}
return
length
;
}
struct
symbol_type
{
symbol_name
value
;
symbol_type
()
{
}
symbol_type
(
symbol_name
s
)
:
value
(
s
)
{
}
bool
is_valid
()
const
{
return
is_valid_symbol
(
value
);
}
uint64_t
precision
()
const
{
return
value
&
0xff
;
}
uint64_t
name
()
const
{
return
value
>>
8
;
}
uint32_t
name_length
()
const
{
return
symbol_name_length
(
value
);
}
operator
symbol_name
()
const
{
return
value
;
}
void
print
(
bool
show_precision
=
true
)
const
{
if
(
show_precision
){
::
eosio
::
print
(
precision
());
prints
(
","
);
}
auto
sym
=
value
;
sym
>>=
8
;
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
char
c
=
(
char
)(
sym
&
0xff
);
if
(
!
c
)
return
;
prints_l
(
&
c
,
1
);
sym
>>=
8
;
}
}
EOSLIB_SERIALIZE
(
symbol_type
,
(
value
)
)
};
struct
extended_symbol
:
public
symbol_type
{
extended_symbol
(
symbol_name
s
=
0
,
account_name
c
=
0
)
:
symbol_type
{
s
},
contract
(
c
){}
account_name
contract
;
void
print
()
const
{
symbol_type
::
print
();
prints
(
"@"
);
printn
(
contract
);
}
friend
bool
operator
==
(
const
extended_symbol
&
a
,
const
extended_symbol
&
b
)
{
return
std
::
tie
(
a
.
value
,
a
.
contract
)
==
std
::
tie
(
b
.
value
,
b
.
contract
);
}
friend
bool
operator
!=
(
const
extended_symbol
&
a
,
const
extended_symbol
&
b
)
{
return
std
::
tie
(
a
.
value
,
a
.
contract
)
!=
std
::
tie
(
b
.
value
,
b
.
contract
);
}
EOSLIB_SERIALIZE
(
extended_symbol
,
(
value
)(
contract
)
)
};
struct
asset
{
struct
asset
{
int64_t
amount
;
int64_t
amount
;
symbol_type
symbol
;
symbol_type
symbol
;
static
constexpr
int64_t
max_amount
=
(
1LL
<<
62
)
-
1
;
static
constexpr
int64_t
max_amount
=
(
1LL
<<
62
)
-
1
;
explicit
asset
(
int64_t
a
=
0
,
symbol_
name
s
=
S
(
4
,
SYS
)
)
explicit
asset
(
int64_t
a
=
0
,
symbol_
type
s
=
CORE_SYMBOL
)
:
amount
(
a
),
symbol
{
s
}
:
amount
(
a
),
symbol
{
s
}
{
{
eosio_assert
(
is_amount_within_range
(),
"magnitude of asset amount must be less than 2^62"
);
eosio_assert
(
is_amount_within_range
(),
"magnitude of asset amount must be less than 2^62"
);
...
...
contracts/eosiolib/core_symbol.hpp.in
0 → 100644
浏览文件 @
26e338f4
/** @file
* @copyright defined in eos/LICENSE.txt
*
* \warning This file is machine generated. DO NOT EDIT. See core_symbol.hpp.in for changes.
*/
#define CORE_SYMBOL S(4,${CORE_SYMBOL_NAME})
\ No newline at end of file
contracts/eosiolib/symbol.hpp
0 → 100644
浏览文件 @
26e338f4
#pragma once
#include <eosiolib/core_symbol.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/system.h>
#include <tuple>
#include <limits>
namespace
eosio
{
static
constexpr
uint64_t
string_to_symbol
(
uint8_t
precision
,
const
char
*
str
)
{
uint32_t
len
=
0
;
while
(
str
[
len
]
)
++
len
;
uint64_t
result
=
0
;
for
(
uint32_t
i
=
0
;
i
<
len
;
++
i
)
{
if
(
str
[
i
]
<
'A'
||
str
[
i
]
>
'Z'
)
{
/// ERRORS?
}
else
{
result
|=
(
uint64_t
(
str
[
i
])
<<
(
8
*
(
1
+
i
)));
}
}
result
|=
uint64_t
(
precision
);
return
result
;
}
#define S(P,X) ::eosio::string_to_symbol(P,#X)
typedef
uint64_t
symbol_name
;
static
constexpr
bool
is_valid_symbol
(
symbol_name
sym
)
{
sym
>>=
8
;
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
char
c
=
(
char
)(
sym
&
0xff
);
if
(
!
(
'A'
<=
c
&&
c
<=
'Z'
)
)
return
false
;
sym
>>=
8
;
if
(
!
(
sym
&
0xff
)
)
{
do
{
sym
>>=
8
;
if
(
(
sym
&
0xff
)
)
return
false
;
++
i
;
}
while
(
i
<
7
);
}
}
return
true
;
}
static
constexpr
uint32_t
symbol_name_length
(
symbol_name
tmp
)
{
tmp
>>=
8
;
/// skip precision
uint32_t
length
=
0
;
while
(
tmp
&
0xff
&&
length
<=
7
)
{
++
length
;
tmp
>>=
8
;
}
return
length
;
}
struct
symbol_type
{
symbol_name
value
;
symbol_type
()
{
}
symbol_type
(
symbol_name
s
)
:
value
(
s
)
{
}
bool
is_valid
()
const
{
return
is_valid_symbol
(
value
);
}
uint64_t
precision
()
const
{
return
value
&
0xff
;
}
uint64_t
name
()
const
{
return
value
>>
8
;
}
uint32_t
name_length
()
const
{
return
symbol_name_length
(
value
);
}
operator
symbol_name
()
const
{
return
value
;
}
void
print
(
bool
show_precision
=
true
)
const
{
if
(
show_precision
){
::
eosio
::
print
(
precision
());
prints
(
","
);
}
auto
sym
=
value
;
sym
>>=
8
;
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
char
c
=
(
char
)(
sym
&
0xff
);
if
(
!
c
)
return
;
prints_l
(
&
c
,
1
);
sym
>>=
8
;
}
}
EOSLIB_SERIALIZE
(
symbol_type
,
(
value
)
)
};
struct
extended_symbol
:
public
symbol_type
{
extended_symbol
(
symbol_name
s
=
0
,
account_name
c
=
0
)
:
symbol_type
{
s
},
contract
(
c
){}
account_name
contract
;
void
print
()
const
{
symbol_type
::
print
();
prints
(
"@"
);
printn
(
contract
);
}
friend
bool
operator
==
(
const
extended_symbol
&
a
,
const
extended_symbol
&
b
)
{
return
std
::
tie
(
a
.
value
,
a
.
contract
)
==
std
::
tie
(
b
.
value
,
b
.
contract
);
}
friend
bool
operator
!=
(
const
extended_symbol
&
a
,
const
extended_symbol
&
b
)
{
return
std
::
tie
(
a
.
value
,
a
.
contract
)
!=
std
::
tie
(
b
.
value
,
b
.
contract
);
}
EOSLIB_SERIALIZE
(
extended_symbol
,
(
value
)(
contract
)
)
};
}
/// namespace eosio
libraries/chain/CMakeLists.txt
浏览文件 @
26e338f4
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/eosio/chain/core_symbol.hpp.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/eosio/chain/core_symbol.hpp
)
file
(
GLOB HEADERS
"include/eosio/chain/*.hpp"
"include/eosio/chain/contracts/*.hpp"
)
file
(
GLOB HEADERS
"include/eosio/chain/*.hpp"
"include/eosio/chain/contracts/*.hpp"
)
## SORT .cpp by most likely to change / break compile
## SORT .cpp by most likely to change / break compile
...
...
libraries/chain/include/eosio/chain/asset.hpp
浏览文件 @
26e338f4
...
@@ -7,13 +7,6 @@
...
@@ -7,13 +7,6 @@
#include <eosio/chain/types.hpp>
#include <eosio/chain/types.hpp>
#include <eosio/chain/symbol.hpp>
#include <eosio/chain/symbol.hpp>
/// eos with 8 digits of precision
#define SYS_SYMBOL_VALUE (int64_t(4) | (uint64_t('S') << 8) | (uint64_t('Y') << 16) | (uint64_t('S') << 24))
static
const
eosio
::
chain
::
symbol
SYS_SYMBOL
(
SYS_SYMBOL_VALUE
);
/// Defined to be largest power of 10 that fits in 53 bits of precision
#define EOS_MAX_SHARE_SUPPLY int64_t(1'000'000'000'000'000ll)
namespace
eosio
{
namespace
chain
{
namespace
eosio
{
namespace
chain
{
/**
/**
...
@@ -29,7 +22,7 @@ struct asset
...
@@ -29,7 +22,7 @@ struct asset
{
{
static
constexpr
int64_t
max_amount
=
(
1LL
<<
62
)
-
1
;
static
constexpr
int64_t
max_amount
=
(
1LL
<<
62
)
-
1
;
explicit
asset
(
share_type
a
=
0
,
symbol
id
=
SYS_SYMBOL
)
:
amount
(
a
),
sym
(
id
)
{
explicit
asset
(
share_type
a
=
0
,
symbol
id
=
symbol
(
CORE_SYMBOL
)
)
:
amount
(
a
),
sym
(
id
)
{
EOS_ASSERT
(
is_amount_within_range
(),
asset_type_exception
,
"magnitude of asset amount must be less than 2^62"
);
EOS_ASSERT
(
is_amount_within_range
(),
asset_type_exception
,
"magnitude of asset amount must be less than 2^62"
);
EOS_ASSERT
(
sym
.
valid
(),
asset_type_exception
,
"invalid symbol"
);
EOS_ASSERT
(
sym
.
valid
(),
asset_type_exception
,
"invalid symbol"
);
}
}
...
...
libraries/chain/include/eosio/chain/core_symbol.hpp.in
0 → 100644
浏览文件 @
26e338f4
/** @file
* @copyright defined in eos/LICENSE.txt
*
* \warning This file is machine generated. DO NOT EDIT. See core_symbol.hpp.in for changes.
*/
#define CORE_SYMBOL SY(4,${CORE_SYMBOL_NAME})
#define CORE_SYMBOL_NAME "${CORE_SYMBOL_NAME}"
\ No newline at end of file
libraries/chain/include/eosio/chain/symbol.hpp
浏览文件 @
26e338f4
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#pragma once
#pragma once
#include <fc/exception/exception.hpp>
#include <fc/exception/exception.hpp>
#include <eosio/chain/types.hpp>
#include <eosio/chain/types.hpp>
#include <eosio/chain/core_symbol.hpp>
#include <string>
#include <string>
#include <functional>
#include <functional>
...
@@ -65,7 +66,7 @@ namespace eosio {
...
@@ -65,7 +66,7 @@ namespace eosio {
explicit
symbol
(
uint8_t
p
,
const
char
*
s
)
:
m_value
(
string_to_symbol
(
p
,
s
))
{
explicit
symbol
(
uint8_t
p
,
const
char
*
s
)
:
m_value
(
string_to_symbol
(
p
,
s
))
{
FC_ASSERT
(
valid
(),
"invalid symbol: ${s}"
,
(
"s"
,
s
));
FC_ASSERT
(
valid
(),
"invalid symbol: ${s}"
,
(
"s"
,
s
));
}
}
explicit
symbol
(
uint64_t
v
=
SY
(
4
,
SYS
)
)
:
m_value
(
v
)
{
explicit
symbol
(
uint64_t
v
=
CORE_SYMBOL
)
:
m_value
(
v
)
{
FC_ASSERT
(
valid
(),
"invalid symbol: ${name}"
,
(
"name"
,
name
()));
FC_ASSERT
(
valid
(),
"invalid symbol: ${name}"
,
(
"name"
,
name
()));
}
}
static
symbol
from_string
(
const
string
&
from
)
static
symbol
from_string
(
const
string
&
from
)
...
...
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
26e338f4
...
@@ -24,6 +24,8 @@ std::ostream& operator<<( std::ostream& osm, const fc::variant_object& v );
...
@@ -24,6 +24,8 @@ std::ostream& operator<<( std::ostream& osm, const fc::variant_object& v );
std
::
ostream
&
operator
<<
(
std
::
ostream
&
osm
,
const
fc
::
variant_object
::
entry
&
e
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
osm
,
const
fc
::
variant_object
::
entry
&
e
);
eosio
::
chain
::
asset
core_from_string
(
const
std
::
string
&
s
);
namespace
boost
{
namespace
test_tools
{
namespace
tt_detail
{
namespace
boost
{
namespace
test_tools
{
namespace
tt_detail
{
template
<
>
template
<
>
...
...
libraries/testing/tester.cpp
浏览文件 @
26e338f4
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
#include <eosio.bios/eosio.bios.wast.hpp>
#include <eosio.bios/eosio.bios.wast.hpp>
#include <eosio.bios/eosio.bios.abi.hpp>
#include <eosio.bios/eosio.bios.abi.hpp>
eosio
::
chain
::
asset
core_from_string
(
const
std
::
string
&
s
)
{
return
eosio
::
chain
::
asset
::
from_string
(
s
+
" "
CORE_SYMBOL_NAME
);
}
namespace
eosio
{
namespace
testing
{
namespace
eosio
{
namespace
testing
{
bool
expect_assert_message
(
const
fc
::
exception
&
ex
,
string
expected
)
{
bool
expect_assert_message
(
const
fc
::
exception
&
ex
,
string
expected
)
{
...
...
tests/CMakeLists.txt
浏览文件 @
26e338f4
...
@@ -22,6 +22,8 @@ target_include_directories( plugin_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_p
...
@@ -22,6 +22,8 @@ target_include_directories( plugin_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_p
add_dependencies
(
plugin_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig
)
add_dependencies
(
plugin_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig
)
#
#
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/core_symbol.py.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/core_symbol.py
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/p2p_tests/sync/test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/p2p_tests/sync/test.sh COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/p2p_tests/sync/test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/p2p_tests/sync/test.sh COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/p2p_tests/dawn_515/test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/p2p_tests/dawn_515/test.sh COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/p2p_tests/dawn_515/test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/p2p_tests/dawn_515/test.sh COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/trans_sync_across_mixed_cluster_test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/trans_sync_across_mixed_cluster_test.sh COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/trans_sync_across_mixed_cluster_test.sh
${
CMAKE_CURRENT_BINARY_DIR
}
/trans_sync_across_mixed_cluster_test.sh COPYONLY
)
...
@@ -30,6 +32,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/distributed-transactions-remote-test.
...
@@ -30,6 +32,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/distributed-transactions-remote-test.
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/sample-cluster-map.json
${
CMAKE_CURRENT_BINARY_DIR
}
/sample-cluster-map.json COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/sample-cluster-map.json
${
CMAKE_CURRENT_BINARY_DIR
}
/sample-cluster-map.json COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/restart-scenarios-test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/restart-scenarios-test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/restart-scenarios-test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/restart-scenarios-test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/testUtils.py
${
CMAKE_CURRENT_BINARY_DIR
}
/testUtils.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/testUtils.py
${
CMAKE_CURRENT_BINARY_DIR
}
/testUtils.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/core_symbol.py
${
CMAKE_CURRENT_BINARY_DIR
}
/core_symbol.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/nodeos_run_test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/nodeos_run_test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/nodeos_run_test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/nodeos_run_test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/nodeos_run_remote_test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/nodeos_run_remote_test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/nodeos_run_remote_test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/nodeos_run_remote_test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/consensus-validation-malicious-producers.py
${
CMAKE_CURRENT_BINARY_DIR
}
/consensus-validation-malicious-producers.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/consensus-validation-malicious-producers.py
${
CMAKE_CURRENT_BINARY_DIR
}
/consensus-validation-malicious-producers.py COPYONLY
)
...
...
tests/core_symbol.py.in
0 → 100644
浏览文件 @
26e338f4
CORE_SYMBOL='${CORE_SYMBOL_NAME}'
\ No newline at end of file
tests/nodeos_run_test.py
浏览文件 @
26e338f4
...
@@ -15,6 +15,7 @@ import re
...
@@ -15,6 +15,7 @@ import re
Print
=
testUtils
.
Utils
.
Print
Print
=
testUtils
.
Utils
.
Print
errorExit
=
testUtils
.
Utils
.
errorExit
errorExit
=
testUtils
.
Utils
.
errorExit
from
core_symbol
import
CORE_SYMBOL
def
cmdError
(
name
,
cmdCode
=
0
,
exitNow
=
False
):
def
cmdError
(
name
,
cmdCode
=
0
,
exitNow
=
False
):
msg
=
"FAILURE - %s%s"
%
(
name
,
(
""
if
cmdCode
==
0
else
(
" returned error code %d"
%
cmdCode
)))
msg
=
"FAILURE - %s%s"
%
(
name
,
(
""
if
cmdCode
==
0
else
(
" returned error code %d"
%
cmdCode
)))
...
@@ -255,7 +256,7 @@ try:
...
@@ -255,7 +256,7 @@ try:
if
not
node
.
verifyAccount
(
testeraAccount
):
if
not
node
.
verifyAccount
(
testeraAccount
):
errorExit
(
"FAILURE - account creation failed."
,
raw
=
True
)
errorExit
(
"FAILURE - account creation failed."
,
raw
=
True
)
transferAmount
=
"97.5321
SYS"
transferAmount
=
"97.5321
{0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
if
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
)
is
None
:
if
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
)
is
None
:
cmdError
(
"%s transfer"
%
(
ClientName
))
cmdError
(
"%s transfer"
%
(
ClientName
))
...
@@ -269,7 +270,7 @@ try:
...
@@ -269,7 +270,7 @@ try:
cmdError
(
"FAILURE - transfer failed"
)
cmdError
(
"FAILURE - transfer failed"
)
errorExit
(
"Transfer verification failed. Excepted %s, actual: %s"
%
(
expectedAmount
,
actualAmount
))
errorExit
(
"Transfer verification failed. Excepted %s, actual: %s"
%
(
expectedAmount
,
actualAmount
))
transferAmount
=
"0.0100
SYS"
transferAmount
=
"0.0100
{0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Force transfer funds %s from account %s to %s"
%
(
Print
(
"Force transfer funds %s from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
if
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
,
force
=
True
)
is
None
:
if
node
.
transferFunds
(
defproduceraAccount
,
testeraAccount
,
transferAmount
,
"test transfer"
,
force
=
True
)
is
None
:
...
@@ -277,7 +278,7 @@ try:
...
@@ -277,7 +278,7 @@ try:
errorExit
(
"Failed to force transfer funds %d from account %s to %s"
%
(
errorExit
(
"Failed to force transfer funds %d from account %s to %s"
%
(
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
transferAmount
,
defproduceraAccount
.
name
,
testeraAccount
.
name
))
expectedAmount
=
"97.5421
SYS"
expectedAmount
=
"97.5421
{0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Verify transfer, Expected: %s"
%
(
expectedAmount
))
Print
(
"Verify transfer, Expected: %s"
%
(
expectedAmount
))
actualAmount
=
node
.
getAccountEosBalanceStr
(
testeraAccount
.
name
)
actualAmount
=
node
.
getAccountEosBalanceStr
(
testeraAccount
.
name
)
if
expectedAmount
!=
actualAmount
:
if
expectedAmount
!=
actualAmount
:
...
@@ -298,7 +299,7 @@ try:
...
@@ -298,7 +299,7 @@ try:
cmdError
(
"%s wallet unlock"
%
(
ClientName
))
cmdError
(
"%s wallet unlock"
%
(
ClientName
))
errorExit
(
"Failed to unlock wallet %s"
%
(
testWallet
.
name
))
errorExit
(
"Failed to unlock wallet %s"
%
(
testWallet
.
name
))
transferAmount
=
"97.5311
SYS"
transferAmount
=
"97.5311
{0}"
.
format
(
CORE_SYMBOL
)
Print
(
"Transfer funds %s from account %s to %s"
%
(
Print
(
"Transfer funds %s from account %s to %s"
%
(
transferAmount
,
testeraAccount
.
name
,
currencyAccount
.
name
))
transferAmount
,
testeraAccount
.
name
,
currencyAccount
.
name
))
trans
=
node
.
transferFunds
(
testeraAccount
,
currencyAccount
,
transferAmount
,
"test transfer a->b"
)
trans
=
node
.
transferFunds
(
testeraAccount
,
currencyAccount
,
transferAmount
,
"test transfer a->b"
)
...
@@ -308,7 +309,7 @@ try:
...
@@ -308,7 +309,7 @@ try:
transferAmount
,
testeraAccount
.
name
,
currencyAccount
.
name
))
transferAmount
,
testeraAccount
.
name
,
currencyAccount
.
name
))
transId
=
testUtils
.
Node
.
getTransId
(
trans
)
transId
=
testUtils
.
Node
.
getTransId
(
trans
)
expectedAmount
=
"98.0311
SYS"
# 5000 initial deposit
expectedAmount
=
"98.0311
{0}"
.
format
(
CORE_SYMBOL
)
# 5000 initial deposit
Print
(
"Verify transfer, Expected: %s"
%
(
expectedAmount
))
Print
(
"Verify transfer, Expected: %s"
%
(
expectedAmount
))
actualAmount
=
node
.
getAccountEosBalanceStr
(
currencyAccount
.
name
)
actualAmount
=
node
.
getAccountEosBalanceStr
(
currencyAccount
.
name
)
if
expectedAmount
!=
actualAmount
:
if
expectedAmount
!=
actualAmount
:
...
...
tests/p2p_stress.py
浏览文件 @
26e338f4
...
@@ -5,6 +5,8 @@ import time
...
@@ -5,6 +5,8 @@ import time
import
copy
import
copy
import
threading
import
threading
from
core_symbol
import
CORE_SYMBOL
class
StressNetwork
:
class
StressNetwork
:
speeds
=
[
1
,
5
,
10
,
30
,
60
,
100
,
500
]
speeds
=
[
1
,
5
,
10
,
30
,
60
,
100
,
500
]
sec
=
10
sec
=
10
...
@@ -50,7 +52,7 @@ class StressNetwork:
...
@@ -50,7 +52,7 @@ class StressNetwork:
print
(
"issue currency0000 into %s"
%
(
acc1
.
name
))
print
(
"issue currency0000 into %s"
%
(
acc1
.
name
))
contract
=
"eosio"
contract
=
"eosio"
action
=
"issue"
action
=
"issue"
data
=
"{
\"
to
\"
:
\"
"
+
acc1
.
name
+
"
\"
,
\"
quantity
\"
:
\"
1000000.0000
SYS
\"
}"
data
=
"{
\"
to
\"
:
\"
"
+
acc1
.
name
+
"
\"
,
\"
quantity
\"
:
\"
1000000.0000
"
+
CORE_SYMBOL
+
"
\"
}"
opts
=
"--permission eosio@active"
opts
=
"--permission eosio@active"
tr
=
node
.
pushMessage
(
contract
,
action
,
data
,
opts
)
tr
=
node
.
pushMessage
(
contract
,
action
,
data
,
opts
)
trid
=
node
.
getTransId
(
tr
[
1
])
trid
=
node
.
getTransId
(
tr
[
1
])
...
...
tests/testUtils.py
浏览文件 @
26e338f4
...
@@ -17,6 +17,8 @@ import random
...
@@ -17,6 +17,8 @@ import random
import
json
import
json
import
shlex
import
shlex
from
core_symbol
import
CORE_SYMBOL
###########################################################################################
###########################################################################################
class
Utils
:
class
Utils
:
Debug
=
False
Debug
=
False
...
@@ -537,9 +539,10 @@ class Node(object):
...
@@ -537,9 +539,10 @@ class Node(object):
# Create & initialize account and return creation transactions. Return transaction json object
# Create & initialize account and return creation transactions. Return transaction json object
def
createInitializeAccount
(
self
,
account
,
creatorAccount
,
stakedDeposit
=
1000
,
waitForTransBlock
=
False
):
def
createInitializeAccount
(
self
,
account
,
creatorAccount
,
stakedDeposit
=
1000
,
waitForTransBlock
=
False
):
cmd
=
'%s %s system newaccount -j %s %s %s %s --stake-net "100
SYS" --stake-cpu "100 SYS" --buy-ram-EOS "100 SYS
"'
%
(
cmd
=
'%s %s system newaccount -j %s %s %s %s --stake-net "100
%s" --stake-cpu "100 %s" --buy-ram-EOS "100 %s
"'
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
,
creatorAccount
.
name
,
account
.
name
,
Utils
.
EosClientPath
,
self
.
endpointArgs
,
creatorAccount
.
name
,
account
.
name
,
account
.
ownerPublicKey
,
account
.
activePublicKey
)
account
.
ownerPublicKey
,
account
.
activePublicKey
,
CORE_SYMBOL
,
CORE_SYMBOL
,
CORE_SYMBOL
)
if
Utils
.
Debug
:
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
if
Utils
.
Debug
:
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
trans
=
None
trans
=
None
...
@@ -553,7 +556,7 @@ class Node(object):
...
@@ -553,7 +556,7 @@ class Node(object):
if
stakedDeposit
>
0
:
if
stakedDeposit
>
0
:
self
.
waitForTransIdOnNode
(
transId
)
# seems like account creation needs to be finlized before transfer can happen
self
.
waitForTransIdOnNode
(
transId
)
# seems like account creation needs to be finlized before transfer can happen
trans
=
self
.
transferFunds
(
creatorAccount
,
account
,
"%0.04f
SYS"
%
(
stakedDeposit
/
10000
),
"init"
)
trans
=
self
.
transferFunds
(
creatorAccount
,
account
,
"%0.04f
%s"
%
(
stakedDeposit
/
10000
,
CORE_SYMBOL
),
"init"
)
transId
=
Node
.
getTransId
(
trans
)
transId
=
Node
.
getTransId
(
trans
)
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
...
@@ -580,7 +583,7 @@ class Node(object):
...
@@ -580,7 +583,7 @@ class Node(object):
if
stakedDeposit
>
0
:
if
stakedDeposit
>
0
:
self
.
waitForTransIdOnNode
(
transId
)
# seems like account creation needs to be finlized before transfer can happen
self
.
waitForTransIdOnNode
(
transId
)
# seems like account creation needs to be finlized before transfer can happen
trans
=
self
.
transferFunds
(
creatorAccount
,
account
,
"%0.04f
SYS"
%
(
stakedDeposit
/
10000
),
"init"
)
trans
=
self
.
transferFunds
(
creatorAccount
,
account
,
"%0.04f
%s"
%
(
stakedDeposit
/
10000
,
CORE_SYMBOL
),
"init"
)
transId
=
Node
.
getTransId
(
trans
)
transId
=
Node
.
getTransId
(
trans
)
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
if
waitForTransBlock
and
not
self
.
waitForTransIdOnNode
(
transId
):
...
@@ -1927,7 +1930,7 @@ class Cluster(object):
...
@@ -1927,7 +1930,7 @@ class Cluster(object):
contract
=
eosioTokenAccount
.
name
contract
=
eosioTokenAccount
.
name
Utils
.
Print
(
"push create action to %s contract"
%
(
contract
))
Utils
.
Print
(
"push create action to %s contract"
%
(
contract
))
action
=
"create"
action
=
"create"
data
=
"{
\"
issuer
\"
:
\"
%s
\"
,
\"
maximum_supply
\"
:
\"
1000000000.0000
SYS
\"
,
\"
can_freeze
\"
:
\"
0
\"
,
\"
can_recall
\"
:
\"
0
\"
,
\"
can_whitelist
\"
:
\"
0
\"
}"
%
(
eosioTokenAccount
.
name
)
data
=
"{
\"
issuer
\"
:
\"
%s
\"
,
\"
maximum_supply
\"
:
\"
1000000000.0000
%s
\"
,
\"
can_freeze
\"
:
\"
0
\"
,
\"
can_recall
\"
:
\"
0
\"
,
\"
can_whitelist
\"
:
\"
0
\"
}"
%
(
eosioTokenAccount
.
name
,
CORE_SYMBOL
)
opts
=
"--permission %s@active"
%
(
contract
)
opts
=
"--permission %s@active"
%
(
contract
)
trans
=
biosNode
.
pushMessage
(
contract
,
action
,
data
,
opts
)
trans
=
biosNode
.
pushMessage
(
contract
,
action
,
data
,
opts
)
if
trans
is
None
or
not
trans
[
0
]:
if
trans
is
None
or
not
trans
[
0
]:
...
@@ -1941,7 +1944,7 @@ class Cluster(object):
...
@@ -1941,7 +1944,7 @@ class Cluster(object):
contract
=
eosioTokenAccount
.
name
contract
=
eosioTokenAccount
.
name
Utils
.
Print
(
"push issue action to %s contract"
%
(
contract
))
Utils
.
Print
(
"push issue action to %s contract"
%
(
contract
))
action
=
"issue"
action
=
"issue"
data
=
"{
\"
to
\"
:
\"
%s
\"
,
\"
quantity
\"
:
\"
1000000000.0000
SYS
\"
,
\"
memo
\"
:
\"
initial issue
\"
}"
%
(
eosioAccount
.
name
)
data
=
"{
\"
to
\"
:
\"
%s
\"
,
\"
quantity
\"
:
\"
1000000000.0000
%s
\"
,
\"
memo
\"
:
\"
initial issue
\"
}"
%
(
eosioAccount
.
name
,
CORE_SYMBOL
)
opts
=
"--permission %s@active"
%
(
contract
)
opts
=
"--permission %s@active"
%
(
contract
)
trans
=
biosNode
.
pushMessage
(
contract
,
action
,
data
,
opts
)
trans
=
biosNode
.
pushMessage
(
contract
,
action
,
data
,
opts
)
if
trans
is
None
or
not
trans
[
0
]:
if
trans
is
None
or
not
trans
[
0
]:
...
@@ -1953,7 +1956,7 @@ class Cluster(object):
...
@@ -1953,7 +1956,7 @@ class Cluster(object):
transId
=
Node
.
getTransId
(
trans
[
1
])
transId
=
Node
.
getTransId
(
trans
[
1
])
biosNode
.
waitForTransIdOnNode
(
transId
)
biosNode
.
waitForTransIdOnNode
(
transId
)
expectedAmount
=
"1000000000.0000
SYS"
expectedAmount
=
"1000000000.0000
{0}"
.
format
(
CORE_SYMBOL
)
Utils
.
Print
(
"Verify eosio issue, Expected: %s"
%
(
expectedAmount
))
Utils
.
Print
(
"Verify eosio issue, Expected: %s"
%
(
expectedAmount
))
actualAmount
=
biosNode
.
getAccountEosBalanceStr
(
eosioAccount
.
name
)
actualAmount
=
biosNode
.
getAccountEosBalanceStr
(
eosioAccount
.
name
)
if
expectedAmount
!=
actualAmount
:
if
expectedAmount
!=
actualAmount
:
...
@@ -1973,7 +1976,7 @@ class Cluster(object):
...
@@ -1973,7 +1976,7 @@ class Cluster(object):
Node
.
validateTransaction
(
trans
)
Node
.
validateTransaction
(
trans
)
initialFunds
=
"1000000.0000
SYS"
initialFunds
=
"1000000.0000
{0}"
.
format
(
CORE_SYMBOL
)
Utils
.
Print
(
"Transfer initial fund %s to individual accounts."
%
(
initialFunds
))
Utils
.
Print
(
"Transfer initial fund %s to individual accounts."
%
(
initialFunds
))
trans
=
None
trans
=
None
contract
=
eosioTokenAccount
.
name
contract
=
eosioTokenAccount
.
name
...
...
unittests/bootseq_tests.cpp
浏览文件 @
26e338f4
...
@@ -156,7 +156,7 @@ public:
...
@@ -156,7 +156,7 @@ public:
}
}
asset
get_balance
(
const
account_name
&
act
)
{
asset
get_balance
(
const
account_name
&
act
)
{
return
get_currency_balance
(
N
(
eosio
.
token
),
symbol
(
SY
(
4
,
SYS
)
),
act
);
return
get_currency_balance
(
N
(
eosio
.
token
),
symbol
(
CORE_SYMBOL
),
act
);
}
}
void
set_code_abi
(
const
account_name
&
account
,
const
char
*
wast
,
const
char
*
abi
,
const
private_key_type
*
signer
=
nullptr
)
{
void
set_code_abi
(
const
account_name
&
account
,
const
char
*
wast
,
const
char
*
abi
,
const
private_key_type
*
signer
=
nullptr
)
{
...
@@ -202,11 +202,11 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
...
@@ -202,11 +202,11 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
BOOST_TEST
(
eosio_token_acc
.
privileged
==
true
);
BOOST_TEST
(
eosio_token_acc
.
privileged
==
true
);
// Create
EO
S tokens in eosio.token, set its manager as eosio
// Create
SY
S tokens in eosio.token, set its manager as eosio
auto
max_supply
=
asset
::
from_string
(
"10000000000.0000 SYS
"
);
/// 1x larger than 1B initial tokens
auto
max_supply
=
core_from_string
(
"10000000000.0000
"
);
/// 1x larger than 1B initial tokens
auto
initial_supply
=
asset
::
from_string
(
"1000000000.0000 SYS
"
);
/// 1x larger than 1B initial tokens
auto
initial_supply
=
core_from_string
(
"1000000000.0000
"
);
/// 1x larger than 1B initial tokens
create_currency
(
N
(
eosio
.
token
),
config
::
system_account_name
,
max_supply
);
create_currency
(
N
(
eosio
.
token
),
config
::
system_account_name
,
max_supply
);
// Issue the genesis supply of 1 billion
EO
S tokens to eosio.system
// Issue the genesis supply of 1 billion
SY
S tokens to eosio.system
issue
(
N
(
eosio
.
token
),
config
::
system_account_name
,
config
::
system_account_name
,
initial_supply
);
issue
(
N
(
eosio
.
token
),
config
::
system_account_name
,
config
::
system_account_name
,
initial_supply
);
auto
actual
=
get_balance
(
config
::
system_account_name
);
auto
actual
=
get_balance
(
config
::
system_account_name
);
...
@@ -321,7 +321,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
...
@@ -321,7 +321,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
BOOST_REQUIRE
(
control
->
head_block_time
().
time_since_epoch
()
<
first_june_2028
);
BOOST_REQUIRE
(
control
->
head_block_time
().
time_since_epoch
()
<
first_june_2028
);
// This should thrown an error, since block one can only unstake all his stake after 10 years
// This should thrown an error, since block one can only unstake all his stake after 10 years
BOOST_REQUIRE_THROW
(
undelegate_bandwidth
(
N
(
b1
),
N
(
b1
),
asset
::
from_string
(
"49999500.0000 EOS"
),
asset
::
from_string
(
"49999500.0000 EOS
"
)),
assert_exception
);
BOOST_REQUIRE_THROW
(
undelegate_bandwidth
(
N
(
b1
),
N
(
b1
),
core_from_string
(
"49999500.0000"
),
core_from_string
(
"49999500.0000
"
)),
assert_exception
);
// Skip 10 years
// Skip 10 years
produce_block
(
first_june_2028
-
control
->
head_block_time
().
time_since_epoch
());
produce_block
(
first_june_2028
-
control
->
head_block_time
().
time_since_epoch
());
...
@@ -330,7 +330,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
...
@@ -330,7 +330,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
register_producer
(
pro
);
register_producer
(
pro
);
}
}
// Block one should be able to unstake all his stake now
// Block one should be able to unstake all his stake now
undelegate_bandwidth
(
N
(
b1
),
N
(
b1
),
asset
::
from_string
(
"49999500.0000 EOS"
),
asset
::
from_string
(
"49999500.0000 EOS
"
));
undelegate_bandwidth
(
N
(
b1
),
N
(
b1
),
core_from_string
(
"49999500.0000"
),
core_from_string
(
"49999500.0000
"
));
return
;
return
;
produce_blocks
(
7000
);
/// produce blocks until virutal bandwidth can acomadate a small user
produce_blocks
(
7000
);
/// produce blocks until virutal bandwidth can acomadate a small user
...
...
unittests/currency_tests.cpp
浏览文件 @
26e338f4
...
@@ -275,18 +275,18 @@ BOOST_FIXTURE_TEST_CASE(test_symbol, TESTER) try {
...
@@ -275,18 +275,18 @@ BOOST_FIXTURE_TEST_CASE(test_symbol, TESTER) try {
}
}
{
{
symbol
eo
s
(
4
,
"SYS"
);
symbol
sy
s
(
4
,
"SYS"
);
BOOST_REQUIRE_EQUAL
(
SY
S_SYMBOL_VALUE
,
eo
s
.
value
());
BOOST_REQUIRE_EQUAL
(
SY
(
4
,
SYS
),
sy
s
.
value
());
BOOST_REQUIRE_EQUAL
(
"4,SYS"
,
eo
s
.
to_string
());
BOOST_REQUIRE_EQUAL
(
"4,SYS"
,
sy
s
.
to_string
());
BOOST_REQUIRE_EQUAL
(
"SYS"
,
eo
s
.
name
());
BOOST_REQUIRE_EQUAL
(
"SYS"
,
sy
s
.
name
());
BOOST_REQUIRE_EQUAL
(
4
,
eo
s
.
decimals
());
BOOST_REQUIRE_EQUAL
(
4
,
sy
s
.
decimals
());
}
}
// default is "4,
EOS
"
// default is "4,
${CORE_SYMBOL_NAME}
"
{
{
symbol
def
;
symbol
def
;
BOOST_REQUIRE_EQUAL
(
4
,
def
.
decimals
());
BOOST_REQUIRE_EQUAL
(
4
,
def
.
decimals
());
BOOST_REQUIRE_EQUAL
(
"SYS"
,
def
.
name
());
BOOST_REQUIRE_EQUAL
(
CORE_SYMBOL_NAME
,
def
.
name
());
}
}
// from string
// from string
{
{
...
...
unittests/dice_tests.cpp
浏览文件 @
26e338f4
...
@@ -237,18 +237,18 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
...
@@ -237,18 +237,18 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
push_action
(
N
(
eosio
.
token
),
N
(
create
),
N
(
eosio
.
token
),
mvo
()
push_action
(
N
(
eosio
.
token
),
N
(
create
),
N
(
eosio
.
token
),
mvo
()
(
"issuer"
,
"eosio.token"
)
(
"issuer"
,
"eosio.token"
)
(
"maximum_supply"
,
"1000000000.0000 SYS"
)
(
"maximum_supply"
,
core_from_string
(
"1000000000.0000"
)
)
);
);
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
N
(
eosio
.
token
),
mvo
()
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
N
(
eosio
.
token
),
mvo
()
(
"to"
,
"eosio"
)
(
"to"
,
"eosio"
)
(
"quantity"
,
"1000000000.0000 SYS"
)
(
"quantity"
,
core_from_string
(
"1000000000.0000"
)
)
(
"memo"
,
""
)
(
"memo"
,
""
)
);
);
transfer
(
N
(
eosio
),
N
(
alice
),
"10000.0000 SYS"
,
""
,
N
(
eosio
.
token
)
);
transfer
(
N
(
eosio
),
N
(
alice
),
core_from_string
(
"10000.0000"
)
,
""
,
N
(
eosio
.
token
)
);
transfer
(
N
(
eosio
),
N
(
bob
),
"10000.0000 SYS"
,
""
,
N
(
eosio
.
token
)
);
transfer
(
N
(
eosio
),
N
(
bob
),
core_from_string
(
"10000.0000"
)
,
""
,
N
(
eosio
.
token
)
);
transfer
(
N
(
eosio
),
N
(
carol
),
"10000.0000 SYS"
,
""
,
N
(
eosio
.
token
)
);
transfer
(
N
(
eosio
),
N
(
carol
),
core_from_string
(
"10000.0000"
)
,
""
,
N
(
eosio
.
token
)
);
produce_block
();
produce_block
();
...
@@ -257,54 +257,54 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
...
@@ -257,54 +257,54 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
produce_block
();
produce_block
();
// Alice deposits 1000
SYS
// Alice deposits 1000
deposit
(
N
(
alice
),
asset
::
from_string
(
"1000.0000 SYS
"
));
deposit
(
N
(
alice
),
core_from_string
(
"1000.0000
"
));
produce_block
();
produce_block
();
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
alice
)),
asset
::
from_string
(
"1000.0000 SYS
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
alice
)),
core_from_string
(
"1000.0000
"
));
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
alice
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
alice
)),
0
);
// Alice tries to bet 0
SYS
(fail)
// Alice tries to bet 0 (fail)
// secret : 9b886346e1351d4144d0b8392a975612eb0f8b6de7eae1cc9bcc55eb52be343c
// secret : 9b886346e1351d4144d0b8392a975612eb0f8b6de7eae1cc9bcc55eb52be343c
BOOST_CHECK_THROW
(
offer_bet
(
N
(
alice
),
asset
::
from_string
(
"0.0000 SYS
"
),
BOOST_CHECK_THROW
(
offer_bet
(
N
(
alice
),
core_from_string
(
"0.0000
"
),
commitment_for
(
"9b886346e1351d4144d0b8392a975612eb0f8b6de7eae1cc9bcc55eb52be343c"
)
commitment_for
(
"9b886346e1351d4144d0b8392a975612eb0f8b6de7eae1cc9bcc55eb52be343c"
)
),
fc
::
exception
);
),
fc
::
exception
);
// Alice bets 10
SYS
(success)
// Alice bets 10 (success)
// secret : 0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46
// secret : 0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46
offer_bet
(
N
(
alice
),
asset
::
from_string
(
"10.0000 SYS
"
),
offer_bet
(
N
(
alice
),
core_from_string
(
"10.0000
"
),
commitment_for
(
"0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46"
)
commitment_for
(
"0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46"
)
);
);
produce_block
();
produce_block
();
// Bob tries to bet using a secret previously used by Alice (fail)
// Bob tries to bet using a secret previously used by Alice (fail)
// secret : 00000000000000000000000000000002c334abe6ce13219a4cf3b862abb03c46
// secret : 00000000000000000000000000000002c334abe6ce13219a4cf3b862abb03c46
BOOST_CHECK_THROW
(
offer_bet
(
N
(
bob
),
asset
::
from_string
(
"10.0000 SYS
"
),
BOOST_CHECK_THROW
(
offer_bet
(
N
(
bob
),
core_from_string
(
"10.0000
"
),
commitment_for
(
"0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46"
)
commitment_for
(
"0ba044d2833758ee2c8f24d8a3f70c82c334abe6ce13219a4cf3b862abb03c46"
)
),
fc
::
exception
);
),
fc
::
exception
);
produce_block
();
produce_block
();
// Alice tries to bet 1000
SYS
(fail)
// Alice tries to bet 1000 (fail)
// secret : a512f6b1b589a8906d574e9de74a529e504a5c53a760f0991a3e00256c027971
// secret : a512f6b1b589a8906d574e9de74a529e504a5c53a760f0991a3e00256c027971
BOOST_CHECK_THROW
(
offer_bet
(
N
(
alice
),
asset
::
from_string
(
"1000.0000 SYS
"
),
BOOST_CHECK_THROW
(
offer_bet
(
N
(
alice
),
core_from_string
(
"1000.0000
"
),
commitment_for
(
"a512f6b1b589a8906d574e9de74a529e504a5c53a760f0991a3e00256c027971"
)
commitment_for
(
"a512f6b1b589a8906d574e9de74a529e504a5c53a760f0991a3e00256c027971"
)
),
fc
::
exception
);
),
fc
::
exception
);
produce_block
();
produce_block
();
// Bob tries to bet 90
SYS
without deposit
// Bob tries to bet 90 without deposit
// secret : 4facfc98932dde46fdc4403125a16337f6879a842a7ff8b0dc8e1ecddd59f3c8
// secret : 4facfc98932dde46fdc4403125a16337f6879a842a7ff8b0dc8e1ecddd59f3c8
BOOST_CHECK_THROW
(
offer_bet
(
N
(
bob
),
asset
::
from_string
(
"90.0000 SYS
"
),
BOOST_CHECK_THROW
(
offer_bet
(
N
(
bob
),
core_from_string
(
"90.0000
"
),
commitment_for
(
"4facfc98932dde46fdc4403125a16337f6879a842a7ff8b0dc8e1ecddd59f3c8"
)
commitment_for
(
"4facfc98932dde46fdc4403125a16337f6879a842a7ff8b0dc8e1ecddd59f3c8"
)
),
fc
::
exception
);
),
fc
::
exception
);
produce_block
();
produce_block
();
// Bob deposits 500
SYS
// Bob deposits 500
deposit
(
N
(
bob
),
asset
::
from_string
(
"500.0000 SYS
"
));
deposit
(
N
(
bob
),
core_from_string
(
"500.0000
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
bob
)),
asset
::
from_string
(
"500.0000 SYS
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
bob
)),
core_from_string
(
"500.0000
"
));
// Bob bets 11
SYS
(success)
// Bob bets 11 (success)
// secret : eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784
// secret : eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784
offer_bet
(
N
(
bob
),
asset
::
from_string
(
"11.0000 SYS
"
),
offer_bet
(
N
(
bob
),
core_from_string
(
"11.0000
"
),
commitment_for
(
"eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784"
)
commitment_for
(
"eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784"
)
);
);
produce_block
();
produce_block
();
...
@@ -314,12 +314,12 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
...
@@ -314,12 +314,12 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
cancel_offer
(
N
(
bob
),
commitment_for
(
"eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784"
)
);
cancel_offer
(
N
(
bob
),
commitment_for
(
"eec3272712d974c474a3e7b4028b53081344a5f50008e9ccf918ba0725a8d784"
)
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
bob
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
bob
)),
0
);
// Carol deposits 300
SYS
// Carol deposits 300
deposit
(
N
(
carol
),
asset
::
from_string
(
"300.0000 SYS
"
));
deposit
(
N
(
carol
),
core_from_string
(
"300.0000
"
));
// Carol bets 10
SYS
(success)
// Carol bets 10 (success)
// secret : 3efb4bd5e19b780f4980c919330c0306f8157f93db1fc72c7cefec63e0e7f37a
// secret : 3efb4bd5e19b780f4980c919330c0306f8157f93db1fc72c7cefec63e0e7f37a
offer_bet
(
N
(
carol
),
asset
::
from_string
(
"10.0000 SYS
"
),
offer_bet
(
N
(
carol
),
core_from_string
(
"10.0000
"
),
commitment_for
(
"3efb4bd5e19b780f4980c919330c0306f8157f93db1fc72c7cefec63e0e7f37a"
)
commitment_for
(
"3efb4bd5e19b780f4980c919330c0306f8157f93db1fc72c7cefec63e0e7f37a"
)
);
);
produce_block
();
produce_block
();
...
@@ -330,7 +330,7 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
...
@@ -330,7 +330,7 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
carol
)),
1
);
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
carol
)),
1
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
carol
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
carol
)),
0
);
BOOST_REQUIRE_EQUAL
(
game_bet
(
1
),
asset
::
from_string
(
"10.0000 SYS
"
));
BOOST_REQUIRE_EQUAL
(
game_bet
(
1
),
core_from_string
(
"10.0000
"
));
// Alice tries to cancel a nonexistent bet (fail)
// Alice tries to cancel a nonexistent bet (fail)
...
@@ -376,31 +376,31 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
...
@@ -376,31 +376,31 @@ BOOST_FIXTURE_TEST_CASE( dice_test, dice_tester ) try {
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
alice
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
alice
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
alice
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
alice
)),
0
);
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
alice
)),
asset
::
from_string
(
"1010.0000 SYS
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
alice
)),
core_from_string
(
"1010.0000
"
));
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
carol
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_games
(
N
(
carol
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
carol
)),
0
);
BOOST_REQUIRE_EQUAL
(
open_offers
(
N
(
carol
)),
0
);
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
carol
)),
asset
::
from_string
(
"290.0000 SYS
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
carol
)),
core_from_string
(
"290.0000
"
));
// Alice withdraw 1009
SYS
(success)
// Alice withdraw 1009 (success)
withdraw
(
N
(
alice
),
asset
::
from_string
(
"1009.0000 SYS
"
));
withdraw
(
N
(
alice
),
core_from_string
(
"1009.0000
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
alice
)),
asset
::
from_string
(
"1.0000 SYS
"
));
BOOST_REQUIRE_EQUAL
(
balance_of
(
N
(
alice
)),
core_from_string
(
"1.0000
"
));
BOOST_REQUIRE_EQUAL
(
BOOST_REQUIRE_EQUAL
(
get_currency_balance
(
N
(
eosio
.
token
),
SYS_SYMBOL
,
N
(
alice
)),
get_currency_balance
(
N
(
eosio
.
token
),
symbol
(
CORE_SYMBOL
)
,
N
(
alice
)),
asset
::
from_string
(
"10009.0000 SYS
"
)
core_from_string
(
"10009.0000
"
)
);
);
// Alice withdraw 2
SYS
(fail)
// Alice withdraw 2 (fail)
BOOST_CHECK_THROW
(
withdraw
(
N
(
alice
),
asset
::
from_string
(
"2.0000 SYS
"
)),
BOOST_CHECK_THROW
(
withdraw
(
N
(
alice
),
core_from_string
(
"2.0000
"
)),
fc
::
exception
);
fc
::
exception
);
// Alice withdraw 1
SYS
(success)
// Alice withdraw 1 (success)
withdraw
(
N
(
alice
),
asset
::
from_string
(
"1.0000 SYS
"
));
withdraw
(
N
(
alice
),
core_from_string
(
"1.0000
"
));
BOOST_REQUIRE_EQUAL
(
BOOST_REQUIRE_EQUAL
(
get_currency_balance
(
N
(
eosio
.
token
),
SYS_SYMBOL
,
N
(
alice
)),
get_currency_balance
(
N
(
eosio
.
token
),
symbol
(
CORE_SYMBOL
)
,
N
(
alice
)),
asset
::
from_string
(
"10010.0000 SYS
"
)
core_from_string
(
"10010.0000
"
)
);
);
// Verify alice account was deleted
// Verify alice account was deleted
...
...
unittests/eosio.system_tests.cpp
浏览文件 @
26e338f4
此差异已折叠。
点击以展开。
unittests/forked_tests.cpp
浏览文件 @
26e338f4
...
@@ -62,14 +62,14 @@ BOOST_AUTO_TEST_CASE( forking ) try {
...
@@ -62,14 +62,14 @@ BOOST_AUTO_TEST_CASE( forking ) try {
auto
cr
=
c
.
push_action
(
N
(
eosio
.
token
),
N
(
create
),
N
(
eosio
.
token
),
mutable_variant_object
()
auto
cr
=
c
.
push_action
(
N
(
eosio
.
token
),
N
(
create
),
N
(
eosio
.
token
),
mutable_variant_object
()
(
"issuer"
,
"eosio"
)
(
"issuer"
,
"eosio"
)
(
"maximum_supply"
,
"10000000.0000 SYS"
)
(
"maximum_supply"
,
core_from_string
(
"10000000.0000"
)
)
);
);
wdump
((
fc
::
json
::
to_pretty_string
(
cr
)));
wdump
((
fc
::
json
::
to_pretty_string
(
cr
)));
cr
=
c
.
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
N
(
eosio
),
mutable_variant_object
()
cr
=
c
.
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
N
(
eosio
),
mutable_variant_object
()
(
"to"
,
"dan"
)
(
"to"
,
"dan"
)
(
"quantity"
,
"100.0000 SYS"
)
(
"quantity"
,
core_from_string
(
"100.0000"
)
)
(
"memo"
,
""
)
(
"memo"
,
""
)
);
);
...
...
unittests/multisig_tests.cpp
浏览文件 @
26e338f4
...
@@ -53,7 +53,7 @@ public:
...
@@ -53,7 +53,7 @@ public:
}
}
transaction_trace_ptr
create_account_with_resources
(
account_name
a
,
account_name
creator
,
asset
ramfunds
,
bool
multisig
,
transaction_trace_ptr
create_account_with_resources
(
account_name
a
,
account_name
creator
,
asset
ramfunds
,
bool
multisig
,
asset
net
=
asset
::
from_string
(
"10.0000 SYS"
),
asset
cpu
=
asset
::
from_string
(
"10.0000 SYS
"
)
)
{
asset
net
=
core_from_string
(
"10.0000"
),
asset
cpu
=
core_from_string
(
"10.0000
"
)
)
{
signed_transaction
trx
;
signed_transaction
trx
;
set_transaction_headers
(
trx
);
set_transaction_headers
(
trx
);
...
@@ -97,17 +97,14 @@ public:
...
@@ -97,17 +97,14 @@ public:
void
create_currency
(
name
contract
,
name
manager
,
asset
maxsupply
)
{
void
create_currency
(
name
contract
,
name
manager
,
asset
maxsupply
)
{
auto
act
=
mutable_variant_object
()
auto
act
=
mutable_variant_object
()
(
"issuer"
,
manager
)
(
"issuer"
,
manager
)
(
"maximum_supply"
,
maxsupply
)
(
"maximum_supply"
,
maxsupply
);
(
"can_freeze"
,
0
)
(
"can_recall"
,
0
)
(
"can_whitelist"
,
0
);
base_tester
::
push_action
(
contract
,
N
(
create
),
contract
,
act
);
base_tester
::
push_action
(
contract
,
N
(
create
),
contract
,
act
);
}
}
void
issue
(
name
to
,
const
string
&
amount
,
name
manager
=
config
::
system_account_name
)
{
void
issue
(
name
to
,
const
asset
&
amount
,
name
manager
=
config
::
system_account_name
)
{
base_tester
::
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
manager
,
mutable_variant_object
()
base_tester
::
push_action
(
N
(
eosio
.
token
),
N
(
issue
),
manager
,
mutable_variant_object
()
(
"to"
,
to
)
(
"to"
,
to
)
(
"quantity"
,
a
sset
::
from_string
(
amount
)
)
(
"quantity"
,
a
mount
)
(
"memo"
,
""
)
(
"memo"
,
""
)
);
);
}
}
...
@@ -120,7 +117,7 @@ public:
...
@@ -120,7 +117,7 @@ public:
);
);
}
}
asset
get_balance
(
const
account_name
&
act
)
{
asset
get_balance
(
const
account_name
&
act
)
{
//return get_currency_balance( config::system_account_name, symbol(
SY(4,EOS)
), act );
//return get_currency_balance( config::system_account_name, symbol(
CORE_SYMBOL
), act );
//temporary code. current get_currency_balancy uses table name N(accounts) from currency.h
//temporary code. current get_currency_balancy uses table name N(accounts) from currency.h
//generic_currency table name is N(account).
//generic_currency table name is N(account).
const
auto
&
db
=
control
->
db
();
const
auto
&
db
=
control
->
db
();
...
@@ -129,14 +126,14 @@ public:
...
@@ -129,14 +126,14 @@ public:
// the balance is implied to be 0 if either the table or row does not exist
// the balance is implied to be 0 if either the table or row does not exist
if
(
tbl
)
{
if
(
tbl
)
{
const
auto
*
obj
=
db
.
find
<
key_value_object
,
by_scope_primary
>
(
boost
::
make_tuple
(
tbl
->
id
,
symbol
(
SY
(
4
,
SYS
)
).
to_symbol_code
()));
const
auto
*
obj
=
db
.
find
<
key_value_object
,
by_scope_primary
>
(
boost
::
make_tuple
(
tbl
->
id
,
symbol
(
CORE_SYMBOL
).
to_symbol_code
()));
if
(
obj
)
{
if
(
obj
)
{
// balance is the first field in the serialization
// balance is the first field in the serialization
fc
::
datastream
<
const
char
*>
ds
(
obj
->
value
.
data
(),
obj
->
value
.
size
());
fc
::
datastream
<
const
char
*>
ds
(
obj
->
value
.
data
(),
obj
->
value
.
size
());
fc
::
raw
::
unpack
(
ds
,
result
);
fc
::
raw
::
unpack
(
ds
,
result
);
}
}
}
}
return
asset
(
result
,
symbol
(
SY
(
4
,
SYS
)
)
);
return
asset
(
result
,
symbol
(
CORE_SYMBOL
)
);
}
}
transaction_trace_ptr
push_action
(
const
account_name
&
signer
,
const
action_name
&
name
,
const
variant_object
&
data
,
bool
auth
=
true
)
{
transaction_trace_ptr
push_action
(
const
account_name
&
signer
,
const
action_name
&
name
,
const
variant_object
&
data
,
bool
auth
=
true
)
{
...
@@ -421,20 +418,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
...
@@ -421,20 +418,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
set_code
(
N
(
eosio
.
token
),
eosio_token_wast
);
set_code
(
N
(
eosio
.
token
),
eosio_token_wast
);
set_abi
(
N
(
eosio
.
token
),
eosio_token_abi
);
set_abi
(
N
(
eosio
.
token
),
eosio_token_abi
);
create_currency
(
N
(
eosio
.
token
),
config
::
system_account_name
,
asset
::
from_string
(
"10000000000.0000 SYS
"
)
);
create_currency
(
N
(
eosio
.
token
),
config
::
system_account_name
,
core_from_string
(
"10000000000.0000
"
)
);
issue
(
config
::
system_account_name
,
"1000000000.0000 SYS"
);
issue
(
config
::
system_account_name
,
core_from_string
(
"1000000000.0000"
)
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000000000.0000 SYS
"
),
get_balance
(
"eosio"
)
);
BOOST_REQUIRE_EQUAL
(
core_from_string
(
"1000000000.0000
"
),
get_balance
(
"eosio"
)
);
set_code
(
config
::
system_account_name
,
eosio_system_wast
);
set_code
(
config
::
system_account_name
,
eosio_system_wast
);
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
produce_blocks
();
produce_blocks
();
create_account_with_resources
(
N
(
alice1111111
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 SYS
"
),
false
);
create_account_with_resources
(
N
(
alice1111111
),
N
(
eosio
),
core_from_string
(
"1.0000
"
),
false
);
create_account_with_resources
(
N
(
bob111111111
),
N
(
eosio
),
asset
::
from_string
(
"0.4500 SYS
"
),
false
);
create_account_with_resources
(
N
(
bob111111111
),
N
(
eosio
),
core_from_string
(
"0.4500
"
),
false
);
create_account_with_resources
(
N
(
carol1111111
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 SYS
"
),
false
);
create_account_with_resources
(
N
(
carol1111111
),
N
(
eosio
),
core_from_string
(
"1.0000
"
),
false
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000000000.0000 SYS
"
),
get_balance
(
"eosio"
)
);
BOOST_REQUIRE_EQUAL
(
core_from_string
(
"1000000000.0000
"
),
get_balance
(
"eosio"
)
);
vector
<
permission_level
>
perm
=
{
{
N
(
alice
),
config
::
active_name
},
{
N
(
bob
),
config
::
active_name
},
vector
<
permission_level
>
perm
=
{
{
N
(
alice
),
config
::
active_name
},
{
N
(
bob
),
config
::
active_name
},
{
N
(
carol
),
config
::
active_name
}
};
{
N
(
carol
),
config
::
active_name
}
};
...
@@ -508,7 +505,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
...
@@ -508,7 +505,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
->
receipt
->
status
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
->
receipt
->
status
);
// can't create account because system contract was replace by the test_api contract
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION
(
create_account_with_resources
(
N
(
alice1111112
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 SYS
"
),
false
),
BOOST_REQUIRE_EXCEPTION
(
create_account_with_resources
(
N
(
alice1111112
),
N
(
eosio
),
core_from_string
(
"1.0000
"
),
false
),
fc
::
assert_exception
,
fc
::
assert_exception
,
[](
const
fc
::
exception
&
e
)
{
[](
const
fc
::
exception
&
e
)
{
return
expect_assert_message
(
e
,
"condition: assertion failed: Unknown Test"
);
return
expect_assert_message
(
e
,
"condition: assertion failed: Unknown Test"
);
...
@@ -532,20 +529,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
...
@@ -532,20 +529,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
set_code
(
N
(
eosio
.
token
),
eosio_token_wast
);
set_code
(
N
(
eosio
.
token
),
eosio_token_wast
);
set_abi
(
N
(
eosio
.
token
),
eosio_token_abi
);
set_abi
(
N
(
eosio
.
token
),
eosio_token_abi
);
create_currency
(
N
(
eosio
.
token
),
config
::
system_account_name
,
asset
::
from_string
(
"10000000000.0000 SYS
"
)
);
create_currency
(
N
(
eosio
.
token
),
config
::
system_account_name
,
core_from_string
(
"10000000000.0000
"
)
);
issue
(
config
::
system_account_name
,
"1000000000.0000 SYS"
);
issue
(
config
::
system_account_name
,
core_from_string
(
"1000000000.0000"
)
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000000000.0000 SYS
"
),
get_balance
(
"eosio"
)
);
BOOST_REQUIRE_EQUAL
(
core_from_string
(
"1000000000.0000
"
),
get_balance
(
"eosio"
)
);
set_code
(
config
::
system_account_name
,
eosio_system_wast
);
set_code
(
config
::
system_account_name
,
eosio_system_wast
);
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
produce_blocks
();
produce_blocks
();
create_account_with_resources
(
N
(
alice1111111
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 SYS
"
),
false
);
create_account_with_resources
(
N
(
alice1111111
),
N
(
eosio
),
core_from_string
(
"1.0000
"
),
false
);
create_account_with_resources
(
N
(
bob111111111
),
N
(
eosio
),
asset
::
from_string
(
"0.4500 SYS
"
),
false
);
create_account_with_resources
(
N
(
bob111111111
),
N
(
eosio
),
core_from_string
(
"0.4500
"
),
false
);
create_account_with_resources
(
N
(
carol1111111
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 SYS
"
),
false
);
create_account_with_resources
(
N
(
carol1111111
),
N
(
eosio
),
core_from_string
(
"1.0000
"
),
false
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000000000.0000 SYS
"
),
get_balance
(
"eosio"
)
);
BOOST_REQUIRE_EQUAL
(
core_from_string
(
"1000000000.0000
"
),
get_balance
(
"eosio"
)
);
vector
<
permission_level
>
perm
=
{
{
N
(
alice
),
config
::
active_name
},
{
N
(
bob
),
config
::
active_name
},
vector
<
permission_level
>
perm
=
{
{
N
(
alice
),
config
::
active_name
},
{
N
(
bob
),
config
::
active_name
},
{
N
(
carol
),
config
::
active_name
},
{
N
(
apple
),
config
::
active_name
}};
{
N
(
carol
),
config
::
active_name
},
{
N
(
apple
),
config
::
active_name
}};
...
@@ -634,7 +631,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
...
@@ -634,7 +631,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
->
receipt
->
status
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
->
receipt
->
status
);
// can't create account because system contract was replace by the test_api contract
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION
(
create_account_with_resources
(
N
(
alice1111112
),
N
(
eosio
),
asset
::
from_string
(
"1.0000 SYS
"
),
false
),
BOOST_REQUIRE_EXCEPTION
(
create_account_with_resources
(
N
(
alice1111112
),
N
(
eosio
),
core_from_string
(
"1.0000
"
),
false
),
fc
::
assert_exception
,
fc
::
assert_exception
,
[](
const
fc
::
exception
&
e
)
{
[](
const
fc
::
exception
&
e
)
{
return
expect_assert_message
(
e
,
"condition: assertion failed: Unknown Test"
);
return
expect_assert_message
(
e
,
"condition: assertion failed: Unknown Test"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录