Logging Verbose During Local Tests with Upgradeable Contracts

Currently working with openzeppelin upgrades version 1.2.4 and running tests on my machine with upgradeable proxies where the logic contracts have structs and enums spits out this message every time the contract is deployed.

Warning: Potentially unsafe deployment of ContractName

You are using the `unsafeAllowCustomTypes` flag to skip storage checks for structs and enums.
Make sure you have manually checked the storage layout for incompatibilities.

I was wondering if there is a way to silence these logs so that the test logs are not spammed with this.

1 Like

There’s no way to silence these currently. The idea was for people to be always reminded they are not checked automatically, but I understand these can be very annoying during testing.

I don’t want to provide a way to silence them fully, but we can provide a way to get only a single message to display once, and then silence everything from then on.

2 Likes

That would be appreciated if it only displays that message once and then silences from then on.

1 Like

Hi @elliot,

I have created an issue: https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/226 for this.

1 Like
2 Likes

Thank you again Francisco! Do I need to change the version I use or should I just remove the node modules and reinstall?

1 Like

Hi @elliot,

The Pull Request hasn’t been merged yet. I can let you know when there is a new release. You can uninstall and install the plugin again.

1 Like

@elliot The latest version contains a function silenceWarnings.

2 Likes

Thank you again Francisco!

2 Likes

A question I have is what flag do I need to turn on to disable printing this warning message out?

I upgraded to version 1.3.0, removed node modules, then ran the test suite and I still got many warning messages about unsafe deployments. I am deploying these contracts with the unsafeAllowCustomTypes flag set to true.

1 Like

Hi @elliot,

We need to call the function silenceWarnings, see my example test below.

// test/Box.proxy.test.js
// Load dependencies
const { expect } = require('chai');
const { deployProxy, silenceWarnings } = require('@openzeppelin/truffle-upgrades');
 
// Load compiled artifacts
const Box = artifacts.require('Box');
 
// Start test block
contract('Box (proxy)', function () {

  before(async function () {
    await silenceWarnings();
  });

  beforeEach(async function () {
    // Deploy a new Box contract for each test
    this.box = await deployProxy(Box, [42], {initializer: 'store', unsafeAllowCustomTypes: true});
  });
...

A warning that Upgrades warnings will be silenced is displayed once.

$ npx truffle test

Compiling your contracts...
===========================
...

  Contract: Box (proxy)

Warning: All subsequent Upgrades warnings will be silenced.

    Make sure you have manually checked all uses of unsafe flags.

    ✓ retrieve returns a value previously initialized
    ✓ retrieve returns a value previously initialized
    ✓ retrieve returns a value previously initialized


  3 passing (3s)
1 Like

Thank you guys! Calling that silenceWarnings function keeps the test run looking nice and clean.

1 Like