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
ace35fde
Unverified
Commit
ace35fde
authored
Sep 16, 2020
by
Francisco Giordano
Committed by
GitHub
Sep 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update all dependencies transitively (#2363)
parent
bf4c9d70
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
281 additions
and
280 deletions
+281
-280
package-lock.json
package-lock.json
+0
-0
renovate.json
renovate.json
+2
-1
gen-nav.js
scripts/gen-nav.js
+1
-1
update-changelog-release-date.js
scripts/release/update-changelog-release-date.js
+1
-1
ERC721GSNRecipientMock.test.js
test/GSN/ERC721GSNRecipientMock.test.js
+3
-3
GSNRecipient.test.js
test/GSN/GSNRecipient.test.js
+2
-2
GSNRecipientSignature.test.js
test/GSN/GSNRecipientSignature.test.js
+11
-11
AccessControl.test.js
test/access/AccessControl.test.js
+5
-5
Ownable.test.js
test/access/Ownable.test.js
+3
-3
ECDSA.test.js
test/cryptography/ECDSA.test.js
+2
-2
sign.js
test/helpers/sign.js
+1
-1
ERC1820Implementer.test.js
test/introspection/ERC1820Implementer.test.js
+3
-3
PaymentSplitter.test.js
test/payment/PaymentSplitter.test.js
+7
-7
ConditionalEscrow.test.js
test/payment/escrow/ConditionalEscrow.test.js
+1
-1
Escrow.behavior.js
test/payment/escrow/Escrow.behavior.js
+2
-2
RefundEscrow.test.js
test/payment/escrow/RefundEscrow.test.js
+13
-13
ERC1155PresetMinterPauser.test.js
test/presets/ERC1155PresetMinterPauser.test.js
+9
-9
ERC20PresetMinterPauser.test.js
test/presets/ERC20PresetMinterPauser.test.js
+2
-2
ERC721PresetMinterPauserAutoId.test.js
test/presets/ERC721PresetMinterPauserAutoId.test.js
+3
-3
ProxyAdmin.test.js
test/proxy/ProxyAdmin.test.js
+3
-3
TransparentUpgradeableProxy.behaviour.js
test/proxy/TransparentUpgradeableProxy.behaviour.js
+1
-1
ERC1155.behavior.js
test/token/ERC1155/ERC1155.behavior.js
+43
-43
ERC1155.test.js
test/token/ERC1155/ERC1155.test.js
+18
-18
ERC1155Burnable.test.js
test/token/ERC1155/ERC1155Burnable.test.js
+2
-2
ERC1155Pausable.test.js
test/token/ERC1155/ERC1155Pausable.test.js
+9
-9
ERC20.behavior.js
test/token/ERC20/ERC20.behavior.js
+10
-10
ERC20.test.js
test/token/ERC20/ERC20.test.js
+8
-8
ERC20Capped.test.js
test/token/ERC20/ERC20Capped.test.js
+1
-1
ERC20Pausable.test.js
test/token/ERC20/ERC20Pausable.test.js
+4
-4
ERC20Snapshot.test.js
test/token/ERC20/ERC20Snapshot.test.js
+7
-7
SafeERC20.test.js
test/token/ERC20/SafeERC20.test.js
+3
-3
TokenTimelock.test.js
test/token/ERC20/TokenTimelock.test.js
+1
-1
ERC20Burnable.behavior.js
test/token/ERC20/behaviors/ERC20Burnable.behavior.js
+3
-3
ERC721.test.js
test/token/ERC721/ERC721.test.js
+34
-34
ERC721Burnable.test.js
test/token/ERC721/ERC721Burnable.test.js
+3
-3
ERC721Pausable.test.js
test/token/ERC721/ERC721Pausable.test.js
+6
-6
ERC777.behavior.js
test/token/ERC777/ERC777.behavior.js
+18
-18
ERC777.test.js
test/token/ERC777/ERC777.test.js
+4
-4
Address.test.js
test/utils/Address.test.js
+9
-9
Create2.test.js
test/utils/Create2.test.js
+4
-4
EnumerableMap.test.js
test/utils/EnumerableMap.test.js
+3
-3
EnumerableSet.behavior.js
test/utils/EnumerableSet.behavior.js
+1
-1
Pausable.test.js
test/utils/Pausable.test.js
+2
-2
ReentrancyGuard.test.js
test/utils/ReentrancyGuard.test.js
+2
-2
SafeCast.test.js
test/utils/SafeCast.test.js
+11
-11
No files found.
package-lock.json
View file @
ace35fde
This source diff could not be displayed because it is too large. You can
view the blob
instead.
renovate.json
View file @
ace35fde
{
{
"rangeStrategy"
:
"
update-lockfil
e"
,
"rangeStrategy"
:
"
replac
e"
,
"extends"
:
[
"extends"
:
[
"config:base"
,
"config:base"
,
":maintainLockFilesWeekly"
,
"group:allNonMajor"
,
"group:allNonMajor"
,
"schedule:weekly"
"schedule:weekly"
],
],
...
...
scripts/gen-nav.js
View file @
ace35fde
...
@@ -7,7 +7,7 @@ const startCase = require('lodash.startcase');
...
@@ -7,7 +7,7 @@ const startCase = require('lodash.startcase');
const
baseDir
=
process
.
argv
[
2
];
const
baseDir
=
process
.
argv
[
2
];
const
files
=
proc
.
execFileSync
(
const
files
=
proc
.
execFileSync
(
'find'
,
[
baseDir
,
'-type'
,
'f'
],
{
encoding
:
'utf8'
}
'find'
,
[
baseDir
,
'-type'
,
'f'
],
{
encoding
:
'utf8'
}
,
).
split
(
'
\
n'
).
filter
(
s
=>
s
!==
''
);
).
split
(
'
\
n'
).
filter
(
s
=>
s
!==
''
);
console
.
log
(
'.API'
);
console
.
log
(
'.API'
);
...
...
scripts/release/update-changelog-release-date.js
View file @
ace35fde
...
@@ -27,7 +27,7 @@ if (changelog.indexOf(`## ${version} (unreleased)`) === -1) {
...
@@ -27,7 +27,7 @@ if (changelog.indexOf(`## ${version} (unreleased)`) === -1) {
fs
.
writeFileSync
(
'CHANGELOG.md'
,
changelog
.
replace
(
fs
.
writeFileSync
(
'CHANGELOG.md'
,
changelog
.
replace
(
`##
${
version
}
(unreleased)`
,
`##
${
version
}
(unreleased)`
,
`##
${
version
}
(
${
new
Date
().
toISOString
().
split
(
'T'
)[
0
]}
)`
)
`##
${
version
}
(
${
new
Date
().
toISOString
().
split
(
'T'
)[
0
]}
)`
)
,
);
);
cp
.
execSync
(
'git add CHANGELOG.md'
,
{
stdio
:
'inherit'
});
cp
.
execSync
(
'git add CHANGELOG.md'
,
{
stdio
:
'inherit'
});
test/GSN/ERC721GSNRecipientMock.test.js
View file @
ace35fde
...
@@ -41,9 +41,9 @@ describe('ERC721GSNRecipient (integration)', function () {
...
@@ -41,9 +41,9 @@ describe('ERC721GSNRecipient (integration)', function () {
await
web3
.
eth
.
sign
(
await
web3
.
eth
.
sign
(
web3
.
utils
.
soliditySha3
(
web3
.
utils
.
soliditySha3
(
// eslint-disable-next-line max-len
// eslint-disable-next-line max-len
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
this
.
token
.
address
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
this
.
token
.
address
,
),
signer
),
signer
,
)
)
,
);
);
await
testMintToken
(
this
.
token
,
sender
,
tokenId
,
{
useGSN
:
true
,
approveFunction
});
await
testMintToken
(
this
.
token
,
sender
,
tokenId
,
{
useGSN
:
true
,
approveFunction
});
...
...
test/GSN/GSNRecipient.test.js
View file @
ace35fde
...
@@ -38,13 +38,13 @@ describe('GSNRecipient', function () {
...
@@ -38,13 +38,13 @@ describe('GSNRecipient', function () {
it
(
'cannot upgrade to the same RelayHub'
,
async
function
()
{
it
(
'cannot upgrade to the same RelayHub'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
recipient
.
upgradeRelayHub
(
singletonRelayHub
),
this
.
recipient
.
upgradeRelayHub
(
singletonRelayHub
),
'GSNRecipient: new RelayHub is the current one'
'GSNRecipient: new RelayHub is the current one'
,
);
);
});
});
it
(
'cannot upgrade to the zero address'
,
async
function
()
{
it
(
'cannot upgrade to the zero address'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
recipient
.
upgradeRelayHub
(
ZERO_ADDRESS
),
'GSNRecipient: new RelayHub is the zero address'
this
.
recipient
.
upgradeRelayHub
(
ZERO_ADDRESS
),
'GSNRecipient: new RelayHub is the zero address'
,
);
);
});
});
...
...
test/GSN/GSNRecipientSignature.test.js
View file @
ace35fde
...
@@ -26,9 +26,9 @@ describe('GSNRecipientSignature', function () {
...
@@ -26,9 +26,9 @@ describe('GSNRecipientSignature', function () {
it
(
'fails when constructor called with a zero address'
,
async
function
()
{
it
(
'fails when constructor called with a zero address'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
GSNRecipientSignatureMock
.
new
(
GSNRecipientSignatureMock
.
new
(
ZERO_ADDRESS
ZERO_ADDRESS
,
),
),
'GSNRecipientSignature: trusted signer is the zero address'
'GSNRecipientSignature: trusted signer is the zero address'
,
);
);
});
});
});
});
...
@@ -49,9 +49,9 @@ describe('GSNRecipientSignature', function () {
...
@@ -49,9 +49,9 @@ describe('GSNRecipientSignature', function () {
web3
.
utils
.
soliditySha3
(
web3
.
utils
.
soliditySha3
(
// the nonce is not signed
// the nonce is not signed
// eslint-disable-next-line max-len
// eslint-disable-next-line max-len
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
)
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
)
,
),
signer
),
signer
,
)
)
,
);
);
await
gsn
.
expectError
(
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
}));
await
gsn
.
expectError
(
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
}));
...
@@ -63,9 +63,9 @@ describe('GSNRecipientSignature', function () {
...
@@ -63,9 +63,9 @@ describe('GSNRecipientSignature', function () {
await
web3
.
eth
.
sign
(
await
web3
.
eth
.
sign
(
web3
.
utils
.
soliditySha3
(
web3
.
utils
.
soliditySha3
(
// eslint-disable-next-line max-len
// eslint-disable-next-line max-len
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
data
.
to
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
data
.
to
,
),
signer
),
signer
,
)
)
,
);
);
const
{
tx
}
=
await
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
});
const
{
tx
}
=
await
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
});
...
@@ -79,9 +79,9 @@ describe('GSNRecipientSignature', function () {
...
@@ -79,9 +79,9 @@ describe('GSNRecipientSignature', function () {
await
web3
.
eth
.
sign
(
await
web3
.
eth
.
sign
(
web3
.
utils
.
soliditySha3
(
web3
.
utils
.
soliditySha3
(
// eslint-disable-next-line max-len
// eslint-disable-next-line max-len
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
data
.
to
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
data
.
to
,
),
other
),
other
,
)
)
,
);
);
await
gsn
.
expectError
(
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
}));
await
gsn
.
expectError
(
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
}));
...
...
test/access/AccessControl.test.js
View file @
ace35fde
...
@@ -42,7 +42,7 @@ describe('AccessControl', function () {
...
@@ -42,7 +42,7 @@ describe('AccessControl', function () {
it
(
'non-admin cannot grant role to other accounts'
,
async
function
()
{
it
(
'non-admin cannot grant role to other accounts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
accessControl
.
grantRole
(
ROLE
,
authorized
,
{
from
:
other
}),
this
.
accessControl
.
grantRole
(
ROLE
,
authorized
,
{
from
:
other
}),
'AccessControl: sender must be an admin to grant'
'AccessControl: sender must be an admin to grant'
,
);
);
});
});
...
@@ -76,7 +76,7 @@ describe('AccessControl', function () {
...
@@ -76,7 +76,7 @@ describe('AccessControl', function () {
it
(
'non-admin cannot revoke role'
,
async
function
()
{
it
(
'non-admin cannot revoke role'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
accessControl
.
revokeRole
(
ROLE
,
authorized
,
{
from
:
other
}),
this
.
accessControl
.
revokeRole
(
ROLE
,
authorized
,
{
from
:
other
}),
'AccessControl: sender must be an admin to revoke'
'AccessControl: sender must be an admin to revoke'
,
);
);
});
});
...
@@ -110,7 +110,7 @@ describe('AccessControl', function () {
...
@@ -110,7 +110,7 @@ describe('AccessControl', function () {
it
(
'only the sender can renounce their roles'
,
async
function
()
{
it
(
'only the sender can renounce their roles'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
accessControl
.
renounceRole
(
ROLE
,
authorized
,
{
from
:
admin
}),
this
.
accessControl
.
renounceRole
(
ROLE
,
authorized
,
{
from
:
admin
}),
'AccessControl: can only renounce roles for self'
'AccessControl: can only renounce roles for self'
,
);
);
});
});
...
@@ -170,14 +170,14 @@ describe('AccessControl', function () {
...
@@ -170,14 +170,14 @@ describe('AccessControl', function () {
it
(
'a role
\'
s previous admins no longer grant roles'
,
async
function
()
{
it
(
'a role
\'
s previous admins no longer grant roles'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
accessControl
.
grantRole
(
ROLE
,
authorized
,
{
from
:
admin
}),
this
.
accessControl
.
grantRole
(
ROLE
,
authorized
,
{
from
:
admin
}),
'AccessControl: sender must be an admin to grant'
'AccessControl: sender must be an admin to grant'
,
);
);
});
});
it
(
'a role
\'
s previous admins no longer revoke roles'
,
async
function
()
{
it
(
'a role
\'
s previous admins no longer revoke roles'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
accessControl
.
revokeRole
(
ROLE
,
authorized
,
{
from
:
admin
}),
this
.
accessControl
.
revokeRole
(
ROLE
,
authorized
,
{
from
:
admin
}),
'AccessControl: sender must be an admin to revoke'
'AccessControl: sender must be an admin to revoke'
,
);
);
});
});
});
});
...
...
test/access/Ownable.test.js
View file @
ace35fde
...
@@ -28,14 +28,14 @@ describe('Ownable', function () {
...
@@ -28,14 +28,14 @@ describe('Ownable', function () {
it
(
'prevents non-owners from transferring'
,
async
function
()
{
it
(
'prevents non-owners from transferring'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
ownable
.
transferOwnership
(
other
,
{
from
:
other
}),
this
.
ownable
.
transferOwnership
(
other
,
{
from
:
other
}),
'Ownable: caller is not the owner'
'Ownable: caller is not the owner'
,
);
);
});
});
it
(
'guards ownership against stuck state'
,
async
function
()
{
it
(
'guards ownership against stuck state'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
ownable
.
transferOwnership
(
ZERO_ADDRESS
,
{
from
:
owner
}),
this
.
ownable
.
transferOwnership
(
ZERO_ADDRESS
,
{
from
:
owner
}),
'Ownable: new owner is the zero address'
'Ownable: new owner is the zero address'
,
);
);
});
});
});
});
...
@@ -51,7 +51,7 @@ describe('Ownable', function () {
...
@@ -51,7 +51,7 @@ describe('Ownable', function () {
it
(
'prevents non-owners from renouncement'
,
async
function
()
{
it
(
'prevents non-owners from renouncement'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
ownable
.
renounceOwnership
({
from
:
other
}),
this
.
ownable
.
renounceOwnership
({
from
:
other
}),
'Ownable: caller is not the owner'
'Ownable: caller is not the owner'
,
);
);
});
});
});
});
...
...
test/cryptography/ECDSA.test.js
View file @
ace35fde
...
@@ -26,7 +26,7 @@ describe('ECDSA', function () {
...
@@ -26,7 +26,7 @@ describe('ECDSA', function () {
await
expectRevert
(
await
expectRevert
(
// eslint-disable-next-line max-len
// eslint-disable-next-line max-len
this
.
ecdsa
.
recover
(
TEST_MESSAGE
,
'0x01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
),
this
.
ecdsa
.
recover
(
TEST_MESSAGE
,
'0x01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
),
'ECDSA: invalid signature length'
'ECDSA: invalid signature length'
,
);
);
});
});
});
});
...
@@ -116,7 +116,7 @@ describe('ECDSA', function () {
...
@@ -116,7 +116,7 @@ describe('ECDSA', function () {
// Recover the signer address from the generated message and signature.
// Recover the signer address from the generated message and signature.
expect
(
await
this
.
ecdsa
.
recover
(
expect
(
await
this
.
ecdsa
.
recover
(
toEthSignedMessageHash
(
TEST_MESSAGE
),
toEthSignedMessageHash
(
TEST_MESSAGE
),
signature
signature
,
)).
to
.
equal
(
other
);
)).
to
.
equal
(
other
);
});
});
});
});
...
...
test/helpers/sign.js
View file @
ace35fde
...
@@ -47,7 +47,7 @@ const getSignFor = (contract, signer) => (redeemer, methodName, methodArgs = [])
...
@@ -47,7 +47,7 @@ const getSignFor = (contract, signer) => (redeemer, methodName, methodArgs = [])
if
(
methodArgs
.
length
>
0
)
{
if
(
methodArgs
.
length
>
0
)
{
parts
.
push
(
parts
.
push
(
contract
.
contract
.
methods
[
methodName
](...
methodArgs
.
concat
([
DUMMY_SIGNATURE
])).
encodeABI
()
contract
.
contract
.
methods
[
methodName
](...
methodArgs
.
concat
([
DUMMY_SIGNATURE
])).
encodeABI
()
.
slice
(
0
,
-
1
*
PADDED_SIGNATURE_SIZE
)
.
slice
(
0
,
-
1
*
PADDED_SIGNATURE_SIZE
)
,
);
);
}
else
{
}
else
{
const
abi
=
contract
.
abi
.
find
(
abi
=>
abi
.
name
===
methodName
);
const
abi
=
contract
.
abi
.
find
(
abi
=>
abi
.
name
===
methodName
);
...
...
test/introspection/ERC1820Implementer.test.js
View file @
ace35fde
...
@@ -29,9 +29,9 @@ describe('ERC1820Implementer', function () {
...
@@ -29,9 +29,9 @@ describe('ERC1820Implementer', function () {
it
(
'reverts when attempting to set as implementer in the registry'
,
async
function
()
{
it
(
'reverts when attempting to set as implementer in the registry'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
registry
.
setInterfaceImplementer
(
this
.
registry
.
setInterfaceImplementer
(
implementee
,
this
.
interfaceA
,
this
.
implementer
.
address
,
{
from
:
implementee
}
implementee
,
this
.
interfaceA
,
this
.
implementer
.
address
,
{
from
:
implementee
}
,
),
),
'Does not implement the interface'
'Does not implement the interface'
,
);
);
});
});
});
});
...
@@ -58,7 +58,7 @@ describe('ERC1820Implementer', function () {
...
@@ -58,7 +58,7 @@ describe('ERC1820Implementer', function () {
it
(
'can be set as an implementer for supported interfaces in the registry'
,
async
function
()
{
it
(
'can be set as an implementer for supported interfaces in the registry'
,
async
function
()
{
await
this
.
registry
.
setInterfaceImplementer
(
await
this
.
registry
.
setInterfaceImplementer
(
implementee
,
this
.
interfaceA
,
this
.
implementer
.
address
,
{
from
:
implementee
}
implementee
,
this
.
interfaceA
,
this
.
implementer
.
address
,
{
from
:
implementee
}
,
);
);
expect
(
await
this
.
registry
.
getInterfaceImplementer
(
implementee
,
this
.
interfaceA
))
expect
(
await
this
.
registry
.
getInterfaceImplementer
(
implementee
,
this
.
interfaceA
))
...
...
test/payment/PaymentSplitter.test.js
View file @
ace35fde
...
@@ -18,31 +18,31 @@ describe('PaymentSplitter', function () {
...
@@ -18,31 +18,31 @@ describe('PaymentSplitter', function () {
it
(
'rejects more payees than shares'
,
async
function
()
{
it
(
'rejects more payees than shares'
,
async
function
()
{
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
,
payee3
],
[
20
,
30
]),
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
,
payee3
],
[
20
,
30
]),
'PaymentSplitter: payees and shares length mismatch'
'PaymentSplitter: payees and shares length mismatch'
,
);
);
});
});
it
(
'rejects more shares than payees'
,
async
function
()
{
it
(
'rejects more shares than payees'
,
async
function
()
{
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
],
[
20
,
30
,
40
]),
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
],
[
20
,
30
,
40
]),
'PaymentSplitter: payees and shares length mismatch'
'PaymentSplitter: payees and shares length mismatch'
,
);
);
});
});
it
(
'rejects null payees'
,
async
function
()
{
it
(
'rejects null payees'
,
async
function
()
{
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
ZERO_ADDRESS
],
[
20
,
30
]),
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
ZERO_ADDRESS
],
[
20
,
30
]),
'PaymentSplitter: account is the zero address'
'PaymentSplitter: account is the zero address'
,
);
);
});
});
it
(
'rejects zero-valued shares'
,
async
function
()
{
it
(
'rejects zero-valued shares'
,
async
function
()
{
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
],
[
20
,
0
]),
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
],
[
20
,
0
]),
'PaymentSplitter: shares are 0'
'PaymentSplitter: shares are 0'
,
);
);
});
});
it
(
'rejects repeated payees'
,
async
function
()
{
it
(
'rejects repeated payees'
,
async
function
()
{
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee1
],
[
20
,
30
]),
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee1
],
[
20
,
30
]),
'PaymentSplitter: account already has shares'
'PaymentSplitter: account already has shares'
,
);
);
});
});
...
@@ -84,13 +84,13 @@ describe('PaymentSplitter', function () {
...
@@ -84,13 +84,13 @@ describe('PaymentSplitter', function () {
describe
(
'release'
,
async
function
()
{
describe
(
'release'
,
async
function
()
{
it
(
'reverts if no funds to claim'
,
async
function
()
{
it
(
'reverts if no funds to claim'
,
async
function
()
{
await
expectRevert
(
this
.
contract
.
release
(
payee1
),
await
expectRevert
(
this
.
contract
.
release
(
payee1
),
'PaymentSplitter: account is not due payment'
'PaymentSplitter: account is not due payment'
,
);
);
});
});
it
(
'reverts if non-payee want to claim'
,
async
function
()
{
it
(
'reverts if non-payee want to claim'
,
async
function
()
{
await
send
.
ether
(
payer1
,
this
.
contract
.
address
,
amount
);
await
send
.
ether
(
payer1
,
this
.
contract
.
address
,
amount
);
await
expectRevert
(
this
.
contract
.
release
(
nonpayee1
),
await
expectRevert
(
this
.
contract
.
release
(
nonpayee1
),
'PaymentSplitter: account has no shares'
'PaymentSplitter: account has no shares'
,
);
);
});
});
});
});
...
...
test/payment/escrow/ConditionalEscrow.test.js
View file @
ace35fde
...
@@ -31,7 +31,7 @@ describe('ConditionalEscrow', function () {
...
@@ -31,7 +31,7 @@ describe('ConditionalEscrow', function () {
await
this
.
escrow
.
deposit
(
payee
,
{
from
:
owner
,
value
:
amount
});
await
this
.
escrow
.
deposit
(
payee
,
{
from
:
owner
,
value
:
amount
});
await
expectRevert
(
this
.
escrow
.
withdraw
(
payee
,
{
from
:
owner
}),
await
expectRevert
(
this
.
escrow
.
withdraw
(
payee
,
{
from
:
owner
}),
'ConditionalEscrow: payee is not allowed to withdraw'
'ConditionalEscrow: payee is not allowed to withdraw'
,
);
);
});
});
});
});
...
...
test/payment/escrow/Escrow.behavior.js
View file @
ace35fde
...
@@ -21,7 +21,7 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
...
@@ -21,7 +21,7 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
it
(
'only the owner can deposit'
,
async
function
()
{
it
(
'only the owner can deposit'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
deposit
(
payee1
,
{
from
:
payee2
}),
await
expectRevert
(
this
.
escrow
.
deposit
(
payee1
,
{
from
:
payee2
}),
'Ownable: caller is not the owner'
'Ownable: caller is not the owner'
,
);
);
});
});
...
@@ -73,7 +73,7 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
...
@@ -73,7 +73,7 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
it
(
'only the owner can withdraw'
,
async
function
()
{
it
(
'only the owner can withdraw'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
withdraw
(
payee1
,
{
from
:
payee1
}),
await
expectRevert
(
this
.
escrow
.
withdraw
(
payee1
,
{
from
:
payee1
}),
'Ownable: caller is not the owner'
'Ownable: caller is not the owner'
,
);
);
});
});
...
...
test/payment/escrow/RefundEscrow.test.js
View file @
ace35fde
...
@@ -15,7 +15,7 @@ describe('RefundEscrow', function () {
...
@@ -15,7 +15,7 @@ describe('RefundEscrow', function () {
it
(
'requires a non-null beneficiary'
,
async
function
()
{
it
(
'requires a non-null beneficiary'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
RefundEscrow
.
new
(
ZERO_ADDRESS
,
{
from
:
owner
}),
'RefundEscrow: beneficiary is the zero address'
RefundEscrow
.
new
(
ZERO_ADDRESS
,
{
from
:
owner
}),
'RefundEscrow: beneficiary is the zero address'
,
);
);
});
});
...
@@ -39,21 +39,21 @@ describe('RefundEscrow', function () {
...
@@ -39,21 +39,21 @@ describe('RefundEscrow', function () {
it
(
'does not refund refundees'
,
async
function
()
{
it
(
'does not refund refundees'
,
async
function
()
{
await
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
});
await
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
});
await
expectRevert
(
this
.
escrow
.
withdraw
(
refundee1
),
await
expectRevert
(
this
.
escrow
.
withdraw
(
refundee1
),
'ConditionalEscrow: payee is not allowed to withdraw'
'ConditionalEscrow: payee is not allowed to withdraw'
,
);
);
});
});
it
(
'does not allow beneficiary withdrawal'
,
async
function
()
{
it
(
'does not allow beneficiary withdrawal'
,
async
function
()
{
await
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
});
await
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
});
await
expectRevert
(
this
.
escrow
.
beneficiaryWithdraw
(),
await
expectRevert
(
this
.
escrow
.
beneficiaryWithdraw
(),
'RefundEscrow: beneficiary can only withdraw while closed'
'RefundEscrow: beneficiary can only withdraw while closed'
,
);
);
});
});
});
});
it
(
'only the owner can enter closed state'
,
async
function
()
{
it
(
'only the owner can enter closed state'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
close
({
from
:
beneficiary
}),
await
expectRevert
(
this
.
escrow
.
close
({
from
:
beneficiary
}),
'Ownable: caller is not the owner'
'Ownable: caller is not the owner'
,
);
);
const
{
logs
}
=
await
this
.
escrow
.
close
({
from
:
owner
});
const
{
logs
}
=
await
this
.
escrow
.
close
({
from
:
owner
});
...
@@ -69,13 +69,13 @@ describe('RefundEscrow', function () {
...
@@ -69,13 +69,13 @@ describe('RefundEscrow', function () {
it
(
'rejects deposits'
,
async
function
()
{
it
(
'rejects deposits'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
}),
await
expectRevert
(
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
}),
'RefundEscrow: can only deposit while active'
'RefundEscrow: can only deposit while active'
,
);
);
});
});
it
(
'does not refund refundees'
,
async
function
()
{
it
(
'does not refund refundees'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
withdraw
(
refundee1
),
await
expectRevert
(
this
.
escrow
.
withdraw
(
refundee1
),
'ConditionalEscrow: payee is not allowed to withdraw'
'ConditionalEscrow: payee is not allowed to withdraw'
,
);
);
});
});
...
@@ -87,20 +87,20 @@ describe('RefundEscrow', function () {
...
@@ -87,20 +87,20 @@ describe('RefundEscrow', function () {
it
(
'prevents entering the refund state'
,
async
function
()
{
it
(
'prevents entering the refund state'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
enableRefunds
({
from
:
owner
}),
await
expectRevert
(
this
.
escrow
.
enableRefunds
({
from
:
owner
}),
'RefundEscrow: can only enable refunds while active'
'RefundEscrow: can only enable refunds while active'
,
);
);
});
});
it
(
'prevents re-entering the closed state'
,
async
function
()
{
it
(
'prevents re-entering the closed state'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
close
({
from
:
owner
}),
await
expectRevert
(
this
.
escrow
.
close
({
from
:
owner
}),
'RefundEscrow: can only close while active'
'RefundEscrow: can only close while active'
,
);
);
});
});
});
});
it
(
'only the owner can enter refund state'
,
async
function
()
{
it
(
'only the owner can enter refund state'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
enableRefunds
({
from
:
beneficiary
}),
await
expectRevert
(
this
.
escrow
.
enableRefunds
({
from
:
beneficiary
}),
'Ownable: caller is not the owner'
'Ownable: caller is not the owner'
,
);
);
const
{
logs
}
=
await
this
.
escrow
.
enableRefunds
({
from
:
owner
});
const
{
logs
}
=
await
this
.
escrow
.
enableRefunds
({
from
:
owner
});
...
@@ -116,7 +116,7 @@ describe('RefundEscrow', function () {
...
@@ -116,7 +116,7 @@ describe('RefundEscrow', function () {
it
(
'rejects deposits'
,
async
function
()
{
it
(
'rejects deposits'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
}),
await
expectRevert
(
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
}),
'RefundEscrow: can only deposit while active'
'RefundEscrow: can only deposit while active'
,
);
);
});
});
...
@@ -130,19 +130,19 @@ describe('RefundEscrow', function () {
...
@@ -130,19 +130,19 @@ describe('RefundEscrow', function () {
it
(
'does not allow beneficiary withdrawal'
,
async
function
()
{
it
(
'does not allow beneficiary withdrawal'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
beneficiaryWithdraw
(),
await
expectRevert
(
this
.
escrow
.
beneficiaryWithdraw
(),
'RefundEscrow: beneficiary can only withdraw while closed'
'RefundEscrow: beneficiary can only withdraw while closed'
,
);
);
});
});
it
(
'prevents entering the closed state'
,
async
function
()
{
it
(
'prevents entering the closed state'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
close
({
from
:
owner
}),
await
expectRevert
(
this
.
escrow
.
close
({
from
:
owner
}),
'RefundEscrow: can only close while active'
'RefundEscrow: can only close while active'
,
);
);
});
});
it
(
'prevents re-entering the refund state'
,
async
function
()
{
it
(
'prevents re-entering the refund state'
,
async
function
()
{
await
expectRevert
(
this
.
escrow
.
enableRefunds
({
from
:
owner
}),
await
expectRevert
(
this
.
escrow
.
enableRefunds
({
from
:
owner
}),
'RefundEscrow: can only enable refunds while active'
'RefundEscrow: can only enable refunds while active'
,
);
);
});
});
});
});
...
...
test/presets/ERC1155PresetMinterPauser.test.js
View file @
ace35fde
...
@@ -50,7 +50,7 @@ describe('ERC1155PresetMinterPauser', function () {
...
@@ -50,7 +50,7 @@ describe('ERC1155PresetMinterPauser', function () {
it
(
'deployer can mint tokens'
,
async
function
()
{
it
(
'deployer can mint tokens'
,
async
function
()
{
const
receipt
=
await
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
deployer
});
const
receipt
=
await
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
deployer
});
expectEvent
(
receipt
,
'TransferSingle'
,
expectEvent
(
receipt
,
'TransferSingle'
,
{
operator
:
deployer
,
from
:
ZERO_ADDRESS
,
to
:
other
,
value
:
firstTokenIdAmount
,
id
:
firstTokenId
}
{
operator
:
deployer
,
from
:
ZERO_ADDRESS
,
to
:
other
,
value
:
firstTokenIdAmount
,
id
:
firstTokenId
}
,
);
);
expect
(
await
this
.
token
.
balanceOf
(
other
,
firstTokenId
)).
to
.
be
.
bignumber
.
equal
(
firstTokenIdAmount
);
expect
(
await
this
.
token
.
balanceOf
(
other
,
firstTokenId
)).
to
.
be
.
bignumber
.
equal
(
firstTokenIdAmount
);
...
@@ -59,7 +59,7 @@ describe('ERC1155PresetMinterPauser', function () {
...
@@ -59,7 +59,7 @@ describe('ERC1155PresetMinterPauser', function () {
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
other
}),
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
other
}),
'ERC1155PresetMinterPauser: must have minter role to mint'
'ERC1155PresetMinterPauser: must have minter role to mint'
,
);
);
});
});
});
});
...
@@ -67,11 +67,11 @@ describe('ERC1155PresetMinterPauser', function () {
...
@@ -67,11 +67,11 @@ describe('ERC1155PresetMinterPauser', function () {
describe
(
'batched minting'
,
function
()
{
describe
(
'batched minting'
,
function
()
{
it
(
'deployer can batch mint tokens'
,
async
function
()
{
it
(
'deployer can batch mint tokens'
,
async
function
()
{
const
receipt
=
await
this
.
token
.
mintBatch
(
const
receipt
=
await
this
.
token
.
mintBatch
(
other
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenIdAmount
,
secondTokenIdAmount
],
'0x'
,
{
from
:
deployer
}
other
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenIdAmount
,
secondTokenIdAmount
],
'0x'
,
{
from
:
deployer
}
,
);
);
expectEvent
(
receipt
,
'TransferBatch'
,
expectEvent
(
receipt
,
'TransferBatch'
,
{
operator
:
deployer
,
from
:
ZERO_ADDRESS
,
to
:
other
}
{
operator
:
deployer
,
from
:
ZERO_ADDRESS
,
to
:
other
}
,
);
);
expect
(
await
this
.
token
.
balanceOf
(
other
,
firstTokenId
)).
to
.
be
.
bignumber
.
equal
(
firstTokenIdAmount
);
expect
(
await
this
.
token
.
balanceOf
(
other
,
firstTokenId
)).
to
.
be
.
bignumber
.
equal
(
firstTokenIdAmount
);
...
@@ -80,9 +80,9 @@ describe('ERC1155PresetMinterPauser', function () {
...
@@ -80,9 +80,9 @@ describe('ERC1155PresetMinterPauser', function () {
it
(
'other accounts cannot batch mint tokens'
,
async
function
()
{
it
(
'other accounts cannot batch mint tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mintBatch
(
this
.
token
.
mintBatch
(
other
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenIdAmount
,
secondTokenIdAmount
],
'0x'
,
{
from
:
other
}
other
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenIdAmount
,
secondTokenIdAmount
],
'0x'
,
{
from
:
other
}
,
),
),
'ERC1155PresetMinterPauser: must have minter role to mint'
'ERC1155PresetMinterPauser: must have minter role to mint'
,
);
);
});
});
});
});
...
@@ -109,14 +109,14 @@ describe('ERC1155PresetMinterPauser', function () {
...
@@ -109,14 +109,14 @@ describe('ERC1155PresetMinterPauser', function () {
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
deployer
}),
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
deployer
}),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'other accounts cannot pause'
,
async
function
()
{
it
(
'other accounts cannot pause'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
pause
({
from
:
other
}),
this
.
token
.
pause
({
from
:
other
}),
'ERC1155PresetMinterPauser: must have pauser role to pause'
'ERC1155PresetMinterPauser: must have pauser role to pause'
,
);
);
});
});
});
});
...
@@ -127,7 +127,7 @@ describe('ERC1155PresetMinterPauser', function () {
...
@@ -127,7 +127,7 @@ describe('ERC1155PresetMinterPauser', function () {
const
receipt
=
await
this
.
token
.
burn
(
other
,
firstTokenId
,
firstTokenIdAmount
.
subn
(
1
),
{
from
:
other
});
const
receipt
=
await
this
.
token
.
burn
(
other
,
firstTokenId
,
firstTokenIdAmount
.
subn
(
1
),
{
from
:
other
});
expectEvent
(
receipt
,
'TransferSingle'
,
expectEvent
(
receipt
,
'TransferSingle'
,
{
operator
:
other
,
from
:
other
,
to
:
ZERO_ADDRESS
,
value
:
firstTokenIdAmount
.
subn
(
1
),
id
:
firstTokenId
}
{
operator
:
other
,
from
:
other
,
to
:
ZERO_ADDRESS
,
value
:
firstTokenIdAmount
.
subn
(
1
),
id
:
firstTokenId
}
,
);
);
expect
(
await
this
.
token
.
balanceOf
(
other
,
firstTokenId
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
expect
(
await
this
.
token
.
balanceOf
(
other
,
firstTokenId
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
...
...
test/presets/ERC20PresetMinterPauser.test.js
View file @
ace35fde
...
@@ -54,7 +54,7 @@ describe('ERC20PresetMinterPauser', function () {
...
@@ -54,7 +54,7 @@ describe('ERC20PresetMinterPauser', function () {
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
other
,
amount
,
{
from
:
other
}),
this
.
token
.
mint
(
other
,
amount
,
{
from
:
other
}),
'ERC20PresetMinterPauser: must have minter role to mint'
'ERC20PresetMinterPauser: must have minter role to mint'
,
);
);
});
});
});
});
...
@@ -81,7 +81,7 @@ describe('ERC20PresetMinterPauser', function () {
...
@@ -81,7 +81,7 @@ describe('ERC20PresetMinterPauser', function () {
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
other
,
amount
,
{
from
:
deployer
}),
this
.
token
.
mint
(
other
,
amount
,
{
from
:
deployer
}),
'ERC20Pausable: token transfer while paused'
'ERC20Pausable: token transfer while paused'
,
);
);
});
});
...
...
test/presets/ERC721PresetMinterPauserAutoId.test.js
View file @
ace35fde
...
@@ -63,7 +63,7 @@ describe('ERC721PresetMinterPauserAutoId', function () {
...
@@ -63,7 +63,7 @@ describe('ERC721PresetMinterPauserAutoId', function () {
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
other
,
{
from
:
other
}),
this
.
token
.
mint
(
other
,
{
from
:
other
}),
'ERC721PresetMinterPauserAutoId: must have minter role to mint'
'ERC721PresetMinterPauserAutoId: must have minter role to mint'
,
);
);
});
});
});
});
...
@@ -90,14 +90,14 @@ describe('ERC721PresetMinterPauserAutoId', function () {
...
@@ -90,14 +90,14 @@ describe('ERC721PresetMinterPauserAutoId', function () {
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
other
,
{
from
:
deployer
}),
this
.
token
.
mint
(
other
,
{
from
:
deployer
}),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
);
});
});
it
(
'other accounts cannot pause'
,
async
function
()
{
it
(
'other accounts cannot pause'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
pause
({
from
:
other
}),
this
.
token
.
pause
({
from
:
other
}),
'ERC721PresetMinterPauserAutoId: must have pauser role to pause'
'ERC721PresetMinterPauserAutoId: must have pauser role to pause'
,
);
);
});
});
});
});
...
...
test/proxy/ProxyAdmin.test.js
View file @
ace35fde
...
@@ -85,7 +85,7 @@ describe('ProxyAdmin', function () {
...
@@ -85,7 +85,7 @@ describe('ProxyAdmin', function () {
const
callData
=
new
ImplV1
(
''
).
contract
.
methods
[
'initializeNonPayable(uint256)'
](
1337
).
encodeABI
();
const
callData
=
new
ImplV1
(
''
).
contract
.
methods
[
'initializeNonPayable(uint256)'
](
1337
).
encodeABI
();
await
expectRevert
(
await
expectRevert
(
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
{
from
:
anotherAccount
}
{
from
:
anotherAccount
}
,
),
),
'caller is not the owner'
,
'caller is not the owner'
,
);
);
...
@@ -98,7 +98,7 @@ describe('ProxyAdmin', function () {
...
@@ -98,7 +98,7 @@ describe('ProxyAdmin', function () {
const
callData
=
'0x12345678'
;
const
callData
=
'0x12345678'
;
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
{
from
:
proxyAdminOwner
}
{
from
:
proxyAdminOwner
}
,
),
),
);
);
});
});
...
@@ -108,7 +108,7 @@ describe('ProxyAdmin', function () {
...
@@ -108,7 +108,7 @@ describe('ProxyAdmin', function () {
it
(
'upgrades implementation'
,
async
function
()
{
it
(
'upgrades implementation'
,
async
function
()
{
const
callData
=
new
ImplV1
(
''
).
contract
.
methods
[
'initializeNonPayable(uint256)'
](
1337
).
encodeABI
();
const
callData
=
new
ImplV1
(
''
).
contract
.
methods
[
'initializeNonPayable(uint256)'
](
1337
).
encodeABI
();
await
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
await
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
{
from
:
proxyAdminOwner
}
{
from
:
proxyAdminOwner
}
,
);
);
const
implementationAddress
=
await
this
.
proxyAdmin
.
getProxyImplementation
(
this
.
proxy
.
address
);
const
implementationAddress
=
await
this
.
proxyAdmin
.
getProxyImplementation
(
this
.
proxy
.
address
);
expect
(
implementationAddress
).
to
.
be
.
equal
(
this
.
implementationV2
.
address
);
expect
(
implementationAddress
).
to
.
be
.
equal
(
this
.
implementationV2
.
address
);
...
...
test/proxy/TransparentUpgradeableProxy.behaviour.js
View file @
ace35fde
...
@@ -89,7 +89,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
...
@@ -89,7 +89,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
proxy
.
upgradeTo
(
this
.
implementationV1
,
{
from
})
this
.
proxy
.
upgradeTo
(
this
.
implementationV1
,
{
from
})
,
);
);
});
});
});
});
...
...
test/token/ERC1155/ERC1155.behavior.js
View file @
ace35fde
...
@@ -25,7 +25,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -25,7 +25,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'reverts when queried about the zero address'
,
async
function
()
{
it
(
'reverts when queried about the zero address'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
balanceOf
(
ZERO_ADDRESS
,
firstTokenId
),
this
.
token
.
balanceOf
(
ZERO_ADDRESS
,
firstTokenId
),
'ERC1155: balance query for the zero address'
'ERC1155: balance query for the zero address'
,
);
);
});
});
...
@@ -33,17 +33,17 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -33,17 +33,17 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'returns zero for given addresses'
,
async
function
()
{
it
(
'returns zero for given addresses'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
firstTokenHolder
,
firstTokenId
firstTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
secondTokenHolder
,
secondTokenHolder
,
secondTokenId
secondTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
firstTokenHolder
,
unknownTokenId
unknownTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
});
});
});
});
...
@@ -60,24 +60,24 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -60,24 +60,24 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
'0x'
,
{
{
from
:
minter
,
from
:
minter
,
}
}
,
);
);
});
});
it
(
'returns the amount of tokens owned by the given addresses'
,
async
function
()
{
it
(
'returns the amount of tokens owned by the given addresses'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
firstTokenHolder
,
firstTokenId
firstTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
firstAmount
);
)).
to
.
be
.
bignumber
.
equal
(
firstAmount
);
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
secondTokenHolder
,
secondTokenHolder
,
secondTokenId
secondTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
secondAmount
);
)).
to
.
be
.
bignumber
.
equal
(
secondAmount
);
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
firstTokenHolder
,
unknownTokenId
unknownTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
});
});
});
});
...
@@ -88,17 +88,17 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -88,17 +88,17 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
await
expectRevert
(
await
expectRevert
(
this
.
token
.
balanceOfBatch
(
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
,
secondTokenHolder
],
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
,
secondTokenHolder
],
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
,
),
),
'ERC1155: accounts and ids length mismatch'
'ERC1155: accounts and ids length mismatch'
,
);
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
balanceOfBatch
(
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
],
[
firstTokenHolder
,
secondTokenHolder
],
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
,
),
),
'ERC1155: accounts and ids length mismatch'
'ERC1155: accounts and ids length mismatch'
,
);
);
});
});
...
@@ -106,9 +106,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -106,9 +106,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
await
expectRevert
(
await
expectRevert
(
this
.
token
.
balanceOfBatch
(
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
,
ZERO_ADDRESS
],
[
firstTokenHolder
,
secondTokenHolder
,
ZERO_ADDRESS
],
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
,
),
),
'ERC1155: batch balance query for the zero address'
'ERC1155: batch balance query for the zero address'
,
);
);
});
});
...
@@ -116,7 +116,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -116,7 +116,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'returns zeros for each account'
,
async
function
()
{
it
(
'returns zeros for each account'
,
async
function
()
{
const
result
=
await
this
.
token
.
balanceOfBatch
(
const
result
=
await
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
],
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
],
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
,
);
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
'0'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
'0'
);
...
@@ -137,14 +137,14 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -137,14 +137,14 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
'0x'
,
{
{
from
:
minter
,
from
:
minter
,
}
}
,
);
);
});
});
it
(
'returns amounts owned by each account in order passed'
,
async
function
()
{
it
(
'returns amounts owned by each account in order passed'
,
async
function
()
{
const
result
=
await
this
.
token
.
balanceOfBatch
(
const
result
=
await
this
.
token
.
balanceOfBatch
(
[
secondTokenHolder
,
firstTokenHolder
,
firstTokenHolder
],
[
secondTokenHolder
,
firstTokenHolder
,
firstTokenHolder
],
[
secondTokenId
,
firstTokenId
,
unknownTokenId
]
[
secondTokenId
,
firstTokenId
,
unknownTokenId
]
,
);
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
secondAmount
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
secondAmount
);
...
@@ -155,7 +155,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -155,7 +155,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'returns multiple times the balance of the same address when asked'
,
async
function
()
{
it
(
'returns multiple times the balance of the same address when asked'
,
async
function
()
{
const
result
=
await
this
.
token
.
balanceOfBatch
(
const
result
=
await
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
],
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
],
[
firstTokenId
,
secondTokenId
,
firstTokenId
]
[
firstTokenId
,
secondTokenId
,
firstTokenId
]
,
);
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
result
[
2
]);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
result
[
2
]);
...
@@ -188,7 +188,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -188,7 +188,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'reverts if attempting to approve self as an operator'
,
async
function
()
{
it
(
'reverts if attempting to approve self as an operator'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
setApprovalForAll
(
multiTokenHolder
,
true
,
{
from
:
multiTokenHolder
}),
this
.
token
.
setApprovalForAll
(
multiTokenHolder
,
true
,
{
from
:
multiTokenHolder
}),
'ERC1155: setting approval status for self'
'ERC1155: setting approval status for self'
,
);
);
});
});
});
});
...
@@ -205,7 +205,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -205,7 +205,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
'0x'
,
{
{
from
:
minter
,
from
:
minter
,
}
}
,
);
);
});
});
...
@@ -219,7 +219,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -219,7 +219,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
'0x'
,
{
from
:
multiTokenHolder
},
{
from
:
multiTokenHolder
},
),
),
'ERC1155: insufficient balance for transfer'
'ERC1155: insufficient balance for transfer'
,
);
);
});
});
...
@@ -233,7 +233,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -233,7 +233,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
'0x'
,
{
from
:
multiTokenHolder
},
{
from
:
multiTokenHolder
},
),
),
'ERC1155: transfer to the zero address'
'ERC1155: transfer to the zero address'
,
);
);
});
});
...
@@ -295,7 +295,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -295,7 +295,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
recipient
,
firstTokenId
,
firstAmount
,
'0x'
,
{
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
recipient
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
proxy
,
from
:
proxy
,
}),
}),
'ERC1155: caller is not owner nor approved'
'ERC1155: caller is not owner nor approved'
,
);
);
});
});
});
});
...
@@ -344,7 +344,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -344,7 +344,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
firstTokenId
,
firstTokenId
,
firstAmount
,
firstAmount
,
'0x'
,
'0x'
,
{
from
:
multiTokenHolder
}
{
from
:
multiTokenHolder
}
,
);
);
({
logs
:
this
.
transferLogs
}
=
this
.
transferReceipt
);
({
logs
:
this
.
transferLogs
}
=
this
.
transferReceipt
);
});
});
...
@@ -377,7 +377,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -377,7 +377,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
firstTokenId
,
firstTokenId
,
firstAmount
,
firstAmount
,
data
,
data
,
{
from
:
multiTokenHolder
}
{
from
:
multiTokenHolder
}
,
);
);
({
logs
:
this
.
transferLogs
}
=
this
.
transferReceipt
);
({
logs
:
this
.
transferLogs
}
=
this
.
transferReceipt
);
});
});
...
@@ -414,7 +414,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -414,7 +414,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
this
.
receiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
this
.
receiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
,
from
:
multiTokenHolder
,
}),
}),
'ERC1155: ERC1155Receiver rejected tokens'
'ERC1155: ERC1155Receiver rejected tokens'
,
);
);
});
});
});
});
...
@@ -432,7 +432,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -432,7 +432,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
this
.
receiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
this
.
receiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
,
from
:
multiTokenHolder
,
}),
}),
'ERC1155ReceiverMock: reverting on receive'
'ERC1155ReceiverMock: reverting on receive'
,
);
);
});
});
});
});
...
@@ -443,7 +443,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -443,7 +443,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
invalidReceiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
invalidReceiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
,
from
:
multiTokenHolder
,
})
})
,
);
);
});
});
});
});
...
@@ -461,7 +461,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -461,7 +461,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
'0x'
,
{
{
from
:
minter
,
from
:
minter
,
}
}
,
);
);
});
});
...
@@ -471,9 +471,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -471,9 +471,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
.
addn
(
1
)],
[
firstAmount
,
secondAmount
.
addn
(
1
)],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
),
),
'ERC1155: insufficient balance for transfer'
'ERC1155: insufficient balance for transfer'
,
);
);
});
});
...
@@ -483,9 +483,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -483,9 +483,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
multiTokenHolder
,
recipient
,
[
firstTokenId
],
[
firstTokenId
],
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
),
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
);
await
expectRevert
(
await
expectRevert
(
...
@@ -493,9 +493,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -493,9 +493,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenId
,
secondTokenId
],
[
firstAmount
],
[
firstAmount
],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
),
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
);
});
});
...
@@ -505,9 +505,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -505,9 +505,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
ZERO_ADDRESS
,
multiTokenHolder
,
ZERO_ADDRESS
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
),
),
'ERC1155: transfer to the zero address'
'ERC1155: transfer to the zero address'
,
);
);
});
});
...
@@ -545,7 +545,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -545,7 +545,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
));
));
});
});
...
@@ -569,9 +569,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -569,9 +569,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
proxy
}
'0x'
,
{
from
:
proxy
}
,
),
),
'ERC1155: transfer caller is not owner nor approved'
'ERC1155: transfer caller is not owner nor approved'
,
);
);
});
});
});
});
...
@@ -691,7 +691,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -691,7 +691,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
},
'0x'
,
{
from
:
multiTokenHolder
},
),
),
'ERC1155: ERC1155Receiver rejected tokens'
'ERC1155: ERC1155Receiver rejected tokens'
,
);
);
});
});
});
});
...
@@ -712,7 +712,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -712,7 +712,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
},
'0x'
,
{
from
:
multiTokenHolder
},
),
),
'ERC1155ReceiverMock: reverting on batch receive'
'ERC1155ReceiverMock: reverting on batch receive'
,
);
);
});
});
});
});
...
@@ -761,7 +761,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
...
@@ -761,7 +761,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
[
firstTokenId
,
secondTokenId
],
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
},
'0x'
,
{
from
:
multiTokenHolder
},
)
)
,
);
);
});
});
});
});
...
...
test/token/ERC1155/ERC1155.test.js
View file @
ace35fde
...
@@ -34,7 +34,7 @@ describe('ERC1155', function () {
...
@@ -34,7 +34,7 @@ describe('ERC1155', function () {
it
(
'reverts with a zero destination address'
,
async
function
()
{
it
(
'reverts with a zero destination address'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
ZERO_ADDRESS
,
tokenId
,
mintAmount
,
data
),
this
.
token
.
mint
(
ZERO_ADDRESS
,
tokenId
,
mintAmount
,
data
),
'ERC1155: mint to the zero address'
'ERC1155: mint to the zero address'
,
);
);
});
});
...
@@ -63,19 +63,19 @@ describe('ERC1155', function () {
...
@@ -63,19 +63,19 @@ describe('ERC1155', function () {
it
(
'reverts with a zero destination address'
,
async
function
()
{
it
(
'reverts with a zero destination address'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mintBatch
(
ZERO_ADDRESS
,
tokenBatchIds
,
mintAmounts
,
data
),
this
.
token
.
mintBatch
(
ZERO_ADDRESS
,
tokenBatchIds
,
mintAmounts
,
data
),
'ERC1155: mint to the zero address'
'ERC1155: mint to the zero address'
,
);
);
});
});
it
(
'reverts if length of inputs do not match'
,
async
function
()
{
it
(
'reverts if length of inputs do not match'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mintBatch
(
tokenBatchHolder
,
tokenBatchIds
,
mintAmounts
.
slice
(
1
),
data
),
this
.
token
.
mintBatch
(
tokenBatchHolder
,
tokenBatchIds
,
mintAmounts
.
slice
(
1
),
data
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mintBatch
(
tokenBatchHolder
,
tokenBatchIds
.
slice
(
1
),
mintAmounts
,
data
),
this
.
token
.
mintBatch
(
tokenBatchHolder
,
tokenBatchIds
.
slice
(
1
),
mintAmounts
,
data
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
);
});
});
...
@@ -86,7 +86,7 @@ describe('ERC1155', function () {
...
@@ -86,7 +86,7 @@ describe('ERC1155', function () {
tokenBatchIds
,
tokenBatchIds
,
mintAmounts
,
mintAmounts
,
data
,
data
,
{
from
:
operator
}
{
from
:
operator
}
,
));
));
});
});
...
@@ -101,7 +101,7 @@ describe('ERC1155', function () {
...
@@ -101,7 +101,7 @@ describe('ERC1155', function () {
it
(
'credits the minted batch of tokens'
,
async
function
()
{
it
(
'credits the minted batch of tokens'
,
async
function
()
{
const
holderBatchBalances
=
await
this
.
token
.
balanceOfBatch
(
const
holderBatchBalances
=
await
this
.
token
.
balanceOfBatch
(
new
Array
(
tokenBatchIds
.
length
).
fill
(
tokenBatchHolder
),
new
Array
(
tokenBatchIds
.
length
).
fill
(
tokenBatchHolder
),
tokenBatchIds
tokenBatchIds
,
);
);
for
(
let
i
=
0
;
i
<
holderBatchBalances
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
holderBatchBalances
.
length
;
i
++
)
{
...
@@ -115,14 +115,14 @@ describe('ERC1155', function () {
...
@@ -115,14 +115,14 @@ describe('ERC1155', function () {
it
(
'reverts when burning the zero account
\'
s tokens'
,
async
function
()
{
it
(
'reverts when burning the zero account
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
ZERO_ADDRESS
,
tokenId
,
mintAmount
),
this
.
token
.
burn
(
ZERO_ADDRESS
,
tokenId
,
mintAmount
),
'ERC1155: burn from the zero address'
'ERC1155: burn from the zero address'
,
);
);
});
});
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
tokenHolder
,
tokenId
,
mintAmount
),
this
.
token
.
burn
(
tokenHolder
,
tokenId
,
mintAmount
),
'ERC1155: burn amount exceeds balance'
'ERC1155: burn amount exceeds balance'
,
);
);
});
});
...
@@ -132,12 +132,12 @@ describe('ERC1155', function () {
...
@@ -132,12 +132,12 @@ describe('ERC1155', function () {
tokenId
,
tokenId
,
mintAmount
,
mintAmount
,
data
,
data
,
{
from
:
operator
}
{
from
:
operator
}
,
);
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
tokenHolder
,
tokenId
,
mintAmount
.
addn
(
1
)),
this
.
token
.
burn
(
tokenHolder
,
tokenId
,
mintAmount
.
addn
(
1
)),
'ERC1155: burn amount exceeds balance'
'ERC1155: burn amount exceeds balance'
,
);
);
});
});
...
@@ -148,7 +148,7 @@ describe('ERC1155', function () {
...
@@ -148,7 +148,7 @@ describe('ERC1155', function () {
tokenHolder
,
tokenHolder
,
tokenId
,
tokenId
,
burnAmount
,
burnAmount
,
{
from
:
operator
}
{
from
:
operator
}
,
));
));
});
});
...
@@ -165,7 +165,7 @@ describe('ERC1155', function () {
...
@@ -165,7 +165,7 @@ describe('ERC1155', function () {
it
(
'accounts for both minting and burning'
,
async
function
()
{
it
(
'accounts for both minting and burning'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
expect
(
await
this
.
token
.
balanceOf
(
tokenHolder
,
tokenHolder
,
tokenId
tokenId
,
)).
to
.
be
.
bignumber
.
equal
(
mintAmount
.
sub
(
burnAmount
));
)).
to
.
be
.
bignumber
.
equal
(
mintAmount
.
sub
(
burnAmount
));
});
});
});
});
...
@@ -175,26 +175,26 @@ describe('ERC1155', function () {
...
@@ -175,26 +175,26 @@ describe('ERC1155', function () {
it
(
'reverts when burning the zero account
\'
s tokens'
,
async
function
()
{
it
(
'reverts when burning the zero account
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burnBatch
(
ZERO_ADDRESS
,
tokenBatchIds
,
burnAmounts
),
this
.
token
.
burnBatch
(
ZERO_ADDRESS
,
tokenBatchIds
,
burnAmounts
),
'ERC1155: burn from the zero address'
'ERC1155: burn from the zero address'
,
);
);
});
});
it
(
'reverts if length of inputs do not match'
,
async
function
()
{
it
(
'reverts if length of inputs do not match'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
.
slice
(
1
)),
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
.
slice
(
1
)),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
.
slice
(
1
),
burnAmounts
),
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
.
slice
(
1
),
burnAmounts
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
);
});
});
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
),
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
),
'ERC1155: burn amount exceeds balance'
'ERC1155: burn amount exceeds balance'
,
);
);
});
});
...
@@ -205,7 +205,7 @@ describe('ERC1155', function () {
...
@@ -205,7 +205,7 @@ describe('ERC1155', function () {
tokenBatchHolder
,
tokenBatchHolder
,
tokenBatchIds
,
tokenBatchIds
,
burnAmounts
,
burnAmounts
,
{
from
:
operator
}
{
from
:
operator
}
,
));
));
});
});
...
@@ -222,7 +222,7 @@ describe('ERC1155', function () {
...
@@ -222,7 +222,7 @@ describe('ERC1155', function () {
it
(
'accounts for both minting and burning'
,
async
function
()
{
it
(
'accounts for both minting and burning'
,
async
function
()
{
const
holderBatchBalances
=
await
this
.
token
.
balanceOfBatch
(
const
holderBatchBalances
=
await
this
.
token
.
balanceOfBatch
(
new
Array
(
tokenBatchIds
.
length
).
fill
(
tokenBatchHolder
),
new
Array
(
tokenBatchIds
.
length
).
fill
(
tokenBatchHolder
),
tokenBatchIds
tokenBatchIds
,
);
);
for
(
let
i
=
0
;
i
<
holderBatchBalances
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
holderBatchBalances
.
length
;
i
++
)
{
...
...
test/token/ERC1155/ERC1155Burnable.test.js
View file @
ace35fde
...
@@ -38,7 +38,7 @@ describe('ERC1155Burnable', function () {
...
@@ -38,7 +38,7 @@ describe('ERC1155Burnable', function () {
it
(
'unapproved accounts cannot burn the holder
\'
s tokens'
,
async
function
()
{
it
(
'unapproved accounts cannot burn the holder
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
holder
,
tokenIds
[
0
],
amounts
[
0
].
subn
(
1
),
{
from
:
other
}),
this
.
token
.
burn
(
holder
,
tokenIds
[
0
],
amounts
[
0
].
subn
(
1
),
{
from
:
other
}),
'ERC1155: caller is not owner nor approved'
'ERC1155: caller is not owner nor approved'
,
);
);
});
});
});
});
...
@@ -62,7 +62,7 @@ describe('ERC1155Burnable', function () {
...
@@ -62,7 +62,7 @@ describe('ERC1155Burnable', function () {
it
(
'unapproved accounts cannot burn the holder
\'
s tokens'
,
async
function
()
{
it
(
'unapproved accounts cannot burn the holder
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burnBatch
(
holder
,
tokenIds
,
[
amounts
[
0
].
subn
(
1
),
amounts
[
1
].
subn
(
2
)
],
{
from
:
other
}),
this
.
token
.
burnBatch
(
holder
,
tokenIds
,
[
amounts
[
0
].
subn
(
1
),
amounts
[
1
].
subn
(
2
)
],
{
from
:
other
}),
'ERC1155: caller is not owner nor approved'
'ERC1155: caller is not owner nor approved'
,
);
);
});
});
});
});
...
...
test/token/ERC1155/ERC1155Pausable.test.js
View file @
ace35fde
...
@@ -32,58 +32,58 @@ describe('ERC1155Pausable', function () {
...
@@ -32,58 +32,58 @@ describe('ERC1155Pausable', function () {
it
(
'reverts when trying to safeTransferFrom from holder'
,
async
function
()
{
it
(
'reverts when trying to safeTransferFrom from holder'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
holder
,
receiver
,
firstTokenId
,
firstTokenAmount
,
'0x'
,
{
from
:
holder
}),
this
.
token
.
safeTransferFrom
(
holder
,
receiver
,
firstTokenId
,
firstTokenAmount
,
'0x'
,
{
from
:
holder
}),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to safeTransferFrom from operator'
,
async
function
()
{
it
(
'reverts when trying to safeTransferFrom from operator'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
holder
,
receiver
,
firstTokenId
,
firstTokenAmount
,
'0x'
,
{
from
:
operator
}),
this
.
token
.
safeTransferFrom
(
holder
,
receiver
,
firstTokenId
,
firstTokenAmount
,
'0x'
,
{
from
:
operator
}),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to safeBatchTransferFrom from holder'
,
async
function
()
{
it
(
'reverts when trying to safeBatchTransferFrom from holder'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeBatchTransferFrom
(
holder
,
receiver
,
[
firstTokenId
],
[
firstTokenAmount
],
'0x'
,
{
from
:
holder
}),
this
.
token
.
safeBatchTransferFrom
(
holder
,
receiver
,
[
firstTokenId
],
[
firstTokenAmount
],
'0x'
,
{
from
:
holder
}),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to safeBatchTransferFrom from operator'
,
async
function
()
{
it
(
'reverts when trying to safeBatchTransferFrom from operator'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeBatchTransferFrom
(
this
.
token
.
safeBatchTransferFrom
(
holder
,
receiver
,
[
firstTokenId
],
[
firstTokenAmount
],
'0x'
,
{
from
:
operator
}
holder
,
receiver
,
[
firstTokenId
],
[
firstTokenAmount
],
'0x'
,
{
from
:
operator
}
,
),
),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to mint'
,
async
function
()
{
it
(
'reverts when trying to mint'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
holder
,
secondTokenId
,
secondTokenAmount
,
'0x'
),
this
.
token
.
mint
(
holder
,
secondTokenId
,
secondTokenAmount
,
'0x'
),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to mintBatch'
,
async
function
()
{
it
(
'reverts when trying to mintBatch'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mintBatch
(
holder
,
[
secondTokenId
],
[
secondTokenAmount
],
'0x'
),
this
.
token
.
mintBatch
(
holder
,
[
secondTokenId
],
[
secondTokenAmount
],
'0x'
),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to burn'
,
async
function
()
{
it
(
'reverts when trying to burn'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
holder
,
firstTokenId
,
firstTokenAmount
),
this
.
token
.
burn
(
holder
,
firstTokenId
,
firstTokenAmount
),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to burnBatch'
,
async
function
()
{
it
(
'reverts when trying to burnBatch'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
holder
,
[
firstTokenId
],
[
firstTokenAmount
]),
this
.
token
.
burn
(
holder
,
[
firstTokenId
],
[
firstTokenAmount
]),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
);
});
});
...
...
test/token/ERC20/ERC20.behavior.js
View file @
ace35fde
...
@@ -27,7 +27,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -27,7 +27,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
shouldBehaveLikeERC20Transfer
(
errorPrefix
,
initialHolder
,
recipient
,
initialSupply
,
shouldBehaveLikeERC20Transfer
(
errorPrefix
,
initialHolder
,
recipient
,
initialSupply
,
function
(
from
,
to
,
value
)
{
function
(
from
,
to
,
value
)
{
return
this
.
token
.
transfer
(
to
,
value
,
{
from
});
return
this
.
token
.
transfer
(
to
,
value
,
{
from
});
}
}
,
);
);
});
});
...
@@ -88,7 +88,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -88,7 +88,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
transferFrom
(
await
expectRevert
(
this
.
token
.
transferFrom
(
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer amount exceeds balance`
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer amount exceeds balance`
,
);
);
});
});
});
});
...
@@ -104,7 +104,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -104,7 +104,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
transferFrom
(
await
expectRevert
(
this
.
token
.
transferFrom
(
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer amount exceeds allowance`
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer amount exceeds allowance`
,
);
);
});
});
});
});
...
@@ -114,7 +114,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -114,7 +114,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
transferFrom
(
await
expectRevert
(
this
.
token
.
transferFrom
(
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer amount exceeds balance`
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer amount exceeds balance`
,
);
);
});
});
});
});
...
@@ -131,7 +131,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -131,7 +131,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
transferFrom
(
await
expectRevert
(
this
.
token
.
transferFrom
(
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer to the zero address`
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer to the zero address`
,
);
);
});
});
});
});
...
@@ -144,7 +144,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -144,7 +144,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
transferFrom
(
await
expectRevert
(
this
.
token
.
transferFrom
(
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer from the zero address`
tokenOwner
,
to
,
amount
,
{
from
:
spender
}),
`
${
errorPrefix
}
: transfer from the zero address`
,
);
);
});
});
});
});
...
@@ -154,7 +154,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
...
@@ -154,7 +154,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
shouldBehaveLikeERC20Approve
(
errorPrefix
,
initialHolder
,
recipient
,
initialSupply
,
shouldBehaveLikeERC20Approve
(
errorPrefix
,
initialHolder
,
recipient
,
initialSupply
,
function
(
owner
,
spender
,
amount
)
{
function
(
owner
,
spender
,
amount
)
{
return
this
.
token
.
approve
(
spender
,
amount
,
{
from
:
owner
});
return
this
.
token
.
approve
(
spender
,
amount
,
{
from
:
owner
});
}
}
,
);
);
});
});
}
}
...
@@ -166,7 +166,7 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
...
@@ -166,7 +166,7 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
transfer
.
call
(
this
,
from
,
to
,
amount
),
await
expectRevert
(
transfer
.
call
(
this
,
from
,
to
,
amount
),
`
${
errorPrefix
}
: transfer amount exceeds balance`
`
${
errorPrefix
}
: transfer amount exceeds balance`
,
);
);
});
});
});
});
...
@@ -219,7 +219,7 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
...
@@ -219,7 +219,7 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
describe
(
'when the recipient is the zero address'
,
function
()
{
describe
(
'when the recipient is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
transfer
.
call
(
this
,
from
,
ZERO_ADDRESS
,
balance
),
await
expectRevert
(
transfer
.
call
(
this
,
from
,
ZERO_ADDRESS
,
balance
),
`
${
errorPrefix
}
: transfer to the zero address`
`
${
errorPrefix
}
: transfer to the zero address`
,
);
);
});
});
});
});
...
@@ -299,7 +299,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr
...
@@ -299,7 +299,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr
describe
(
'when the spender is the zero address'
,
function
()
{
describe
(
'when the spender is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
approve
.
call
(
this
,
owner
,
ZERO_ADDRESS
,
supply
),
await
expectRevert
(
approve
.
call
(
this
,
owner
,
ZERO_ADDRESS
,
supply
),
`
${
errorPrefix
}
: approve to the zero address`
`
${
errorPrefix
}
: approve to the zero address`
,
);
);
});
});
});
});
...
...
test/token/ERC20/ERC20.test.js
View file @
ace35fde
...
@@ -56,7 +56,7 @@ describe('ERC20', function () {
...
@@ -56,7 +56,7 @@ describe('ERC20', function () {
describe
(
'when there was no approved amount before'
,
function
()
{
describe
(
'when there was no approved amount before'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
decreaseAllowance
(
await
expectRevert
(
this
.
token
.
decreaseAllowance
(
spender
,
amount
,
{
from
:
initialHolder
}),
'ERC20: decreased allowance below zero'
spender
,
amount
,
{
from
:
initialHolder
}),
'ERC20: decreased allowance below zero'
,
);
);
});
});
});
});
...
@@ -92,7 +92,7 @@ describe('ERC20', function () {
...
@@ -92,7 +92,7 @@ describe('ERC20', function () {
it
(
'reverts when more than the full allowance is removed'
,
async
function
()
{
it
(
'reverts when more than the full allowance is removed'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
decreaseAllowance
(
spender
,
approvedAmount
.
addn
(
1
),
{
from
:
initialHolder
}),
this
.
token
.
decreaseAllowance
(
spender
,
approvedAmount
.
addn
(
1
),
{
from
:
initialHolder
}),
'ERC20: decreased allowance below zero'
'ERC20: decreased allowance below zero'
,
);
);
});
});
});
});
...
@@ -117,7 +117,7 @@ describe('ERC20', function () {
...
@@ -117,7 +117,7 @@ describe('ERC20', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
decreaseAllowance
(
await
expectRevert
(
this
.
token
.
decreaseAllowance
(
spender
,
amount
,
{
from
:
initialHolder
}),
'ERC20: decreased allowance below zero'
spender
,
amount
,
{
from
:
initialHolder
}),
'ERC20: decreased allowance below zero'
,
);
);
});
});
});
});
...
@@ -201,7 +201,7 @@ describe('ERC20', function () {
...
@@ -201,7 +201,7 @@ describe('ERC20', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
increaseAllowance
(
spender
,
amount
,
{
from
:
initialHolder
}),
'ERC20: approve to the zero address'
this
.
token
.
increaseAllowance
(
spender
,
amount
,
{
from
:
initialHolder
}),
'ERC20: approve to the zero address'
,
);
);
});
});
});
});
...
@@ -211,7 +211,7 @@ describe('ERC20', function () {
...
@@ -211,7 +211,7 @@ describe('ERC20', function () {
const
amount
=
new
BN
(
50
);
const
amount
=
new
BN
(
50
);
it
(
'rejects a null account'
,
async
function
()
{
it
(
'rejects a null account'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
ZERO_ADDRESS
,
amount
),
'ERC20: mint to the zero address'
this
.
token
.
mint
(
ZERO_ADDRESS
,
amount
),
'ERC20: mint to the zero address'
,
);
);
});
});
...
@@ -250,7 +250,7 @@ describe('ERC20', function () {
...
@@ -250,7 +250,7 @@ describe('ERC20', function () {
describe
(
'for a non zero account'
,
function
()
{
describe
(
'for a non zero account'
,
function
()
{
it
(
'rejects burning more than balance'
,
async
function
()
{
it
(
'rejects burning more than balance'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
burn
(
await
expectRevert
(
this
.
token
.
burn
(
initialHolder
,
initialSupply
.
addn
(
1
)),
'ERC20: burn amount exceeds balance'
initialHolder
,
initialSupply
.
addn
(
1
)),
'ERC20: burn amount exceeds balance'
,
);
);
});
});
...
@@ -295,7 +295,7 @@ describe('ERC20', function () {
...
@@ -295,7 +295,7 @@ describe('ERC20', function () {
describe
(
'when the sender is the zero address'
,
function
()
{
describe
(
'when the sender is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
transferInternal
(
ZERO_ADDRESS
,
recipient
,
initialSupply
),
await
expectRevert
(
this
.
token
.
transferInternal
(
ZERO_ADDRESS
,
recipient
,
initialSupply
),
'ERC20: transfer from the zero address'
'ERC20: transfer from the zero address'
,
);
);
});
});
});
});
...
@@ -309,7 +309,7 @@ describe('ERC20', function () {
...
@@ -309,7 +309,7 @@ describe('ERC20', function () {
describe
(
'when the owner is the zero address'
,
function
()
{
describe
(
'when the owner is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
approveInternal
(
ZERO_ADDRESS
,
recipient
,
initialSupply
),
await
expectRevert
(
this
.
token
.
approveInternal
(
ZERO_ADDRESS
,
recipient
,
initialSupply
),
'ERC20: approve from the zero address'
'ERC20: approve from the zero address'
,
);
);
});
});
});
});
...
...
test/token/ERC20/ERC20Capped.test.js
View file @
ace35fde
...
@@ -15,7 +15,7 @@ describe('ERC20Capped', function () {
...
@@ -15,7 +15,7 @@ describe('ERC20Capped', function () {
it
(
'requires a non-zero cap'
,
async
function
()
{
it
(
'requires a non-zero cap'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
ERC20Capped
.
new
(
name
,
symbol
,
new
BN
(
0
),
{
from
:
minter
}),
'ERC20Capped: cap is 0'
ERC20Capped
.
new
(
name
,
symbol
,
new
BN
(
0
),
{
from
:
minter
}),
'ERC20Capped: cap is 0'
,
);
);
});
});
...
...
test/token/ERC20/ERC20Pausable.test.js
View file @
ace35fde
...
@@ -41,7 +41,7 @@ describe('ERC20Pausable', function () {
...
@@ -41,7 +41,7 @@ describe('ERC20Pausable', function () {
await
this
.
token
.
pause
();
await
this
.
token
.
pause
();
await
expectRevert
(
this
.
token
.
transfer
(
recipient
,
initialSupply
,
{
from
:
holder
}),
await
expectRevert
(
this
.
token
.
transfer
(
recipient
,
initialSupply
,
{
from
:
holder
}),
'ERC20Pausable: token transfer while paused'
'ERC20Pausable: token transfer while paused'
,
);
);
});
});
});
});
...
@@ -74,7 +74,7 @@ describe('ERC20Pausable', function () {
...
@@ -74,7 +74,7 @@ describe('ERC20Pausable', function () {
await
this
.
token
.
pause
();
await
this
.
token
.
pause
();
await
expectRevert
(
this
.
token
.
transferFrom
(
await
expectRevert
(
this
.
token
.
transferFrom
(
holder
,
recipient
,
allowance
,
{
from
:
anotherAccount
}),
'ERC20Pausable: token transfer while paused'
holder
,
recipient
,
allowance
,
{
from
:
anotherAccount
}),
'ERC20Pausable: token transfer while paused'
,
);
);
});
});
});
});
...
@@ -101,7 +101,7 @@ describe('ERC20Pausable', function () {
...
@@ -101,7 +101,7 @@ describe('ERC20Pausable', function () {
await
this
.
token
.
pause
();
await
this
.
token
.
pause
();
await
expectRevert
(
this
.
token
.
mint
(
recipient
,
amount
),
await
expectRevert
(
this
.
token
.
mint
(
recipient
,
amount
),
'ERC20Pausable: token transfer while paused'
'ERC20Pausable: token transfer while paused'
,
);
);
});
});
});
});
...
@@ -128,7 +128,7 @@ describe('ERC20Pausable', function () {
...
@@ -128,7 +128,7 @@ describe('ERC20Pausable', function () {
await
this
.
token
.
pause
();
await
this
.
token
.
pause
();
await
expectRevert
(
this
.
token
.
burn
(
holder
,
amount
),
await
expectRevert
(
this
.
token
.
burn
(
holder
,
amount
),
'ERC20Pausable: token transfer while paused'
'ERC20Pausable: token transfer while paused'
,
);
);
});
});
});
});
...
...
test/token/ERC20/ERC20Snapshot.test.js
View file @
ace35fde
...
@@ -76,7 +76,7 @@ describe('ERC20Snapshot', function () {
...
@@ -76,7 +76,7 @@ describe('ERC20Snapshot', function () {
expect
(
await
this
.
token
.
totalSupplyAt
(
this
.
initialSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
initialSupply
);
expect
(
await
this
.
token
.
totalSupplyAt
(
this
.
initialSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
initialSupply
);
expect
(
await
this
.
token
.
totalSupplyAt
(
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
totalSupplyAt
(
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
totalSupply
()
await
this
.
token
.
totalSupply
()
,
);
);
});
});
});
});
...
@@ -160,13 +160,13 @@ describe('ERC20Snapshot', function () {
...
@@ -160,13 +160,13 @@ describe('ERC20Snapshot', function () {
expect
(
await
this
.
token
.
balanceOfAt
(
other
,
this
.
initialSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOfAt
(
other
,
this
.
initialSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOfAt
(
initialHolder
,
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
balanceOfAt
(
initialHolder
,
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
balanceOf
(
initialHolder
)
await
this
.
token
.
balanceOf
(
initialHolder
)
,
);
);
expect
(
await
this
.
token
.
balanceOfAt
(
recipient
,
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
balanceOfAt
(
recipient
,
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
balanceOf
(
recipient
)
await
this
.
token
.
balanceOf
(
recipient
)
,
);
);
expect
(
await
this
.
token
.
balanceOfAt
(
other
,
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
balanceOfAt
(
other
,
this
.
secondSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
balanceOf
(
other
)
await
this
.
token
.
balanceOf
(
other
)
,
);
);
});
});
});
});
...
@@ -189,13 +189,13 @@ describe('ERC20Snapshot', function () {
...
@@ -189,13 +189,13 @@ describe('ERC20Snapshot', function () {
for
(
const
id
of
this
.
secondSnapshotIds
)
{
for
(
const
id
of
this
.
secondSnapshotIds
)
{
expect
(
await
this
.
token
.
balanceOfAt
(
initialHolder
,
id
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
balanceOfAt
(
initialHolder
,
id
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
balanceOf
(
initialHolder
)
await
this
.
token
.
balanceOf
(
initialHolder
)
,
);
);
expect
(
await
this
.
token
.
balanceOfAt
(
recipient
,
id
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
balanceOfAt
(
recipient
,
id
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
balanceOf
(
recipient
)
await
this
.
token
.
balanceOf
(
recipient
)
,
);
);
expect
(
await
this
.
token
.
balanceOfAt
(
other
,
id
)).
to
.
be
.
bignumber
.
equal
(
expect
(
await
this
.
token
.
balanceOfAt
(
other
,
id
)).
to
.
be
.
bignumber
.
equal
(
await
this
.
token
.
balanceOf
(
other
)
await
this
.
token
.
balanceOf
(
other
)
,
);
);
}
}
});
});
...
...
test/token/ERC20/SafeERC20.test.js
View file @
ace35fde
...
@@ -97,7 +97,7 @@ function shouldOnlyRevertOnErrors () {
...
@@ -97,7 +97,7 @@ function shouldOnlyRevertOnErrors () {
it
(
'reverts when decreasing the allowance'
,
async
function
()
{
it
(
'reverts when decreasing the allowance'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
wrapper
.
decreaseAllowance
(
10
),
this
.
wrapper
.
decreaseAllowance
(
10
),
'SafeERC20: decreased allowance below zero'
'SafeERC20: decreased allowance below zero'
,
);
);
});
});
});
});
...
@@ -110,7 +110,7 @@ function shouldOnlyRevertOnErrors () {
...
@@ -110,7 +110,7 @@ function shouldOnlyRevertOnErrors () {
it
(
'reverts when approving a non-zero allowance'
,
async
function
()
{
it
(
'reverts when approving a non-zero allowance'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
wrapper
.
approve
(
20
),
this
.
wrapper
.
approve
(
20
),
'SafeERC20: approve from non-zero to non-zero allowance'
'SafeERC20: approve from non-zero to non-zero allowance'
,
);
);
});
});
...
@@ -129,7 +129,7 @@ function shouldOnlyRevertOnErrors () {
...
@@ -129,7 +129,7 @@ function shouldOnlyRevertOnErrors () {
it
(
'reverts when decreasing the allowance to a negative value'
,
async
function
()
{
it
(
'reverts when decreasing the allowance to a negative value'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
wrapper
.
decreaseAllowance
(
200
),
this
.
wrapper
.
decreaseAllowance
(
200
),
'SafeERC20: decreased allowance below zero'
'SafeERC20: decreased allowance below zero'
,
);
);
});
});
});
});
...
...
test/token/ERC20/TokenTimelock.test.js
View file @
ace35fde
...
@@ -24,7 +24,7 @@ describe('TokenTimelock', function () {
...
@@ -24,7 +24,7 @@ describe('TokenTimelock', function () {
const
pastReleaseTime
=
(
await
time
.
latest
()).
sub
(
time
.
duration
.
years
(
1
));
const
pastReleaseTime
=
(
await
time
.
latest
()).
sub
(
time
.
duration
.
years
(
1
));
await
expectRevert
(
await
expectRevert
(
TokenTimelock
.
new
(
this
.
token
.
address
,
beneficiary
,
pastReleaseTime
),
TokenTimelock
.
new
(
this
.
token
.
address
,
beneficiary
,
pastReleaseTime
),
'TokenTimelock: release time is before current time'
'TokenTimelock: release time is before current time'
,
);
);
});
});
...
...
test/token/ERC20/behaviors/ERC20Burnable.behavior.js
View file @
ace35fde
...
@@ -38,7 +38,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
...
@@ -38,7 +38,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
burn
(
amount
,
{
from
:
owner
}),
await
expectRevert
(
this
.
token
.
burn
(
amount
,
{
from
:
owner
}),
'ERC20: burn amount exceeds balance'
'ERC20: burn amount exceeds balance'
,
);
);
});
});
});
});
...
@@ -87,7 +87,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
...
@@ -87,7 +87,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
this
.
token
.
approve
(
burner
,
amount
,
{
from
:
owner
});
await
this
.
token
.
approve
(
burner
,
amount
,
{
from
:
owner
});
await
expectRevert
(
this
.
token
.
burnFrom
(
owner
,
amount
,
{
from
:
burner
}),
await
expectRevert
(
this
.
token
.
burnFrom
(
owner
,
amount
,
{
from
:
burner
}),
'ERC20: burn amount exceeds balance'
'ERC20: burn amount exceeds balance'
,
);
);
});
});
});
});
...
@@ -98,7 +98,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
...
@@ -98,7 +98,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
this
.
token
.
approve
(
burner
,
allowance
,
{
from
:
owner
});
await
this
.
token
.
approve
(
burner
,
allowance
,
{
from
:
owner
});
await
expectRevert
(
this
.
token
.
burnFrom
(
owner
,
allowance
.
addn
(
1
),
{
from
:
burner
}),
await
expectRevert
(
this
.
token
.
burnFrom
(
owner
,
allowance
.
addn
(
1
),
{
from
:
burner
}),
'ERC20: burn amount exceeds allowance'
'ERC20: burn amount exceeds allowance'
,
);
);
});
});
});
});
...
...
test/token/ERC721/ERC721.test.js
View file @
ace35fde
...
@@ -56,7 +56,7 @@ describe('ERC721', function () {
...
@@ -56,7 +56,7 @@ describe('ERC721', function () {
it
(
'reverts when queried for non existent token id'
,
async
function
()
{
it
(
'reverts when queried for non existent token id'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenURI
(
nonExistentTokenId
),
'ERC721Metadata: URI query for nonexistent token'
this
.
token
.
tokenURI
(
nonExistentTokenId
),
'ERC721Metadata: URI query for nonexistent token'
,
);
);
});
});
...
@@ -67,7 +67,7 @@ describe('ERC721', function () {
...
@@ -67,7 +67,7 @@ describe('ERC721', function () {
it
(
'reverts when setting for non existent token id'
,
async
function
()
{
it
(
'reverts when setting for non existent token id'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
setTokenURI
(
nonExistentTokenId
,
sampleUri
),
'ERC721Metadata: URI set of nonexistent token'
this
.
token
.
setTokenURI
(
nonExistentTokenId
,
sampleUri
),
'ERC721Metadata: URI set of nonexistent token'
,
);
);
});
});
...
@@ -105,7 +105,7 @@ describe('ERC721', function () {
...
@@ -105,7 +105,7 @@ describe('ERC721', function () {
expect
(
await
this
.
token
.
exists
(
firstTokenId
)).
to
.
equal
(
false
);
expect
(
await
this
.
token
.
exists
(
firstTokenId
)).
to
.
equal
(
false
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenURI
(
firstTokenId
),
'ERC721Metadata: URI query for nonexistent token'
this
.
token
.
tokenURI
(
firstTokenId
),
'ERC721Metadata: URI query for nonexistent token'
,
);
);
});
});
});
});
...
@@ -134,7 +134,7 @@ describe('ERC721', function () {
...
@@ -134,7 +134,7 @@ describe('ERC721', function () {
context
(
'when querying the zero address'
,
function
()
{
context
(
'when querying the zero address'
,
function
()
{
it
(
'throws'
,
async
function
()
{
it
(
'throws'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
balanceOf
(
ZERO_ADDRESS
),
'ERC721: balance query for the zero address'
this
.
token
.
balanceOf
(
ZERO_ADDRESS
),
'ERC721: balance query for the zero address'
,
);
);
});
});
});
});
...
@@ -154,7 +154,7 @@ describe('ERC721', function () {
...
@@ -154,7 +154,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
ownerOf
(
tokenId
),
'ERC721: owner query for nonexistent token'
this
.
token
.
ownerOf
(
tokenId
),
'ERC721: owner query for nonexistent token'
,
);
);
});
});
});
});
...
@@ -259,10 +259,10 @@ describe('ERC721', function () {
...
@@ -259,10 +259,10 @@ describe('ERC721', function () {
it
(
'keeps same tokens by index'
,
async
function
()
{
it
(
'keeps same tokens by index'
,
async
function
()
{
if
(
!
this
.
token
.
tokenOfOwnerByIndex
)
return
;
if
(
!
this
.
token
.
tokenOfOwnerByIndex
)
return
;
const
tokensListed
=
await
Promise
.
all
(
const
tokensListed
=
await
Promise
.
all
(
[
0
,
1
].
map
(
i
=>
this
.
token
.
tokenOfOwnerByIndex
(
owner
,
i
))
[
0
,
1
].
map
(
i
=>
this
.
token
.
tokenOfOwnerByIndex
(
owner
,
i
))
,
);
);
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
(
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
(
[
firstTokenId
.
toNumber
(),
secondTokenId
.
toNumber
()]
[
firstTokenId
.
toNumber
(),
secondTokenId
.
toNumber
()]
,
);
);
});
});
});
});
...
@@ -271,7 +271,7 @@ describe('ERC721', function () {
...
@@ -271,7 +271,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
transferFunction
.
call
(
this
,
other
,
other
,
tokenId
,
{
from
:
owner
}),
transferFunction
.
call
(
this
,
other
,
other
,
tokenId
,
{
from
:
owner
}),
'ERC721: transfer of token that is not own'
'ERC721: transfer of token that is not own'
,
);
);
});
});
});
});
...
@@ -280,7 +280,7 @@ describe('ERC721', function () {
...
@@ -280,7 +280,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
transferFunction
.
call
(
this
,
owner
,
other
,
tokenId
,
{
from
:
other
}),
transferFunction
.
call
(
this
,
owner
,
other
,
tokenId
,
{
from
:
other
}),
'ERC721: transfer caller is not owner nor approved'
'ERC721: transfer caller is not owner nor approved'
,
);
);
});
});
});
});
...
@@ -289,7 +289,7 @@ describe('ERC721', function () {
...
@@ -289,7 +289,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
transferFunction
.
call
(
this
,
owner
,
other
,
nonExistentTokenId
,
{
from
:
owner
}),
transferFunction
.
call
(
this
,
owner
,
other
,
nonExistentTokenId
,
{
from
:
owner
}),
'ERC721: operator query for nonexistent token'
'ERC721: operator query for nonexistent token'
,
);
);
});
});
});
});
...
@@ -298,7 +298,7 @@ describe('ERC721', function () {
...
@@ -298,7 +298,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
transferFunction
.
call
(
this
,
owner
,
ZERO_ADDRESS
,
tokenId
,
{
from
:
owner
}),
transferFunction
.
call
(
this
,
owner
,
ZERO_ADDRESS
,
tokenId
,
{
from
:
owner
}),
'ERC721: transfer to the zero address'
'ERC721: transfer to the zero address'
,
);
);
});
});
});
});
...
@@ -364,7 +364,7 @@ describe('ERC721', function () {
...
@@ -364,7 +364,7 @@ describe('ERC721', function () {
nonExistentTokenId
,
nonExistentTokenId
,
{
from
:
owner
},
{
from
:
owner
},
),
),
'ERC721: operator query for nonexistent token'
'ERC721: operator query for nonexistent token'
,
);
);
});
});
});
});
...
@@ -384,7 +384,7 @@ describe('ERC721', function () {
...
@@ -384,7 +384,7 @@ describe('ERC721', function () {
const
invalidReceiver
=
await
ERC721ReceiverMock
.
new
(
'0x42'
,
false
);
const
invalidReceiver
=
await
ERC721ReceiverMock
.
new
(
'0x42'
,
false
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
owner
,
invalidReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
this
.
token
.
safeTransferFrom
(
owner
,
invalidReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
'ERC721: transfer to non ERC721Receiver implementer'
'ERC721: transfer to non ERC721Receiver implementer'
,
);
);
});
});
});
});
...
@@ -394,7 +394,7 @@ describe('ERC721', function () {
...
@@ -394,7 +394,7 @@ describe('ERC721', function () {
const
revertingReceiver
=
await
ERC721ReceiverMock
.
new
(
RECEIVER_MAGIC_VALUE
,
true
);
const
revertingReceiver
=
await
ERC721ReceiverMock
.
new
(
RECEIVER_MAGIC_VALUE
,
true
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
owner
,
revertingReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
this
.
token
.
safeTransferFrom
(
owner
,
revertingReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
'ERC721ReceiverMock: reverting'
'ERC721ReceiverMock: reverting'
,
);
);
});
});
});
});
...
@@ -404,7 +404,7 @@ describe('ERC721', function () {
...
@@ -404,7 +404,7 @@ describe('ERC721', function () {
const
nonReceiver
=
this
.
token
;
const
nonReceiver
=
this
.
token
;
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
owner
,
nonReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
this
.
token
.
safeTransferFrom
(
owner
,
nonReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
'ERC721: transfer to non ERC721Receiver implementer'
'ERC721: transfer to non ERC721Receiver implementer'
,
);
);
});
});
});
});
...
@@ -443,7 +443,7 @@ describe('ERC721', function () {
...
@@ -443,7 +443,7 @@ describe('ERC721', function () {
const
invalidReceiver
=
await
ERC721ReceiverMock
.
new
(
'0x42'
,
false
);
const
invalidReceiver
=
await
ERC721ReceiverMock
.
new
(
'0x42'
,
false
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeMint
(
invalidReceiver
.
address
,
tokenId
),
this
.
token
.
safeMint
(
invalidReceiver
.
address
,
tokenId
),
'ERC721: transfer to non ERC721Receiver implementer'
'ERC721: transfer to non ERC721Receiver implementer'
,
);
);
});
});
});
});
...
@@ -453,7 +453,7 @@ describe('ERC721', function () {
...
@@ -453,7 +453,7 @@ describe('ERC721', function () {
const
revertingReceiver
=
await
ERC721ReceiverMock
.
new
(
RECEIVER_MAGIC_VALUE
,
true
);
const
revertingReceiver
=
await
ERC721ReceiverMock
.
new
(
RECEIVER_MAGIC_VALUE
,
true
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeMint
(
revertingReceiver
.
address
,
tokenId
),
this
.
token
.
safeMint
(
revertingReceiver
.
address
,
tokenId
),
'ERC721ReceiverMock: reverting'
'ERC721ReceiverMock: reverting'
,
);
);
});
});
});
});
...
@@ -463,7 +463,7 @@ describe('ERC721', function () {
...
@@ -463,7 +463,7 @@ describe('ERC721', function () {
const
nonReceiver
=
this
.
token
;
const
nonReceiver
=
this
.
token
;
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeMint
(
nonReceiver
.
address
,
tokenId
),
this
.
token
.
safeMint
(
nonReceiver
.
address
,
tokenId
),
'ERC721: transfer to non ERC721Receiver implementer'
'ERC721: transfer to non ERC721Receiver implementer'
,
);
);
});
});
});
});
...
@@ -552,7 +552,7 @@ describe('ERC721', function () {
...
@@ -552,7 +552,7 @@ describe('ERC721', function () {
context
(
'when the address that receives the approval is the owner'
,
function
()
{
context
(
'when the address that receives the approval is the owner'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
approve
(
owner
,
tokenId
,
{
from
:
owner
}),
'ERC721: approval to current owner'
this
.
token
.
approve
(
owner
,
tokenId
,
{
from
:
owner
}),
'ERC721: approval to current owner'
,
);
);
});
});
});
});
...
@@ -674,7 +674,7 @@ describe('ERC721', function () {
...
@@ -674,7 +674,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
getApproved
(
nonExistentTokenId
),
this
.
token
.
getApproved
(
nonExistentTokenId
),
'ERC721: approved query for nonexistent token'
'ERC721: approved query for nonexistent token'
,
);
);
});
});
});
});
...
@@ -682,7 +682,7 @@ describe('ERC721', function () {
...
@@ -682,7 +682,7 @@ describe('ERC721', function () {
context
(
'when token has been minted '
,
async
function
()
{
context
(
'when token has been minted '
,
async
function
()
{
it
(
'should return the zero address'
,
async
function
()
{
it
(
'should return the zero address'
,
async
function
()
{
expect
(
await
this
.
token
.
getApproved
(
firstTokenId
)).
to
.
be
.
equal
(
expect
(
await
this
.
token
.
getApproved
(
firstTokenId
)).
to
.
be
.
equal
(
ZERO_ADDRESS
ZERO_ADDRESS
,
);
);
});
});
...
@@ -714,7 +714,7 @@ describe('ERC721', function () {
...
@@ -714,7 +714,7 @@ describe('ERC721', function () {
describe
(
'when the index is greater than or equal to the total tokens owned by the given address'
,
function
()
{
describe
(
'when the index is greater than or equal to the total tokens owned by the given address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenOfOwnerByIndex
(
owner
,
2
),
'EnumerableSet: index out of bounds'
this
.
token
.
tokenOfOwnerByIndex
(
owner
,
2
),
'EnumerableSet: index out of bounds'
,
);
);
});
});
});
});
...
@@ -722,7 +722,7 @@ describe('ERC721', function () {
...
@@ -722,7 +722,7 @@ describe('ERC721', function () {
describe
(
'when the given address does not own any token'
,
function
()
{
describe
(
'when the given address does not own any token'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenOfOwnerByIndex
(
other
,
0
),
'EnumerableSet: index out of bounds'
this
.
token
.
tokenOfOwnerByIndex
(
other
,
0
),
'EnumerableSet: index out of bounds'
,
);
);
});
});
});
});
...
@@ -736,7 +736,7 @@ describe('ERC721', function () {
...
@@ -736,7 +736,7 @@ describe('ERC721', function () {
it
(
'returns correct token IDs for target'
,
async
function
()
{
it
(
'returns correct token IDs for target'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
other
)).
to
.
be
.
bignumber
.
equal
(
'2'
);
expect
(
await
this
.
token
.
balanceOf
(
other
)).
to
.
be
.
bignumber
.
equal
(
'2'
);
const
tokensListed
=
await
Promise
.
all
(
const
tokensListed
=
await
Promise
.
all
(
[
0
,
1
].
map
(
i
=>
this
.
token
.
tokenOfOwnerByIndex
(
other
,
i
))
[
0
,
1
].
map
(
i
=>
this
.
token
.
tokenOfOwnerByIndex
(
other
,
i
))
,
);
);
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
([
firstTokenId
.
toNumber
(),
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
([
firstTokenId
.
toNumber
(),
secondTokenId
.
toNumber
()]);
secondTokenId
.
toNumber
()]);
...
@@ -745,7 +745,7 @@ describe('ERC721', function () {
...
@@ -745,7 +745,7 @@ describe('ERC721', function () {
it
(
'returns empty collection for original owner'
,
async
function
()
{
it
(
'returns empty collection for original owner'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenOfOwnerByIndex
(
owner
,
0
),
'EnumerableSet: index out of bounds'
this
.
token
.
tokenOfOwnerByIndex
(
owner
,
0
),
'EnumerableSet: index out of bounds'
,
);
);
});
});
});
});
...
@@ -754,7 +754,7 @@ describe('ERC721', function () {
...
@@ -754,7 +754,7 @@ describe('ERC721', function () {
describe
(
'tokenByIndex'
,
function
()
{
describe
(
'tokenByIndex'
,
function
()
{
it
(
'returns all tokens'
,
async
function
()
{
it
(
'returns all tokens'
,
async
function
()
{
const
tokensListed
=
await
Promise
.
all
(
const
tokensListed
=
await
Promise
.
all
(
[
0
,
1
].
map
(
i
=>
this
.
token
.
tokenByIndex
(
i
))
[
0
,
1
].
map
(
i
=>
this
.
token
.
tokenByIndex
(
i
))
,
);
);
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
([
firstTokenId
.
toNumber
(),
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
([
firstTokenId
.
toNumber
(),
secondTokenId
.
toNumber
()]);
secondTokenId
.
toNumber
()]);
...
@@ -762,7 +762,7 @@ describe('ERC721', function () {
...
@@ -762,7 +762,7 @@ describe('ERC721', function () {
it
(
'reverts if index is greater than supply'
,
async
function
()
{
it
(
'reverts if index is greater than supply'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenByIndex
(
2
),
'EnumerableMap: index out of bounds'
this
.
token
.
tokenByIndex
(
2
),
'EnumerableMap: index out of bounds'
,
);
);
});
});
...
@@ -778,10 +778,10 @@ describe('ERC721', function () {
...
@@ -778,10 +778,10 @@ describe('ERC721', function () {
expect
(
await
this
.
token
.
totalSupply
()).
to
.
be
.
bignumber
.
equal
(
'3'
);
expect
(
await
this
.
token
.
totalSupply
()).
to
.
be
.
bignumber
.
equal
(
'3'
);
const
tokensListed
=
await
Promise
.
all
(
const
tokensListed
=
await
Promise
.
all
(
[
0
,
1
,
2
].
map
(
i
=>
this
.
token
.
tokenByIndex
(
i
))
[
0
,
1
,
2
].
map
(
i
=>
this
.
token
.
tokenByIndex
(
i
))
,
);
);
const
expectedTokens
=
[
firstTokenId
,
secondTokenId
,
newTokenId
,
anotherNewTokenId
].
filter
(
const
expectedTokens
=
[
firstTokenId
,
secondTokenId
,
newTokenId
,
anotherNewTokenId
].
filter
(
x
=>
(
x
!==
tokenId
)
x
=>
(
x
!==
tokenId
)
,
);
);
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
(
expectedTokens
.
map
(
t
=>
t
.
toNumber
()));
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
(
expectedTokens
.
map
(
t
=>
t
.
toNumber
()));
});
});
...
@@ -792,7 +792,7 @@ describe('ERC721', function () {
...
@@ -792,7 +792,7 @@ describe('ERC721', function () {
describe
(
'_mint(address, uint256)'
,
function
()
{
describe
(
'_mint(address, uint256)'
,
function
()
{
it
(
'reverts with a null destination address'
,
async
function
()
{
it
(
'reverts with a null destination address'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
ZERO_ADDRESS
,
firstTokenId
),
'ERC721: mint to the zero address'
this
.
token
.
mint
(
ZERO_ADDRESS
,
firstTokenId
),
'ERC721: mint to the zero address'
,
);
);
});
});
...
@@ -827,7 +827,7 @@ describe('ERC721', function () {
...
@@ -827,7 +827,7 @@ describe('ERC721', function () {
describe
(
'_burn'
,
function
()
{
describe
(
'_burn'
,
function
()
{
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
firstTokenId
),
'ERC721: owner query for nonexistent token'
this
.
token
.
burn
(
firstTokenId
),
'ERC721: owner query for nonexistent token'
,
);
);
});
});
...
@@ -853,7 +853,7 @@ describe('ERC721', function () {
...
@@ -853,7 +853,7 @@ describe('ERC721', function () {
it
(
'deletes the token'
,
async
function
()
{
it
(
'deletes the token'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
ownerOf
(
firstTokenId
),
'ERC721: owner query for nonexistent token'
this
.
token
.
ownerOf
(
firstTokenId
),
'ERC721: owner query for nonexistent token'
,
);
);
});
});
...
@@ -869,13 +869,13 @@ describe('ERC721', function () {
...
@@ -869,13 +869,13 @@ describe('ERC721', function () {
await
this
.
token
.
burn
(
secondTokenId
,
{
from
:
owner
});
await
this
.
token
.
burn
(
secondTokenId
,
{
from
:
owner
});
expect
(
await
this
.
token
.
totalSupply
()).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
totalSupply
()).
to
.
be
.
bignumber
.
equal
(
'0'
);
await
expectRevert
(
await
expectRevert
(
this
.
token
.
tokenByIndex
(
0
),
'EnumerableMap: index out of bounds'
this
.
token
.
tokenByIndex
(
0
),
'EnumerableMap: index out of bounds'
,
);
);
});
});
it
(
'reverts when burning a token id that has been deleted'
,
async
function
()
{
it
(
'reverts when burning a token id that has been deleted'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
firstTokenId
),
'ERC721: owner query for nonexistent token'
this
.
token
.
burn
(
firstTokenId
),
'ERC721: owner query for nonexistent token'
,
);
);
});
});
});
});
...
...
test/token/ERC721/ERC721Burnable.test.js
View file @
ace35fde
...
@@ -40,7 +40,7 @@ describe('ERC721Burnable', function () {
...
@@ -40,7 +40,7 @@ describe('ERC721Burnable', function () {
it
(
'burns the given token ID and adjusts the balance of the owner'
,
async
function
()
{
it
(
'burns the given token ID and adjusts the balance of the owner'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
ownerOf
(
tokenId
),
this
.
token
.
ownerOf
(
tokenId
),
'ERC721: owner query for nonexistent token'
'ERC721: owner query for nonexistent token'
,
);
);
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
});
});
...
@@ -64,7 +64,7 @@ describe('ERC721Burnable', function () {
...
@@ -64,7 +64,7 @@ describe('ERC721Burnable', function () {
context
(
'getApproved'
,
function
()
{
context
(
'getApproved'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
getApproved
(
tokenId
),
'ERC721: approved query for nonexistent token'
this
.
token
.
getApproved
(
tokenId
),
'ERC721: approved query for nonexistent token'
,
);
);
});
});
});
});
...
@@ -73,7 +73,7 @@ describe('ERC721Burnable', function () {
...
@@ -73,7 +73,7 @@ describe('ERC721Burnable', function () {
describe
(
'when the given token ID was not tracked by this contract'
,
function
()
{
describe
(
'when the given token ID was not tracked by this contract'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
unknownTokenId
,
{
from
:
owner
}),
'ERC721: operator query for nonexistent token'
this
.
token
.
burn
(
unknownTokenId
,
{
from
:
owner
}),
'ERC721: operator query for nonexistent token'
,
);
);
});
});
});
});
...
...
test/token/ERC721/ERC721Pausable.test.js
View file @
ace35fde
...
@@ -31,36 +31,36 @@ describe('ERC721Pausable', function () {
...
@@ -31,36 +31,36 @@ describe('ERC721Pausable', function () {
it
(
'reverts when trying to transferFrom'
,
async
function
()
{
it
(
'reverts when trying to transferFrom'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
transferFrom
(
owner
,
receiver
,
firstTokenId
,
{
from
:
owner
}),
this
.
token
.
transferFrom
(
owner
,
receiver
,
firstTokenId
,
{
from
:
owner
}),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to safeTransferFrom'
,
async
function
()
{
it
(
'reverts when trying to safeTransferFrom'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
owner
,
receiver
,
firstTokenId
,
{
from
:
owner
}),
this
.
token
.
safeTransferFrom
(
owner
,
receiver
,
firstTokenId
,
{
from
:
owner
}),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to safeTransferFrom with data'
,
async
function
()
{
it
(
'reverts when trying to safeTransferFrom with data'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
methods
[
'safeTransferFrom(address,address,uint256,bytes)'
](
this
.
token
.
methods
[
'safeTransferFrom(address,address,uint256,bytes)'
](
owner
,
receiver
,
firstTokenId
,
mockData
,
{
from
:
owner
}
owner
,
receiver
,
firstTokenId
,
mockData
,
{
from
:
owner
}
,
),
'ERC721Pausable: token transfer while paused'
),
'ERC721Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to mint'
,
async
function
()
{
it
(
'reverts when trying to mint'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
mint
(
receiver
,
secondTokenId
),
this
.
token
.
mint
(
receiver
,
secondTokenId
),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
);
});
});
it
(
'reverts when trying to burn'
,
async
function
()
{
it
(
'reverts when trying to burn'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
burn
(
firstTokenId
),
this
.
token
.
burn
(
firstTokenId
),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
);
});
});
...
...
test/token/ERC777/ERC777.behavior.js
View file @
ace35fde
...
@@ -58,15 +58,15 @@ function shouldBehaveLikeERC777OperatorSend (holder, recipient, operator, data,
...
@@ -58,15 +58,15 @@ function shouldBehaveLikeERC777OperatorSend (holder, recipient, operator, data,
it
(
'reverts when sending more than the balance'
,
async
function
()
{
it
(
'reverts when sending more than the balance'
,
async
function
()
{
const
balance
=
await
this
.
token
.
balanceOf
(
holder
);
const
balance
=
await
this
.
token
.
balanceOf
(
holder
);
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorSend
(
holder
,
recipient
,
balance
.
addn
(
1
),
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorSend
(
holder
,
recipient
,
balance
.
addn
(
1
),
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
it
(
'reverts when sending to the zero address'
,
async
function
()
{
it
(
'reverts when sending to the zero address'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorSend
(
this
.
token
.
operatorSend
(
holder
,
ZERO_ADDRESS
,
new
BN
(
'1'
),
data
,
operatorData
,
{
from
:
operator
}
holder
,
ZERO_ADDRESS
,
new
BN
(
'1'
),
data
,
operatorData
,
{
from
:
operator
}
,
)
)
,
);
);
});
});
});
});
...
@@ -78,7 +78,7 @@ function shouldBehaveLikeERC777OperatorSend (holder, recipient, operator, data,
...
@@ -78,7 +78,7 @@ function shouldBehaveLikeERC777OperatorSend (holder, recipient, operator, data,
it
(
'reverts when sending a non-zero amount'
,
async
function
()
{
it
(
'reverts when sending a non-zero amount'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorSend
(
holder
,
recipient
,
new
BN
(
'1'
),
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorSend
(
holder
,
recipient
,
new
BN
(
'1'
),
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
...
@@ -86,8 +86,8 @@ function shouldBehaveLikeERC777OperatorSend (holder, recipient, operator, data,
...
@@ -86,8 +86,8 @@ function shouldBehaveLikeERC777OperatorSend (holder, recipient, operator, data,
// This is not yet reflected in the spec
// This is not yet reflected in the spec
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorSend
(
this
.
token
.
operatorSend
(
ZERO_ADDRESS
,
recipient
,
new
BN
(
'0'
),
data
,
operatorData
,
{
from
:
operator
}
ZERO_ADDRESS
,
recipient
,
new
BN
(
'0'
),
data
,
operatorData
,
{
from
:
operator
}
,
)
)
,
);
);
});
});
});
});
...
@@ -135,7 +135,7 @@ function shouldBehaveLikeERC777OperatorBurn (holder, operator, data, operatorDat
...
@@ -135,7 +135,7 @@ function shouldBehaveLikeERC777OperatorBurn (holder, operator, data, operatorDat
it
(
'reverts when burning more than the balance'
,
async
function
()
{
it
(
'reverts when burning more than the balance'
,
async
function
()
{
const
balance
=
await
this
.
token
.
balanceOf
(
holder
);
const
balance
=
await
this
.
token
.
balanceOf
(
holder
);
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorBurn
(
holder
,
balance
.
addn
(
1
),
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorBurn
(
holder
,
balance
.
addn
(
1
),
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
});
});
...
@@ -147,7 +147,7 @@ function shouldBehaveLikeERC777OperatorBurn (holder, operator, data, operatorDat
...
@@ -147,7 +147,7 @@ function shouldBehaveLikeERC777OperatorBurn (holder, operator, data, operatorDat
it
(
'reverts when burning a non-zero amount'
,
async
function
()
{
it
(
'reverts when burning a non-zero amount'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorBurn
(
holder
,
new
BN
(
'1'
),
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorBurn
(
holder
,
new
BN
(
'1'
),
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
...
@@ -155,8 +155,8 @@ function shouldBehaveLikeERC777OperatorBurn (holder, operator, data, operatorDat
...
@@ -155,8 +155,8 @@ function shouldBehaveLikeERC777OperatorBurn (holder, operator, data, operatorDat
// This is not yet reflected in the spec
// This is not yet reflected in the spec
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorBurn
(
this
.
token
.
operatorBurn
(
ZERO_ADDRESS
,
new
BN
(
'0'
),
data
,
operatorData
,
{
from
:
operator
}
ZERO_ADDRESS
,
new
BN
(
'0'
),
data
,
operatorData
,
{
from
:
operator
}
,
)
)
,
);
);
});
});
});
});
...
@@ -282,7 +282,7 @@ function shouldBehaveLikeERC777InternalMint (recipient, operator, amount, data,
...
@@ -282,7 +282,7 @@ function shouldBehaveLikeERC777InternalMint (recipient, operator, amount, data,
it
(
'reverts when minting tokens for the zero address'
,
async
function
()
{
it
(
'reverts when minting tokens for the zero address'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
mintInternal
(
ZERO_ADDRESS
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
mintInternal
(
ZERO_ADDRESS
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
}
}
...
@@ -328,13 +328,13 @@ function shouldBehaveLikeERC777SendBurnMintInternalWithReceiveHook (operator, am
...
@@ -328,13 +328,13 @@ function shouldBehaveLikeERC777SendBurnMintInternalWithReceiveHook (operator, am
it
(
'operatorSend reverts'
,
async
function
()
{
it
(
'operatorSend reverts'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorSend
(
this
.
sender
,
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorSend
(
this
.
sender
,
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
it
(
'mint (internal) reverts'
,
async
function
()
{
it
(
'mint (internal) reverts'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
mintInternal
(
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
mintInternal
(
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
});
});
...
@@ -389,7 +389,7 @@ function shouldBehaveLikeERC777SendBurnMintInternalWithReceiveHook (operator, am
...
@@ -389,7 +389,7 @@ function shouldBehaveLikeERC777SendBurnMintInternalWithReceiveHook (operator, am
it
(
'TokensRecipient receives mint (internal) data and is called after state mutation'
,
async
function
()
{
it
(
'TokensRecipient receives mint (internal) data and is called after state mutation'
,
async
function
()
{
const
{
tx
}
=
await
this
.
token
.
mintInternal
(
const
{
tx
}
=
await
this
.
token
.
mintInternal
(
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
}
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
}
,
);
);
const
postRecipientBalance
=
await
this
.
token
.
balanceOf
(
this
.
recipient
);
const
postRecipientBalance
=
await
this
.
token
.
balanceOf
(
this
.
recipient
);
...
@@ -422,7 +422,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
...
@@ -422,7 +422,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
it
(
'operatorSend reverts'
,
async
function
()
{
it
(
'operatorSend reverts'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorSend
(
this
.
sender
,
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorSend
(
this
.
sender
,
this
.
recipient
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
...
@@ -432,7 +432,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
...
@@ -432,7 +432,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
it
(
'operatorBurn reverts'
,
async
function
()
{
it
(
'operatorBurn reverts'
,
async
function
()
{
await
expectRevert
.
unspecified
(
await
expectRevert
.
unspecified
(
this
.
token
.
operatorBurn
(
this
.
sender
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
this
.
token
.
operatorBurn
(
this
.
sender
,
amount
,
data
,
operatorData
,
{
from
:
operator
})
,
);
);
});
});
});
});
...
@@ -491,7 +491,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
...
@@ -491,7 +491,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
const
{
tx
}
=
await
burnFromHolder
(
this
.
token
,
this
.
sender
,
amount
,
data
,
{
from
:
this
.
sender
});
const
{
tx
}
=
await
burnFromHolder
(
this
.
token
,
this
.
sender
,
amount
,
data
,
{
from
:
this
.
sender
});
await
assertTokensToSendCalled
(
await
assertTokensToSendCalled
(
this
.
token
,
tx
,
this
.
sender
,
this
.
sender
,
ZERO_ADDRESS
,
amount
,
data
,
null
,
preSenderBalance
this
.
token
,
tx
,
this
.
sender
,
this
.
sender
,
ZERO_ADDRESS
,
amount
,
data
,
null
,
preSenderBalance
,
);
);
});
});
...
@@ -501,7 +501,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
...
@@ -501,7 +501,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
const
{
tx
}
=
await
this
.
token
.
operatorBurn
(
this
.
sender
,
amount
,
data
,
operatorData
,
{
from
:
operator
});
const
{
tx
}
=
await
this
.
token
.
operatorBurn
(
this
.
sender
,
amount
,
data
,
operatorData
,
{
from
:
operator
});
await
assertTokensToSendCalled
(
await
assertTokensToSendCalled
(
this
.
token
,
tx
,
operator
,
this
.
sender
,
ZERO_ADDRESS
,
amount
,
data
,
operatorData
,
preSenderBalance
this
.
token
,
tx
,
operator
,
this
.
sender
,
ZERO_ADDRESS
,
amount
,
data
,
operatorData
,
preSenderBalance
,
);
);
});
});
});
});
...
...
test/token/ERC777/ERC777.test.js
View file @
ace35fde
...
@@ -53,7 +53,7 @@ describe('ERC777', function () {
...
@@ -53,7 +53,7 @@ describe('ERC777', function () {
describe
(
'when the owner is the zero address'
,
function
()
{
describe
(
'when the owner is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
approveInternal
(
ZERO_ADDRESS
,
anyone
,
initialSupply
),
await
expectRevert
(
this
.
token
.
approveInternal
(
ZERO_ADDRESS
,
anyone
,
initialSupply
),
'ERC777: approve from the zero address'
'ERC777: approve from the zero address'
,
);
);
});
});
});
});
...
@@ -182,13 +182,13 @@ describe('ERC777', function () {
...
@@ -182,13 +182,13 @@ describe('ERC777', function () {
it
(
'reverts when self-authorizing'
,
async
function
()
{
it
(
'reverts when self-authorizing'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
authorizeOperator
(
holder
,
{
from
:
holder
}),
'ERC777: authorizing self as operator'
this
.
token
.
authorizeOperator
(
holder
,
{
from
:
holder
}),
'ERC777: authorizing self as operator'
,
);
);
});
});
it
(
'reverts when self-revoking'
,
async
function
()
{
it
(
'reverts when self-revoking'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
revokeOperator
(
holder
,
{
from
:
holder
}),
'ERC777: revoking self as operator'
this
.
token
.
revokeOperator
(
holder
,
{
from
:
holder
}),
'ERC777: revoking self as operator'
,
);
);
});
});
...
@@ -252,7 +252,7 @@ describe('ERC777', function () {
...
@@ -252,7 +252,7 @@ describe('ERC777', function () {
it
(
'cannot be revoked for themselves'
,
async
function
()
{
it
(
'cannot be revoked for themselves'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
token
.
revokeOperator
(
defaultOperatorA
,
{
from
:
defaultOperatorA
}),
this
.
token
.
revokeOperator
(
defaultOperatorA
,
{
from
:
defaultOperatorA
}),
'ERC777: revoking self as operator'
'ERC777: revoking self as operator'
,
);
);
});
});
...
...
test/utils/Address.test.js
View file @
ace35fde
...
@@ -87,7 +87,7 @@ describe('Address', function () {
...
@@ -87,7 +87,7 @@ describe('Address', function () {
await
this
.
contractRecipient
.
setAcceptEther
(
false
);
await
this
.
contractRecipient
.
setAcceptEther
(
false
);
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
sendValue
(
this
.
contractRecipient
.
address
,
funds
),
this
.
mock
.
sendValue
(
this
.
contractRecipient
.
address
,
funds
),
'Address: unable to send value, recipient may have reverted'
'Address: unable to send value, recipient may have reverted'
,
);
);
});
});
});
});
...
@@ -122,7 +122,7 @@ describe('Address', function () {
...
@@ -122,7 +122,7 @@ describe('Address', function () {
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
);
});
});
...
@@ -135,7 +135,7 @@ describe('Address', function () {
...
@@ -135,7 +135,7 @@ describe('Address', function () {
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'CallReceiverMock: reverting'
'CallReceiverMock: reverting'
,
);
);
});
});
...
@@ -152,7 +152,7 @@ describe('Address', function () {
...
@@ -152,7 +152,7 @@ describe('Address', function () {
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
);
}).
timeout
(
5000
);
}).
timeout
(
5000
);
...
@@ -165,7 +165,7 @@ describe('Address', function () {
...
@@ -165,7 +165,7 @@ describe('Address', function () {
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
);
});
});
...
@@ -178,7 +178,7 @@ describe('Address', function () {
...
@@ -178,7 +178,7 @@ describe('Address', function () {
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
);
});
});
});
});
...
@@ -228,7 +228,7 @@ describe('Address', function () {
...
@@ -228,7 +228,7 @@ describe('Address', function () {
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCallWithValue
(
this
.
contractRecipient
.
address
,
abiEncodedCall
,
amount
),
this
.
mock
.
functionCallWithValue
(
this
.
contractRecipient
.
address
,
abiEncodedCall
,
amount
),
'Address: insufficient balance for call'
'Address: insufficient balance for call'
,
);
);
});
});
...
@@ -261,7 +261,7 @@ describe('Address', function () {
...
@@ -261,7 +261,7 @@ describe('Address', function () {
expect
(
await
balance
.
current
(
this
.
mock
.
address
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
balance
.
current
(
this
.
mock
.
address
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
const
receipt
=
await
this
.
mock
.
functionCallWithValue
(
const
receipt
=
await
this
.
mock
.
functionCallWithValue
(
this
.
contractRecipient
.
address
,
abiEncodedCall
,
amount
,
{
from
:
other
,
value
:
amount
}
this
.
contractRecipient
.
address
,
abiEncodedCall
,
amount
,
{
from
:
other
,
value
:
amount
}
,
);
);
expect
(
await
tracker
.
delta
()).
to
.
be
.
bignumber
.
equal
(
amount
);
expect
(
await
tracker
.
delta
()).
to
.
be
.
bignumber
.
equal
(
amount
);
...
@@ -280,7 +280,7 @@ describe('Address', function () {
...
@@ -280,7 +280,7 @@ describe('Address', function () {
await
send
.
ether
(
other
,
this
.
mock
.
address
,
amount
);
await
send
.
ether
(
other
,
this
.
mock
.
address
,
amount
);
await
expectRevert
(
await
expectRevert
(
this
.
mock
.
functionCallWithValue
(
this
.
contractRecipient
.
address
,
abiEncodedCall
,
amount
),
this
.
mock
.
functionCallWithValue
(
this
.
contractRecipient
.
address
,
abiEncodedCall
,
amount
),
'Address: low-level call with value failed'
'Address: low-level call with value failed'
,
);
);
});
});
});
});
...
...
test/utils/Create2.test.js
View file @
ace35fde
...
@@ -15,7 +15,7 @@ describe('Create2', function () {
...
@@ -15,7 +15,7 @@ describe('Create2', function () {
const
encodedParams
=
web3
.
eth
.
abi
.
encodeParameters
(
const
encodedParams
=
web3
.
eth
.
abi
.
encodeParameters
(
[
'string'
,
'string'
,
'address'
,
'uint256'
],
[
'string'
,
'string'
,
'address'
,
'uint256'
],
[
'MyToken'
,
'MTKN'
,
deployerAccount
,
100
]
[
'MyToken'
,
'MTKN'
,
deployerAccount
,
100
]
,
).
slice
(
2
);
).
slice
(
2
);
const
constructorByteCode
=
`
${
ERC20Mock
.
bytecode
}${
encodedParams
}
`
;
const
constructorByteCode
=
`
${
ERC20Mock
.
bytecode
}${
encodedParams
}
`
;
...
@@ -73,20 +73,20 @@ describe('Create2', function () {
...
@@ -73,20 +73,20 @@ describe('Create2', function () {
it
(
'fails deploying a contract in an existent address'
,
async
function
()
{
it
(
'fails deploying a contract in an existent address'
,
async
function
()
{
await
this
.
factory
.
deploy
(
0
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
});
await
this
.
factory
.
deploy
(
0
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
});
await
expectRevert
(
await
expectRevert
(
this
.
factory
.
deploy
(
0
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
}),
'Create2: Failed on deploy'
this
.
factory
.
deploy
(
0
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
}),
'Create2: Failed on deploy'
,
);
);
});
});
it
(
'fails deploying a contract if the bytecode length is zero'
,
async
function
()
{
it
(
'fails deploying a contract if the bytecode length is zero'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
factory
.
deploy
(
0
,
saltHex
,
'0x'
,
{
from
:
deployerAccount
}),
'Create2: bytecode length is zero'
this
.
factory
.
deploy
(
0
,
saltHex
,
'0x'
,
{
from
:
deployerAccount
}),
'Create2: bytecode length is zero'
,
);
);
});
});
it
(
'fails deploying a contract if factory contract does not have sufficient balance'
,
async
function
()
{
it
(
'fails deploying a contract if factory contract does not have sufficient balance'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
factory
.
deploy
(
1
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
}),
this
.
factory
.
deploy
(
1
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
}),
'Create2: insufficient balance'
'Create2: insufficient balance'
,
);
);
});
});
});
});
...
...
test/utils/EnumerableMap.test.js
View file @
ace35fde
...
@@ -21,13 +21,13 @@ describe('EnumerableMap', function () {
...
@@ -21,13 +21,13 @@ describe('EnumerableMap', function () {
expect
(
keys
.
length
).
to
.
equal
(
values
.
length
);
expect
(
keys
.
length
).
to
.
equal
(
values
.
length
);
await
Promise
.
all
(
keys
.
map
(
async
key
=>
await
Promise
.
all
(
keys
.
map
(
async
key
=>
expect
(
await
map
.
contains
(
key
)).
to
.
equal
(
true
)
expect
(
await
map
.
contains
(
key
)).
to
.
equal
(
true
)
,
));
));
expect
(
await
map
.
length
()).
to
.
bignumber
.
equal
(
keys
.
length
.
toString
());
expect
(
await
map
.
length
()).
to
.
bignumber
.
equal
(
keys
.
length
.
toString
());
expect
(
await
Promise
.
all
(
keys
.
map
(
key
=>
expect
(
await
Promise
.
all
(
keys
.
map
(
key
=>
map
.
get
(
key
)
map
.
get
(
key
)
,
))).
to
.
have
.
same
.
members
(
values
);
))).
to
.
have
.
same
.
members
(
values
);
// To compare key-value pairs, we zip keys and values, and convert BNs to
// To compare key-value pairs, we zip keys and values, and convert BNs to
...
@@ -36,7 +36,7 @@ describe('EnumerableMap', function () {
...
@@ -36,7 +36,7 @@ describe('EnumerableMap', function () {
const
entry
=
await
map
.
at
(
index
);
const
entry
=
await
map
.
at
(
index
);
return
[
entry
.
key
.
toString
(),
entry
.
value
];
return
[
entry
.
key
.
toString
(),
entry
.
value
];
}))).
to
.
have
.
same
.
deep
.
members
(
}))).
to
.
have
.
same
.
deep
.
members
(
zip
(
keys
.
map
(
k
=>
k
.
toString
()),
values
)
zip
(
keys
.
map
(
k
=>
k
.
toString
()),
values
)
,
);
);
}
}
...
...
test/utils/EnumerableSet.behavior.js
View file @
ace35fde
...
@@ -4,7 +4,7 @@ const { expect } = require('chai');
...
@@ -4,7 +4,7 @@ const { expect } = require('chai');
function
shouldBehaveLikeSet
(
valueA
,
valueB
,
valueC
)
{
function
shouldBehaveLikeSet
(
valueA
,
valueB
,
valueC
)
{
async
function
expectMembersMatch
(
set
,
values
)
{
async
function
expectMembersMatch
(
set
,
values
)
{
await
Promise
.
all
(
values
.
map
(
async
value
=>
await
Promise
.
all
(
values
.
map
(
async
value
=>
expect
(
await
set
.
contains
(
value
)).
to
.
equal
(
true
)
expect
(
await
set
.
contains
(
value
)).
to
.
equal
(
true
)
,
));
));
expect
(
await
set
.
length
()).
to
.
bignumber
.
equal
(
values
.
length
.
toString
());
expect
(
await
set
.
length
()).
to
.
bignumber
.
equal
(
values
.
length
.
toString
());
...
...
test/utils/Pausable.test.js
View file @
ace35fde
...
@@ -27,7 +27,7 @@ describe('Pausable', function () {
...
@@ -27,7 +27,7 @@ describe('Pausable', function () {
it
(
'cannot take drastic measure in non-pause'
,
async
function
()
{
it
(
'cannot take drastic measure in non-pause'
,
async
function
()
{
await
expectRevert
(
this
.
pausable
.
drasticMeasure
(),
await
expectRevert
(
this
.
pausable
.
drasticMeasure
(),
'Pausable: not paused'
'Pausable: not paused'
,
);
);
expect
(
await
this
.
pausable
.
drasticMeasureTaken
()).
to
.
equal
(
false
);
expect
(
await
this
.
pausable
.
drasticMeasureTaken
()).
to
.
equal
(
false
);
});
});
...
@@ -77,7 +77,7 @@ describe('Pausable', function () {
...
@@ -77,7 +77,7 @@ describe('Pausable', function () {
it
(
'should prevent drastic measure'
,
async
function
()
{
it
(
'should prevent drastic measure'
,
async
function
()
{
await
expectRevert
(
this
.
pausable
.
drasticMeasure
(),
await
expectRevert
(
this
.
pausable
.
drasticMeasure
(),
'Pausable: not paused'
'Pausable: not paused'
,
);
);
});
});
...
...
test/utils/ReentrancyGuard.test.js
View file @
ace35fde
...
@@ -23,13 +23,13 @@ describe('ReentrancyGuard', function () {
...
@@ -23,13 +23,13 @@ describe('ReentrancyGuard', function () {
// in the side-effects.
// in the side-effects.
it
(
'does not allow local recursion'
,
async
function
()
{
it
(
'does not allow local recursion'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
reentrancyMock
.
countLocalRecursive
(
10
),
'ReentrancyGuard: reentrant call'
this
.
reentrancyMock
.
countLocalRecursive
(
10
),
'ReentrancyGuard: reentrant call'
,
);
);
});
});
it
(
'does not allow indirect local recursion'
,
async
function
()
{
it
(
'does not allow indirect local recursion'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
reentrancyMock
.
countThisRecursive
(
10
),
'ReentrancyMock: failed call'
this
.
reentrancyMock
.
countThisRecursive
(
10
),
'ReentrancyMock: failed call'
,
);
);
});
});
});
});
test/utils/SafeCast.test.js
View file @
ace35fde
...
@@ -29,14 +29,14 @@ describe('SafeCast', async () => {
...
@@ -29,14 +29,14 @@ describe('SafeCast', async () => {
it
(
`reverts when downcasting 2^
${
bits
}
(
${
maxValue
.
addn
(
1
)}
)`
,
async
function
()
{
it
(
`reverts when downcasting 2^
${
bits
}
(
${
maxValue
.
addn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
[
`toUint
${
bits
}
`
](
maxValue
.
addn
(
1
)),
this
.
safeCast
[
`toUint
${
bits
}
`
](
maxValue
.
addn
(
1
)),
`SafeCast: value doesn't fit in
${
bits
}
bits`
`SafeCast: value doesn't fit in
${
bits
}
bits`
,
);
);
});
});
it
(
`reverts when downcasting 2^
${
bits
}
+ 1 (
${
maxValue
.
addn
(
2
)}
)`
,
async
function
()
{
it
(
`reverts when downcasting 2^
${
bits
}
+ 1 (
${
maxValue
.
addn
(
2
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
[
`toUint
${
bits
}
`
](
maxValue
.
addn
(
2
)),
this
.
safeCast
[
`toUint
${
bits
}
`
](
maxValue
.
addn
(
2
)),
`SafeCast: value doesn't fit in
${
bits
}
bits`
`SafeCast: value doesn't fit in
${
bits
}
bits`
,
);
);
});
});
});
});
...
@@ -64,21 +64,21 @@ describe('SafeCast', async () => {
...
@@ -64,21 +64,21 @@ describe('SafeCast', async () => {
it
(
'reverts when casting -1'
,
async
function
()
{
it
(
'reverts when casting -1'
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
.
toUint256
(
-
1
),
this
.
safeCast
.
toUint256
(
-
1
),
'SafeCast: value must be positive'
'SafeCast: value must be positive'
,
);
);
});
});
it
(
`reverts when casting INT256_MIN (
${
minInt256
}
)`
,
async
function
()
{
it
(
`reverts when casting INT256_MIN (
${
minInt256
}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
.
toUint256
(
minInt256
),
this
.
safeCast
.
toUint256
(
minInt256
),
'SafeCast: value must be positive'
'SafeCast: value must be positive'
,
);
);
});
});
it
(
`reverts when casting UINT256_MAX (
${
maxUint256
}
)`
,
async
function
()
{
it
(
`reverts when casting UINT256_MAX (
${
maxUint256
}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
.
toUint256
(
maxUint256
),
this
.
safeCast
.
toUint256
(
maxUint256
),
'SafeCast: value must be positive'
'SafeCast: value must be positive'
,
);
);
});
});
});
});
...
@@ -111,28 +111,28 @@ describe('SafeCast', async () => {
...
@@ -111,28 +111,28 @@ describe('SafeCast', async () => {
it
(
`reverts when downcasting -2^
${
bits
-
1
}
- 1 (
${
minValue
.
subn
(
1
)}
)`
,
async
function
()
{
it
(
`reverts when downcasting -2^
${
bits
-
1
}
- 1 (
${
minValue
.
subn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
[
`toInt
${
bits
}
`
](
minValue
.
subn
(
1
)),
this
.
safeCast
[
`toInt
${
bits
}
`
](
minValue
.
subn
(
1
)),
`SafeCast: value doesn't fit in
${
bits
}
bits`
`SafeCast: value doesn't fit in
${
bits
}
bits`
,
);
);
});
});
it
(
`reverts when downcasting -2^
${
bits
-
1
}
- 2 (
${
minValue
.
subn
(
2
)}
)`
,
async
function
()
{
it
(
`reverts when downcasting -2^
${
bits
-
1
}
- 2 (
${
minValue
.
subn
(
2
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
[
`toInt
${
bits
}
`
](
minValue
.
subn
(
2
)),
this
.
safeCast
[
`toInt
${
bits
}
`
](
minValue
.
subn
(
2
)),
`SafeCast: value doesn't fit in
${
bits
}
bits`
`SafeCast: value doesn't fit in
${
bits
}
bits`
,
);
);
});
});
it
(
`reverts when downcasting 2^
${
bits
-
1
}
(
${
maxValue
.
addn
(
1
)}
)`
,
async
function
()
{
it
(
`reverts when downcasting 2^
${
bits
-
1
}
(
${
maxValue
.
addn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
[
`toInt
${
bits
}
`
](
maxValue
.
addn
(
1
)),
this
.
safeCast
[
`toInt
${
bits
}
`
](
maxValue
.
addn
(
1
)),
`SafeCast: value doesn't fit in
${
bits
}
bits`
`SafeCast: value doesn't fit in
${
bits
}
bits`
,
);
);
});
});
it
(
`reverts when downcasting 2^
${
bits
-
1
}
+ 1 (
${
maxValue
.
addn
(
2
)}
)`
,
async
function
()
{
it
(
`reverts when downcasting 2^
${
bits
-
1
}
+ 1 (
${
maxValue
.
addn
(
2
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
[
`toInt
${
bits
}
`
](
maxValue
.
addn
(
2
)),
this
.
safeCast
[
`toInt
${
bits
}
`
](
maxValue
.
addn
(
2
)),
`SafeCast: value doesn't fit in
${
bits
}
bits`
`SafeCast: value doesn't fit in
${
bits
}
bits`
,
);
);
});
});
});
});
...
@@ -159,14 +159,14 @@ describe('SafeCast', async () => {
...
@@ -159,14 +159,14 @@ describe('SafeCast', async () => {
it
(
`reverts when casting INT256_MAX + 1 (
${
maxInt256
.
addn
(
1
)}
)`
,
async
function
()
{
it
(
`reverts when casting INT256_MAX + 1 (
${
maxInt256
.
addn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
.
toInt256
(
maxInt256
.
addn
(
1
)),
this
.
safeCast
.
toInt256
(
maxInt256
.
addn
(
1
)),
'SafeCast: value doesn
\'
t fit in an int256'
'SafeCast: value doesn
\'
t fit in an int256'
,
);
);
});
});
it
(
`reverts when casting UINT256_MAX (
${
maxUint256
}
)`
,
async
function
()
{
it
(
`reverts when casting UINT256_MAX (
${
maxUint256
}
)`
,
async
function
()
{
await
expectRevert
(
await
expectRevert
(
this
.
safeCast
.
toInt256
(
maxUint256
),
this
.
safeCast
.
toInt256
(
maxUint256
),
'SafeCast: value doesn
\'
t fit in an int256'
'SafeCast: value doesn
\'
t fit in an int256'
,
);
);
});
});
});
});
...
...
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