GSNSignatureBouncer Tests not passing on my local machine

Hello team!

I see that all the tests for oz-contracts are passing on the CI, however when I try to run them on my personal machine, not all the tests actually pass. In particular I am trying to investigate why I am having trouble getting the GSNSignatureBouncer.sol to work in practice. My personal setup (using Eth-crypto) does not seem to create the proper signature, but in attempting to mimic the tests, I am dismayed to find the same (stock) tests are also not passing.

The error I am getting from the test is:


Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



  Contract: GSNBouncerSignature
    when called directly
      βœ“ mock function can be called (56ms)
    when relay-called
      βœ“ rejects unsigned relay requests (112ms)
      βœ“ rejects relay requests where some parameters are signed (91ms)
      1) accepts relay requests where all parameters are signed

    Events emitted during test:
    ---------------------------

    Deposited(recipient: <indexed> 0x0b30f794473AB83910ED4fb5DB36838714a7839f (address), from: <indexed> 0x76ba33B93f013f4ca9906498695e6114D2D1eF3B (address), amount: 1000000000000000000 (uint256))

    ---------------------------
      βœ“ rejects relay requests where all parameters are signed by an invalid signer (75ms)


  4 passing (3s)
  1 failing

  1) Contract: GSNBouncerSignature
       when relay-called
         accepts relay requests where all parameters are signed:
     Error: Error: Returned error: sender account not recognized
      at Object._fireError (/Users/dennison/.nvm/versions/node/v10.16.0/lib/node_modules/truffle/build/webpack:/~/web3-utils/src/index.js:56:1)
      at sendTxCallback (/Users/dennison/.nvm/versions/node/v10.16.0/lib/node_modules/truffle/build/webpack:/~/web3-eth/~/web3-core-method/src/index.js:491:1)
      at /Users/dennison/.nvm/versions/node/v10.16.0/lib/node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:136:1
      at fn.then.catch.err (node_modules/@openzeppelin/gsn-provider/src/utils.js:23:9)

One thing in the test I didn't understand: (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/GSN/GSNBouncerSignature.test.js)

Was why line 49 and line 65 there is a difference in the way data.txfee, data.gasPrice, data.gas, data.nonce are passed? In line 49 they are BN objects and line 65 they appear to not be BN instances. Maybe @nventuro could help me to shed some light on this? I'm confused why not only my implementation and the tests should be failing on my machine.

1 Like

As a note, I ran test for just this Contract, but at I also ran the entire test suite, both with the command truffle test with an external instance of ganache running in it's own terminal. When running the entire tests for openzepelin-contracts this test above also did not pass. Nor did the GSNBouncerERC20Fee.test.js final test pass either, with the same error message.

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



  Contract: GSNBouncerERC20Fee
    token
      βœ“ has a name
      βœ“ has a symbol
      βœ“ has decimals
    when called directly
      βœ“ mock function can be called (79ms)
    when relay-called
      1) charges the sender for GSN fees in tokens

    Events emitted during test:
    ---------------------------

    PrimaryTransferred(recipient: 0xfAa9D9939cE16C3D193edc22F577A3B75F195138 (address))
    Deposited(recipient: <indexed> 0xfAa9D9939cE16C3D193edc22F577A3B75F195138 (address), from: <indexed> 0x76ba33B93f013f4ca9906498695e6114D2D1eF3B (address), amount: 1000000000000000000 (uint256))
    Transfer(from: <indexed> 0x0000000000000000000000000000000000000000 (address), to: <indexed> 0x9F28a9952dfb2d2173Ac213CD2a48168F260Adda (address), value: 2000000000000000000 (uint256))

    ---------------------------


  4 passing (2s)
  1 failing

  1) Contract: GSNBouncerERC20Fee
       when relay-called
         charges the sender for GSN fees in tokens:
     Error: Error: Returned error: sender account not recognized
      at Object._fireError (/Users/dennison/.nvm/versions/node/v10.16.0/lib/node_modules/truffle/build/webpack:/~/web3-utils/src/index.js:56:1)
      at sendTxCallback (/Users/dennison/.nvm/versions/node/v10.16.0/lib/node_modules/truffle/build/webpack:/~/web3-eth/~/web3-core-method/src/index.js:491:1)
      at /Users/dennison/.nvm/versions/node/v10.16.0/lib/node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:136:1
      at fn.then.catch.err (node_modules/@openzeppelin/gsn-provider/src/utils.js:23:9)

1 Like

The issue is that the setting up of the relayer uses a hardcoded address, which is derived from one of the private keys passed to ganache in the test.sh script, called when running npm test. If using truffle test or running your own ganache, the required accounts will not be unlocked, and usage of the relayer will fail. We should improve that script to make this less fragile.

That seems to be a bug in the tests themselves :sweat_smile: Since they expect any failure, a type error will also cause the assertion to be true and the test to pass, but we should definitely fix those (and add GSN-specific assertions in the future).

2 Likes