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
3e9bfbc7
Commit
3e9bfbc7
authored
Nov 16, 2016
by
Manuel Araoz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add simple tests for BasicToken
parent
8acc7833
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
1 deletions
+62
-1
BasicTokenMock.sol
contracts/test-helpers/BasicTokenMock.sol
+12
-0
BasicToken.sol
contracts/token/BasicToken.sol
+1
-1
BasicToken.js
test/BasicToken.js
+49
-0
No files found.
contracts/test-helpers/BasicTokenMock.sol
0 → 100644
View file @
3e9bfbc7
pragma solidity ^0.4.4;
import '../token/BasicToken.sol';
// mock class using BasicToken
contract BasicTokenMock is BasicToken {
function BasicTokenMock(address initialAccount, uint initialBalance) {
balances[initialAccount] = initialBalance;
totalSupply = initialBalance;
}
}
contracts/token/BasicToken.sol
View file @
3e9bfbc7
...
...
@@ -7,7 +7,7 @@ import '../SafeMath.sol';
* Basic token
* Basic version of StandardToken, with no allowances
*/
contract BasicToken is ERC20
Lite
, SafeMath {
contract BasicToken is ERC20
Basic
, SafeMath {
mapping(address => uint) balances;
...
...
test/BasicToken.js
0 → 100644
View file @
3e9bfbc7
contract
(
'BasicToken'
,
function
(
accounts
)
{
it
(
"should return the correct totalSupply after construction"
,
function
(
done
)
{
return
BasicTokenMock
.
new
(
accounts
[
0
],
100
)
.
then
(
function
(
token
)
{
return
token
.
totalSupply
();
})
.
then
(
function
(
totalSupply
)
{
assert
.
equal
(
totalSupply
,
100
);
})
.
then
(
done
);
})
it
(
"should return correct balances after transfer"
,
function
(
done
)
{
var
token
;
return
BasicTokenMock
.
new
(
accounts
[
0
],
100
)
.
then
(
function
(
_token
)
{
token
=
_token
;
return
token
.
transfer
(
accounts
[
1
],
100
);
})
.
then
(
function
()
{
return
token
.
balanceOf
(
accounts
[
0
]);
})
.
then
(
function
(
balance
)
{
assert
.
equal
(
balance
,
0
);
})
.
then
(
function
()
{
return
token
.
balanceOf
(
accounts
[
1
]);
})
.
then
(
function
(
balance
)
{
assert
.
equal
(
balance
,
100
);
})
.
then
(
done
);
});
it
(
"should throw an error when trying to transfer more than balance"
,
function
(
done
)
{
var
token
;
return
BasicTokenMock
.
new
(
accounts
[
0
],
100
)
.
then
(
function
(
_token
)
{
token
=
_token
;
return
token
.
transfer
(
accounts
[
1
],
101
);
})
.
catch
(
function
(
error
)
{
if
(
error
.
message
.
search
(
'invalid JUMP'
)
==
-
1
)
throw
error
})
.
then
(
done
);
});
});
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