Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #181 from zeppelinos/extend_app_wrapper_functionality
Browse files Browse the repository at this point in the history
Extend App wrapper functionality
  • Loading branch information
facuspagnuolo committed Jun 25, 2018
2 parents 0a2295b + 45f6ffd commit eff6653
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/App.js
Expand Up @@ -9,6 +9,7 @@ import AppProvider from './AppProvider'
import AppDeployer from './AppDeployer'

const log = new Logger('App')
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

export default class App {

Expand Down Expand Up @@ -49,6 +50,10 @@ export default class App {
return this.currentDirectory().stdlib()
}

async hasStdlib() {
return (await this.currentStdlib()) === ZERO_ADDRESS
}

async getImplementation(contractName) {
const directory = this.currentDirectory()
return directory.getImplementation(contractName)
Expand All @@ -67,6 +72,12 @@ export default class App {
return implementation
}

async unsetImplementation(contractName) {
log.info(`Unsetting implementation of ${contractName} in directory...`)
await this.currentDirectory().unsetImplementation(contractName, this.txParams)
log.info(`Implementation unset`)
}

async setStdlib(stdlibAddress = 0x0) {
log.info(`Setting stdlib ${stdlibAddress}...`)
await this.currentDirectory().setStdlib(stdlibAddress, this.txParams)
Expand Down
22 changes: 22 additions & 0 deletions test/src/app/App.test.js
Expand Up @@ -49,6 +49,10 @@ contract('App', function ([_, owner]) {
const stdlib = await this.app.currentStdlib();
stdlib.should.be.eq(currentStdlib)
});

it('should tell whether current stdlib is zero', async function () {
(await this.app.hasStdlib()).should.be.false
})
};

describe('without stdlib', function () {
Expand All @@ -58,6 +62,10 @@ contract('App', function ([_, owner]) {

describe('deploy', function () {
shouldInitialize();

it('should not have an stdlib initially', async function () {
(await this.app.hasStdlib()).should.be.true
})
});

describe('connect', function () {
Expand All @@ -66,6 +74,10 @@ contract('App', function ([_, owner]) {
});

shouldInitialize();

it('should not have an stdlib initially', async function () {
(await this.app.hasStdlib()).should.be.true
})
});

const newVersion = '2.0';
Expand Down Expand Up @@ -108,6 +120,16 @@ contract('App', function ([_, owner]) {
});
});

describe('unsetImplementation', function () {
beforeEach('setting implementation', setImplementation)

it('should unset implementation on directory', async function () {
await this.app.unsetImplementation(contractName)
const implementation = await this.app.currentDirectory().getImplementation(contractName)
implementation.should.be.zeroAddress
})
})

const createProxy = async function () {
this.proxy = await this.app.createProxy(ImplV1, contractName);
};
Expand Down

0 comments on commit eff6653

Please sign in to comment.