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
94797978
Unverified
Commit
94797978
authored
Aug 06, 2018
by
Nicolás Venturo
Committed by
GitHub
Aug 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SplitPayment now requires payees. (#1131)
* SplitPayment now requires payees. * Improved test phrasing.
parent
31ac59b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
SplitPayment.sol
contracts/payment/SplitPayment.sol
+1
-0
SplitPayment.test.js
test/payment/SplitPayment.test.js
+14
-0
No files found.
contracts/payment/SplitPayment.sol
View file @
94797978
...
@@ -23,6 +23,7 @@ contract SplitPayment {
...
@@ -23,6 +23,7 @@ contract SplitPayment {
*/
*/
constructor(address[] _payees, uint256[] _shares) public payable {
constructor(address[] _payees, uint256[] _shares) public payable {
require(_payees.length == _shares.length);
require(_payees.length == _shares.length);
require(_payees.length > 0);
for (uint256 i = 0; i < _payees.length; i++) {
for (uint256 i = 0; i < _payees.length; i++) {
addPayee(_payees[i], _shares[i]);
addPayee(_payees[i], _shares[i]);
...
...
test/payment/SplitPayment.test.js
View file @
94797978
...
@@ -13,6 +13,19 @@ const SplitPayment = artifacts.require('SplitPayment');
...
@@ -13,6 +13,19 @@ const SplitPayment = artifacts.require('SplitPayment');
contract
(
'SplitPayment'
,
function
([
_
,
owner
,
payee1
,
payee2
,
payee3
,
nonpayee1
,
payer1
])
{
contract
(
'SplitPayment'
,
function
([
_
,
owner
,
payee1
,
payee2
,
payee3
,
nonpayee1
,
payer1
])
{
const
amount
=
web3
.
toWei
(
1.0
,
'ether'
);
const
amount
=
web3
.
toWei
(
1.0
,
'ether'
);
it
(
'cannot be created with no payees'
,
async
function
()
{
await
expectThrow
(
SplitPayment
.
new
([],
[]),
EVMThrow
);
});
it
(
'requires shares for each payee'
,
async
function
()
{
await
expectThrow
(
SplitPayment
.
new
([
payee1
,
payee2
,
payee3
],
[
20
,
30
]),
EVMThrow
);
});
it
(
'requires a payee for each share'
,
async
function
()
{
await
expectThrow
(
SplitPayment
.
new
([
payee1
,
payee2
],
[
20
,
30
,
40
]),
EVMThrow
);
});
context
(
'once deployed'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
payees
=
[
payee1
,
payee2
,
payee3
];
this
.
payees
=
[
payee1
,
payee2
,
payee3
];
this
.
shares
=
[
20
,
10
,
70
];
this
.
shares
=
[
20
,
10
,
70
];
...
@@ -77,4 +90,5 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
...
@@ -77,4 +90,5 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
const
totalReleased
=
await
this
.
contract
.
totalReleased
.
call
();
const
totalReleased
=
await
this
.
contract
.
totalReleased
.
call
();
totalReleased
.
should
.
be
.
bignumber
.
equal
(
initBalance
);
totalReleased
.
should
.
be
.
bignumber
.
equal
(
initBalance
);
});
});
});
});
});
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