-
Notifications
You must be signed in to change notification settings - Fork 412
/
Copy pathupgrade.test.ts
45 lines (35 loc) · 1.34 KB
/
upgrade.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { ethers } from 'hardhat';
import {
MysteryMathV2__factory,
UpgradeBeaconController,
UpgradeBeaconController__factory,
} from '../types';
import { MysteryMathUpgrade, UpgradeTestHelpers } from './lib/upgrade';
describe('Upgrade', async () => {
const utils = new UpgradeTestHelpers();
let signer: SignerWithAddress,
mysteryMath: MysteryMathUpgrade,
ubc: UpgradeBeaconController;
before(async () => {
// set signer
[signer] = await ethers.getSigners();
const ubcFactory = new UpgradeBeaconController__factory(signer);
ubc = await ubcFactory.deploy();
// deploy upgrade setup for mysteryMath contract
mysteryMath = await utils.deployMysteryMathUpgradeSetup(signer, ubc);
});
it('Pre-Upgrade returns values from MysteryMathV1', async () => {
await utils.expectMysteryMathV1(mysteryMath.proxy);
});
it('Upgrades without problem', async () => {
// Deploy Implementation 2
const factory = new MysteryMathV2__factory(signer);
const implementation = await factory.deploy();
// Upgrade to implementation 2
await ubc.upgrade(mysteryMath.beacon.address, implementation.address);
});
it('Post-Upgrade returns values from MysteryMathV2', async () => {
await utils.expectMysteryMathV2(mysteryMath.proxy);
});
});