Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
fd74b16e
Commit
fd74b16e
authored
Nov 14, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#627 add issuance unit test
parent
9051d557
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+4
-3
issuance_test.go
plugin/dapp/issuance/executor/issuance_test.go
+0
-0
issuancedb.go
plugin/dapp/issuance/executor/issuancedb.go
+4
-3
No files found.
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
fd74b16e
...
...
@@ -607,6 +607,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
coll
.
Status
=
pty
.
CollateralizeStatusCreated
coll
.
Balance
-=
borrow
.
Value
coll
.
CollBalance
+=
btyFrozen
coll
.
LatestExpireTime
=
getLatestExpireTime
(
&
coll
.
Collateralize
)
coll
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
coll
.
GetKVSet
()
...
)
...
...
@@ -871,7 +872,6 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
collDB
:=
&
CollateralizeDB
{
*
coll
}
for
index
,
borrowRecord
:=
range
coll
.
BorrowRecords
{
if
borrowRecord
.
LiquidationPrice
*
PriceWarningRate
<
price
{
if
borrowRecord
.
Status
==
pty
.
CollateralizeUserStatusWarning
{
...
...
@@ -922,6 +922,7 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
// 保存
coll
.
LatestLiquidationPrice
=
getLatestLiquidationPrice
(
coll
)
coll
.
LatestExpireTime
=
getLatestExpireTime
(
coll
)
collDB
:=
&
CollateralizeDB
{
*
coll
}
collDB
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
collDB
.
GetKVSet
()
...
)
...
...
@@ -934,7 +935,6 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
collDB
:=
&
CollateralizeDB
{
*
coll
}
for
index
,
borrowRecord
:=
range
coll
.
BorrowRecords
{
if
borrowRecord
.
ExpireTime
-
ExpireWarningTime
>
action
.
blocktime
{
continue
...
...
@@ -981,6 +981,7 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
// 保存
coll
.
LatestLiquidationPrice
=
getLatestLiquidationPrice
(
coll
)
coll
.
LatestExpireTime
=
getLatestExpireTime
(
coll
)
collDB
:=
&
CollateralizeDB
{
*
coll
}
collDB
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
collDB
.
GetKVSet
()
...
)
...
...
@@ -1101,7 +1102,7 @@ func (action *Action) CollateralizeClose(close *pty.CollateralizeClose) (*types.
}
// 解冻ccny
receipt
,
err
=
action
.
tokenAccount
.
ExecActive
(
action
.
fromaddr
,
action
.
execaddr
,
collateralize
.
Total
Balance
*
Coin
)
receipt
,
err
=
action
.
tokenAccount
.
ExecActive
(
action
.
fromaddr
,
action
.
execaddr
,
collateralize
.
Balance
*
Coin
)
if
err
!=
nil
{
clog
.
Error
(
"IssuanceClose.ExecActive"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"amount"
,
collateralize
.
TotalBalance
)
return
nil
,
err
...
...
plugin/dapp/issuance/executor/issuance_test.go
0 → 100644
View file @
fd74b16e
This diff is collapsed.
Click to expand it.
plugin/dapp/issuance/executor/issuancedb.go
View file @
fd74b16e
...
...
@@ -614,6 +614,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
issu
.
CollateralValue
+=
btyFrozen
issu
.
DebtValue
+=
debt
.
Value
issu
.
Balance
-=
debt
.
Value
issu
.
LatestExpireTime
=
getLatestExpireTime
(
&
issu
.
Issuance
)
issu
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
issu
.
GetKVSet
()
...
)
...
...
@@ -723,7 +724,6 @@ func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*typ
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
collDB
:=
&
IssuanceDB
{
*
issu
}
for
index
,
debtRecord
:=
range
issu
.
DebtRecords
{
if
debtRecord
.
LiquidationPrice
*
PriceWarningRate
<
price
{
if
debtRecord
.
Status
==
pty
.
IssuanceUserStatusWarning
{
...
...
@@ -773,6 +773,7 @@ func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*typ
// 保存
issu
.
LatestLiquidationPrice
=
getLatestLiquidationPrice
(
issu
)
issu
.
LatestExpireTime
=
getLatestExpireTime
(
issu
)
collDB
:=
&
IssuanceDB
{
*
issu
}
collDB
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
collDB
.
GetKVSet
()
...
)
...
...
@@ -785,7 +786,6 @@ func (action *Action) expireLiquidation(issu *pty.Issuance) (*types.Receipt, err
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
collDB
:=
&
IssuanceDB
{
*
issu
}
for
index
,
debtRecord
:=
range
issu
.
DebtRecords
{
if
debtRecord
.
ExpireTime
-
ExpireWarningTime
>
action
.
blocktime
{
continue
...
...
@@ -831,6 +831,7 @@ func (action *Action) expireLiquidation(issu *pty.Issuance) (*types.Receipt, err
// 保存
issu
.
LatestLiquidationPrice
=
getLatestLiquidationPrice
(
issu
)
issu
.
LatestExpireTime
=
getLatestExpireTime
(
issu
)
collDB
:=
&
IssuanceDB
{
*
issu
}
collDB
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
collDB
.
GetKVSet
()
...
)
...
...
@@ -954,7 +955,7 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e
}
// 解冻ccny
receipt
,
err
=
action
.
tokenAccount
.
ExecActive
(
action
.
fromaddr
,
action
.
execaddr
,
issuance
.
Total
Balance
*
Coin
)
receipt
,
err
=
action
.
tokenAccount
.
ExecActive
(
action
.
fromaddr
,
action
.
execaddr
,
issuance
.
Balance
*
Coin
)
if
err
!=
nil
{
clog
.
Error
(
"IssuanceClose.ExecActive"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"amount"
,
issuance
.
TotalBalance
)
return
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment