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
1bb1d41b
Commit
1bb1d41b
authored
Jul 21, 2017
by
Francisco Giordano
Committed by
GitHub
Jul 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #281 from rudygodoy/master
Tests refactoring and typo fixes
parents
1db46aa5
6735a3cc
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
30 deletions
+30
-30
StandardToken.sol
contracts/token/StandardToken.sol
+1
-1
DayLimit.js
test/DayLimit.js
+7
-14
PullPayment.js
test/PullPayment.js
+11
-11
StandardToken.js
test/StandardToken.js
+6
-2
TokenDestructible.js
test/TokenDestructible.js
+5
-2
No files found.
contracts/token/StandardToken.sol
View file @
1bb1d41b
...
...
@@ -58,7 +58,7 @@ contract StandardToken is ERC20, BasicToken {
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still avaible for the spender.
* @return A uint256 specifing the amount of tokens still avai
la
ble for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
...
...
test/DayLimit.js
View file @
1bb1d41b
...
...
@@ -7,17 +7,19 @@ var DayLimitMock = artifacts.require('./helpers/DayLimitMock.sol');
contract
(
'DayLimit'
,
function
(
accounts
)
{
const
day
=
60
*
60
*
24
;
it
(
'should construct with the passed daily limit'
,
async
function
()
{
let
dayLimit
;
let
initLimit
=
10
;
let
dayLimit
=
await
DayLimitMock
.
new
(
initLimit
);
beforeEach
(
async
function
()
{
dayLimit
=
await
DayLimitMock
.
new
(
initLimit
);
});
it
(
'should construct with the passed daily limit'
,
async
function
()
{
let
dailyLimit
=
await
dayLimit
.
dailyLimit
();
assert
.
equal
(
initLimit
,
dailyLimit
);
});
it
(
'should be able to spend if daily limit is not reached'
,
async
function
()
{
let
limit
=
10
;
let
dayLimit
=
await
DayLimitMock
.
new
(
limit
);
await
dayLimit
.
attemptSpend
(
8
);
let
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
...
...
@@ -28,9 +30,6 @@ contract('DayLimit', function(accounts) {
});
it
(
'should prevent spending if daily limit is reached'
,
async
function
()
{
let
limit
=
10
;
let
dayLimit
=
await
DayLimitMock
.
new
(
limit
);
await
dayLimit
.
attemptSpend
(
8
);
let
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
...
...
@@ -43,9 +42,6 @@ contract('DayLimit', function(accounts) {
});
it
(
'should allow spending if daily limit is reached and then set higher'
,
async
function
()
{
let
limit
=
10
;
let
dayLimit
=
await
DayLimitMock
.
new
(
limit
);
await
dayLimit
.
attemptSpend
(
8
);
let
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
...
...
@@ -65,9 +61,6 @@ contract('DayLimit', function(accounts) {
});
it
(
'should allow spending if daily limit is reached and then amount spent is reset'
,
async
function
()
{
let
limit
=
10
;
let
dayLimit
=
await
DayLimitMock
.
new
(
limit
);
await
dayLimit
.
attemptSpend
(
8
);
let
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
...
...
test/PullPayment.js
View file @
1bb1d41b
var
PullPaymentMock
=
artifacts
.
require
(
"./helpers/PullPaymentMock.sol"
);
contract
(
'PullPayment'
,
function
(
accounts
)
{
let
ppce
;
let
amount
=
17
*
1
e18
;
beforeEach
(
async
function
()
{
ppce
=
await
PullPaymentMock
.
new
({
value
:
amount
});
});
it
(
"can't call asyncSend externally"
,
async
function
()
{
let
ppc
=
await
PullPaymentMock
.
new
();
assert
.
isUndefined
(
ppc
.
asyncSend
);
assert
.
isUndefined
(
ppce
.
asyncSend
);
});
it
(
"can record an async payment correctly"
,
async
function
()
{
let
AMOUNT
=
100
;
let
ppce
=
await
PullPaymentMock
.
new
();
let
callSend
=
await
ppce
.
callSend
(
accounts
[
0
],
AMOUNT
);
let
paymentsToAccount0
=
await
ppce
.
payments
(
accounts
[
0
]);
let
totalPayments
=
await
ppce
.
totalPayments
();
...
...
@@ -19,7 +23,6 @@ contract('PullPayment', function(accounts) {
});
it
(
"can add multiple balances on one account"
,
async
function
()
{
let
ppce
=
await
PullPaymentMock
.
new
();
let
call1
=
await
ppce
.
callSend
(
accounts
[
0
],
200
);
let
call2
=
await
ppce
.
callSend
(
accounts
[
0
],
300
);
let
paymentsToAccount0
=
await
ppce
.
payments
(
accounts
[
0
]);
...
...
@@ -30,7 +33,6 @@ contract('PullPayment', function(accounts) {
});
it
(
"can add balances on multiple accounts"
,
async
function
()
{
let
ppce
=
await
PullPaymentMock
.
new
();
let
call1
=
await
ppce
.
callSend
(
accounts
[
0
],
200
);
let
call2
=
await
ppce
.
callSend
(
accounts
[
1
],
300
);
...
...
@@ -45,18 +47,16 @@ contract('PullPayment', function(accounts) {
});
it
(
"can withdraw payment"
,
async
function
()
{
let
AMOUNT
=
17
*
1
e18
;
let
payee
=
accounts
[
1
];
let
initialBalance
=
web3
.
eth
.
getBalance
(
payee
);
let
ppce
=
await
PullPaymentMock
.
new
({
value
:
AMOUNT
});
let
call1
=
await
ppce
.
callSend
(
payee
,
AMOUNT
);
let
call1
=
await
ppce
.
callSend
(
payee
,
amount
);
let
payment1
=
await
ppce
.
payments
(
payee
);
assert
.
equal
(
payment1
,
AMOUNT
);
assert
.
equal
(
payment1
,
amount
);
let
totalPayments
=
await
ppce
.
totalPayments
();
assert
.
equal
(
totalPayments
,
AMOUNT
);
assert
.
equal
(
totalPayments
,
amount
);
let
withdraw
=
await
ppce
.
withdrawPayments
({
from
:
payee
});
let
payment2
=
await
ppce
.
payments
(
payee
);
...
...
@@ -66,7 +66,7 @@ contract('PullPayment', function(accounts) {
assert
.
equal
(
totalPayments
,
0
);
let
balance
=
web3
.
eth
.
getBalance
(
payee
);
assert
(
Math
.
abs
(
balance
-
initialBalance
-
AMOUNT
)
<
1
e16
);
assert
(
Math
.
abs
(
balance
-
initialBalance
-
amount
)
<
1
e16
);
});
});
test/StandardToken.js
View file @
1bb1d41b
...
...
@@ -5,8 +5,13 @@ var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol');
contract
(
'StandardToken'
,
function
(
accounts
)
{
let
token
;
beforeEach
(
async
function
()
{
token
=
await
StandardTokenMock
.
new
(
accounts
[
0
],
100
);
});
it
(
'should return the correct totalSupply after construction'
,
async
function
()
{
let
token
=
await
StandardTokenMock
.
new
(
accounts
[
0
],
100
);
let
totalSupply
=
await
token
.
totalSupply
();
assert
.
equal
(
totalSupply
,
100
);
...
...
@@ -56,7 +61,6 @@ contract('StandardToken', function(accounts) {
});
it
(
'should throw an error when trying to transfer more than allowed'
,
async
function
()
{
let
token
=
await
StandardTokenMock
.
new
();
await
token
.
approve
(
accounts
[
1
],
99
);
try
{
await
token
.
transferFrom
(
accounts
[
0
],
accounts
[
2
],
100
,
{
from
:
accounts
[
1
]});
...
...
test/TokenDestructible.js
View file @
1bb1d41b
...
...
@@ -5,9 +5,13 @@ var StandardTokenMock = artifacts.require("./helpers/StandardTokenMock.sol");
require
(
'./helpers/transactionMined.js'
);
contract
(
'TokenDestructible'
,
function
(
accounts
)
{
let
destructible
;
beforeEach
(
async
function
()
{
destructible
=
await
TokenDestructible
.
new
({
fron
:
accounts
[
0
],
value
:
web3
.
toWei
(
'10'
,
'ether'
)});
});
it
(
'should send balance to owner after destruction'
,
async
function
()
{
let
destructible
=
await
TokenDestructible
.
new
({
from
:
accounts
[
0
],
value
:
web3
.
toWei
(
'10'
,
'ether'
)});
let
owner
=
await
destructible
.
owner
();
let
initBalance
=
web3
.
eth
.
getBalance
(
owner
);
await
destructible
.
destroy
([],
{
from
:
owner
});
...
...
@@ -16,7 +20,6 @@ contract('TokenDestructible', function(accounts) {
});
it
(
'should send tokens to owner after destruction'
,
async
function
()
{
let
destructible
=
await
TokenDestructible
.
new
({
from
:
accounts
[
0
],
value
:
web3
.
toWei
(
'10'
,
'ether'
)});
let
owner
=
await
destructible
.
owner
();
let
token
=
await
StandardTokenMock
.
new
(
destructible
.
address
,
100
);
let
initContractBalance
=
await
token
.
balanceOf
(
destructible
.
address
);
...
...
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