GSN compatibility (#1880)
* 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.
This commit is contained in:
committed by
Francisco Giordano
parent
f095b62856
commit
d1158ea68c
46
test/GSN/ERC721GSNRecipientMock.test.js
Normal file
46
test/GSN/ERC721GSNRecipientMock.test.js
Normal file
@ -0,0 +1,46 @@
|
||||
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 });
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user