diff --git a/contracts/gateway/EIP20CoGateway.sol b/contracts/gateway/EIP20CoGateway.sol index 5753c564..77638219 100644 --- a/contracts/gateway/EIP20CoGateway.sol +++ b/contracts/gateway/EIP20CoGateway.sol @@ -55,6 +55,7 @@ pragma solidity ^0.5.0; import "./UtilityTokenInterface.sol"; import "./GatewayBase.sol"; +import "../lib/IsMemberInterface.sol"; /** * @title EIP20CoGateway Contract @@ -194,7 +195,7 @@ contract EIP20CoGateway is GatewayBase { /* Constructor */ /** - * @notice Initialise the contract by providing the Gateway contract + * @notice Initialize the contract by providing the Gateway contract * address for which the CoGateway will enable facilitation of * mint and redeem. * @@ -202,9 +203,9 @@ contract EIP20CoGateway is GatewayBase { * @param _utilityToken The utility token address that will be used for * minting the utility token. * @param _core Core contract address. - * @param _bounty The amount that facilitator will stake to initiate the - * stake process. - * @param _organisation Organisation address. + * @param _bounty The amount that facilitator stakes to initiate the stake + * process. + * @param _membersManager Address of a contract that manages workers. * @param _gateway Gateway contract address. */ constructor( @@ -212,13 +213,13 @@ contract EIP20CoGateway is GatewayBase { address _utilityToken, CoreInterface _core, uint256 _bounty, - address _organisation, + IsMemberInterface _membersManager, address _gateway ) GatewayBase( _core, _bounty, - _organisation + _membersManager ) public { diff --git a/contracts/gateway/EIP20Gateway.sol b/contracts/gateway/EIP20Gateway.sol index 66086098..b58f07b5 100644 --- a/contracts/gateway/EIP20Gateway.sol +++ b/contracts/gateway/EIP20Gateway.sol @@ -55,6 +55,7 @@ pragma solidity ^0.5.0; import "./SimpleStake.sol"; import "./GatewayBase.sol"; +import "../lib/IsMemberInterface.sol"; /** * @title EIP20Gateway Contract @@ -212,19 +213,19 @@ contract EIP20Gateway is GatewayBase { * @param _core Core contract address. * @param _bounty The amount that facilitator will stakes to initiate the * stake process. - * @param _organisation Organisation address. + * @param _membersManager Address of a contract that manages workers. */ constructor( EIP20Interface _token, EIP20Interface _baseToken, CoreInterface _core, uint256 _bounty, - address _organisation + IsMemberInterface _membersManager ) GatewayBase( _core, _bounty, - _organisation + _membersManager ) public { @@ -973,7 +974,7 @@ contract EIP20Gateway is GatewayBase { address _coGatewayAddress ) external - onlyOrganisation + onlyOrganization returns (bool success_) { @@ -1000,7 +1001,7 @@ contract EIP20Gateway is GatewayBase { */ function deactivateGateway() external - onlyOrganisation + onlyOrganization returns (bool success_) { require( diff --git a/contracts/gateway/GatewayBase.sol b/contracts/gateway/GatewayBase.sol index bcec737d..553e082e 100644 --- a/contracts/gateway/GatewayBase.sol +++ b/contracts/gateway/GatewayBase.sol @@ -1,26 +1,28 @@ pragma solidity ^0.5.0; -import "../lib/GatewayLib.sol"; import "./CoreInterface.sol"; -import "../lib/SafeMath.sol"; +import "./EIP20Interface.sol"; import "./MessageBus.sol"; import "../StateRootInterface.sol"; -import "./EIP20Interface.sol"; +import "../lib/GatewayLib.sol"; +import "../lib/IsMemberInterface.sol"; +import "../lib/Organized.sol"; +import "../lib/SafeMath.sol"; /** * @title GatewayBase contract. * * @notice GatewayBase contains general purpose functions shared between - * gateway and co-gateway contract. + * gateway and co-gateway contract. */ -contract GatewayBase { - +contract GatewayBase is Organized { using SafeMath for uint256; + /** * Emitted whenever a Gateway/CoGateway contract is proven. * wasAlreadyProved parameter differentiates between first call and replay - * call of proveGateway method for same block height + * call of proveGateway method for same block height. */ event GatewayProven( address _gateway, @@ -54,21 +56,21 @@ contract GatewayBase { /* constants */ - /** Position of message bus in the storage */ + /** Position of message bus in the storage. */ uint8 constant MESSAGE_BOX_OFFSET = 1; /** - * Penalty in bounty amount percentage charged to staker on revert stake + * Penalty in bounty amount percentage charged to staker on revert stake. */ uint8 constant REVOCATION_PENALTY = 150; //todo identify how to get block time for both chains - /** Unlock period for change bounty in block height */ + /** Unlock period for change bounty in block height. */ uint256 private constant BOUNTY_CHANGE_UNLOCK_PERIOD = 100; /** * Message box. - * @dev keep this is at location 1, in case this is changed then update + * @dev Keep this is at location 1, in case this is changed then update * constant MESSAGE_BOX_OFFSET accordingly. */ MessageBus.MessageBox messageBox; @@ -76,34 +78,32 @@ contract GatewayBase { /** Specifies if the Gateway is activated for any new process. */ bool public activated; - /** Organisation address. */ - address public organisation; - - /** address of core contract. */ + /** Address of core contract. */ CoreInterface public core; - /** path to prove merkle account proof for Gateway/CoGateway contract. */ + /** Path to make Merkle account proof for Gateway/CoGateway contract. */ bytes internal encodedGatewayPath; /** - * Remote gateway contract address. If gateway contract remote gateway - * is CoGateway and vice versa. + * Remote gateway contract address. If this is a gateway contract, then the + * remote gateway is a CoGateway and vice versa. */ address public remoteGateway; - /** amount of ERC20 which is staked by facilitator. */ + /** Amount of ERC20 which is staked by facilitator. */ uint256 public bounty; /** Proposed new bounty amount for bounty change. */ uint256 public proposedBounty; - /** bounty proposal block height*/ + + /** Bounty proposal block height. */ uint256 public proposedBountyUnlockHeight; /** Maps messageHash to the Message object. */ - mapping(bytes32 /*messageHash*/ => MessageBus.Message) messages; + mapping(bytes32 => MessageBus.Message) messages; - /** Mapping to store blockHeight to storageRoot. */ - mapping(uint256 /* block height */ => bytes32 /* storageRoot */) internal storageRoots; + /** Maps blockHeight to storageRoot. */ + mapping(uint256 => bytes32) internal storageRoots; /** * Maps address to message hash. @@ -114,7 +114,7 @@ contract GatewayBase { * for a particular address. This is also used to determine the * nonce of the particular address. Refer getNonce for the details. */ - mapping(address /*address*/ => bytes32 /*messageHash*/) inboxActiveProcess; + mapping(address => bytes32) inboxActiveProcess; /** * Maps address to message hash. @@ -125,18 +125,10 @@ contract GatewayBase { * for a particular address. This is also used to determine the * nonce of the particular address. Refer getNonce for the details. */ - mapping(address /*address*/ => bytes32 /*messageHash*/) outboxActiveProcess; + mapping(address => bytes32) outboxActiveProcess; - /* modifiers */ - /** checks that only organisation can call a particular function. */ - modifier onlyOrganisation() { - require( - msg.sender == organisation, - "Only organisation can call the function" - ); - _; - } + /* Modifiers */ /** checks that contract is activated */ modifier isActive() { @@ -150,51 +142,44 @@ contract GatewayBase { /* Constructor */ /** - * @notice Initialise the contract and set default values. + * @notice Initialize the contract and set default values. * * @param _core Core contract address. * @param _bounty The amount that facilitator will stakes to initiate the * stake process. - * @param _organisation Organisation address. + * @param _membersManager Address of a contract that manages workers. */ constructor( CoreInterface _core, uint256 _bounty, - address _organisation + IsMemberInterface _membersManager ) + Organized(_membersManager) public { require( address(_core) != address(0), "Core contract address must not be zero." ); - require( - _organisation != address(0), - "Organisation address must not be zero." - ); core = _core; bounty = _bounty; - organisation = _organisation; - } - /* external functions */ + /* External functions */ /** - * @notice External function prove gateway/co-gateway. - * - * @dev proveGateway can be called by anyone to verify merkle proof of - * gateway/co-gateway contract address. Trust factor is brought by - * stateRoots mapping. stateRoot is committed in commitStateRoot - * function by mosaic process which is a trusted decentralized system - * running separately. It's important to note that in replay calls of - * proveGateway bytes _rlpParentNodes variable is not validated. In - * this case input storage root derived from merkle proof account - * nodes is verified with stored storage root of given blockHeight. - * GatewayProven event has parameter wasAlreadyProved to - * differentiate between first call and replay calls. + * @notice proveGateway can be called by anyone to verify merkle proof of + * gateway/co-gateway contract address. Trust factor is brought by + * stateRoots mapping. stateRoot is committed in commitStateRoot + * function by mosaic process which is a trusted decentralized system + * running separately. It's important to note that in replay calls of + * proveGateway bytes _rlpParentNodes variable is not validated. In + * this case input storage root derived from merkle proof account + * nodes is verified with stored storage root of given blockHeight. + * GatewayProven event has parameter wasAlreadyProved to + * differentiate between first call and replay calls. * * @param _blockHeight Block height at which Gateway/CoGateway is to be * proven. @@ -294,8 +279,8 @@ contract GatewayBase { * @return uint256 proposed bounty amount. */ function initiateBountyAmountChange(uint256 _proposedBounty) - onlyOrganisation() external + onlyOrganization returns(uint256) { proposedBounty = _proposedBounty; @@ -318,8 +303,8 @@ contract GatewayBase { * @return previousBountyAmount_ previous bounty amount. */ function confirmBountyAmountChange() - onlyOrganisation() external + onlyOrganization returns ( uint256 changedBountyAmount_, uint256 previousBountyAmount_ @@ -459,7 +444,7 @@ contract GatewayBase { delete messages[previousMessageHash_]; } - // Update the active proccess. + // Update the active process. outboxActiveProcess[_account] = _messageHash; } diff --git a/contracts/gateway/MockMessageBus.sol b/contracts/gateway/MockMessageBus.sol index a1fa52a8..a9029524 100644 --- a/contracts/gateway/MockMessageBus.sol +++ b/contracts/gateway/MockMessageBus.sol @@ -22,7 +22,7 @@ pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- -import "../test/MockMerklePatriciaProof.sol"; +import "../test/lib/MockMerklePatriciaProof.sol"; import "../lib/SafeMath.sol"; import "../lib/BytesLib.sol"; diff --git a/contracts/gateway/UtilityToken.sol b/contracts/gateway/UtilityToken.sol index 54dc713c..3a020f29 100644 --- a/contracts/gateway/UtilityToken.sol +++ b/contracts/gateway/UtilityToken.sol @@ -31,7 +31,7 @@ import "./CoGatewayUtilityTokenInterface.sol"; * @title UtilityToken is an EIP20Token and implements UtilityTokenInterface. * * @notice This contract has mint and burn functions and can be called only - * by CoGateway. TODO: Add organisation details. + * by CoGateway. TODO: Add organization details. * */ contract UtilityToken is @@ -58,7 +58,7 @@ contract UtilityToken is /* Modifiers */ - /** checks that only organisation can call a particular function. */ + /** checks that only organization can call a particular function. */ modifier onlyCoGateway() { require( msg.sender == coGateway, @@ -72,7 +72,7 @@ contract UtilityToken is /** * @notice Contract constructor. * - * @dev TODO: Sets Organisation with msg.sender address. + * @dev TODO: Sets Organization with msg.sender address. * * @param _symbol Symbol of token * @param _name Name of token @@ -87,7 +87,7 @@ contract UtilityToken is ) public EIP20Token(_symbol, _name, _decimals) - //TODO: add organisation + //TODO: add organization { require( _valueToken != address(0), @@ -102,7 +102,7 @@ contract UtilityToken is /** * @notice Sets the CoGateway contract address. * - * @dev This will be set with zero gas. Can be called only by Organisation + * @dev This will be set with zero gas. Can be called only by Organization * * @param _coGatewayAddress CoGateway contract address * @@ -110,7 +110,7 @@ contract UtilityToken is */ function setCoGateway(address _coGatewayAddress) external - //TODO: add organisation + //TODO: add organization returns (bool) { require( diff --git a/contracts/lib/IsWorkerInterface.sol b/contracts/lib/IsMemberInterface.sol similarity index 71% rename from contracts/lib/IsWorkerInterface.sol rename to contracts/lib/IsMemberInterface.sol index 677586a5..94bea44f 100644 --- a/contracts/lib/IsWorkerInterface.sol +++ b/contracts/lib/IsMemberInterface.sol @@ -15,10 +15,20 @@ pragma solidity ^0.5.0; // limitations under the License. /** - * @title IsWorkerInterface provides a method to check if an address is + * @title IsMemberInterface provides a method to check if an address is * currently registered as an active worker. */ -interface IsWorkerInterface { +interface IsMemberInterface { + + /** + * @notice Checks if an address is currently registered as the owner. + * + * @param _owner Address to check. + * + * @return isOwner_ True if the given address is the owner of the + * organization. Returns false otherwise. + */ + function isOwner(address _owner) external view returns (bool isOwner_); /** * @notice Checks if an address is currently registered as an active worker. diff --git a/contracts/lib/Organization.sol b/contracts/lib/Organization.sol index 4a48211a..2467eab5 100644 --- a/contracts/lib/Organization.sol +++ b/contracts/lib/Organization.sol @@ -16,7 +16,7 @@ pragma solidity ^0.5.0; import "./SafeMath.sol"; import "./OrganizationInterface.sol"; -import "./IsWorkerInterface.sol"; +import "./IsMemberInterface.sol"; /** @@ -26,7 +26,7 @@ import "./IsWorkerInterface.sol"; * mosaic ecosystem and therefore the Organization.sol contract holds * all the keys required to administer the mosaic contracts. */ -contract Organization is OrganizationInterface, IsWorkerInterface { +contract Organization is OrganizationInterface, IsMemberInterface { using SafeMath for uint256; /* Storage */ @@ -234,6 +234,18 @@ contract Organization is OrganizationInterface, IsWorkerInterface { emit WorkerUnset(_worker, isUnset_); } + /** + * @notice Checks if an address is currently registered as the owner. + * + * @param _owner Address to check. + * + * @return isOwner_ True if the given address is the owner of the + * organization. Returns false otherwise. + */ + function isOwner(address _owner) external view returns (bool isOwner_) { + isOwner_ = _owner == owner; + } + /** * @notice Checks if an address is currently registered as an active worker. * diff --git a/contracts/lib/Organized.sol b/contracts/lib/Organized.sol index c4ea7dd6..71d524b1 100644 --- a/contracts/lib/Organized.sol +++ b/contracts/lib/Organized.sol @@ -14,7 +14,7 @@ pragma solidity ^0.5.0; // See the License for the specific language governing permissions and // limitations under the License. -import "./IsWorkerInterface.sol"; +import "./IsMemberInterface.sol"; /** * @title Organized contract. @@ -24,43 +24,50 @@ import "./IsWorkerInterface.sol"; */ contract Organized { - /* Storage */ /** - * IsWorkerInterface of organization contract which holds all the + * IsMemberInterface of worker manager contract which holds all the * keys needed to administer the economy. */ - IsWorkerInterface public organization; - + IsMemberInterface public membersManager; /* Modifiers */ + modifier onlyOrganization() + { + require( + membersManager.isOwner(msg.sender), + "Only the organization is allowed to call this method." + ); + + _; + } + modifier onlyWorker() { require( - organization.isWorker(msg.sender), + membersManager.isWorker(msg.sender), "Only whitelisted workers are allowed to call this method." ); + _; } - /* Constructor */ /** * @notice Sets the address of the organization contract. * - * @param _organization Organization contract address containing - * different administration keys. + * @param _membersManager A contract that manages worker keys. */ - constructor(IsWorkerInterface _organization) public { + constructor(IsMemberInterface _membersManager) public { require( - address(_organization) != address(0), - "Organization contract address must not be address(0)." + address(_membersManager) != address(0), + "MembersManager contract address must not be address(0)." ); - organization = _organization; + membersManager = _membersManager; } } diff --git a/contracts/test/TestEIP20Gateway.sol b/contracts/test/TestEIP20Gateway.sol index 3c317c87..4cc29db7 100644 --- a/contracts/test/TestEIP20Gateway.sol +++ b/contracts/test/TestEIP20Gateway.sol @@ -37,21 +37,21 @@ contract TestEIP20Gateway is EIP20Gateway { * @param _core Core contract address. * @param _bounty The amount that facilitator will stakes to initiate the * stake process. - * @param _organisation Organisation address. + * @param _membersManager Address of a contract that manages workers. */ constructor( EIP20Interface _token, EIP20Interface _baseToken, CoreInterface _core, uint256 _bounty, - address _organisation + IsMemberInterface _membersManager ) EIP20Gateway( _token, _baseToken, _core, _bounty, - _organisation + _membersManager ) public { diff --git a/contracts/test/MockCore.sol b/contracts/test/core/MockCore.sol similarity index 95% rename from contracts/test/MockCore.sol rename to contracts/test/core/MockCore.sol index 3a588823..089db440 100644 --- a/contracts/test/MockCore.sol +++ b/contracts/test/core/MockCore.sol @@ -1,7 +1,7 @@ pragma solidity ^0.5.0; -import "../gateway/WorkersInterface.sol"; -import "../gateway/Core.sol"; +import "../../gateway/WorkersInterface.sol"; +import "../../gateway/Core.sol"; /** * @title CoreMock contract diff --git a/contracts/test/MockGatewayBase.sol b/contracts/test/gateway/MockGatewayBase.sol similarity index 94% rename from contracts/test/MockGatewayBase.sol rename to contracts/test/gateway/MockGatewayBase.sol index 30f29f92..bd2513d8 100644 --- a/contracts/test/MockGatewayBase.sol +++ b/contracts/test/gateway/MockGatewayBase.sol @@ -1,7 +1,8 @@ pragma solidity ^0.5.0; -import "../gateway/GatewayBase.sol"; -import "./MockGatewayLib.sol"; +import "../lib/MockGatewayLib.sol"; +import "../../gateway/GatewayBase.sol"; +import "../../lib/IsMemberInterface.sol"; /** * @title MockGatewayBase contract @@ -13,13 +14,13 @@ contract MockGatewayBase is GatewayBase { constructor( CoreInterface _core, uint256 _bounty, - address _organisation + IsMemberInterface _membersManager ) public GatewayBase( _core, _bounty, - _organisation + _membersManager ) {} diff --git a/contracts/test/MockGatewayLib.sol b/contracts/test/lib/MockGatewayLib.sol similarity index 100% rename from contracts/test/MockGatewayLib.sol rename to contracts/test/lib/MockGatewayLib.sol diff --git a/contracts/test/MockMerklePatriciaProof.sol b/contracts/test/lib/MockMerklePatriciaProof.sol similarity index 100% rename from contracts/test/MockMerklePatriciaProof.sol rename to contracts/test/lib/MockMerklePatriciaProof.sol diff --git a/contracts/test/lib/MockWorkerManager.sol b/contracts/test/lib/MockWorkerManager.sol new file mode 100644 index 00000000..81ffe11d --- /dev/null +++ b/contracts/test/lib/MockWorkerManager.sol @@ -0,0 +1,74 @@ +pragma solidity ^0.5.0; + +// Copyright 2018 OpenST Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import "../../lib/IsMemberInterface.sol"; + +/** + * @title Mocks a member manager interface implementation. + * + * @notice The only valid registered owner and worker are given at + * construction and cannot be changed or removed. + */ +contract MockMembersManager is IsMemberInterface { + + + /* Storage */ + + /** The address of the registered owner. */ + address owner; + + /** The address of the registered worker. */ + address worker; + + + /* Constructor */ + + /** + * @notice Sets the address of the owner and the worker. + * + * @param _owner Address that should be used as a registered owner. + * @param _worker Address that should be used as a registered worker. + */ + constructor(address _owner, address _worker) public { + owner = _owner; + worker = _worker; + } + + + /* External functions */ + + /** + * @notice Checks if an address is currently registered as the owner. + * + * @param _owner Address to check. + * + * @return isOwner_ True if the given address is the registered owner. + */ + function isOwner(address _owner) external view returns (bool isOwner_) { + isOwner_ = owner == _owner; + } + + /** + * @notice Checks if an address is currently registered as an active worker. + * + * @param _worker Address to check. + * + * @return isWorker_ True if the given address is a registered worker. + */ + function isWorker(address _worker) external view returns (bool isWorker_) { + isWorker_ = worker == _worker; + } +} diff --git a/test/gateway/eip20_cogateway/constructor.js b/test/gateway/eip20_cogateway/constructor.js index 2deb4c17..2e8a1bae 100644 --- a/test/gateway/eip20_cogateway/constructor.js +++ b/test/gateway/eip20_cogateway/constructor.js @@ -20,17 +20,18 @@ const CoGateway = artifacts.require("EIP20CoGateway"); const MockToken = artifacts.require("MockToken"); +const MockMembersManager = artifacts.require('MockMembersManager.sol'); const Utils = require("./../../test_lib/utils"), BN = require('bn.js'); const NullAddress = "0x0000000000000000000000000000000000000000"; -contract('EIP20CoGateway,constructor() ', function (accounts) { +contract('EIP20CoGateway.constructor() ', function (accounts) { - let valueToken, utilityToken, bountyAmount, coreAddress, organisation, - coGateway, gatewayAddress = accounts[6]; + let valueToken, utilityToken, bountyAmount, coreAddress, owner, worker, + membersManager, coGateway, gatewayAddress = accounts[6]; beforeEach(async function () { @@ -38,7 +39,10 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityToken = await MockToken.new(); coreAddress = accounts[1]; bountyAmount = new BN(100); - organisation = accounts[2]; + + owner = accounts[2]; + worker = accounts[3]; + membersManager = await MockMembersManager.new(owner, worker); }); it('should able to deploy contract with correct parameters.', async function () { @@ -48,7 +52,7 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityToken.address, coreAddress, bountyAmount, - organisation, + membersManager.address, gatewayAddress ); @@ -65,7 +69,7 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityToken.address, coreAddress, bountyAmount, - organisation, + membersManager.address, gatewayAddress ); @@ -97,12 +101,6 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { 'Invalid bounty amount from contract' ); - let orgAdd = await coGateway.organisation.call(); - assert.strictEqual( - orgAdd, - organisation, - 'Invalid organisationAddress address from contract.' - ); }); it('should not deploy contract if value token is passed as zero.', async function () { @@ -114,7 +112,7 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityToken.address, coreAddress, bountyAmount, - organisation, + membersManager.address, gatewayAddress ), 'Value token address must not be zero.' @@ -130,7 +128,7 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityTokenAddress, coreAddress, bountyAmount, - organisation, + membersManager.address, gatewayAddress ), 'Utility token address must not be zero.' @@ -146,7 +144,7 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityToken.address, coreAddress, bountyAmount, - organisation, + membersManager.address, gatewayAddress ), 'Core contract address must not be zero.' @@ -154,23 +152,6 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { }); - it('should not deploy contract if organisation address is passed as' + - ' zero.', async function () { - let organisation = NullAddress; - - await Utils.expectRevert( - CoGateway.new( - valueToken.address, - utilityToken.address, - coreAddress, - bountyAmount, - organisation, - gatewayAddress - ), - 'Organisation address must not be zero.' - ); - }); - it('should able to deploy contract with zero bounty.', async function () { let bountyAmount = new BN(0); @@ -180,7 +161,7 @@ contract('EIP20CoGateway,constructor() ', function (accounts) { utilityToken.address, coreAddress, bountyAmount, - organisation, + membersManager.address, gatewayAddress ); diff --git a/test/gateway/eip20_gateway/activate_gateway.js b/test/gateway/eip20_gateway/activate_gateway.js index d23f3fcd..1082d5c6 100644 --- a/test/gateway/eip20_gateway/activate_gateway.js +++ b/test/gateway/eip20_gateway/activate_gateway.js @@ -1,103 +1,83 @@ const Gateway = artifacts.require("./EIP20Gateway.sol") - , BN = require('bn.js'); +const MockMembersManager = artifacts.require('MockMembersManager.sol'); +const BN = require('bn.js'); const Utils = require('../../../test/test_lib/utils'); -contract('GatewayBase.sol', function (accounts) { +contract('EIP20Gateway.(de)activateGateway()', function (accounts) { - describe('Deactivate gateway', async () => { - let gateway; - let organisation = accounts[2]; + let gateway; + let coGateway = accounts[5]; + let owner = accounts[2]; + let worker = accounts[3]; + let membersManager; - beforeEach(async function () { + beforeEach(async function () { - let mockToken = accounts[0], - baseToken = accounts[1], - coreAddress = accounts[2], - bountyAmount = new BN(100); + let mockToken = accounts[0], + baseToken = accounts[1], + coreAddress = accounts[2], + bountyAmount = new BN(100); - gateway = await Gateway.new( - mockToken, - baseToken, - coreAddress, - bountyAmount, - organisation - ); + membersManager = await MockMembersManager.new(owner, worker); - let coGateway = accounts[5]; - await gateway.activateGateway(coGateway, {from: organisation}); - - }); - - it('should deactivate if activated', async function () { - - assert((await gateway.deactivateGateway.call({from: organisation}))); - await gateway.deactivateGateway({from: organisation}); - assert( - !(await gateway.activated.call()), - 'Activation flag is true but expected as false.' - ); - }); - - it('should not deactivate if already deactivated', async function () { - - await gateway.deactivateGateway({from: organisation}); - await Utils.expectThrow(gateway.deactivateGateway.call({from: organisation})); - }); - - it('should deactivated by organization only', async function () { + gateway = await Gateway.new( + mockToken, + baseToken, + coreAddress, + bountyAmount, + membersManager.address + ); + }); - await Utils.expectThrow(gateway.deactivateGateway.call({from: accounts[0]})); - }); + it('should deactivate if activated', async function () { + await gateway.activateGateway(coGateway, { from: owner }); + assert((await gateway.deactivateGateway.call({ from: owner }))); + await gateway.deactivateGateway({ from: owner }); + assert( + !(await gateway.activated.call()), + 'Activation flag is true but expected as false.' + ); }); - describe('Activate Gateway', async () => { - let gateway; - let organisation = accounts[2]; - let coGateway = accounts[5]; + it('should not deactivate if already deactivated', async function () { - beforeEach(async function () { - let mockToken = accounts[0], - baseToken = accounts[1], - coreAddress = accounts[2], - bountyAmount = new BN(100); + await gateway.activateGateway(coGateway, { from: owner }); + await gateway.deactivateGateway({ from: owner }); + await Utils.expectThrow(gateway.deactivateGateway.call({ from: owner })); + }); - gateway = await Gateway.new( - mockToken, - baseToken, - coreAddress, - bountyAmount, - organisation - ); - }); + it('should deactivated by organization only', async function () { - it('should activate if deActivated', async function () { + await gateway.activateGateway(coGateway, { from: owner }); + await Utils.expectThrow(gateway.deactivateGateway.call({ from: accounts[0] })); + }); - assert( - (await gateway.activateGateway.call(coGateway, {from: organisation})), - "Gateway activation failed, activateGateway returned false.", - ); + it('should activate if deActivated', async function () { - await gateway.activateGateway(coGateway, {from: organisation}); - assert( - (await gateway.activated.call()), - 'Activation flag is false but expected as true.' - ); - }); + assert( + (await gateway.activateGateway.call(coGateway, { from: owner })), + "Gateway activation failed, activateGateway returned false.", + ); - it('should not activate if already activated', async function () { + await gateway.activateGateway(coGateway, { from: owner }); + assert( + (await gateway.activated.call()), + 'Activation flag is false but expected as true.' + ); + }); - await gateway.activateGateway(coGateway, {from: organisation}); - await Utils.expectThrow(gateway.activateGateway.call(coGateway, {from: organisation})); - }); + it('should not activate if already activated', async function () { - it('should be activated by organization only', async function () { + await gateway.activateGateway(coGateway, { from: owner }); + await Utils.expectThrow(gateway.activateGateway.call(coGateway, { from: owner })); + }); - await Utils.expectThrow(gateway.activateGateway.call(coGateway, {from: accounts[0]})); - }); + it('should be activated by organization only', async function () { + await Utils.expectThrow(gateway.activateGateway.call(coGateway, { from: accounts[0] })); }); }); diff --git a/test/gateway/eip20_gateway/constructor.js b/test/gateway/eip20_gateway/constructor.js index 4b46d5fd..d9c05eb5 100644 --- a/test/gateway/eip20_gateway/constructor.js +++ b/test/gateway/eip20_gateway/constructor.js @@ -20,6 +20,7 @@ const Gateway = artifacts.require("EIP20Gateway"); const MockToken = artifacts.require("MockToken"); +const MockMembersManager = artifacts.require('MockMembersManager.sol'); const Utils = require("./../../test_lib/utils"), BN = require('bn.js'); @@ -28,8 +29,8 @@ const NullAddress = "0x0000000000000000000000000000000000000000"; contract('EIP20Gateway.constructor() ', function (accounts) { - let mockToken, baseToken, bountyAmount, coreAddress, organisation, - gateway; + let mockToken, baseToken, bountyAmount, coreAddress, membersManager, + gateway, owner, worker; beforeEach(async function () { @@ -37,7 +38,10 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseToken = await MockToken.new(); coreAddress = accounts[1]; bountyAmount = new BN(100); - organisation = accounts[2]; + + owner = accounts[2]; + worker = accounts[3]; + membersManager = await MockMembersManager.new(owner, worker); }); it('should able to deploy contract with correct parameters.', async function () { @@ -47,7 +51,7 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseToken.address, coreAddress, bountyAmount, - organisation + membersManager.address ); assert( @@ -63,7 +67,7 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseToken.address, coreAddress, bountyAmount, - organisation + membersManager.address ); let tokenAddress = await gateway.token.call(); @@ -94,13 +98,6 @@ contract('EIP20Gateway.constructor() ', function (accounts) { "Invalid bounty amount from contract" ); - let orgAdd = await gateway.organisation.call(); - assert.equal( - orgAdd, - organisation, - "Invalid organisationAddress address from contract" - ); - let isActivated = await gateway.activated.call(); assert( !isActivated, @@ -117,7 +114,7 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseToken.address, coreAddress, bountyAmount, - organisation + membersManager.address ), "Token contract address must not be zero." ); @@ -132,7 +129,7 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseTokenAddress, coreAddress, bountyAmount, - organisation + membersManager.address ), "Base token contract address for bounty must not be zero." ); @@ -147,29 +144,13 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseToken.address, coreAddress, bountyAmount, - organisation + membersManager.address ), "Core contract address must not be zero." ); }); - it('should not deploy contract if organisation address is passed as' + - ' zero.', async function () { - let organisation = NullAddress; - - await Utils.expectRevert( - Gateway.new( - mockToken.address, - baseToken.address, - coreAddress, - bountyAmount, - organisation - ), - "Organisation address must not be zero." - ); - }); - it('should able to deploy contract with zero bounty.', async function () { let bountyAmount = new BN(0); @@ -179,7 +160,7 @@ contract('EIP20Gateway.constructor() ', function (accounts) { baseToken.address, coreAddress, bountyAmount, - organisation + membersManager.address ); assert( diff --git a/test/gateway/eip20_gateway/stake.js b/test/gateway/eip20_gateway/stake.js index 6e802dee..e03956a2 100644 --- a/test/gateway/eip20_gateway/stake.js +++ b/test/gateway/eip20_gateway/stake.js @@ -63,7 +63,7 @@ async function _setup(accounts) { baseToken.address, accounts[3], //core address bountyAmount, - accounts[4] // organisation address + accounts[4] // organization address ); helper = new HelperKlass(gateway); @@ -73,7 +73,7 @@ async function _setup(accounts) { hashLockObj = utils.generateHashLock(); facilitator = accounts[4]; - nonce = await helper.getNonce(accounts[1]); + nonce = await helper.getNonce(accounts[1]); stakeAmount = new BN(100000000000); beneficiary = accounts[2]; stakerAddress = accounts[1]; @@ -82,11 +82,11 @@ async function _setup(accounts) { hashLock = hashLockObj.l; - await mockToken.transfer(stakerAddress, stakeAmount, {from: accounts[0]}); - await mockToken.approve(gateway.address, stakeAmount, {from: stakerAddress}); + await mockToken.transfer(stakerAddress, stakeAmount, { from: accounts[0] }); + await mockToken.approve(gateway.address, stakeAmount, { from: stakerAddress }); - await baseToken.transfer(facilitator, bountyAmount, {from: accounts[0]}); - await baseToken.approve(gateway.address, bountyAmount, {from: facilitator}); + await baseToken.transfer(facilitator, bountyAmount, { from: accounts[0] }); + await baseToken.approve(gateway.address, bountyAmount, { from: facilitator }); errorMessage = ""; } @@ -130,7 +130,7 @@ async function _stake(resultType) { }; let expectedResult = { - returns: {messageHash: messageHash}, + returns: { messageHash: messageHash }, events: { StakeIntentDeclared: { _messageHash: messageHash, @@ -214,14 +214,14 @@ contract('EIP20Gateway.stake() ', function (accounts) { it('should fail to stake when staker has balance less than the stake amount', async function () { stakeAmount = new BN(200000000000); - await mockToken.approve(gateway.address, stakeAmount, {from: stakerAddress}); + await mockToken.approve(gateway.address, stakeAmount, { from: stakerAddress }); await _prepareData(); errorMessage = "revert"; await _stake(utils.ResultType.FAIL); }); it('should fail to stake when facilitator has balance less than the bounty amount', async function () { - await baseToken.transfer(accounts[0], new BN(50), {from: facilitator}); + await baseToken.transfer(accounts[0], new BN(50), { from: facilitator }); await _prepareData(); errorMessage = "revert"; await _stake(utils.ResultType.FAIL); @@ -229,7 +229,7 @@ contract('EIP20Gateway.stake() ', function (accounts) { it('should fail to stake when gateway is not approved by the staker', async function () { stakerAddress = accounts[5]; - await mockToken.transfer(stakerAddress, stakeAmount, {from: accounts[0]}); + await mockToken.transfer(stakerAddress, stakeAmount, { from: accounts[0] }); await _prepareData(); errorMessage = "revert"; await _stake(utils.ResultType.FAIL); @@ -237,7 +237,7 @@ contract('EIP20Gateway.stake() ', function (accounts) { it('should fail to stake when gateway is not approved by the facilitator', async function () { facilitator = accounts[6]; - await baseToken.transfer(facilitator, bountyAmount, {from: accounts[0]}); + await baseToken.transfer(facilitator, bountyAmount, { from: accounts[0] }); await _prepareData(); errorMessage = "revert"; await _stake(utils.ResultType.FAIL); @@ -253,10 +253,10 @@ contract('EIP20Gateway.stake() ', function (accounts) { await _prepareData(); await _stake(utils.ResultType.SUCCESS); - await mockToken.transfer(stakerAddress, stakeAmount, {from: accounts[0]}); - await baseToken.transfer(facilitator, bountyAmount, {from: accounts[0]}); - await mockToken.approve(gateway.address, stakeAmount, {from: stakerAddress}); - await baseToken.approve(gateway.address, bountyAmount, {from: facilitator}); + await mockToken.transfer(stakerAddress, stakeAmount, { from: accounts[0] }); + await baseToken.transfer(facilitator, bountyAmount, { from: accounts[0] }); + await mockToken.approve(gateway.address, stakeAmount, { from: stakerAddress }); + await baseToken.approve(gateway.address, bountyAmount, { from: facilitator }); errorMessage = "Invalid nonce"; await _stake(utils.ResultType.FAIL); @@ -267,10 +267,10 @@ contract('EIP20Gateway.stake() ', function (accounts) { await _prepareData(); await _stake(utils.ResultType.SUCCESS); - await mockToken.transfer(stakerAddress, stakeAmount, {from: accounts[0]}); - await baseToken.transfer(facilitator, bountyAmount, {from: accounts[0]}); - await mockToken.approve(gateway.address, stakeAmount, {from: stakerAddress}); - await baseToken.approve(gateway.address, bountyAmount, {from: facilitator}); + await mockToken.transfer(stakerAddress, stakeAmount, { from: accounts[0] }); + await baseToken.transfer(facilitator, bountyAmount, { from: accounts[0] }); + await mockToken.approve(gateway.address, stakeAmount, { from: stakerAddress }); + await baseToken.approve(gateway.address, bountyAmount, { from: facilitator }); nonce = new BN(2); await _prepareData(); @@ -287,17 +287,17 @@ contract('EIP20Gateway.stake() ', function (accounts) { let penalty = new BN(bountyAmount * PENALTY_PERCENT); // funding staker for penalty amount - await baseToken.transfer(stakerAddress, penalty, {from: accounts[0]}); + await baseToken.transfer(stakerAddress, penalty, { from: accounts[0] }); // approving gateway for penalty amount - await baseToken.approve(gateway.address, penalty, {from: stakerAddress}); + await baseToken.approve(gateway.address, penalty, { from: stakerAddress }); //revertStaking - await gateway.revertStake(messageHash, {from: stakerAddress}); + await gateway.revertStake(messageHash, { from: stakerAddress }); - await mockToken.transfer(stakerAddress, stakeAmount, {from: accounts[0]}); - await baseToken.transfer(facilitator, bountyAmount, {from: accounts[0]}); - await mockToken.approve(gateway.address, stakeAmount, {from: stakerAddress}); - await baseToken.approve(gateway.address, bountyAmount, {from: facilitator}); + await mockToken.transfer(stakerAddress, stakeAmount, { from: accounts[0] }); + await baseToken.transfer(facilitator, bountyAmount, { from: accounts[0] }); + await mockToken.approve(gateway.address, stakeAmount, { from: stakerAddress }); + await baseToken.approve(gateway.address, bountyAmount, { from: facilitator }); nonce = new BN(2); await _prepareData(); diff --git a/test/gateway/gateway_base/bounty_change.js b/test/gateway/gateway_base/bounty_change.js index c7b1328b..58a7505d 100644 --- a/test/gateway/gateway_base/bounty_change.js +++ b/test/gateway/gateway_base/bounty_change.js @@ -1,17 +1,18 @@ const GatewayBase = artifacts.require("./GatewayBase.sol") , BN = require('bn.js'); +const MockMembersManager = artifacts.require('MockMembersManager.sol'); const Utils = require('../../../test/test_lib/utils'); let unlockTimeInBlocks = 100; -async function proposeBountyChange(gatewayBaseInstance, proposedBounty, organisation, currentBounty) { +async function proposeBountyChange(gatewayBaseInstance, proposedBounty, organization, currentBounty) { - let actualProposedBounty = await gatewayBaseInstance.initiateBountyAmountChange.call(proposedBounty, { from: organisation }); + let actualProposedBounty = await gatewayBaseInstance.initiateBountyAmountChange.call(proposedBounty, { from: organization }); assert(proposedBounty.eq(actualProposedBounty)); - let response = await gatewayBaseInstance.initiateBountyAmountChange(proposedBounty, { from: organisation }); + let response = await gatewayBaseInstance.initiateBountyAmountChange(proposedBounty, { from: organization }); let expectedUnlockHeight = response.receipt.blockNumber + unlockTimeInBlocks; @@ -39,17 +40,20 @@ contract('GatewayBase.sol', function (accounts) { describe('Initiate change bounty', async () => { let gatewayBaseInstance; - let organisation = accounts[2]; + let owner = accounts[2]; + let worker = accounts[3]; beforeEach(async function () { let core = accounts[0] , bounty = new BN(100); + let membersManager = await MockMembersManager.new(owner, worker); + gatewayBaseInstance = await GatewayBase.new( core, bounty, - organisation + membersManager.address ); }); @@ -59,7 +63,7 @@ contract('GatewayBase.sol', function (accounts) { let proposedBounty = new BN(50); let currentBounty = new BN(100); - await proposeBountyChange(gatewayBaseInstance, proposedBounty, organisation, currentBounty); + await proposeBountyChange(gatewayBaseInstance, proposedBounty, owner, currentBounty); }); @@ -68,12 +72,12 @@ contract('GatewayBase.sol', function (accounts) { let proposedBounty = new BN(50); let currentBounty = new BN(100); - await proposeBountyChange(gatewayBaseInstance, proposedBounty, organisation, currentBounty); + await proposeBountyChange(gatewayBaseInstance, proposedBounty, owner, currentBounty); proposedBounty = new BN(150); currentBounty = new BN(100); - await proposeBountyChange(gatewayBaseInstance, proposedBounty, organisation, currentBounty); + await proposeBountyChange(gatewayBaseInstance, proposedBounty, owner, currentBounty); }); it('should accept propose bounty change from organization only', async function () { @@ -90,7 +94,8 @@ contract('GatewayBase.sol', function (accounts) { describe('Confirm Bounty change', async () => { let gatewayBaseInstance; - let organisation = accounts[2]; + let owner = accounts[2]; + let worker = accounts[3]; let unlockHeight; let currentBlock; let proposedBounty = new BN(50); @@ -101,22 +106,24 @@ contract('GatewayBase.sol', function (accounts) { let core = accounts[0] , bounty = new BN(100); + let membersManager = await MockMembersManager.new(owner, worker); + gatewayBaseInstance = await GatewayBase.new( core, bounty, - organisation + membersManager.address ); - unlockHeight = await proposeBountyChange(gatewayBaseInstance, proposedBounty, organisation, currentBounty); + unlockHeight = await proposeBountyChange(gatewayBaseInstance, proposedBounty, owner, currentBounty); currentBlock = unlockHeight - unlockTimeInBlocks; }); it('should be able to confirm bounty change after unlockHeight', async function () { while (currentBlock < unlockHeight) { - await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: organisation })); + await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: owner })); currentBlock++; } - let response = await gatewayBaseInstance.confirmBountyAmountChange({ from: organisation }) + let response = await gatewayBaseInstance.confirmBountyAmountChange({ from: owner }) let expectedEvent = { BountyChangeConfirmed: { @@ -138,7 +145,7 @@ contract('GatewayBase.sol', function (accounts) { it('should not be able to confirm bounty change before unlockHeight', async function () { while (currentBlock < unlockHeight) { - await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: organisation })); + await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: owner })); currentBlock++; } }); @@ -146,7 +153,7 @@ contract('GatewayBase.sol', function (accounts) { it('should not accept a bounty change from another address than the organization', async function () { while (currentBlock < unlockHeight) { - await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: organisation })); + await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: owner })); currentBlock++; } await Utils.expectThrow(gatewayBaseInstance.confirmBountyAmountChange({ from: accounts[5] })); diff --git a/test/gateway/gateway_base/construction.js b/test/gateway/gateway_base/construction.js index cba4bfe1..aeca80f7 100644 --- a/test/gateway/gateway_base/construction.js +++ b/test/gateway/gateway_base/construction.js @@ -1,6 +1,7 @@ const GatewayBase = artifacts.require("./GatewayBase.sol") , BN = require('bn.js'); +const MockMembersManager = artifacts.require('MockMembersManager.sol'); const Utils = require('../../../test/test_lib/utils'); const NullAddress = "0x0000000000000000000000000000000000000000"; @@ -8,32 +9,29 @@ contract('GatewayBase.sol', function (accounts) { describe('Construction', async () => { - let core, bounty, organisation; + let core, bounty, worker, membersManager; - beforeEach(function () { + beforeEach(async function () { - organisation = accounts[2] + owner = accounts[2] + , worker = accounts[3] , core = accounts[0] , bounty = new BN(100); + + membersManager = await MockMembersManager.new(owner, worker); }); it('should pass with right set of parameters', async function () { - - let gatewayBaseInstance = await GatewayBase.new( + gatewayBaseInstance = await GatewayBase.new( core, bounty, - organisation + membersManager.address ); assert.strictEqual( - core, - await gatewayBaseInstance.core.call(), - "Core contract address doesn't match." - ); - assert.strictEqual( - organisation, - await gatewayBaseInstance.organisation.call(), - "Organization address doesn't match." + core, + await gatewayBaseInstance.core.call(), + "Core contract address doesn't match." ); assert((await gatewayBaseInstance.bounty.call()).eq(bounty)); }); @@ -42,33 +40,31 @@ contract('GatewayBase.sol', function (accounts) { bounty = new BN(0); - let gatewayBaseInstance = await GatewayBase.new( + gatewayBaseInstance = await GatewayBase.new( core, bounty, - organisation + membersManager.address ); assert.equal(core, await gatewayBaseInstance.core.call()); - assert.equal(organisation, await gatewayBaseInstance.organisation.call()); assert((await gatewayBaseInstance.bounty.call()).eq(bounty)); }); it('should fail if core address is not passed', async function () { core = NullAddress; - await Utils.expectRevert( - GatewayBase.new(core, bounty, organisation), - "Core contract address must not be zero." - ); + await Utils.expectRevert( + GatewayBase.new(core, bounty, membersManager.address), + "Core contract address must not be zero." + ); }); - it('should fail if organisation address is not passed', async function () { + it('should fail if worker manager address is not passed', async function () { - organisation = NullAddress; await Utils.expectRevert( - GatewayBase.new(core, bounty, organisation), - "Organisation address must not be zero." + GatewayBase.new(core, bounty, NullAddress), + "MembersManager contract address must not be address\\(0\\)." ); }); diff --git a/test/gateway/gateway_base/get_nonce.js b/test/gateway/gateway_base/get_nonce.js index c633cba5..11f6ca41 100644 --- a/test/gateway/gateway_base/get_nonce.js +++ b/test/gateway/gateway_base/get_nonce.js @@ -1,8 +1,7 @@ const GatewayBase = artifacts.require("./GatewayBase.sol") , BN = require('bn.js'); -const Utils = require('../../../test/test_lib/utils'); - +const MockMembersManager = artifacts.require('MockMembersManager.sol'); contract('GatewayBase.sol', function (accounts) { @@ -12,14 +11,17 @@ contract('GatewayBase.sol', function (accounts) { beforeEach(async function () { - let organisation = accounts[2] + let owner = accounts[2] + , worker = accounts[3] , core = accounts[0] , bounty = new BN(100); + let membersManager = await MockMembersManager.new(owner, worker); + gatewayBaseInstance = await GatewayBase.new( core, bounty, - organisation + membersManager.address ); }); @@ -34,7 +36,7 @@ contract('GatewayBase.sol', function (accounts) { it('should return nonce incremented by 1 if stake process is initiated', async function () { - //todo implement this when stake unit tests are done + //todo implement this when stake unit tests are done }); it('should return nonce incremented by 1 if linking process is initiated', async function () { diff --git a/test/gateway/gateway_base/prove_gateway.js b/test/gateway/gateway_base/prove_gateway.js index 1e9466f1..5da440d8 100644 --- a/test/gateway/gateway_base/prove_gateway.js +++ b/test/gateway/gateway_base/prove_gateway.js @@ -2,6 +2,7 @@ const GatewayBase = artifacts.require("./MockGatewayBase.sol") , Core = artifacts.require("./MockCore.sol") , BN = require('bn.js'); +const MockMembersManager = artifacts.require('MockMembersManager.sol'); const Utils = require('../../../test/test_lib/utils'); @@ -17,13 +18,16 @@ contract('GatewayBase.sol', function (accounts) { beforeEach(async function () { let core = await Core.new(1, 2, 0, stateRoot, accounts[1]) - , organisation = accounts[2] + , owner = accounts[2] + , worker = accounts[3] , bounty = new BN(100); + let membersManager = await MockMembersManager.new(owner, worker); + gatewayBaseInstance = await GatewayBase.new( core.address, bounty, - organisation + membersManager.address ); }); @@ -92,4 +96,4 @@ contract('GatewayBase.sol', function (accounts) { }); -}); \ No newline at end of file +}); diff --git a/test/gateway/helpers/helper.js b/test/gateway/helpers/helper.js index 92a4eaba..4802f57e 100644 --- a/test/gateway/helpers/helper.js +++ b/test/gateway/helpers/helper.js @@ -2,7 +2,7 @@ const web3 = require('../../test_lib/web3.js'); -const GatewayHelper = function(gateway) { +const GatewayHelper = function (gateway) { const oThis = this; oThis.gateway = gateway; }; @@ -21,7 +21,7 @@ GatewayHelper.prototype = { bountyToken = params.bountyToken, coreAddress = params.core, bountyAmount = params.bounty, - organisationAddress = params.organisation; + organizationAddress = params.organization; if (resultType === utils.ResultType.FAIL) { await utils.expectThrow(Gateway.new( @@ -29,7 +29,7 @@ GatewayHelper.prototype = { bountyToken, coreAddress, bountyAmount, - organisationAddress + organizationAddress )); } else { this.gateway = await Gateway.new( @@ -37,7 +37,7 @@ GatewayHelper.prototype = { bountyToken, coreAddress, bountyAmount, - organisationAddress + organizationAddress ); let addressValidationResult = await this.isAddress( @@ -78,11 +78,11 @@ GatewayHelper.prototype = { "Invalid bounty amount from contract" ); - let orgAdd = await this.gateway.organisation.call(); + let orgAdd = await this.gateway.organization.call(); assert.equal( orgAdd, - organisationAddress, - "Invalid organisationAddress address from contract" + organizationAddress, + "Invalid organizationAddress address from contract" ); } diff --git a/test/lib/organized/constructor.js b/test/lib/organized/constructor.js index 3feb594f..0fc72890 100644 --- a/test/lib/organized/constructor.js +++ b/test/lib/organized/constructor.js @@ -33,7 +33,7 @@ contract('Organized.constructor()', async (accounts) => { { from: owner }, ), // Escaping as a regular expression is expected. - 'Organization contract address must not be address\\(0\\)\\.', + 'MembersManager contract address must not be address\\(0\\)\\.', ); }); @@ -41,7 +41,7 @@ contract('Organized.constructor()', async (accounts) => { it('checks that valid organization address is set', async () => { organized = await Organized.new(organization.address, { from: owner }); assert.strictEqual( - await organized.organization.call(), + await organized.membersManager.call(), organization.address, 'The organized contract should store the given organization.', );