Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
俞永鹏
openzeppelin-contracts-upgradeable
Commits
d2dd6e40
Commit
d2dd6e40
authored
Jul 02, 2017
by
Jakub Wojciechowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new test for a day passed scenario to the DayLimit contract
parent
262b7dd7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletions
+26
-1
DayLimit.js
test/DayLimit.js
+26
-1
No files found.
test/DayLimit.js
View file @
d2dd6e40
'use strict'
;
'use strict'
;
const
assertJump
=
require
(
'./helpers/assertJump'
);
const
assertJump
=
require
(
'./helpers/assertJump'
);
const
timer
=
require
(
'./helpers/timer'
);
var
DayLimitMock
=
artifacts
.
require
(
'helpers/DayLimitMock.sol'
);
var
DayLimitMock
=
artifacts
.
require
(
'
./
helpers/DayLimitMock.sol'
);
contract
(
'DayLimit'
,
function
(
accounts
)
{
contract
(
'DayLimit'
,
function
(
accounts
)
{
const
day
=
60
*
60
*
24
;
it
(
'should construct with the passed daily limit'
,
async
function
()
{
it
(
'should construct with the passed daily limit'
,
async
function
()
{
let
initLimit
=
10
;
let
initLimit
=
10
;
...
@@ -84,4 +86,27 @@ contract('DayLimit', function(accounts) {
...
@@ -84,4 +86,27 @@ contract('DayLimit', function(accounts) {
assert
.
equal
(
spentToday
,
3
);
assert
.
equal
(
spentToday
,
3
);
});
});
it
(
'should allow spending if daily limit is reached and then the next has come'
,
async
function
()
{
let
limit
=
10
;
let
dayLimit
=
await
DayLimitMock
.
new
(
limit
);
await
dayLimit
.
attemptSpend
(
8
);
let
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
try
{
await
dayLimit
.
attemptSpend
(
3
);
}
catch
(
error
)
{
assertJump
(
error
);
}
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
await
timer
(
day
);
await
dayLimit
.
attemptSpend
(
3
);
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
3
);
});
});
});
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