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
6e2e4954
Commit
6e2e4954
authored
Jan 26, 2019
by
linj
Committed by
vipwzw
Jan 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test all means
parent
ed0c6ba6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
1 deletion
+116
-1
means_test.go
plugin/dapp/unfreeze/executor/means_test.go
+116
-1
No files found.
plugin/dapp/unfreeze/executor/means_test.go
View file @
6e2e4954
...
...
@@ -6,10 +6,12 @@ import (
"github.com/stretchr/testify/assert"
pty
"github.com/33cn/plugin/plugin/dapp/unfreeze/types"
"github.com/33cn/chain33/types"
)
func
TestCalcFrozen
(
t
*
testing
.
T
)
{
m
,
err
:=
newMeans
(
"LeftProportion"
,
1
)
types
.
SetTitleOnlyForTest
(
"chain33"
)
m
,
err
:=
newMeans
(
"LeftProportion"
,
15000000
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
m
)
...
...
@@ -66,3 +68,115 @@ func TestCalcFrozen(t *testing.T) {
})
}
}
func
TestLeftV1
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
start
int64
now
int64
period
int64
total
int64
tenThousandth
int64
expect
int64
}{
{
10000
,
10001
,
10
,
10000
,
2
,
9998
},
{
10000
,
10011
,
10
,
10000
,
2
,
9996
},
{
10000
,
10001
,
10
,
1e17
,
2
,
9998
*
1e13
},
{
10000
,
10011
,
10
,
1e17
,
2
,
9998
*
9998
*
1e9
},
}
for
_
,
c
:=
range
cases
{
c
:=
c
t
.
Run
(
"test LeftProportionV1"
,
func
(
t
*
testing
.
T
)
{
create
:=
pty
.
UnfreezeCreate
{
StartTime
:
c
.
start
,
AssetExec
:
"coins"
,
AssetSymbol
:
"bty"
,
TotalCount
:
c
.
total
,
Beneficiary
:
"x"
,
Means
:
pty
.
LeftProportionX
,
MeansOpt
:
&
pty
.
UnfreezeCreate_LeftProportion
{
LeftProportion
:
&
pty
.
LeftProportion
{
Period
:
c
.
period
,
TenThousandth
:
c
.
tenThousandth
,
},
},
}
u
:=
&
pty
.
Unfreeze
{
TotalCount
:
c
.
total
,
Means
:
pty
.
LeftProportionX
,
StartTime
:
c
.
start
,
MeansOpt
:
&
pty
.
Unfreeze_LeftProportion
{
LeftProportion
:
&
pty
.
LeftProportion
{
Period
:
c
.
period
,
TenThousandth
:
c
.
tenThousandth
,
},
},
}
m
:=
leftProportion
{}
u
,
err
:=
m
.
setOpt
(
u
,
&
create
)
assert
.
Nil
(
t
,
err
)
f
,
err
:=
m
.
calcFrozen
(
u
,
c
.
now
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
c
.
expect
,
f
)
})
}
}
func
TestFixV1
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
start
int64
now
int64
period
int64
total
int64
amount
int64
expect
int64
}{
{
10000
,
10001
,
10
,
10000
,
2
,
9998
},
{
10000
,
10011
,
10
,
10000
,
2
,
9996
},
{
10000
,
10001
,
10
,
1e17
,
2
,
1e17
-
2
},
{
10000
,
10011
,
10
,
1e17
,
2
,
1e17
-
4
},
}
for
_
,
c
:=
range
cases
{
c
:=
c
t
.
Run
(
"test FixAmountV1"
,
func
(
t
*
testing
.
T
)
{
create
:=
pty
.
UnfreezeCreate
{
StartTime
:
c
.
start
,
AssetExec
:
"coins"
,
AssetSymbol
:
"bty"
,
TotalCount
:
c
.
total
,
Beneficiary
:
"x"
,
Means
:
pty
.
FixAmountX
,
MeansOpt
:
&
pty
.
UnfreezeCreate_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
c
.
period
,
Amount
:
c
.
amount
,
},
},
}
u
:=
&
pty
.
Unfreeze
{
TotalCount
:
c
.
total
,
Means
:
pty
.
FixAmountX
,
StartTime
:
c
.
start
,
MeansOpt
:
&
pty
.
Unfreeze_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
c
.
period
,
Amount
:
c
.
amount
,
},
},
}
m
:=
fixAmount
{}
u
,
err
:=
m
.
setOpt
(
u
,
&
create
)
assert
.
Nil
(
t
,
err
)
f
,
err
:=
m
.
calcFrozen
(
u
,
c
.
now
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
c
.
expect
,
f
)
})
}
}
\ No newline at end of file
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