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
b52912c7
Commit
b52912c7
authored
Aug 13, 2018
by
Francisco Giordano
Committed by
Nicolás Venturo
Aug 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change dos file format to unix (#1198)
used dos2unix program
parent
66c19689
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
87 deletions
+87
-87
CappedToken.behavior.js
test/token/ERC20/CappedToken.behavior.js
+36
-36
RBACCappedToken.test.js
test/token/ERC20/RBACCappedToken.test.js
+19
-19
RBACMintableToken.behavior.js
test/token/ERC20/RBACMintableToken.behavior.js
+32
-32
No files found.
test/token/ERC20/CappedToken.behavior.js
View file @
b52912c7
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
BigNumber
=
web3
.
BigNumber
;
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
function
shouldBehaveLikeCappedToken
(
minter
,
[
anyone
],
cap
)
{
describe
(
'capped token'
,
function
()
{
const
from
=
minter
;
it
(
'should start with the correct cap'
,
async
function
()
{
(
await
this
.
token
.
cap
()).
should
.
be
.
bignumber
.
equal
(
cap
);
});
it
(
'should mint when amount is less than cap'
,
async
function
()
{
const
result
=
await
this
.
token
.
mint
(
anyone
,
cap
.
sub
(
1
),
{
from
});
result
.
logs
[
0
].
event
.
should
.
equal
(
'Mint'
);
});
it
(
'should fail to mint if the ammount exceeds the cap'
,
async
function
()
{
await
this
.
token
.
mint
(
anyone
,
cap
.
sub
(
1
),
{
from
});
await
expectThrow
(
this
.
token
.
mint
(
anyone
,
100
,
{
from
}));
});
it
(
'should fail to mint after cap is reached'
,
async
function
()
{
await
this
.
token
.
mint
(
anyone
,
cap
,
{
from
});
await
expectThrow
(
this
.
token
.
mint
(
anyone
,
1
,
{
from
}));
});
});
}
module
.
exports
=
{
shouldBehaveLikeCappedToken
,
};
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
BigNumber
=
web3
.
BigNumber
;
require
(
'chai'
)
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
function
shouldBehaveLikeCappedToken
(
minter
,
[
anyone
],
cap
)
{
describe
(
'capped token'
,
function
()
{
const
from
=
minter
;
it
(
'should start with the correct cap'
,
async
function
()
{
(
await
this
.
token
.
cap
()).
should
.
be
.
bignumber
.
equal
(
cap
);
});
it
(
'should mint when amount is less than cap'
,
async
function
()
{
const
result
=
await
this
.
token
.
mint
(
anyone
,
cap
.
sub
(
1
),
{
from
});
result
.
logs
[
0
].
event
.
should
.
equal
(
'Mint'
);
});
it
(
'should fail to mint if the ammount exceeds the cap'
,
async
function
()
{
await
this
.
token
.
mint
(
anyone
,
cap
.
sub
(
1
),
{
from
});
await
expectThrow
(
this
.
token
.
mint
(
anyone
,
100
,
{
from
}));
});
it
(
'should fail to mint after cap is reached'
,
async
function
()
{
await
this
.
token
.
mint
(
anyone
,
cap
,
{
from
});
await
expectThrow
(
this
.
token
.
mint
(
anyone
,
1
,
{
from
}));
});
});
}
module
.
exports
=
{
shouldBehaveLikeCappedToken
,
};
test/token/ERC20/RBACCappedToken.test.js
View file @
b52912c7
const
{
ether
}
=
require
(
'../../helpers/ether'
);
const
{
shouldBehaveLikeRBACMintableToken
}
=
require
(
'./RBACMintableToken.behavior'
);
const
{
shouldBehaveLikeMintableToken
}
=
require
(
'./MintableToken.behavior'
);
const
{
shouldBehaveLikeCappedToken
}
=
require
(
'./CappedToken.behavior'
);
const
RBACCappedTokenMock
=
artifacts
.
require
(
'RBACCappedTokenMock'
);
contract
(
'RBACCappedToken'
,
function
([
_
,
owner
,
minter
,
...
otherAccounts
])
{
const
cap
=
ether
(
1000
);
beforeEach
(
async
function
()
{
this
.
token
=
await
RBACCappedTokenMock
.
new
(
cap
,
{
from
:
owner
});
await
this
.
token
.
addMinter
(
minter
,
{
from
:
owner
});
});
shouldBehaveLikeMintableToken
(
owner
,
minter
,
otherAccounts
);
shouldBehaveLikeRBACMintableToken
(
owner
,
otherAccounts
);
shouldBehaveLikeCappedToken
(
minter
,
otherAccounts
,
cap
);
});
const
{
ether
}
=
require
(
'../../helpers/ether'
);
const
{
shouldBehaveLikeRBACMintableToken
}
=
require
(
'./RBACMintableToken.behavior'
);
const
{
shouldBehaveLikeMintableToken
}
=
require
(
'./MintableToken.behavior'
);
const
{
shouldBehaveLikeCappedToken
}
=
require
(
'./CappedToken.behavior'
);
const
RBACCappedTokenMock
=
artifacts
.
require
(
'RBACCappedTokenMock'
);
contract
(
'RBACCappedToken'
,
function
([
_
,
owner
,
minter
,
...
otherAccounts
])
{
const
cap
=
ether
(
1000
);
beforeEach
(
async
function
()
{
this
.
token
=
await
RBACCappedTokenMock
.
new
(
cap
,
{
from
:
owner
});
await
this
.
token
.
addMinter
(
minter
,
{
from
:
owner
});
});
shouldBehaveLikeMintableToken
(
owner
,
minter
,
otherAccounts
);
shouldBehaveLikeRBACMintableToken
(
owner
,
otherAccounts
);
shouldBehaveLikeCappedToken
(
minter
,
otherAccounts
,
cap
);
});
test/token/ERC20/RBACMintableToken.behavior.js
View file @
b52912c7
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
ROLE_MINTER
=
'minter'
;
function
shouldBehaveLikeRBACMintableToken
(
owner
,
[
anyone
])
{
describe
(
'handle roles'
,
function
()
{
it
(
'owner can add and remove a minter role'
,
async
function
()
{
await
this
.
token
.
addMinter
(
anyone
,
{
from
:
owner
});
let
hasRole
=
await
this
.
token
.
hasRole
(
anyone
,
ROLE_MINTER
);
hasRole
.
should
.
be
.
true
;
await
this
.
token
.
removeMinter
(
anyone
,
{
from
:
owner
});
hasRole
=
await
this
.
token
.
hasRole
(
anyone
,
ROLE_MINTER
);
hasRole
.
should
.
be
.
false
;
});
it
(
'anyone can
\'
t add or remove a minter role'
,
async
function
()
{
await
expectThrow
(
this
.
token
.
addMinter
(
anyone
,
{
from
:
anyone
})
);
await
this
.
token
.
addMinter
(
anyone
,
{
from
:
owner
});
await
expectThrow
(
this
.
token
.
removeMinter
(
anyone
,
{
from
:
anyone
})
);
});
});
}
module
.
exports
=
{
shouldBehaveLikeRBACMintableToken
,
};
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
ROLE_MINTER
=
'minter'
;
function
shouldBehaveLikeRBACMintableToken
(
owner
,
[
anyone
])
{
describe
(
'handle roles'
,
function
()
{
it
(
'owner can add and remove a minter role'
,
async
function
()
{
await
this
.
token
.
addMinter
(
anyone
,
{
from
:
owner
});
let
hasRole
=
await
this
.
token
.
hasRole
(
anyone
,
ROLE_MINTER
);
hasRole
.
should
.
be
.
true
;
await
this
.
token
.
removeMinter
(
anyone
,
{
from
:
owner
});
hasRole
=
await
this
.
token
.
hasRole
(
anyone
,
ROLE_MINTER
);
hasRole
.
should
.
be
.
false
;
});
it
(
'anyone can
\'
t add or remove a minter role'
,
async
function
()
{
await
expectThrow
(
this
.
token
.
addMinter
(
anyone
,
{
from
:
anyone
})
);
await
this
.
token
.
addMinter
(
anyone
,
{
from
:
owner
});
await
expectThrow
(
this
.
token
.
removeMinter
(
anyone
,
{
from
:
anyone
})
);
});
});
}
module
.
exports
=
{
shouldBehaveLikeRBACMintableToken
,
};
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