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
71edad12
Commit
71edad12
authored
Oct 27, 2016
by
Arseniy Klempner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create tests for StandardToken
parent
04323763
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
StandardTokenMock.sol
contracts/test-helpers/StandardTokenMock.sol
+11
-0
StandardToken.js
test/StandardToken.js
+81
-0
No files found.
contracts/test-helpers/StandardTokenMock.sol
0 → 100644
View file @
71edad12
pragma solidity ^0.4.0;
import '../StandardToken.sol';
// mock class using StandardToken
contract StandardTokenMock is StandardToken {
function StandardTokenMock(address initialAccount, uint initialBalance) {
balances[initialAccount] = initialBalance;
}
}
test/StandardToken.js
0 → 100644
View file @
71edad12
contract
(
'StandardToken'
,
function
(
accounts
)
{
it
(
"should return the correct allowance amount after approval"
,
function
(
done
)
{
var
token
;
return
StandardTokenMock
.
new
()
.
then
(
function
(
_token
)
{
token
=
_token
;
return
token
.
approve
(
accounts
[
1
],
100
);
})
.
then
(
function
()
{
return
token
.
allowance
(
accounts
[
0
],
accounts
[
1
]);
})
.
then
(
function
(
allowance
)
{
assert
.
equal
(
allowance
,
100
);
})
.
then
(
done
);
});
it
(
"should return correct balances after transfer"
,
function
(
done
)
{
var
token
;
return
StandardTokenMock
.
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
StandardTokenMock
.
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
);
});
it
(
"should return correct balances after transfering from another account"
,
function
(
done
)
{
var
token
;
return
StandardTokenMock
.
new
(
accounts
[
0
],
100
)
.
then
(
function
(
_token
)
{
token
=
_token
;
return
token
.
approve
(
accounts
[
1
],
100
);
})
.
then
(
function
()
{
return
token
.
transferFrom
(
accounts
[
0
],
accounts
[
2
],
100
,
{
from
:
accounts
[
1
]});
})
.
then
(
function
()
{
return
token
.
balanceOf
(
accounts
[
0
]);
})
.
then
(
function
(
balance
)
{
assert
.
equal
(
balance
,
0
);
return
token
.
balanceOf
(
accounts
[
2
]);
})
.
then
(
function
(
balance
)
{
assert
.
equal
(
balance
,
100
)
return
token
.
balanceOf
(
accounts
[
1
]);
})
.
then
(
function
(
balance
)
{
assert
.
equal
(
balance
,
0
);
})
.
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