# How to test upgradeable contracts?

**URL:** <https://forum.openzeppelin.com/t/how-to-test-upgradeable-contracts/3181>\
**Category:** SDK\
**Created:** [June 24, 2020, 8:31am UTC](https://forum.openzeppelin.com/t/how-to-test-upgradeable-contracts/3181 "2020-06-24T08:31:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtp5](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/dtp5/32/2589_2.png) [@dtp5](https://forum.openzeppelin.com/u/dtp5)\
**Post date:** [June 24, 2020, 8:31am UTC](https://forum.openzeppelin.com/t/how-to-test-upgradeable-contracts/3181/1 "2020-06-24T08:31:08Z")

</div>

Hi @abcoathup. For upgradable contracts, would you always recommend writing duplicate test files, with upgradability being the only difference between them? When should we test an upgradable contract as _just_ a logic implementation? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 25, 2020, 6:34am UTC](https://forum.openzeppelin.com/t/how-to-test-upgradeable-contracts/3181/2 "2020-06-25T06:34:51Z")

</div>

Hi @dtp5,

My thoughts are to write unit tests for your logic contract with a high level of coverage.

You can then create tests specific to the upgradeable version. I don’t think you need to duplicate your logic contract tests. As well as some general tests, you should focus on any interactions that may have specific gas restrictions. (See [OpenZeppelin upgradeable contracts affected by Istanbul hardfork](https://forum.openzeppelin.com/t/openzeppelin-upgradeable-contracts-affected-by-istanbul-hardfork/1616) for more details)

When you upgrade, you should have automated tests to check the upgrade and you should also test using a fork of mainnet. (see [Testing real-world contract upgrades](https://blog.openzeppelin.com/testing-real-world-contract-upgrades/) for concepts)

I’d be interested to here other community thoughts on the best way to test upgradeable contracts.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 26, 2020, 7:27am UTC](https://forum.openzeppelin.com/t/how-to-test-upgradeable-contracts/3181/3 "2020-06-26T07:27:34Z")

</div>

Hi @dtp5,

To set up more integration-like tests, or test an actual upgrade, you can set up the upgradeable contract using a snippet similar to the one in [Upgrades library example](https://github.com/OpenZeppelin/openzeppelin-sdk/tree/master/examples/upgrades-library)
