From f9a94788fbd50e2e2f4eb0eb40bbfd57a5645a4e Mon Sep 17 00:00:00 2001 From: Dennison Bertram Date: Fri, 4 Oct 2019 11:39:56 -0400 Subject: [PATCH] GSNSignatureBouncer fix (#1920) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * GSNSignatureBoucer does not accept zero address * Linting code. * Update contracts/GSN/bouncers/GSNBouncerSignature.sol Makes sense! Co-Authored-By: Nicolás Venturo * Update test/GSN/GSNBouncerSignature.test.js ok! Co-Authored-By: Nicolás Venturo * Add zero address constant from OZ test Helpers * revert prettier formatting --- contracts/GSN/bouncers/GSNBouncerSignature.sol | 1 + test/GSN/GSNBouncerSignature.test.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contracts/GSN/bouncers/GSNBouncerSignature.sol b/contracts/GSN/bouncers/GSNBouncerSignature.sol index ecbc3db48..de3602a1d 100644 --- a/contracts/GSN/bouncers/GSNBouncerSignature.sol +++ b/contracts/GSN/bouncers/GSNBouncerSignature.sol @@ -22,6 +22,7 @@ contract GSNBouncerSignature is GSNBouncerBase { * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls. */ constructor(address trustedSigner) public { + require(trustedSigner != address(0), "GSNBouncerSignature: trusted signer is the zero address"); _trustedSigner = trustedSigner; } diff --git a/test/GSN/GSNBouncerSignature.test.js b/test/GSN/GSNBouncerSignature.test.js index af61ed6fb..832d625fb 100644 --- a/test/GSN/GSNBouncerSignature.test.js +++ b/test/GSN/GSNBouncerSignature.test.js @@ -1,7 +1,8 @@ -const { expectEvent } = require('openzeppelin-test-helpers'); +const { expectEvent, expectRevert, constants } = require('openzeppelin-test-helpers'); const gsn = require('@openzeppelin/gsn-helpers'); const { fixSignature } = require('../helpers/sign'); const { utils: { toBN } } = require('web3'); +const { ZERO_ADDRESS } = constants; const GSNBouncerSignatureMock = artifacts.require('GSNBouncerSignatureMock'); @@ -17,6 +18,17 @@ contract('GSNBouncerSignature', function ([_, signer, other]) { }); }); + context('when constructor is called with a zero address', function () { + it('fails when constructor called with a zero address', async function () { + await expectRevert( + GSNBouncerSignatureMock.new( + ZERO_ADDRESS + ), + 'GSNBouncerSignature: trusted signer is the zero address' + ); + }); + }); + context('when relay-called', function () { beforeEach(async function () { await gsn.fundRecipient(web3, { recipient: this.recipient.address });