Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "zos-lib", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "zeppelin_os library", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
# zOS Upgradeability Library | ||
# zeppelin_os library | ||
[![NPM Package](https://img.shields.io/npm/v/zos-lib.svg?style=flat-square)](https://www.npmjs.org/package/zos-lib) | ||
@@ -6,2 +6,2 @@ [![Build Status](https://travis-ci.org/zeppelinos/zos-lib.svg?branch=master)](https://travis-ci.org/zeppelinos/zos-lib) | ||
:warning: **Under heavy development: do not use in production** | ||
:warning: **Under heavy development: do not use in production** :warning: |
@@ -97,3 +97,3 @@ const Package = artifacts.require('Package') | ||
const { receipt } = await this.manager.create(contract) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -134,3 +134,3 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
const { receipt } = await this.manager.createAndCall(contract, initializeData, { value }) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -179,3 +179,3 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
const { receipt } = await this.manager.create(contract) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -228,3 +228,3 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
const { receipt } = await this.manager.create(contract) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -231,0 +231,0 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) |
@@ -53,3 +53,3 @@ const encodeCall = require('../../helpers/encodeCall') | ||
const { receipt } = await this.manager.create(contract) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -90,3 +90,3 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
const { receipt } = await this.manager.createAndCall(contract, initializeData, { value }) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -135,3 +135,3 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
const { receipt } = await this.manager.create(contract) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -180,3 +180,3 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
const { receipt } = await this.manager.create(contract) | ||
this.logs = decodeLogs([receipt.logs[0]], UpgradeabilityProxyFactory) | ||
this.logs = decodeLogs([receipt.logs[1]], UpgradeabilityProxyFactory) | ||
this.proxyAddress = this.logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
@@ -183,0 +183,0 @@ this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) |
@@ -9,7 +9,14 @@ const assertRevert = require('../helpers/assertRevert') | ||
it('starts uninitialized', async function () { | ||
const isInitialized = await this.initializable.isInitialized() | ||
assert.isFalse(isInitialized) | ||
}) | ||
describe('initialize', function () { | ||
it('can be called once', async function () { | ||
beforeEach(async function () { | ||
await this.initializable.initialize(42) | ||
}) | ||
it('can be called only once', async function () { | ||
const x = await this.initializable.x() | ||
assert.equal(x, 42) | ||
@@ -19,4 +26,7 @@ await assertRevert(this.initializable.initialize(100)) | ||
it('becomes initialized') | ||
it('becomes initialized', async function () { | ||
const isInitialized = await this.initializable.isInitialized() | ||
assert.isTrue(isInitialized) | ||
}) | ||
}) | ||
}) |
@@ -18,7 +18,10 @@ const assert = require('chai').assert; | ||
const DummyImplementation = artifacts.require('DummyImplementation'); | ||
contract('Migratable', function ([_, owner, registrar]) { | ||
const from = owner; | ||
let v1, v2, v3, v4, v5; | ||
let v0, v1, v2, v3, v4, v5; | ||
before(async function () { | ||
v0 = await DummyImplementation.new({ from: registrar }); | ||
v1 = await SampleChildV1.new({ from: registrar }); | ||
@@ -32,3 +35,3 @@ v2 = await SampleChildV2.new({ from: registrar }); | ||
beforeEach(async function () { | ||
this.proxy = await OwnedUpgradeabilityProxy.new({ from }); | ||
this.proxy = await OwnedUpgradeabilityProxy.new(v0.address, { from }); | ||
this.contract = SampleChildV1.at(this.proxy.address); | ||
@@ -345,2 +348,2 @@ }); | ||
}); | ||
}); | ||
}); |
@@ -20,16 +20,6 @@ 'use strict' | ||
beforeEach(async function () { | ||
this.factory = await UpgradeabilityProxyFactory.new() | ||
const { logs } = await this.factory.createProxy(owner, this.implementation_v0) | ||
this.proxyAddress = logs.find(l => l.event === 'ProxyCreated').args.proxy | ||
this.proxy = await OwnedUpgradeabilityProxy.at(this.proxyAddress) | ||
this.proxy = await OwnedUpgradeabilityProxy.new(this.implementation_v0, { from: owner }) | ||
this.proxyAddress = this.proxy.address; | ||
}) | ||
describe('owner', function () { | ||
it('transfers the ownership to the requested owner', async function () { | ||
const proxyOwner = await this.proxy.proxyOwner() | ||
assert.equal(proxyOwner, owner) | ||
}) | ||
}) | ||
describe('implementation', function () { | ||
@@ -41,27 +31,9 @@ it('returns the current implementation address', async function () { | ||
}) | ||
}) | ||
describe('fallback', function () { | ||
beforeEach(async function () { | ||
this.behavior = await InitializableMock.new() | ||
this.proxy = await OwnedUpgradeabilityProxy.new() | ||
this.mock = InitializableMock.at(this.proxy.address) | ||
}) | ||
it('delegates to the implementation', async function () { | ||
const dummy = new DummyImplementation(this.proxyAddress); | ||
const value = await dummy.get(); | ||
describe('when there is an implementation set', function () { | ||
it('calls the implementation', async function () { | ||
await this.proxy.upgradeTo(this.behavior.address) | ||
await this.mock.initialize(42) | ||
const value = await this.mock.x() | ||
assert.equal(value, 42) | ||
}) | ||
assert.equal(value, true) | ||
}) | ||
describe('when there is no implementation set', function () { | ||
it('reverts', async function () { | ||
await assertRevert(this.mock.initialize(42)) | ||
}) | ||
}) | ||
}) | ||
@@ -68,0 +40,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111194
44
1533