Hello. I'm new to doing tests and currently trying to do a test with the initialize for the upgrade openZeppelin contracts. Here is the error I'm getting - https://gyazo.com/577c38e953d125110042a75f8b37913a
Here is my code.
// migrations/3_deploy_upgradeable_box.js
const { deployProxy } = require('@openzeppelin/truffle-upgrades');
const Box = artifacts.require('Box');
module.exports = async function (deployer) {
await deployProxy(Box, [42], { deployer, initializer: 'store' });
};
// migrations/4_upgrade_box.js
const { upgradeProxy } = require('@openzeppelin/truffle-upgrades');
const Box = artifacts.require('Box');
const BoxV2 = artifacts.require('BoxV2');
module.exports = async function (deployer) {
const existing = await Box.deployed();
await upgradeProxy(existing.address, BoxV2, { deployer });
};
// migrations/5_deploy_upgradeable_adminbox.js
const { deployProxy } = require('@openzeppelin/truffle-upgrades');
const AdminBox = artifacts.require('AdminBox');
module.exports = async function (deployer) {
await deployProxy(AdminBox, ['0x287895F1cA934e95731E9BF8c7DfA8EBca699028'], { deployer, initializer: 'initialize' });
};
// test/Box.test.js
// Load dependencies
const { expect } = require('chai');
// Import utilities from Test Helpers
const { BN, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
// Load compiled artifacts
const Box = artifacts.require('Box');
const AdminBox = artifacts.require('AdminBox');
contract('AdminBox', function([owner, other]) {
// Use large integers ('big numbers')
const value = new BN('52');
beforeEach(async function () {
this.box = await AdminBox.new({ from: owner });
await this.box.initialize({ from: owner });
});
// Test case
it('retrieve returns a value previously stored', async function() {
// Store a value
await this.box.store(value, { from: owner });
// Use large integer comparisons
expect(await this.box.retrieve()).to.be.bignumber.equal(value);
});
})