`@0x/contracts-zero-ex`: `bootstrap()` de-registers itself and self-destructs once it's called. `@0x/contracts-zero-ex`: `bootstrap()` now takes arbitrary call data, but the callee is fixed in an immutable. `@0x/contracts-zero-ex`: `bootstrap()` caller is fixed in an immutable. `@0x/contracts-zero-ex`: `bootstrap()` only calls a single target. `@0x/contracts-zero-ex`: Renamed `BasicMigration` to `InitialMigration`. `@0x/contracts-zero-ex`: `InitialMigration` is now the bootstrap target and multiplexes to the initial features. `@0x/contracts-zero-ex`: Add `Migrate` feature and tests. `@0x/contracts-zero-ex`: Re-organize contract locatins (remove `interfaces` folder).
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { blockchainTests, expect, randomAddress, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
|
import { OwnableRevertErrors } from '@0x/utils';
|
|
|
|
import { initialMigrateAsync } from '../utils/migration';
|
|
import { IOwnableContract, IOwnableEvents } from '../wrappers';
|
|
|
|
blockchainTests.resets('Ownable feature', env => {
|
|
const notOwner = randomAddress();
|
|
let owner: string;
|
|
let ownable: IOwnableContract;
|
|
|
|
before(async () => {
|
|
[owner] = await env.getAccountAddressesAsync();
|
|
const zeroEx = await initialMigrateAsync(owner, env.provider, env.txDefaults);
|
|
ownable = new IOwnableContract(zeroEx.address, env.provider, env.txDefaults);
|
|
});
|
|
|
|
describe('transferOwnership()', () => {
|
|
it('non-owner cannot transfer ownership', async () => {
|
|
const newOwner = randomAddress();
|
|
const tx = ownable.transferOwnership(newOwner).callAsync({ from: notOwner });
|
|
return expect(tx).to.revertWith(new OwnableRevertErrors.OnlyOwnerError(notOwner, owner));
|
|
});
|
|
|
|
it('owner can transfer ownership', async () => {
|
|
const newOwner = randomAddress();
|
|
const receipt = await ownable.transferOwnership(newOwner).awaitTransactionSuccessAsync({ from: owner });
|
|
verifyEventsFromLogs(
|
|
receipt.logs,
|
|
[
|
|
{
|
|
previousOwner: owner,
|
|
newOwner,
|
|
},
|
|
],
|
|
IOwnableEvents.OwnershipTransferred,
|
|
);
|
|
expect(await ownable.getOwner().callAsync()).to.eq(newOwner);
|
|
});
|
|
});
|
|
});
|