123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774 |
- const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
- const { ZERO_ADDRESS } = constants;
- const { expect } = require('chai');
- const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
- const ERC1155ReceiverMock = artifacts.require('ERC1155ReceiverMock');
- function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, multiTokenHolder, recipient, proxy]) {
- const firstTokenId = new BN(1);
- const secondTokenId = new BN(2);
- const unknownTokenId = new BN(3);
- const firstAmount = new BN(1000);
- const secondAmount = new BN(2000);
- const RECEIVER_SINGLE_MAGIC_VALUE = '0xf23a6e61';
- const RECEIVER_BATCH_MAGIC_VALUE = '0xbc197c81';
- describe('like an ERC1155', function () {
- describe('balanceOf', function () {
- 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',
- );
- });
- context('when accounts don\'t own tokens', function () {
- it('returns zero for given addresses', async function () {
- expect(await this.token.balanceOf(
- firstTokenHolder,
- firstTokenId,
- )).to.be.bignumber.equal('0');
- expect(await this.token.balanceOf(
- secondTokenHolder,
- secondTokenId,
- )).to.be.bignumber.equal('0');
- expect(await this.token.balanceOf(
- firstTokenHolder,
- unknownTokenId,
- )).to.be.bignumber.equal('0');
- });
- });
- context('when accounts own some tokens', function () {
- beforeEach(async function () {
- await this.token.mint(firstTokenHolder, firstTokenId, firstAmount, '0x', {
- from: minter,
- });
- await this.token.mint(
- secondTokenHolder,
- secondTokenId,
- secondAmount,
- '0x',
- {
- from: minter,
- },
- );
- });
- it('returns the amount of tokens owned by the given addresses', async function () {
- expect(await this.token.balanceOf(
- firstTokenHolder,
- firstTokenId,
- )).to.be.bignumber.equal(firstAmount);
- expect(await this.token.balanceOf(
- secondTokenHolder,
- secondTokenId,
- )).to.be.bignumber.equal(secondAmount);
- expect(await this.token.balanceOf(
- firstTokenHolder,
- unknownTokenId,
- )).to.be.bignumber.equal('0');
- });
- });
- });
- describe('balanceOfBatch', function () {
- it('reverts when input arrays don\'t match up', async function () {
- await expectRevert(
- this.token.balanceOfBatch(
- [firstTokenHolder, secondTokenHolder, firstTokenHolder, secondTokenHolder],
- [firstTokenId, secondTokenId, unknownTokenId],
- ),
- 'ERC1155: accounts and ids length mismatch',
- );
- await expectRevert(
- this.token.balanceOfBatch(
- [firstTokenHolder, secondTokenHolder],
- [firstTokenId, secondTokenId, unknownTokenId],
- ),
- 'ERC1155: accounts and ids length mismatch',
- );
- });
- it('reverts when one of the addresses is the zero address', async function () {
- await expectRevert(
- this.token.balanceOfBatch(
- [firstTokenHolder, secondTokenHolder, ZERO_ADDRESS],
- [firstTokenId, secondTokenId, unknownTokenId],
- ),
- 'ERC1155: batch balance query for the zero address',
- );
- });
- context('when accounts don\'t own tokens', function () {
- it('returns zeros for each account', async function () {
- const result = await this.token.balanceOfBatch(
- [firstTokenHolder, secondTokenHolder, firstTokenHolder],
- [firstTokenId, secondTokenId, unknownTokenId],
- );
- expect(result).to.be.an('array');
- expect(result[0]).to.be.a.bignumber.equal('0');
- expect(result[1]).to.be.a.bignumber.equal('0');
- expect(result[2]).to.be.a.bignumber.equal('0');
- });
- });
- context('when accounts own some tokens', function () {
- beforeEach(async function () {
- await this.token.mint(firstTokenHolder, firstTokenId, firstAmount, '0x', {
- from: minter,
- });
- await this.token.mint(
- secondTokenHolder,
- secondTokenId,
- secondAmount,
- '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],
- );
- expect(result).to.be.an('array');
- expect(result[0]).to.be.a.bignumber.equal(secondAmount);
- expect(result[1]).to.be.a.bignumber.equal(firstAmount);
- expect(result[2]).to.be.a.bignumber.equal('0');
- });
- 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],
- );
- expect(result).to.be.an('array');
- expect(result[0]).to.be.a.bignumber.equal(result[2]);
- expect(result[0]).to.be.a.bignumber.equal(firstAmount);
- expect(result[1]).to.be.a.bignumber.equal(secondAmount);
- expect(result[2]).to.be.a.bignumber.equal(firstAmount);
- });
- });
- });
- describe('setApprovalForAll', function () {
- let logs;
- beforeEach(async function () {
- ({ logs } = await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder }));
- });
- it('sets approval status which can be queried via isApprovedForAll', async function () {
- expect(await this.token.isApprovedForAll(multiTokenHolder, proxy)).to.be.equal(true);
- });
- it('emits an ApprovalForAll log', function () {
- expectEvent.inLogs(logs, 'ApprovalForAll', { account: multiTokenHolder, operator: proxy, approved: true });
- });
- it('can unset approval for an operator', async function () {
- await this.token.setApprovalForAll(proxy, false, { from: multiTokenHolder });
- expect(await this.token.isApprovedForAll(multiTokenHolder, proxy)).to.be.equal(false);
- });
- 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',
- );
- });
- });
- describe('safeTransferFrom', function () {
- beforeEach(async function () {
- await this.token.mint(multiTokenHolder, firstTokenId, firstAmount, '0x', {
- from: minter,
- });
- await this.token.mint(
- multiTokenHolder,
- secondTokenId,
- secondAmount,
- '0x',
- {
- from: minter,
- },
- );
- });
- it('reverts when transferring more than balance', async function () {
- await expectRevert(
- this.token.safeTransferFrom(
- multiTokenHolder,
- recipient,
- firstTokenId,
- firstAmount.addn(1),
- '0x',
- { from: multiTokenHolder },
- ),
- 'ERC1155: insufficient balance for transfer',
- );
- });
- it('reverts when transferring to zero address', async function () {
- await expectRevert(
- this.token.safeTransferFrom(
- multiTokenHolder,
- ZERO_ADDRESS,
- firstTokenId,
- firstAmount,
- '0x',
- { from: multiTokenHolder },
- ),
- 'ERC1155: transfer to the zero address',
- );
- });
- function transferWasSuccessful ({ operator, from, id, value }) {
- it('debits transferred balance from sender', async function () {
- const newBalance = await this.token.balanceOf(from, id);
- expect(newBalance).to.be.a.bignumber.equal('0');
- });
- it('credits transferred balance to receiver', async function () {
- const newBalance = await this.token.balanceOf(this.toWhom, id);
- expect(newBalance).to.be.a.bignumber.equal(value);
- });
- it('emits a TransferSingle log', function () {
- expectEvent.inLogs(this.transferLogs, 'TransferSingle', {
- operator,
- from,
- to: this.toWhom,
- id,
- value,
- });
- });
- }
- context('when called by the multiTokenHolder', async function () {
- beforeEach(async function () {
- this.toWhom = recipient;
- ({ logs: this.transferLogs } =
- await this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', {
- from: multiTokenHolder,
- }));
- });
- transferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- id: firstTokenId,
- value: firstAmount,
- });
- it('preserves existing balances which are not transferred by multiTokenHolder', async function () {
- const balance1 = await this.token.balanceOf(multiTokenHolder, secondTokenId);
- expect(balance1).to.be.a.bignumber.equal(secondAmount);
- const balance2 = await this.token.balanceOf(recipient, secondTokenId);
- expect(balance2).to.be.a.bignumber.equal('0');
- });
- });
- context('when called by an operator on behalf of the multiTokenHolder', function () {
- context('when operator is not approved by multiTokenHolder', function () {
- beforeEach(async function () {
- await this.token.setApprovalForAll(proxy, false, { from: multiTokenHolder });
- });
- it('reverts', async function () {
- await expectRevert(
- this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', {
- from: proxy,
- }),
- 'ERC1155: caller is not owner nor approved',
- );
- });
- });
- context('when operator is approved by multiTokenHolder', function () {
- beforeEach(async function () {
- this.toWhom = recipient;
- await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder });
- ({ logs: this.transferLogs } =
- await this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', {
- from: proxy,
- }));
- });
- transferWasSuccessful.call(this, {
- operator: proxy,
- from: multiTokenHolder,
- id: firstTokenId,
- value: firstAmount,
- });
- it('preserves operator\'s balances not involved in the transfer', async function () {
- const balance1 = await this.token.balanceOf(proxy, firstTokenId);
- expect(balance1).to.be.a.bignumber.equal('0');
- const balance2 = await this.token.balanceOf(proxy, secondTokenId);
- expect(balance2).to.be.a.bignumber.equal('0');
- });
- });
- });
- context('when sending to a valid receiver', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- RECEIVER_SINGLE_MAGIC_VALUE, false,
- RECEIVER_BATCH_MAGIC_VALUE, false,
- );
- });
- context('without data', function () {
- beforeEach(async function () {
- this.toWhom = this.receiver.address;
- this.transferReceipt = await this.token.safeTransferFrom(
- multiTokenHolder,
- this.receiver.address,
- firstTokenId,
- firstAmount,
- '0x',
- { from: multiTokenHolder },
- );
- ({ logs: this.transferLogs } = this.transferReceipt);
- });
- transferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- id: firstTokenId,
- value: firstAmount,
- });
- it('calls onERC1155Received', async function () {
- await expectEvent.inTransaction(this.transferReceipt.tx, ERC1155ReceiverMock, 'Received', {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- id: firstTokenId,
- value: firstAmount,
- data: null,
- });
- });
- });
- context('with data', function () {
- const data = '0xf00dd00d';
- beforeEach(async function () {
- this.toWhom = this.receiver.address;
- this.transferReceipt = await this.token.safeTransferFrom(
- multiTokenHolder,
- this.receiver.address,
- firstTokenId,
- firstAmount,
- data,
- { from: multiTokenHolder },
- );
- ({ logs: this.transferLogs } = this.transferReceipt);
- });
- transferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- id: firstTokenId,
- value: firstAmount,
- });
- it('calls onERC1155Received', async function () {
- await expectEvent.inTransaction(this.transferReceipt.tx, ERC1155ReceiverMock, 'Received', {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- id: firstTokenId,
- value: firstAmount,
- data,
- });
- });
- });
- });
- context('to a receiver contract returning unexpected value', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- '0x00c0ffee', false,
- RECEIVER_BATCH_MAGIC_VALUE, false,
- );
- });
- it('reverts', async function () {
- await expectRevert(
- this.token.safeTransferFrom(multiTokenHolder, this.receiver.address, firstTokenId, firstAmount, '0x', {
- from: multiTokenHolder,
- }),
- 'ERC1155: ERC1155Receiver rejected tokens',
- );
- });
- });
- context('to a receiver contract that reverts', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- RECEIVER_SINGLE_MAGIC_VALUE, true,
- RECEIVER_BATCH_MAGIC_VALUE, false,
- );
- });
- it('reverts', async function () {
- await expectRevert(
- this.token.safeTransferFrom(multiTokenHolder, this.receiver.address, firstTokenId, firstAmount, '0x', {
- from: multiTokenHolder,
- }),
- 'ERC1155ReceiverMock: reverting on receive',
- );
- });
- });
- context('to a contract that does not implement the required function', function () {
- it('reverts', async function () {
- const invalidReceiver = this.token;
- await expectRevert.unspecified(
- this.token.safeTransferFrom(multiTokenHolder, invalidReceiver.address, firstTokenId, firstAmount, '0x', {
- from: multiTokenHolder,
- }),
- );
- });
- });
- });
- describe('safeBatchTransferFrom', function () {
- beforeEach(async function () {
- await this.token.mint(multiTokenHolder, firstTokenId, firstAmount, '0x', {
- from: minter,
- });
- await this.token.mint(
- multiTokenHolder,
- secondTokenId,
- secondAmount,
- '0x',
- {
- from: minter,
- },
- );
- });
- it('reverts when transferring amount more than any of balances', async function () {
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, recipient,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount.addn(1)],
- '0x', { from: multiTokenHolder },
- ),
- 'ERC1155: insufficient balance for transfer',
- );
- });
- it('reverts when ids array length doesn\'t match amounts array length', async function () {
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, recipient,
- [firstTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- ),
- 'ERC1155: ids and amounts length mismatch',
- );
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, recipient,
- [firstTokenId, secondTokenId],
- [firstAmount],
- '0x', { from: multiTokenHolder },
- ),
- 'ERC1155: ids and amounts length mismatch',
- );
- });
- it('reverts when transferring to zero address', async function () {
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, ZERO_ADDRESS,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- ),
- 'ERC1155: transfer to the zero address',
- );
- });
- function batchTransferWasSuccessful ({ operator, from, ids, values }) {
- it('debits transferred balances from sender', async function () {
- const newBalances = await this.token.balanceOfBatch(new Array(ids.length).fill(from), ids);
- for (const newBalance of newBalances) {
- expect(newBalance).to.be.a.bignumber.equal('0');
- }
- });
- it('credits transferred balances to receiver', async function () {
- const newBalances = await this.token.balanceOfBatch(new Array(ids.length).fill(this.toWhom), ids);
- for (let i = 0; i < newBalances.length; i++) {
- expect(newBalances[i]).to.be.a.bignumber.equal(values[i]);
- }
- });
- it('emits a TransferBatch log', function () {
- expectEvent.inLogs(this.transferLogs, 'TransferBatch', {
- operator,
- from,
- to: this.toWhom,
- // ids,
- // values,
- });
- });
- }
- context('when called by the multiTokenHolder', async function () {
- beforeEach(async function () {
- this.toWhom = recipient;
- ({ logs: this.transferLogs } =
- await this.token.safeBatchTransferFrom(
- multiTokenHolder, recipient,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- ));
- });
- batchTransferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- ids: [firstTokenId, secondTokenId],
- values: [firstAmount, secondAmount],
- });
- });
- context('when called by an operator on behalf of the multiTokenHolder', function () {
- context('when operator is not approved by multiTokenHolder', function () {
- beforeEach(async function () {
- await this.token.setApprovalForAll(proxy, false, { from: multiTokenHolder });
- });
- it('reverts', async function () {
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, recipient,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: proxy },
- ),
- 'ERC1155: transfer caller is not owner nor approved',
- );
- });
- });
- context('when operator is approved by multiTokenHolder', function () {
- beforeEach(async function () {
- this.toWhom = recipient;
- await this.token.setApprovalForAll(proxy, true, { from: multiTokenHolder });
- ({ logs: this.transferLogs } =
- await this.token.safeBatchTransferFrom(
- multiTokenHolder, recipient,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: proxy },
- ));
- });
- batchTransferWasSuccessful.call(this, {
- operator: proxy,
- from: multiTokenHolder,
- ids: [firstTokenId, secondTokenId],
- values: [firstAmount, secondAmount],
- });
- it('preserves operator\'s balances not involved in the transfer', async function () {
- const balance1 = await this.token.balanceOf(proxy, firstTokenId);
- expect(balance1).to.be.a.bignumber.equal('0');
- const balance2 = await this.token.balanceOf(proxy, secondTokenId);
- expect(balance2).to.be.a.bignumber.equal('0');
- });
- });
- });
- context('when sending to a valid receiver', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- RECEIVER_SINGLE_MAGIC_VALUE, false,
- RECEIVER_BATCH_MAGIC_VALUE, false,
- );
- });
- context('without data', function () {
- beforeEach(async function () {
- this.toWhom = this.receiver.address;
- this.transferReceipt = await this.token.safeBatchTransferFrom(
- multiTokenHolder, this.receiver.address,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- );
- ({ logs: this.transferLogs } = this.transferReceipt);
- });
- batchTransferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- ids: [firstTokenId, secondTokenId],
- values: [firstAmount, secondAmount],
- });
- it('calls onERC1155BatchReceived', async function () {
- await expectEvent.inTransaction(this.transferReceipt.tx, ERC1155ReceiverMock, 'BatchReceived', {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- // ids: [firstTokenId, secondTokenId],
- // values: [firstAmount, secondAmount],
- data: null,
- });
- });
- });
- context('with data', function () {
- const data = '0xf00dd00d';
- beforeEach(async function () {
- this.toWhom = this.receiver.address;
- this.transferReceipt = await this.token.safeBatchTransferFrom(
- multiTokenHolder, this.receiver.address,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- data, { from: multiTokenHolder },
- );
- ({ logs: this.transferLogs } = this.transferReceipt);
- });
- batchTransferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- ids: [firstTokenId, secondTokenId],
- values: [firstAmount, secondAmount],
- });
- it('calls onERC1155Received', async function () {
- await expectEvent.inTransaction(this.transferReceipt.tx, ERC1155ReceiverMock, 'BatchReceived', {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- // ids: [firstTokenId, secondTokenId],
- // values: [firstAmount, secondAmount],
- data,
- });
- });
- });
- });
- context('to a receiver contract returning unexpected value', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- RECEIVER_SINGLE_MAGIC_VALUE, false,
- RECEIVER_SINGLE_MAGIC_VALUE, false,
- );
- });
- it('reverts', async function () {
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, this.receiver.address,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- ),
- 'ERC1155: ERC1155Receiver rejected tokens',
- );
- });
- });
- context('to a receiver contract that reverts', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- RECEIVER_SINGLE_MAGIC_VALUE, false,
- RECEIVER_BATCH_MAGIC_VALUE, true,
- );
- });
- it('reverts', async function () {
- await expectRevert(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, this.receiver.address,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- ),
- 'ERC1155ReceiverMock: reverting on batch receive',
- );
- });
- });
- context('to a receiver contract that reverts only on single transfers', function () {
- beforeEach(async function () {
- this.receiver = await ERC1155ReceiverMock.new(
- RECEIVER_SINGLE_MAGIC_VALUE, true,
- RECEIVER_BATCH_MAGIC_VALUE, false,
- );
- this.toWhom = this.receiver.address;
- this.transferReceipt = await this.token.safeBatchTransferFrom(
- multiTokenHolder, this.receiver.address,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- );
- ({ logs: this.transferLogs } = this.transferReceipt);
- });
- batchTransferWasSuccessful.call(this, {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- ids: [firstTokenId, secondTokenId],
- values: [firstAmount, secondAmount],
- });
- it('calls onERC1155BatchReceived', async function () {
- await expectEvent.inTransaction(this.transferReceipt.tx, ERC1155ReceiverMock, 'BatchReceived', {
- operator: multiTokenHolder,
- from: multiTokenHolder,
- // ids: [firstTokenId, secondTokenId],
- // values: [firstAmount, secondAmount],
- data: null,
- });
- });
- });
- context('to a contract that does not implement the required function', function () {
- it('reverts', async function () {
- const invalidReceiver = this.token;
- await expectRevert.unspecified(
- this.token.safeBatchTransferFrom(
- multiTokenHolder, invalidReceiver.address,
- [firstTokenId, secondTokenId],
- [firstAmount, secondAmount],
- '0x', { from: multiTokenHolder },
- ),
- );
- });
- });
- });
- shouldSupportInterfaces(['ERC165', 'ERC1155']);
- });
- }
- module.exports = {
- shouldBehaveLikeERC1155,
- };
|