@ -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 ;
const MAX _UINT48 = web3 . utils . toBN ( 1 ) . shln ( 48 ) . subn ( 1 ) . toString ( ) ;
@ -84,11 +84,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 } ) ;
} ) ;
} ) ;
@ -117,5 +117,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 } ) ;
} ) ;
} ) ;
} ) ;