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"
:
[
"config:base"
,
":maintainLockFilesWeekly"
,
"group:allNonMajor"
,
"schedule:weekly"
],
...
...
scripts/gen-nav.js
View file @
ace35fde
...
...
@@ -7,7 +7,7 @@ const startCase = require('lodash.startcase');
const
baseDir
=
process
.
argv
[
2
];
const
files
=
proc
.
execFileSync
(
'find'
,
[
baseDir
,
'-type'
,
'f'
],
{
encoding
:
'utf8'
}
'find'
,
[
baseDir
,
'-type'
,
'f'
],
{
encoding
:
'utf8'
}
,
).
split
(
'
\
n'
).
filter
(
s
=>
s
!==
''
);
console
.
log
(
'.API'
);
...
...
scripts/release/update-changelog-release-date.js
View file @
ace35fde
...
...
@@ -27,7 +27,7 @@ if (changelog.indexOf(`## ${version} (unreleased)`) === -1) {
fs
.
writeFileSync
(
'CHANGELOG.md'
,
changelog
.
replace
(
`##
${
version
}
(unreleased)`
,
`##
${
version
}
(
${
new
Date
().
toISOString
().
split
(
'T'
)[
0
]}
)`
)
`##
${
version
}
(
${
new
Date
().
toISOString
().
split
(
'T'
)[
0
]}
)`
)
,
);
cp
.
execSync
(
'git add CHANGELOG.md'
,
{
stdio
:
'inherit'
});
test/GSN/ERC721GSNRecipientMock.test.js
View file @
ace35fde
...
...
@@ -41,9 +41,9 @@ describe('ERC721GSNRecipient (integration)', function () {
await
web3
.
eth
.
sign
(
web3
.
utils
.
soliditySha3
(
// 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
),
signer
)
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
this
.
token
.
address
,
),
signer
,
)
,
);
await
testMintToken
(
this
.
token
,
sender
,
tokenId
,
{
useGSN
:
true
,
approveFunction
});
...
...
test/GSN/GSNRecipient.test.js
View file @
ace35fde
...
...
@@ -38,13 +38,13 @@ describe('GSNRecipient', function () {
it
(
'cannot upgrade to the same RelayHub'
,
async
function
()
{
await
expectRevert
(
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
()
{
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 () {
it
(
'fails when constructor called with a zero address'
,
async
function
()
{
await
expectRevert
(
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 () {
web3
.
utils
.
soliditySha3
(
// the nonce is not signed
// eslint-disable-next-line max-len
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
)
),
signer
)
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
)
,
),
signer
,
)
,
);
await
gsn
.
expectError
(
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
}));
...
...
@@ -63,9 +63,9 @@ describe('GSNRecipientSignature', function () {
await
web3
.
eth
.
sign
(
web3
.
utils
.
soliditySha3
(
// 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
),
signer
)
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
data
.
to
,
),
signer
,
)
,
);
const
{
tx
}
=
await
this
.
recipient
.
mockFunction
({
value
:
0
,
useGSN
:
true
,
approveFunction
});
...
...
@@ -79,9 +79,9 @@ describe('GSNRecipientSignature', function () {
await
web3
.
eth
.
sign
(
web3
.
utils
.
soliditySha3
(
// 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
),
other
)
data
.
relayerAddress
,
data
.
from
,
data
.
encodedFunctionCall
,
toBN
(
data
.
txFee
),
toBN
(
data
.
gasPrice
),
toBN
(
data
.
gas
),
toBN
(
data
.
nonce
),
data
.
relayHubAddress
,
data
.
to
,
),
other
,
)
,
);
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 () {
it
(
'non-admin cannot grant role to other accounts'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'non-admin cannot revoke role'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'only the sender can renounce their roles'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'a role
\'
s previous admins no longer grant roles'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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 () {
it
(
'prevents non-owners from transferring'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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 () {
it
(
'prevents non-owners from renouncement'
,
async
function
()
{
await
expectRevert
(
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 () {
await
expectRevert
(
// eslint-disable-next-line max-len
this
.
ecdsa
.
recover
(
TEST_MESSAGE
,
'0x01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
),
'ECDSA: invalid signature length'
'ECDSA: invalid signature length'
,
);
});
});
...
...
@@ -116,7 +116,7 @@ describe('ECDSA', function () {
// Recover the signer address from the generated message and signature.
expect
(
await
this
.
ecdsa
.
recover
(
toEthSignedMessageHash
(
TEST_MESSAGE
),
signature
signature
,
)).
to
.
equal
(
other
);
});
});
...
...
test/helpers/sign.js
View file @
ace35fde
...
...
@@ -47,7 +47,7 @@ const getSignFor = (contract, signer) => (redeemer, methodName, methodArgs = [])
if
(
methodArgs
.
length
>
0
)
{
parts
.
push
(
contract
.
contract
.
methods
[
methodName
](...
methodArgs
.
concat
([
DUMMY_SIGNATURE
])).
encodeABI
()
.
slice
(
0
,
-
1
*
PADDED_SIGNATURE_SIZE
)
.
slice
(
0
,
-
1
*
PADDED_SIGNATURE_SIZE
)
,
);
}
else
{
const
abi
=
contract
.
abi
.
find
(
abi
=>
abi
.
name
===
methodName
);
...
...
test/introspection/ERC1820Implementer.test.js
View file @
ace35fde
...
...
@@ -29,9 +29,9 @@ describe('ERC1820Implementer', function () {
it
(
'reverts when attempting to set as implementer in the registry'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'can be set as an implementer for supported interfaces in the registry'
,
async
function
()
{
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
))
...
...
test/payment/PaymentSplitter.test.js
View file @
ace35fde
...
...
@@ -18,31 +18,31 @@ describe('PaymentSplitter', function () {
it
(
'rejects more payees than shares'
,
async
function
()
{
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
()
{
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
()
{
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
()
{
await
expectRevert
(
PaymentSplitter
.
new
([
payee1
,
payee2
],
[
20
,
0
]),
'PaymentSplitter: shares are 0'
'PaymentSplitter: shares are 0'
,
);
});
it
(
'rejects repeated payees'
,
async
function
()
{
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 () {
describe
(
'release'
,
async
function
()
{
it
(
'reverts if no funds to claim'
,
async
function
()
{
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
()
{
await
send
.
ether
(
payer1
,
this
.
contract
.
address
,
amount
);
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 () {
await
this
.
escrow
.
deposit
(
payee
,
{
from
:
owner
,
value
:
amount
});
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]) {
it
(
'only the owner can deposit'
,
async
function
()
{
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]) {
it
(
'only the owner can withdraw'
,
async
function
()
{
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 () {
it
(
'requires a non-null beneficiary'
,
async
function
()
{
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 () {
it
(
'does not refund refundees'
,
async
function
()
{
await
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
});
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
()
{
await
this
.
escrow
.
deposit
(
refundee1
,
{
from
:
owner
,
value
:
amount
});
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
()
{
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
});
...
...
@@ -69,13 +69,13 @@ describe('RefundEscrow', function () {
it
(
'rejects deposits'
,
async
function
()
{
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
()
{
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 () {
it
(
'prevents entering the refund state'
,
async
function
()
{
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
()
{
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
()
{
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
});
...
...
@@ -116,7 +116,7 @@ describe('RefundEscrow', function () {
it
(
'rejects deposits'
,
async
function
()
{
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 () {
it
(
'does not allow beneficiary withdrawal'
,
async
function
()
{
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
()
{
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
()
{
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 () {
it
(
'deployer can mint tokens'
,
async
function
()
{
const
receipt
=
await
this
.
token
.
mint
(
other
,
firstTokenId
,
firstTokenIdAmount
,
'0x'
,
{
from
:
deployer
});
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
);
...
...
@@ -59,7 +59,7 @@ describe('ERC1155PresetMinterPauser', function () {
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
await
expectRevert
(
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 () {
describe
(
'batched minting'
,
function
()
{
it
(
'deployer can batch mint tokens'
,
async
function
()
{
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'
,
{
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
);
...
...
@@ -80,9 +80,9 @@ describe('ERC1155PresetMinterPauser', function () {
it
(
'other accounts cannot batch mint tokens'
,
async
function
()
{
await
expectRevert
(
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 () {
await
expectRevert
(
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
()
{
await
expectRevert
(
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 () {
const
receipt
=
await
this
.
token
.
burn
(
other
,
firstTokenId
,
firstTokenIdAmount
.
subn
(
1
),
{
from
:
other
});
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'
);
...
...
test/presets/ERC20PresetMinterPauser.test.js
View file @
ace35fde
...
...
@@ -54,7 +54,7 @@ describe('ERC20PresetMinterPauser', function () {
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
await
expectRevert
(
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 () {
await
expectRevert
(
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 () {
it
(
'other accounts cannot mint tokens'
,
async
function
()
{
await
expectRevert
(
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 () {
await
expectRevert
(
this
.
token
.
mint
(
other
,
{
from
:
deployer
}),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
});
it
(
'other accounts cannot pause'
,
async
function
()
{
await
expectRevert
(
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 () {
const
callData
=
new
ImplV1
(
''
).
contract
.
methods
[
'initializeNonPayable(uint256)'
](
1337
).
encodeABI
();
await
expectRevert
(
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
{
from
:
anotherAccount
}
{
from
:
anotherAccount
}
,
),
'caller is not the owner'
,
);
...
...
@@ -98,7 +98,7 @@ describe('ProxyAdmin', function () {
const
callData
=
'0x12345678'
;
await
expectRevert
.
unspecified
(
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
{
from
:
proxyAdminOwner
}
{
from
:
proxyAdminOwner
}
,
),
);
});
...
...
@@ -108,7 +108,7 @@ describe('ProxyAdmin', function () {
it
(
'upgrades implementation'
,
async
function
()
{
const
callData
=
new
ImplV1
(
''
).
contract
.
methods
[
'initializeNonPayable(uint256)'
](
1337
).
encodeABI
();
await
this
.
proxyAdmin
.
upgradeAndCall
(
this
.
proxy
.
address
,
this
.
implementationV2
.
address
,
callData
,
{
from
:
proxyAdminOwner
}
{
from
:
proxyAdminOwner
}
,
);
const
implementationAddress
=
await
this
.
proxyAdmin
.
getProxyImplementation
(
this
.
proxy
.
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
it
(
'reverts'
,
async
function
()
{
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,
it
(
'reverts when queried about the zero address'
,
async
function
()
{
await
expectRevert
(
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,
it
(
'returns zero for given addresses'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
firstTokenId
firstTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOf
(
secondTokenHolder
,
secondTokenId
secondTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
unknownTokenId
unknownTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
});
});
...
...
@@ -60,24 +60,24 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
{
from
:
minter
,
}
}
,
);
});
it
(
'returns the amount of tokens owned by the given addresses'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
firstTokenId
firstTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
firstAmount
);
expect
(
await
this
.
token
.
balanceOf
(
secondTokenHolder
,
secondTokenId
secondTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
secondAmount
);
expect
(
await
this
.
token
.
balanceOf
(
firstTokenHolder
,
unknownTokenId
unknownTokenId
,
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
});
});
...
...
@@ -88,17 +88,17 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
await
expectRevert
(
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'
,
);
await
expectRevert
(
this
.
token
.
balanceOfBatch
(
[
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,
await
expectRevert
(
this
.
token
.
balanceOfBatch
(
[
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,
it
(
'returns zeros for each account'
,
async
function
()
{
const
result
=
await
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
],
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
[
firstTokenId
,
secondTokenId
,
unknownTokenId
]
,
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
'0'
);
...
...
@@ -137,14 +137,14 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
{
from
:
minter
,
}
}
,
);
});
it
(
'returns amounts owned by each account in order passed'
,
async
function
()
{
const
result
=
await
this
.
token
.
balanceOfBatch
(
[
secondTokenHolder
,
firstTokenHolder
,
firstTokenHolder
],
[
secondTokenId
,
firstTokenId
,
unknownTokenId
]
[
secondTokenId
,
firstTokenId
,
unknownTokenId
]
,
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
secondAmount
);
...
...
@@ -155,7 +155,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'returns multiple times the balance of the same address when asked'
,
async
function
()
{
const
result
=
await
this
.
token
.
balanceOfBatch
(
[
firstTokenHolder
,
secondTokenHolder
,
firstTokenHolder
],
[
firstTokenId
,
secondTokenId
,
firstTokenId
]
[
firstTokenId
,
secondTokenId
,
firstTokenId
]
,
);
expect
(
result
).
to
.
be
.
an
(
'array'
);
expect
(
result
[
0
]).
to
.
be
.
a
.
bignumber
.
equal
(
result
[
2
]);
...
...
@@ -188,7 +188,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
it
(
'reverts if attempting to approve self as an operator'
,
async
function
()
{
await
expectRevert
(
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,
'0x'
,
{
from
:
minter
,
}
}
,
);
});
...
...
@@ -219,7 +219,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
{
from
:
multiTokenHolder
},
),
'ERC1155: insufficient balance for transfer'
'ERC1155: insufficient balance for transfer'
,
);
});
...
...
@@ -233,7 +233,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
{
from
:
multiTokenHolder
},
),
'ERC1155: transfer to the zero address'
'ERC1155: transfer to the zero address'
,
);
});
...
...
@@ -295,7 +295,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
recipient
,
firstTokenId
,
firstAmount
,
'0x'
,
{
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,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
}
{
from
:
multiTokenHolder
}
,
);
({
logs
:
this
.
transferLogs
}
=
this
.
transferReceipt
);
});
...
...
@@ -377,7 +377,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
firstTokenId
,
firstAmount
,
data
,
{
from
:
multiTokenHolder
}
{
from
:
multiTokenHolder
}
,
);
({
logs
:
this
.
transferLogs
}
=
this
.
transferReceipt
);
});
...
...
@@ -414,7 +414,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
this
.
receiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
,
}),
'ERC1155: ERC1155Receiver rejected tokens'
'ERC1155: ERC1155Receiver rejected tokens'
,
);
});
});
...
...
@@ -432,7 +432,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
this
.
receiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
,
}),
'ERC1155ReceiverMock: reverting on receive'
'ERC1155ReceiverMock: reverting on receive'
,
);
});
});
...
...
@@ -443,7 +443,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
await
expectRevert
.
unspecified
(
this
.
token
.
safeTransferFrom
(
multiTokenHolder
,
invalidReceiver
.
address
,
firstTokenId
,
firstAmount
,
'0x'
,
{
from
:
multiTokenHolder
,
})
})
,
);
});
});
...
...
@@ -461,7 +461,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
'0x'
,
{
from
:
minter
,
}
}
,
);
});
...
...
@@ -471,9 +471,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
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,
multiTokenHolder
,
recipient
,
[
firstTokenId
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
await
expectRevert
(
...
...
@@ -493,9 +493,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
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,
multiTokenHolder
,
ZERO_ADDRESS
,
[
firstTokenId
,
secondTokenId
],
[
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,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
}
'0x'
,
{
from
:
multiTokenHolder
}
,
));
});
...
...
@@ -569,9 +569,9 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
multiTokenHolder
,
recipient
,
[
firstTokenId
,
secondTokenId
],
[
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,
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
},
),
'ERC1155: ERC1155Receiver rejected tokens'
'ERC1155: ERC1155Receiver rejected tokens'
,
);
});
});
...
...
@@ -712,7 +712,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
},
),
'ERC1155ReceiverMock: reverting on batch receive'
'ERC1155ReceiverMock: reverting on batch receive'
,
);
});
});
...
...
@@ -761,7 +761,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder,
[
firstTokenId
,
secondTokenId
],
[
firstAmount
,
secondAmount
],
'0x'
,
{
from
:
multiTokenHolder
},
)
)
,
);
});
});
...
...
test/token/ERC1155/ERC1155.test.js
View file @
ace35fde
...
...
@@ -34,7 +34,7 @@ describe('ERC1155', function () {
it
(
'reverts with a zero destination address'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts with a zero destination address'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
this
.
token
.
mintBatch
(
tokenBatchHolder
,
tokenBatchIds
,
mintAmounts
.
slice
(
1
),
data
),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
await
expectRevert
(
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 () {
tokenBatchIds
,
mintAmounts
,
data
,
{
from
:
operator
}
{
from
:
operator
}
,
));
});
...
...
@@ -101,7 +101,7 @@ describe('ERC1155', function () {
it
(
'credits the minted batch of tokens'
,
async
function
()
{
const
holderBatchBalances
=
await
this
.
token
.
balanceOfBatch
(
new
Array
(
tokenBatchIds
.
length
).
fill
(
tokenBatchHolder
),
tokenBatchIds
tokenBatchIds
,
);
for
(
let
i
=
0
;
i
<
holderBatchBalances
.
length
;
i
++
)
{
...
...
@@ -115,14 +115,14 @@ describe('ERC1155', function () {
it
(
'reverts when burning the zero account
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
this
.
token
.
burn
(
tokenHolder
,
tokenId
,
mintAmount
),
'ERC1155: burn amount exceeds balance'
'ERC1155: burn amount exceeds balance'
,
);
});
...
...
@@ -132,12 +132,12 @@ describe('ERC1155', function () {
tokenId
,
mintAmount
,
data
,
{
from
:
operator
}
{
from
:
operator
}
,
);
await
expectRevert
(
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 () {
tokenHolder
,
tokenId
,
burnAmount
,
{
from
:
operator
}
{
from
:
operator
}
,
));
});
...
...
@@ -165,7 +165,7 @@ describe('ERC1155', function () {
it
(
'accounts for both minting and burning'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
tokenHolder
,
tokenId
tokenId
,
)).
to
.
be
.
bignumber
.
equal
(
mintAmount
.
sub
(
burnAmount
));
});
});
...
...
@@ -175,26 +175,26 @@ describe('ERC1155', function () {
it
(
'reverts when burning the zero account
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
.
slice
(
1
)),
'ERC1155: ids and amounts length mismatch'
'ERC1155: ids and amounts length mismatch'
,
);
await
expectRevert
(
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
()
{
await
expectRevert
(
this
.
token
.
burnBatch
(
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
),
'ERC1155: burn amount exceeds balance'
'ERC1155: burn amount exceeds balance'
,
);
});
...
...
@@ -205,7 +205,7 @@ describe('ERC1155', function () {
tokenBatchHolder
,
tokenBatchIds
,
burnAmounts
,
{
from
:
operator
}
{
from
:
operator
}
,
));
});
...
...
@@ -222,7 +222,7 @@ describe('ERC1155', function () {
it
(
'accounts for both minting and burning'
,
async
function
()
{
const
holderBatchBalances
=
await
this
.
token
.
balanceOfBatch
(
new
Array
(
tokenBatchIds
.
length
).
fill
(
tokenBatchHolder
),
tokenBatchIds
tokenBatchIds
,
);
for
(
let
i
=
0
;
i
<
holderBatchBalances
.
length
;
i
++
)
{
...
...
test/token/ERC1155/ERC1155Burnable.test.js
View file @
ace35fde
...
...
@@ -38,7 +38,7 @@ describe('ERC1155Burnable', function () {
it
(
'unapproved accounts cannot burn the holder
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'unapproved accounts cannot burn the holder
\'
s tokens'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts when trying to safeTransferFrom from holder'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
this
.
token
.
burn
(
holder
,
firstTokenId
,
firstTokenAmount
),
'ERC1155Pausable: token transfer while paused'
'ERC1155Pausable: token transfer while paused'
,
);
});
it
(
'reverts when trying to burnBatch'
,
async
function
()
{
await
expectRevert
(
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
shouldBehaveLikeERC20Transfer
(
errorPrefix
,
initialHolder
,
recipient
,
initialSupply
,
function
(
from
,
to
,
value
)
{
return
this
.
token
.
transfer
(
to
,
value
,
{
from
});
}
}
,
);
});
...
...
@@ -88,7 +88,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it
(
'reverts'
,
async
function
()
{
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
it
(
'reverts'
,
async
function
()
{
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
it
(
'reverts'
,
async
function
()
{
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
it
(
'reverts'
,
async
function
()
{
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
it
(
'reverts'
,
async
function
()
{
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
shouldBehaveLikeERC20Approve
(
errorPrefix
,
initialHolder
,
recipient
,
initialSupply
,
function
(
owner
,
spender
,
amount
)
{
return
this
.
token
.
approve
(
spender
,
amount
,
{
from
:
owner
});
}
}
,
);
});
}
...
...
@@ -166,7 +166,7 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
it
(
'reverts'
,
async
function
()
{
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
describe
(
'when the recipient is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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
describe
(
'when the spender is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
describe
(
'when there was no approved amount before'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'reverts when more than the full allowance is removed'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'reverts'
,
async
function
()
{
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 () {
const
amount
=
new
BN
(
50
);
it
(
'rejects a null account'
,
async
function
()
{
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 () {
describe
(
'for a non zero account'
,
function
()
{
it
(
'rejects burning more than balance'
,
async
function
()
{
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 () {
describe
(
'when the sender is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
describe
(
'when the owner is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'requires a non-zero cap'
,
async
function
()
{
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 () {
await
this
.
token
.
pause
();
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 () {
await
this
.
token
.
pause
();
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 () {
await
this
.
token
.
pause
();
await
expectRevert
(
this
.
token
.
mint
(
recipient
,
amount
),
'ERC20Pausable: token transfer while paused'
'ERC20Pausable: token transfer while paused'
,
);
});
});
...
...
@@ -128,7 +128,7 @@ describe('ERC20Pausable', function () {
await
this
.
token
.
pause
();
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 () {
expect
(
await
this
.
token
.
totalSupplyAt
(
this
.
initialSnapshotId
)).
to
.
be
.
bignumber
.
equal
(
initialSupply
);
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 () {
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
(
await
this
.
token
.
balanceOf
(
initialHolder
)
await
this
.
token
.
balanceOf
(
initialHolder
)
,
);
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
(
await
this
.
token
.
balanceOf
(
other
)
await
this
.
token
.
balanceOf
(
other
)
,
);
});
});
...
...
@@ -189,13 +189,13 @@ describe('ERC20Snapshot', function () {
for
(
const
id
of
this
.
secondSnapshotIds
)
{
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
(
await
this
.
token
.
balanceOf
(
recipient
)
await
this
.
token
.
balanceOf
(
recipient
)
,
);
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 () {
it
(
'reverts when decreasing the allowance'
,
async
function
()
{
await
expectRevert
(
this
.
wrapper
.
decreaseAllowance
(
10
),
'SafeERC20: decreased allowance below zero'
'SafeERC20: decreased allowance below zero'
,
);
});
});
...
...
@@ -110,7 +110,7 @@ function shouldOnlyRevertOnErrors () {
it
(
'reverts when approving a non-zero allowance'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts when decreasing the allowance to a negative value'
,
async
function
()
{
await
expectRevert
(
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 () {
const
pastReleaseTime
=
(
await
time
.
latest
()).
sub
(
time
.
duration
.
years
(
1
));
await
expectRevert
(
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]) {
it
(
'reverts'
,
async
function
()
{
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]) {
it
(
'reverts'
,
async
function
()
{
await
this
.
token
.
approve
(
burner
,
amount
,
{
from
:
owner
});
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]) {
it
(
'reverts'
,
async
function
()
{
await
this
.
token
.
approve
(
burner
,
allowance
,
{
from
:
owner
});
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 () {
it
(
'reverts when queried for non existent token id'
,
async
function
()
{
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 () {
it
(
'reverts when setting for non existent token id'
,
async
function
()
{
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 () {
expect
(
await
this
.
token
.
exists
(
firstTokenId
)).
to
.
equal
(
false
);
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 () {
context
(
'when querying the zero address'
,
function
()
{
it
(
'throws'
,
async
function
()
{
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 () {
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'keeps same tokens by index'
,
async
function
()
{
if
(
!
this
.
token
.
tokenOfOwnerByIndex
)
return
;
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
(
[
firstTokenId
.
toNumber
(),
secondTokenId
.
toNumber
()]
[
firstTokenId
.
toNumber
(),
secondTokenId
.
toNumber
()]
,
);
});
});
...
...
@@ -271,7 +271,7 @@ describe('ERC721', function () {
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
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 () {
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
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 () {
nonExistentTokenId
,
{
from
:
owner
},
),
'ERC721: operator query for nonexistent token'
'ERC721: operator query for nonexistent token'
,
);
});
});
...
...
@@ -384,7 +384,7 @@ describe('ERC721', function () {
const
invalidReceiver
=
await
ERC721ReceiverMock
.
new
(
'0x42'
,
false
);
await
expectRevert
(
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 () {
const
revertingReceiver
=
await
ERC721ReceiverMock
.
new
(
RECEIVER_MAGIC_VALUE
,
true
);
await
expectRevert
(
this
.
token
.
safeTransferFrom
(
owner
,
revertingReceiver
.
address
,
tokenId
,
{
from
:
owner
}),
'ERC721ReceiverMock: reverting'
'ERC721ReceiverMock: reverting'
,
);
});
});
...
...
@@ -404,7 +404,7 @@ describe('ERC721', function () {
const
nonReceiver
=
this
.
token
;
await
expectRevert
(
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 () {
const
invalidReceiver
=
await
ERC721ReceiverMock
.
new
(
'0x42'
,
false
);
await
expectRevert
(
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 () {
const
revertingReceiver
=
await
ERC721ReceiverMock
.
new
(
RECEIVER_MAGIC_VALUE
,
true
);
await
expectRevert
(
this
.
token
.
safeMint
(
revertingReceiver
.
address
,
tokenId
),
'ERC721ReceiverMock: reverting'
'ERC721ReceiverMock: reverting'
,
);
});
});
...
...
@@ -463,7 +463,7 @@ describe('ERC721', function () {
const
nonReceiver
=
this
.
token
;
await
expectRevert
(
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 () {
context
(
'when the address that receives the approval is the owner'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'reverts'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
getApproved
(
nonExistentTokenId
),
'ERC721: approved query for nonexistent token'
'ERC721: approved query for nonexistent token'
,
);
});
});
...
...
@@ -682,7 +682,7 @@ describe('ERC721', function () {
context
(
'when token has been minted '
,
async
function
()
{
it
(
'should return the zero address'
,
async
function
()
{
expect
(
await
this
.
token
.
getApproved
(
firstTokenId
)).
to
.
be
.
equal
(
ZERO_ADDRESS
ZERO_ADDRESS
,
);
});
...
...
@@ -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
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
describe
(
'when the given address does not own any token'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'returns correct token IDs for target'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
other
)).
to
.
be
.
bignumber
.
equal
(
'2'
);
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
(),
secondTokenId
.
toNumber
()]);
...
...
@@ -745,7 +745,7 @@ describe('ERC721', function () {
it
(
'returns empty collection for original owner'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
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 () {
describe
(
'tokenByIndex'
,
function
()
{
it
(
'returns all tokens'
,
async
function
()
{
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
(),
secondTokenId
.
toNumber
()]);
...
...
@@ -762,7 +762,7 @@ describe('ERC721', function () {
it
(
'reverts if index is greater than supply'
,
async
function
()
{
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 () {
expect
(
await
this
.
token
.
totalSupply
()).
to
.
be
.
bignumber
.
equal
(
'3'
);
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
(
x
=>
(
x
!==
tokenId
)
x
=>
(
x
!==
tokenId
)
,
);
expect
(
tokensListed
.
map
(
t
=>
t
.
toNumber
())).
to
.
have
.
members
(
expectedTokens
.
map
(
t
=>
t
.
toNumber
()));
});
...
...
@@ -792,7 +792,7 @@ describe('ERC721', function () {
describe
(
'_mint(address, uint256)'
,
function
()
{
it
(
'reverts with a null destination address'
,
async
function
()
{
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 () {
describe
(
'_burn'
,
function
()
{
it
(
'reverts when burning a non-existent token id'
,
async
function
()
{
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 () {
it
(
'deletes the token'
,
async
function
()
{
expect
(
await
this
.
token
.
balanceOf
(
owner
)).
to
.
be
.
bignumber
.
equal
(
'1'
);
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 () {
await
this
.
token
.
burn
(
secondTokenId
,
{
from
:
owner
});
expect
(
await
this
.
token
.
totalSupply
()).
to
.
be
.
bignumber
.
equal
(
'0'
);
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
()
{
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 () {
it
(
'burns the given token ID and adjusts the balance of the owner'
,
async
function
()
{
await
expectRevert
(
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'
);
});
...
...
@@ -64,7 +64,7 @@ describe('ERC721Burnable', function () {
context
(
'getApproved'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
describe
(
'when the given token ID was not tracked by this contract'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'reverts when trying to transferFrom'
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
this
.
token
.
methods
[
'safeTransferFrom(address,address,uint256,bytes)'
](
owner
,
receiver
,
firstTokenId
,
mockData
,
{
from
:
owner
}
),
'ERC721Pausable: token transfer while paused'
owner
,
receiver
,
firstTokenId
,
mockData
,
{
from
:
owner
}
,
),
'ERC721Pausable: token transfer while paused'
,
);
});
it
(
'reverts when trying to mint'
,
async
function
()
{
await
expectRevert
(
this
.
token
.
mint
(
receiver
,
secondTokenId
),
'ERC721Pausable: token transfer while paused'
'ERC721Pausable: token transfer while paused'
,
);
});
it
(
'reverts when trying to burn'
,
async
function
()
{
await
expectRevert
(
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,
it
(
'reverts when sending more than the balance'
,
async
function
()
{
const
balance
=
await
this
.
token
.
balanceOf
(
holder
);
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
()
{
await
expectRevert
.
unspecified
(
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,
it
(
'reverts when sending a non-zero amount'
,
async
function
()
{
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,
// This is not yet reflected in the spec
await
expectRevert
.
unspecified
(
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
it
(
'reverts when burning more than the balance'
,
async
function
()
{
const
balance
=
await
this
.
token
.
balanceOf
(
holder
);
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
it
(
'reverts when burning a non-zero amount'
,
async
function
()
{
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
// This is not yet reflected in the spec
await
expectRevert
.
unspecified
(
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,
it
(
'reverts when minting tokens for the zero address'
,
async
function
()
{
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
it
(
'operatorSend reverts'
,
async
function
()
{
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
()
{
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
it
(
'TokensRecipient receives mint (internal) data and is called after state mutation'
,
async
function
()
{
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
);
...
...
@@ -422,7 +422,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope
it
(
'operatorSend reverts'
,
async
function
()
{
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
it
(
'operatorBurn reverts'
,
async
function
()
{
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
const
{
tx
}
=
await
burnFromHolder
(
this
.
token
,
this
.
sender
,
amount
,
data
,
{
from
:
this
.
sender
});
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
const
{
tx
}
=
await
this
.
token
.
operatorBurn
(
this
.
sender
,
amount
,
data
,
operatorData
,
{
from
:
operator
});
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 () {
describe
(
'when the owner is the zero address'
,
function
()
{
it
(
'reverts'
,
async
function
()
{
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 () {
it
(
'reverts when self-authorizing'
,
async
function
()
{
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
()
{
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 () {
it
(
'cannot be revoked for themselves'
,
async
function
()
{
await
expectRevert
(
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 () {
await
this
.
contractRecipient
.
setAcceptEther
(
false
);
await
expectRevert
(
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 () {
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
});
...
...
@@ -135,7 +135,7 @@ describe('Address', function () {
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'CallReceiverMock: reverting'
'CallReceiverMock: reverting'
,
);
});
...
...
@@ -152,7 +152,7 @@ describe('Address', function () {
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
}).
timeout
(
5000
);
...
...
@@ -165,7 +165,7 @@ describe('Address', function () {
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
});
...
...
@@ -178,7 +178,7 @@ describe('Address', function () {
await
expectRevert
(
this
.
mock
.
functionCall
(
this
.
contractRecipient
.
address
,
abiEncodedCall
),
'Address: low-level call failed'
'Address: low-level call failed'
,
);
});
});
...
...
@@ -228,7 +228,7 @@ describe('Address', function () {
await
expectRevert
(
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 () {
expect
(
await
balance
.
current
(
this
.
mock
.
address
)).
to
.
be
.
bignumber
.
equal
(
'0'
);
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
);
...
...
@@ -280,7 +280,7 @@ describe('Address', function () {
await
send
.
ether
(
other
,
this
.
mock
.
address
,
amount
);
await
expectRevert
(
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 () {
const
encodedParams
=
web3
.
eth
.
abi
.
encodeParameters
(
[
'string'
,
'string'
,
'address'
,
'uint256'
],
[
'MyToken'
,
'MTKN'
,
deployerAccount
,
100
]
[
'MyToken'
,
'MTKN'
,
deployerAccount
,
100
]
,
).
slice
(
2
);
const
constructorByteCode
=
`
${
ERC20Mock
.
bytecode
}${
encodedParams
}
`
;
...
...
@@ -73,20 +73,20 @@ describe('Create2', function () {
it
(
'fails deploying a contract in an existent address'
,
async
function
()
{
await
this
.
factory
.
deploy
(
0
,
saltHex
,
constructorByteCode
,
{
from
:
deployerAccount
});
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
()
{
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
()
{
await
expectRevert
(
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 () {
expect
(
keys
.
length
).
to
.
equal
(
values
.
length
);
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
Promise
.
all
(
keys
.
map
(
key
=>
map
.
get
(
key
)
map
.
get
(
key
)
,
))).
to
.
have
.
same
.
members
(
values
);
// To compare key-value pairs, we zip keys and values, and convert BNs to
...
...
@@ -36,7 +36,7 @@ describe('EnumerableMap', function () {
const
entry
=
await
map
.
at
(
index
);
return
[
entry
.
key
.
toString
(),
entry
.
value
];
}))).
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');
function
shouldBehaveLikeSet
(
valueA
,
valueB
,
valueC
)
{
async
function
expectMembersMatch
(
set
,
values
)
{
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
());
...
...
test/utils/Pausable.test.js
View file @
ace35fde
...
...
@@ -27,7 +27,7 @@ describe('Pausable', function () {
it
(
'cannot take drastic measure in non-pause'
,
async
function
()
{
await
expectRevert
(
this
.
pausable
.
drasticMeasure
(),
'Pausable: not paused'
'Pausable: not paused'
,
);
expect
(
await
this
.
pausable
.
drasticMeasureTaken
()).
to
.
equal
(
false
);
});
...
...
@@ -77,7 +77,7 @@ describe('Pausable', function () {
it
(
'should prevent drastic measure'
,
async
function
()
{
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 () {
// in the side-effects.
it
(
'does not allow local recursion'
,
async
function
()
{
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
()
{
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 () => {
it
(
`reverts when downcasting 2^
${
bits
}
(
${
maxValue
.
addn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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 () => {
it
(
'reverts when casting -1'
,
async
function
()
{
await
expectRevert
(
this
.
safeCast
.
toUint256
(
-
1
),
'SafeCast: value must be positive'
'SafeCast: value must be positive'
,
);
});
it
(
`reverts when casting INT256_MIN (
${
minInt256
}
)`
,
async
function
()
{
await
expectRevert
(
this
.
safeCast
.
toUint256
(
minInt256
),
'SafeCast: value must be positive'
'SafeCast: value must be positive'
,
);
});
it
(
`reverts when casting UINT256_MAX (
${
maxUint256
}
)`
,
async
function
()
{
await
expectRevert
(
this
.
safeCast
.
toUint256
(
maxUint256
),
'SafeCast: value must be positive'
'SafeCast: value must be positive'
,
);
});
});
...
...
@@ -111,28 +111,28 @@ describe('SafeCast', async () => {
it
(
`reverts when downcasting -2^
${
bits
-
1
}
- 1 (
${
minValue
.
subn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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 () => {
it
(
`reverts when casting INT256_MAX + 1 (
${
maxInt256
.
addn
(
1
)}
)`
,
async
function
()
{
await
expectRevert
(
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
()
{
await
expectRevert
(
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