diff --git a/implementation/contracts/system/TBTCSystem.sol b/implementation/contracts/system/TBTCSystem.sol index 9278a128f..1eb3d29b3 100644 --- a/implementation/contracts/system/TBTCSystem.sol +++ b/implementation/contracts/system/TBTCSystem.sol @@ -98,8 +98,14 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog { /// @dev Lot sizes should be /// @param _lotSizes Array of allowed lot sizes. function setLotSizes(uint256[] calldata _lotSizes) external onlyOwner { - lotSizesSatoshis = _lotSizes; - emit LotSizesUpdated(_lotSizes); + for( uint i = 0; i < _lotSizes.length; i++){ + if (_lotSizes[i] == 10**8){ + lotSizesSatoshis = _lotSizes; + emit LotSizesUpdated(_lotSizes); + return; + } + } + revert("Lot size array must always contain 1BTC"); } /// @notice Gets the allowed lot sizes diff --git a/implementation/test/TBTCSystemTest.js b/implementation/test/TBTCSystemTest.js index 68e695618..5adac8f38 100644 --- a/implementation/test/TBTCSystemTest.js +++ b/implementation/test/TBTCSystemTest.js @@ -89,6 +89,34 @@ contract('TBTCSystem', (accounts) => { }) }) + describe('setLotSizes', async () => { + it('sets a different lot size array', async () => { + const blockNumber = await web3.eth.getBlock('latest').number + const lotSizes = [10**8, 10**6] + await tbtcSystem.setLotSizes(lotSizes) + + const eventList = await tbtcSystem.getPastEvents('LotSizesUpdated', { fromBlock: blockNumber, toBlock: 'latest' }) + assert.equal(eventList.length, 1) + expect(eventList[0].returnValues._lotSizes).to.eql(['100000000', '1000000']) // deep equality check + }) + + it('reverts if lot size array is empty', async () => { + const lotSizes = [] + await expectThrow( + tbtcSystem.setLotSizes(lotSizes), + 'Lot size array must always contain 1BTC' + ) + }) + + it('reverts if lot size array does not contain a 1BTC lot size', async () => { + const lotSizes = [10**7] + await expectThrow( + tbtcSystem.setLotSizes(lotSizes), + 'Lot size array must always contain 1BTC' + ) + }) + }) + describe('emergencyPauseNewDeposits', async () => { let term