@ -12,7 +12,7 @@ const ContextMockCaller = artifacts.require('ContextMockCaller');
const { shouldBehaveLikeRegularContext } = require ( '../utils/Context.behavior' ) ;
contract ( 'ERC2771Context' , function ( accounts ) {
const [ , anotherAccount ] = accounts ;
const [ , trustedForwarder ] = accounts ;
beforeEach ( async function ( ) {
this . forwarder = await MinimalForwarder . new ( ) ;
@ -78,11 +78,11 @@ contract('ERC2771Context', function (accounts) {
it ( 'returns the original sender when calldata length is less than 20 bytes (address length)' , async function ( ) {
// The forwarder doesn't produce calls with calldata length less than 20 bytes
const recipient = await ERC2771ContextMock . new ( anotherAccount ) ;
const recipient = await ERC2771ContextMock . new ( trustedForwarder ) ;
const { receipt } = await recipient . msgSender ( { from : anotherAccount } ) ;
const { receipt } = await recipient . msgSender ( { from : trustedForwarder } ) ;
await expectEvent ( receipt , 'Sender' , { sender : anotherAccount } ) ;
await expectEvent ( receipt , 'Sender' , { sender : trustedForwarder } ) ;
} ) ;
} ) ;
@ -108,5 +108,15 @@ contract('ERC2771Context', function (accounts) {
await expectEvent . inTransaction ( tx , ERC2771ContextMock , 'Data' , { data , integerValue , stringValue } ) ;
} ) ;
} ) ;
it ( 'returns the full original data when calldata length is less than 20 bytes (address length)' , async function ( ) {
// The forwarder doesn't produce calls with calldata length less than 20 bytes
const recipient = await ERC2771ContextMock . new ( trustedForwarder ) ;
const { receipt } = await recipient . msgDataShort ( { from : trustedForwarder } ) ;
const data = recipient . contract . methods . msgDataShort ( ) . encodeABI ( ) ;
await expectEvent ( receipt , 'DataShort' , { data } ) ;
} ) ;
} ) ;
} ) ;