* switch to using Context internally
* add context import
* Add smoke test to make sure enabling GSN support works
* Update test/GSN/ERC721GSNRecipientMock.test.js
Co-Authored-By: Francisco Giordano <frangio.1@gmail.com>
* Upgrade truffle
* add missing awaits
* Revert "Upgrade truffle"
This reverts commit f9b0ba9019.
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
const { constants, expectEvent } = require('openzeppelin-test-helpers');
|
|
const { ZERO_ADDRESS } = constants;
|
|
const gsn = require('@openzeppelin/gsn-helpers');
|
|
const { fixSignature } = require('../helpers/sign');
|
|
const { utils: { toBN } } = require('web3');
|
|
|
|
const ERC721GSNRecipientMock = artifacts.require('ERC721GSNRecipientMock');
|
|
|
|
contract('ERC721GSNRecipient (integration)', function ([_, signer, sender]) {
|
|
const tokenId = '42';
|
|
|
|
beforeEach(async function () {
|
|
this.token = await ERC721GSNRecipientMock.new(signer);
|
|
});
|
|
|
|
async function testMintToken (token, from, tokenId, options = {}) {
|
|
const { tx } = await token.mint(tokenId, { from, ...options });
|
|
await expectEvent.inTransaction(tx, ERC721GSNRecipientMock, 'Transfer', { from: ZERO_ADDRESS, to: from, tokenId });
|
|
}
|
|
|
|
context('when called directly', function () {
|
|
it('sender can mint tokens', async function () {
|
|
await testMintToken(this.token, sender, tokenId);
|
|
});
|
|
});
|
|
|
|
context('when relay-called', function () {
|
|
beforeEach(async function () {
|
|
await gsn.fundRecipient(web3, { recipient: this.token.address });
|
|
});
|
|
|
|
it('sender can mint tokens', async function () {
|
|
const approveFunction = async (data) =>
|
|
fixSignature(
|
|
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
|
|
)
|
|
);
|
|
|
|
await testMintToken(this.token, sender, tokenId, { useGSN: true, approveFunction });
|
|
});
|
|
});
|
|
});
|