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.
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.
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.
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)