Help required with writing extensive test suite for ZeppelinOS project

OK, I managed to get a test written for the ‘Upgraded’ event using the following code:

const initializeData = Buffer.from('');
this.implementation_v1 = (await MyContract.new()).address;

aup = await AdminUpgradeabilityProxy
  .new(this.implementation_v1, proxyAdminAddress, initializeData, { from: proxyAdminOwner });



  it('PET-008 (et008) should check Upgraded event', async () => {
    this.implementation_v2 = (await MyContractV2.new()).address;
    [_, proxyAdminAddress, proxyAdminOwner] = _accounts;

    const { events } = await aup.methods
      .upgradeTo(this.implementation_v2)
      .send({ from: proxyAdminAddress });

    events.should.have.key('Upgraded');
    events.Upgraded.returnValues.implementation.should.be.equal(
      this.implementation_v2,
    );
  });

However, when I try a similar pattern for running the ‘changeAdmin’ function on the Proxy then I get a transaction revert but without any error message? The code I have is:

  it('PET-009 (et009) should check AdminChanged event', async () => {
    [_, anotherAccount, proxyAdminAddress, proxyAdminOwner] = _accounts;

    let newProxyAdmin = await aup.methods
      .admin()
      .call({ from: proxyAdminAddress });

    const newAdmin = anotherAccount;
    const { events } = await aup.methods
      .changeAdmin(newAdmin)
      .send({ from: proxyAdminAddress });

    newProxyAdmin = await aup.methods
      .admin()
      .call({ from: newAdmin });

    newProxyAdmin.should.be.equalIgnoreCase(anotherAccount);
    events.should.have.key('AdminChanged');
    events.AdminChanged
      .returnValues.previousAdmin.should.be.equalIgnoreCase(
        proxyAdminAddress,
      );
    this.events.AdminChanged
      .returnValues.newAdmin.should.be.equalIgnoreCase(
        newAdmin,
      );
  });

In fact even just checking who is the admin in this function causes a revert:

  let newProxyAdmin = await aup.methods
      .admin()
      .call({ from: proxyAdminAddress });

I am just wondering if this is anything to do with point 2 from @spalladino here: Best Practice for transfer of Proxy Admin or Proxy Owner?

Any help appreciated! @spalladino @ylv-io @abcoathup

Cheers
Rick

2 Likes