diff --git a/src/dhtproto/client/internal/NodeHashRanges.d b/src/dhtproto/client/internal/NodeHashRanges.d index e81e5e50..9ccd793c 100644 --- a/src/dhtproto/client/internal/NodeHashRanges.d +++ b/src/dhtproto/client/internal/NodeHashRanges.d @@ -269,6 +269,7 @@ private class NodeHashRangesBase import swarm.neo.client.ConnectionSet; import swarm.util.Hash : isWithinNodeResponsibility; import ocean.core.array.Mutation : sort; + import ocean.core.Verify; /// Value of the next created NodeHashRange's order field. private static ulong order_counter; @@ -309,7 +310,7 @@ private class NodeHashRangesBase // Update an existing node. if ( auto nhr = addr.cmp_id in this.node_hash_ranges ) { - assert(nhr.addr == addr); + verify(nhr.addr == addr); nhr.hash_range = NodeHashRange.HashRange(min, max); nhr.order = order_counter++; } @@ -352,7 +353,7 @@ private class NodeHashRangesBase bool sortPred ( NodeHashRange e1, NodeHashRange e2 ) { - assert(e1.order != e2.order); + verify(e1.order != e2.order); return e1.order > e2.order; } diff --git a/src/dhtproto/client/internal/SharedResources.d b/src/dhtproto/client/internal/SharedResources.d index 6b207a4a..07c0d089 100644 --- a/src/dhtproto/client/internal/SharedResources.d +++ b/src/dhtproto/client/internal/SharedResources.d @@ -22,6 +22,7 @@ public final class SharedResources import swarm.neo.client.ConnectionSet; import ocean.util.container.pool.FreeList; import ocean.core.TypeConvert : downcast; + import ocean.core.Verify; import ocean.io.compress.Lzo; import swarm.neo.util.MessageFiber; import swarm.neo.util.VoidBufferAsArrayOf; @@ -59,7 +60,7 @@ public final class SharedResources public static SharedResources fromObject ( Object obj ) { auto shared_resources = downcast!(SharedResources)(obj); - assert(shared_resources !is null); + verify(shared_resources !is null); return shared_resources; } diff --git a/src/dhtproto/client/mixins/NeoSupport.d b/src/dhtproto/client/mixins/NeoSupport.d index 997109d6..f4c8ae2b 100644 --- a/src/dhtproto/client/mixins/NeoSupport.d +++ b/src/dhtproto/client/mixins/NeoSupport.d @@ -44,6 +44,7 @@ template NeoSupport ( ) import swarm.neo.client.mixins.Controllers; import swarm.neo.client.request_options.RequestOptions; import ocean.core.SmartUnion; + import ocean.core.Verify; /*********************************************************************** @@ -614,7 +615,7 @@ template NeoSupport ( ) public void waitAllHashRangesKnown ( ) { auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); auto old_user_conn_notifier = this.outer.user_conn_notifier; @@ -742,14 +743,10 @@ template NeoSupport ( ) public void put ( cstring channel, hash_t key, Const!(void)[] value, Neo.Put.Notifier user_notifier ) - in - { - assert(user_notifier !is null); - } - body { + verify(user_notifier !is null); auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); bool finished; @@ -767,7 +764,7 @@ template NeoSupport ( ) this.outer.neo.put(channel, key, value, ¬ifier); if ( !finished ) // if request not completed, suspend task.suspend(); - assert(finished); + verify(finished); } /*********************************************************************** @@ -813,7 +810,7 @@ template NeoSupport ( ) public PutResult put ( cstring channel, hash_t key, Const!(void)[] value ) { auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); enum FinishedStatus { @@ -853,7 +850,7 @@ template NeoSupport ( ) this.outer.neo.put(channel, key, value, ¬ifier); if ( state == state.None ) // if request not completed, suspend task.suspend(); - assert(state != state.None); + verify(state != state.None); PutResult res; res.succeeded = state == state.Succeeded; @@ -876,14 +873,10 @@ template NeoSupport ( ) public void get ( cstring channel, hash_t key, Neo.Get.Notifier user_notifier ) - in - { - assert(user_notifier !is null); - } - body { + verify(user_notifier !is null); auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); bool finished; @@ -901,7 +894,7 @@ template NeoSupport ( ) this.outer.neo.get(channel, key, ¬ifier); if ( !finished ) // if request not completed, suspend task.suspend(); - assert(finished); + verify(finished); } /*********************************************************************** @@ -957,7 +950,7 @@ template NeoSupport ( ) public GetResult get ( cstring channel, hash_t key, ref void[] value ) { auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); enum FinishedStatus { @@ -1003,7 +996,7 @@ template NeoSupport ( ) this.outer.neo.get(channel, key, ¬ifier); if ( state == state.None ) // if request not completed, suspend task.suspend(); - assert(state != state.None); + verify(state != state.None); res.succeeded = state == state.Succeeded; return res; @@ -1025,14 +1018,10 @@ template NeoSupport ( ) public void update ( cstring channel, hash_t key, Neo.Update.Notifier user_notifier ) - in - { - assert(user_notifier !is null); - } - body { + verify(user_notifier !is null); auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); bool finished; @@ -1061,7 +1050,7 @@ template NeoSupport ( ) this.outer.neo.update(channel, key, ¬ifier); if ( !finished ) // if request not completed, suspend task.suspend(); - assert(finished); + verify(finished); } /*********************************************************************** @@ -1080,14 +1069,10 @@ template NeoSupport ( ) public void exists ( cstring channel, hash_t key, Neo.Exists.Notifier user_notifier ) - in - { - assert(user_notifier !is null); - } - body { + verify(user_notifier !is null); auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); bool finished; @@ -1106,7 +1091,7 @@ template NeoSupport ( ) this.outer.neo.exists(channel, key, ¬ifier); if ( !finished ) // if request not completed, suspend task.suspend(); - assert(finished); + verify(finished); } /*********************************************************************** @@ -1158,7 +1143,7 @@ template NeoSupport ( ) public ExistsResult exists ( cstring channel, hash_t key ) { auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); bool finished; ExistsResult res; @@ -1199,7 +1184,7 @@ template NeoSupport ( ) this.outer.neo.exists(channel, key, ¬ifier); if ( !finished ) // if request not completed, suspend task.suspend(); - assert(finished); + verify(finished); return res; } @@ -1220,14 +1205,10 @@ template NeoSupport ( ) public void remove ( cstring channel, hash_t key, Neo.Remove.Notifier user_notifier ) - in - { - assert(user_notifier !is null); - } - body { + verify(user_notifier !is null); auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); bool finished; @@ -1246,7 +1227,7 @@ template NeoSupport ( ) this.outer.neo.remove(channel, key, ¬ifier); if ( !finished ) // if request not completed, suspend task.suspend(); - assert(finished); + verify(finished); } /*********************************************************************** @@ -1298,7 +1279,7 @@ template NeoSupport ( ) public RemoveResult remove ( cstring channel, hash_t key ) { auto task = Task.getThis(); - assert(task, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); enum FinishedStatus { @@ -1343,7 +1324,7 @@ template NeoSupport ( ) this.outer.neo.remove(channel, key, ¬ifier); if ( state == state.None ) // if request not completed, suspend task.suspend(); - assert(state != state.None); + verify(state != state.None); res.succeeded = state == state.Succeeded; return res; @@ -1537,7 +1518,7 @@ template NeoSupport ( ) public GetAllFruct getAll ( cstring channel, ref void[] record_buffer ) { auto task = Task.getThis(); - assert(task !is null, + verify(task !is null, "This method may only be called from inside a Task"); GetAllFruct res; @@ -1695,7 +1676,7 @@ template NeoSupport ( ) public GetChannelsFruct getChannels ( ref mstring channel_buffer ) { auto task = Task.getThis(); - assert(task !is null, + verify(task !is null, "This method may only be called from inside a Task"); GetChannelsFruct res; @@ -1747,7 +1728,7 @@ template NeoSupport ( ) public RemoveChannelResult removeChannel ( cstring channel ) { auto task = Task.getThis(); - assert(task !is null, "This method may only be called from inside a Task"); + verify(task !is null, "This method may only be called from inside a Task"); enum FinishedStatus { @@ -1785,7 +1766,7 @@ template NeoSupport ( ) this.outer.neo.removeChannel(channel, ¬ifier); if ( state == state.None ) // if request not completed, suspend task.suspend(); - assert(state != state.None); + verify(state != state.None); RemoveChannelResult res; res.succeeded = state == state.Succeeded; @@ -1846,12 +1827,8 @@ template NeoSupport ( ) private void neoInit ( Neo.Config config, Neo.DhtConnectionNotifier user_conn_notifier ) - in - { - assert(user_conn_notifier !is null); - } - body { + verify(user_conn_notifier !is null); this.user_conn_notifier = user_conn_notifier; this.shared_resources = new SharedResources; @@ -1888,12 +1865,8 @@ template NeoSupport ( ) private void neoInit ( cstring auth_name, ubyte[] auth_key, Neo.DhtConnectionNotifier user_conn_notifier ) - in - { - assert(user_conn_notifier !is null); - } - body { + verify(user_conn_notifier !is null); this.user_conn_notifier = user_conn_notifier; this.shared_resources = new SharedResources; diff --git a/src/dhtproto/client/request/internal/GetAll.d b/src/dhtproto/client/request/internal/GetAll.d index 5efcc627..77e666b1 100644 --- a/src/dhtproto/client/request/internal/GetAll.d +++ b/src/dhtproto/client/request/internal/GetAll.d @@ -14,6 +14,7 @@ module dhtproto.client.request.internal.GetAll; import ocean.transition; import ocean.util.log.Logger; +import ocean.core.Verify; /******************************************************************************* @@ -369,8 +370,8 @@ private scope class GetAllHandler this.request_event_dispatcher.eventLoop(this.conn); - assert(controller.fiber.finished()); - assert(reader.fiber.finished()); + verify(controller.fiber.finished()); + verify(reader.fiber.finished()); } /*************************************************************************** diff --git a/src/dhtproto/client/request/internal/Mirror.d b/src/dhtproto/client/request/internal/Mirror.d index a1c7b948..94191091 100644 --- a/src/dhtproto/client/request/internal/Mirror.d +++ b/src/dhtproto/client/request/internal/Mirror.d @@ -14,6 +14,7 @@ module dhtproto.client.request.internal.Mirror; import ocean.transition; import ocean.util.log.Logger; +import ocean.core.Verify; /******************************************************************************* @@ -326,8 +327,8 @@ private scope class MirrorHandler this.request_event_dispatcher.eventLoop(this.conn); - assert(controller.fiber.finished()); - assert(reader.fiber.finished()); + verify(controller.fiber.finished()); + verify(reader.fiber.finished()); } /*************************************************************************** diff --git a/src/dhtproto/client/request/internal/Update.d b/src/dhtproto/client/request/internal/Update.d index 378158e3..7e7ef088 100644 --- a/src/dhtproto/client/request/internal/Update.d +++ b/src/dhtproto/client/request/internal/Update.d @@ -14,6 +14,7 @@ module dhtproto.client.request.internal.Update; import ocean.transition; import ocean.util.log.Logger; +import ocean.core.Verify; /******************************************************************************* @@ -450,7 +451,7 @@ private struct FirstROCHandler auto value = conn.message_parser.getArray!(void)(payload); this.context.shared_working.original_hash = Fnv1a(value); - assert(this.context.shared_working.updated_value is null); + verify(this.context.shared_working.updated_value is null); this.context.shared_working.updated_value = acquired_resources.getVoidBuffer(); @@ -580,8 +581,8 @@ private struct FirstROCHandler // the buffer for the updated value. If this ROC were to simply exit at // this stage, this buffer would be relinquished.) auto event = conn.nextEvent(conn.NextEventFlags.init); - assert(event.active == event.Active.resumed); - assert(event.resumed.code == Update.SecondROCFinished); + verify(event.active == event.Active.resumed); + verify(event.resumed.code == Update.SecondROCFinished); // If the request on the second request-on-conn failed, the result code // will already have been set in the shared working data. diff --git a/src/dhtproto/node/neo/request/Get.d b/src/dhtproto/node/neo/request/Get.d index 9321e341..b9284b33 100644 --- a/src/dhtproto/node/neo/request/Get.d +++ b/src/dhtproto/node/neo/request/Get.d @@ -27,6 +27,7 @@ public abstract class GetProtocol_v0 : IRequestHandler import dhtproto.node.neo.request.core.Mixins; import ocean.transition; + import ocean.core.Verify; import ocean.core.array.Mutation : copy; /*************************************************************************** @@ -106,8 +107,8 @@ public abstract class GetProtocol_v0 : IRequestHandler auto ok = this.get(cast(char[])*this.channel, this.key, ( Const!(void)[] value ) { - assert(value !is null); - assert(value.length); + verify(value !is null); + verify(value.length > 0); sendResponse(MessageType.Got, ( ed.Payload payload ) diff --git a/src/dhtproto/node/neo/request/GetAll.d b/src/dhtproto/node/neo/request/GetAll.d index d592375a..6dd4aeb7 100644 --- a/src/dhtproto/node/neo/request/GetAll.d +++ b/src/dhtproto/node/neo/request/GetAll.d @@ -26,6 +26,7 @@ public abstract class GetAllProtocol_v0 : IRequestHandler import dhtproto.common.GetAll; import dhtproto.node.neo.request.core.Mixins; import ocean.transition; + import ocean.core.Verify; /*************************************************************************** @@ -344,7 +345,7 @@ public abstract class GetAllProtocol_v0 : IRequestHandler this.sendBatch(); add_result = this.addToBatch(key_slice, cast(cstring)value); - assert(add_result == Added); + verify(add_result == Added); break; case TooBig: // Impossible to fit the record even in empty batch diff --git a/src/dhtproto/node/neo/request/GetHashRange.d b/src/dhtproto/node/neo/request/GetHashRange.d index f3dac897..3b4073a1 100644 --- a/src/dhtproto/node/neo/request/GetHashRange.d +++ b/src/dhtproto/node/neo/request/GetHashRange.d @@ -53,6 +53,7 @@ public abstract scope class GetHashRangeProtocol_v0 : IRequestHandler import dhtproto.node.neo.request.core.Mixins; import ocean.transition; + import ocean.core.Verify; /// Mixin the initialiser and the connection and resources members. mixin IRequestHandlerRequestCore!(); @@ -139,7 +140,7 @@ public abstract scope class GetHashRangeProtocol_v0 : IRequestHandler // Wait for updates about the hash range this.resume_fiber_on_update = true; auto resume_code = connection.suspendFiber(); - assert(resume_code == NodeFiberResumeCode.HashRangeUpdate, + verify(resume_code == NodeFiberResumeCode.HashRangeUpdate, "Unexpected fiber resume code"); this.resume_fiber_on_update = false; } diff --git a/src/dhtproto/node/neo/request/Mirror.d b/src/dhtproto/node/neo/request/Mirror.d index 7a6d7c8b..b481c385 100644 --- a/src/dhtproto/node/neo/request/Mirror.d +++ b/src/dhtproto/node/neo/request/Mirror.d @@ -32,6 +32,7 @@ public abstract class MirrorProtocol_v0 : IRequestHandler import dhtproto.common.Mirror; import dhtproto.node.neo.request.core.Mixins; import ocean.transition; + import ocean.core.Verify; /*************************************************************************** @@ -161,12 +162,8 @@ public abstract class MirrorProtocol_v0 : IRequestHandler ***********************************************************************/ public E pop ( ) - in - { - assert(this.num_elems > 0); - } - body { + verify(this.num_elems > 0); E e; e = this.queue[this.read_from_elem]; this.incWrap(this.read_from_elem); @@ -212,7 +209,7 @@ public abstract class MirrorProtocol_v0 : IRequestHandler private void incWrap ( ref size_t elem_index ) { elem_index++; - assert(elem_index <= this.max_elems); + verify(elem_index <= this.max_elems); if ( elem_index == this.max_elems ) elem_index = 0; } @@ -515,16 +512,12 @@ public abstract class MirrorProtocol_v0 : IRequestHandler ***************************************************************************/ private void refreshed ( hash_t key ) - in - { - assert(!this.refresh_queue.isFull()); - } - body { + verify(!this.refresh_queue.isFull()); auto pushed = this.refresh_queue.push(key); // The logic in PeriodicRefresh ensures that the refresh queue will // never overflow. - assert(pushed); + verify(pushed); if ( this.writer.suspended_waiting_for_events ) this.request_event_dispatcher.signal( @@ -747,12 +740,8 @@ public abstract class MirrorProtocol_v0 : IRequestHandler ***********************************************************************/ private void sendQueuedUpdate ( ) - in - { - assert(this.outer.update_queue.length > 0); - } - body { + verify(this.outer.update_queue.length > 0); auto update = this.outer.update_queue.pop(); with ( UpdateType ) switch ( update.type ) { @@ -784,12 +773,8 @@ public abstract class MirrorProtocol_v0 : IRequestHandler ***********************************************************************/ private void sendQueuedRefresh ( ) - in - { - assert(this.outer.refresh_queue.length > 0); - } - body { + verify(this.outer.refresh_queue.length > 0); void sendBatch ( ) { this.outer.request_event_dispatcher.send(this.fiber, @@ -911,7 +896,7 @@ public abstract class MirrorProtocol_v0 : IRequestHandler Signal(NodeFiberResumeCode.PushedToQueue), Signal(NodeFiberResumeCode.QueueOverflowNotification), Signal(NodeFiberResumeCode.ChannelRemoved)); - assert(event.active == event.active.signal, + verify(event.active == event.active.signal, "Unexpected event: waiting only for fiber resume code"); with ( NodeFiberResumeCode ) switch ( event.signal.code ) diff --git a/src/dhtproto/node/neo/request/core/Mixins.d b/src/dhtproto/node/neo/request/core/Mixins.d index d9f1a902..369e7eff 100644 --- a/src/dhtproto/node/neo/request/core/Mixins.d +++ b/src/dhtproto/node/neo/request/core/Mixins.d @@ -53,6 +53,7 @@ public template RequestCore ( ) public template IRequestHandlerRequestCore ( ) { + import ocean.core.Verify; import swarm.neo.node.RequestOnConn; import dhtproto.node.neo.request.core.IRequestResources; @@ -76,6 +77,6 @@ public template IRequestHandlerRequestCore ( ) { this.connection = connection; this.resources = cast(IRequestResources)resources_object; - assert(this.resources !is null); + verify(this.resources !is null); } } diff --git a/src/dhttest/DhtClient.d b/src/dhttest/DhtClient.d index a7fd0838..74d04b08 100644 --- a/src/dhttest/DhtClient.d +++ b/src/dhttest/DhtClient.d @@ -32,6 +32,7 @@ import ocean.util.log.Logger; class DhtClient { import ocean.core.Enforce; + import ocean.core.Verify; import ocean.core.Array : copy; import ocean.task.Task; import ocean.task.Scheduler; @@ -78,7 +79,7 @@ class DhtClient public this ( ) { this.task = Task.getThis(); - assert(this.task !is null); + verify(this.task !is null); } /*********************************************************************** @@ -203,7 +204,7 @@ class DhtClient this.swarm_client.addNode("127.0.0.1".dup, port); auto task = Task.getThis(); - assert(task !is null); + verify(task !is null); bool finished; @@ -628,7 +629,7 @@ class DhtClient public this ( ) { this.task = Task.getThis(); - assert(this.task !is null); + verify(this.task !is null); } /*********************************************************************** diff --git a/src/dhttest/DhtTestCase.d b/src/dhttest/DhtTestCase.d index 180df7d9..ef53c6f5 100644 --- a/src/dhttest/DhtTestCase.d +++ b/src/dhttest/DhtTestCase.d @@ -108,6 +108,7 @@ abstract class DhtTestCase : TestCase abstract class NeoDhtTestCase : TestCase { import ocean.core.Enforce; + import ocean.core.Verify; import ocean.task.Scheduler; import ocean.task.Task; import ocean.util.log.Logger; @@ -233,7 +234,7 @@ abstract class NeoDhtTestCase : TestCase public void connect ( ushort legacy_port ) { this.connect_task = Task.getThis(); - assert(this.connect_task !is null); + verify(this.connect_task !is null); this.dht.neo.addNode("127.0.0.1".dup, cast(ushort)(legacy_port + 100)); @@ -262,7 +263,7 @@ abstract class NeoDhtTestCase : TestCase this.dht.addNode("127.0.0.1".dup, legacy_port); auto task = Task.getThis(); - assert(task !is null); + verify(task !is null); bool ok, finished; diff --git a/src/dhttest/cases/neo/GetAll.d b/src/dhttest/cases/neo/GetAll.d index 497cec92..abc9332b 100644 --- a/src/dhttest/cases/neo/GetAll.d +++ b/src/dhttest/cases/neo/GetAll.d @@ -17,6 +17,7 @@ module dhttest.cases.neo.GetAll; import ocean.transition; import ocean.core.Test; +import ocean.core.Verify; import ocean.math.random.Random; import dhttest.DhtTestCase : NeoDhtTestCase; import dhtproto.client.DhtClient; @@ -272,16 +273,13 @@ private struct GetAll public void start ( cstring channel, DhtClient.Neo.GetAll.Notifier user_notifier ) - in - { - assert(this.user_notifier is null); - } out { assert(this.user_notifier !is null); } body { + verify(this.user_notifier is null); this.user_notifier = user_notifier; this.id = this.dht.neo.getAll(channel, &this.counterNotifier); } @@ -295,12 +293,8 @@ private struct GetAll ***************************************************************************/ public void suspend ( ) - in - { - assert(this.id != this.id.init); - } - body { + verify(this.id != this.id.init); this.dht.neo.control(this.id, ( DhtClient.Neo.GetAll.IController getall ) { @@ -318,12 +312,8 @@ private struct GetAll ***************************************************************************/ public void resume ( ) - in - { - assert(this.id != this.id.init); - } - body { + verify(this.id != this.id.init); this.dht.neo.control(this.id, ( DhtClient.Neo.GetAll.IController getall ) { @@ -340,12 +330,8 @@ private struct GetAll ***************************************************************************/ public void stop ( ) - in - { - assert(this.id != this.id.init); - } - body { + verify(this.id != this.id.init); this.dht.neo.control(this.id, ( DhtClient.Neo.GetAll.IController getall ) { diff --git a/src/dhttest/cases/neo/Mirror.d b/src/dhttest/cases/neo/Mirror.d index f64708c2..aa3be834 100644 --- a/src/dhttest/cases/neo/Mirror.d +++ b/src/dhttest/cases/neo/Mirror.d @@ -14,6 +14,7 @@ module dhttest.cases.neo.Mirror; import ocean.transition; import ocean.core.Test; +import ocean.core.Verify; import dhttest.DhtTestCase : NeoDhtTestCase; import dhtproto.client.DhtClient; @@ -631,16 +632,13 @@ private struct Mirror public void start ( DhtClient.Neo.Mirror.Settings mirror_settings, cstring channel, DhtClient.Neo.Mirror.Notifier user_notifier ) - in - { - assert(this.user_notifier is null); - } out { assert(this.user_notifier !is null); } body { + verify(this.user_notifier is null); this.user_notifier = user_notifier; this.id = this.dht.neo.mirror(channel, &this.counterNotifier, mirror_settings); @@ -655,12 +653,8 @@ private struct Mirror ***************************************************************************/ public void suspend ( ) - in - { - assert(this.id != this.id.init); - } - body { + verify(this.id != this.id.init); this.dht.neo.control(this.id, ( DhtClient.Neo.Mirror.IController mirror ) { @@ -678,12 +672,8 @@ private struct Mirror ***************************************************************************/ public void resume ( ) - in - { - assert(this.id != this.id.init); - } - body { + verify(this.id != this.id.init); this.dht.neo.control(this.id, ( DhtClient.Neo.Mirror.IController mirror ) { @@ -700,12 +690,8 @@ private struct Mirror ***************************************************************************/ public void stop ( ) - in - { - assert(this.id != this.id.init); - } - body { + verify(this.id != this.id.init); this.dht.neo.control(this.id, ( DhtClient.Neo.Mirror.IController mirror ) { diff --git a/src/fakedht/ConnectionHandler.d b/src/fakedht/ConnectionHandler.d index 2185d714..9c8b58c5 100644 --- a/src/fakedht/ConnectionHandler.d +++ b/src/fakedht/ConnectionHandler.d @@ -72,6 +72,8 @@ public class DhtConnectionHandler : import fakedht.request.Remove; import fakedht.request.RemoveChannel; + import ocean.core.Enforce; + import ocean.core.Verify; import ocean.io.Stdout : Stderr; import core.stdc.stdlib : abort; @@ -199,7 +201,8 @@ public class DhtConnectionHandler : RedistributeNode[]* getRedistributeNodeBuffer ( ) { - assert (false); + enforce(false); + return null; } } diff --git a/src/fakedht/Storage.d b/src/fakedht/Storage.d index e0ce2706..681df80e 100644 --- a/src/fakedht/Storage.d +++ b/src/fakedht/Storage.d @@ -200,6 +200,7 @@ struct DHT class Channel { + import ocean.core.Verify; import ocean.text.convert.Formatter; /*************************************************************************** @@ -258,7 +259,7 @@ class Channel public void listenerFlushed ( ) { - assert(this.sending_listeners); + verify(this.sending_listeners > 0); this.sending_listeners--; if ( this.sending_listeners == 0 && (this.caller !is null) ) diff --git a/src/fakedht/neo/SharedResources.d b/src/fakedht/neo/SharedResources.d index 07e56d28..7899a82a 100644 --- a/src/fakedht/neo/SharedResources.d +++ b/src/fakedht/neo/SharedResources.d @@ -26,6 +26,7 @@ import dhtproto.node.neo.request.core.IRequestResources; class SharedResources : IRequestResources { + import ocean.core.Verify; import ocean.io.compress.Lzo; import swarm.neo.util.MessageFiber; import swarm.util.RecordBatcher; @@ -114,14 +115,10 @@ class SharedResources : IRequestResources public ITimer getTimer ( uint period_s, uint period_ms, void delegate ( ) timer_dg ) - in - { - assert(period_ms < 1_000); - assert(period_s > 0 || period_ms > 0); - assert(timer_dg !is null); - } - body { + verify(period_ms < 1_000); + verify(period_s > 0 || period_ms > 0); + verify(timer_dg !is null); return new Timer(period_s, period_ms, timer_dg); } diff --git a/src/fakedht/neo/request/GetAll.d b/src/fakedht/neo/request/GetAll.d index ee22c8f9..9ff7ad5e 100644 --- a/src/fakedht/neo/request/GetAll.d +++ b/src/fakedht/neo/request/GetAll.d @@ -35,6 +35,7 @@ import ocean.transition; public class GetAllImpl_v0 : GetAllProtocol_v0 { import fakedht.Storage; + import ocean.core.Verify; import ocean.text.convert.Hash : toHashT; /// Reference to channel being iterated over. @@ -91,7 +92,7 @@ public class GetAllImpl_v0 : GetAllProtocol_v0 { hash_t key; auto ok = toHashT(str_key, key); - assert(ok); + verify(ok); if ( key == continue_from ) { index = i; @@ -130,7 +131,7 @@ public class GetAllImpl_v0 : GetAllProtocol_v0 hash_t key; auto ok = toHashT(str_key, key); - assert(ok); + verify(ok); auto value = this.channel.get(key); dg(key, value); diff --git a/src/fakedht/neo/request/Mirror.d b/src/fakedht/neo/request/Mirror.d index df65fcce..77db9780 100644 --- a/src/fakedht/neo/request/Mirror.d +++ b/src/fakedht/neo/request/Mirror.d @@ -37,6 +37,7 @@ import fakedht.Storage; // DhtListener public class MirrorImpl_v0 : MirrorProtocol_v0, DhtListener { import fakedht.Storage; + import ocean.core.Verify; import ocean.core.array.Mutation : copy; import ocean.text.convert.Hash : toHashT; @@ -89,7 +90,7 @@ public class MirrorImpl_v0 : MirrorProtocol_v0, DhtListener override protected void registerForUpdates ( ) { - assert(this.channel !is null); + verify(this.channel !is null); this.channel.register(this); } @@ -137,12 +138,8 @@ public class MirrorImpl_v0 : MirrorProtocol_v0, DhtListener ***************************************************************************/ override protected void startIteration ( ) - in - { - assert(this.iterate_keys.length == 0, "Iteration already in progress"); - } - body { + verify(this.iterate_keys.length == 0, "Iteration already in progress"); this.iterate_keys = this.channel.getKeys(); } @@ -168,7 +165,7 @@ public class MirrorImpl_v0 : MirrorProtocol_v0, DhtListener this.iterate_keys.length = this.iterate_keys.length - 1; auto ok = toHashT(key, hash_key); - assert(ok); + verify(ok); return true; } @@ -191,7 +188,7 @@ public class MirrorImpl_v0 : MirrorProtocol_v0, DhtListener case DataReady: hash_t hash_key; auto ok = toHashT(key, hash_key); - assert(ok); + verify(ok); this.updated(Update(UpdateType.Change, hash_key)); break; @@ -199,7 +196,8 @@ public class MirrorImpl_v0 : MirrorProtocol_v0, DhtListener case Deletion: hash_t hash_key; auto ok = toHashT(key, hash_key); - assert(ok); + verify(ok); + verify(ok); this.updated(Update(UpdateType.Deletion, hash_key)); break; diff --git a/src/fakedht/request/GetNumConnections.d b/src/fakedht/request/GetNumConnections.d index 3599d396..271192b5 100644 --- a/src/fakedht/request/GetNumConnections.d +++ b/src/fakedht/request/GetNumConnections.d @@ -28,6 +28,7 @@ import Protocol = dhtproto.node.request.GetNumConnections; public scope class GetNumConnections : Protocol.GetNumConnections { + import ocean.core.Enforce; import fakedht.mixins.RequestConstruction; /*************************************************************************** @@ -50,7 +51,8 @@ public scope class GetNumConnections : Protocol.GetNumConnections override protected NumConnectionsData getConnectionsData ( ) { - assert (false, + enforce(false, "GetNumConnections is not supported by the fake DHT node"); + return NumConnectionsData.init; } } diff --git a/src/fakedht/request/Listen.d b/src/fakedht/request/Listen.d index 8cc39fc8..2a21b1b6 100644 --- a/src/fakedht/request/Listen.d +++ b/src/fakedht/request/Listen.d @@ -46,6 +46,7 @@ static this ( ) public scope class Listen : Protocol.Listen, DhtListener { + import ocean.core.Verify; import fakedht.mixins.RequestConstruction; /*************************************************************************** @@ -143,7 +144,7 @@ public scope class Listen : Protocol.Listen, DhtListener override protected bool getNextRecord( cstring channel_name, mstring key, out Const!(void)[] value ) { - assert (key.length == HashDigits); + verify(key.length == HashDigits); if (this.remaining_keys.length == 0) return false; diff --git a/src/fakedht/request/Redistribute.d b/src/fakedht/request/Redistribute.d index bee38065..fba60c48 100644 --- a/src/fakedht/request/Redistribute.d +++ b/src/fakedht/request/Redistribute.d @@ -28,6 +28,7 @@ import Protocol = dhtproto.node.request.Redistribute; public scope class Redistribute : Protocol.Redistribute { + import ocean.core.Enforce; import dhtproto.node.request.params.RedistributeNode; import fakedht.mixins.RequestConstruction; @@ -44,13 +45,13 @@ public scope class Redistribute : Protocol.Redistribute override protected void adjustHashRange ( hash_t min, hash_t max ) { - assert (false, "Not supported by fake DHT node"); + enforce(false, "Not supported by fake DHT node"); } /**************************************************************************/ override protected void redistributeData ( RedistributeNode[] dataset ) { - assert (false, "Not supported by fake DHT node"); + enforce(false, "Not supported by fake DHT node"); } } diff --git a/src/turtle/env/Dht.d b/src/turtle/env/Dht.d index 0d08d61c..643d79ab 100644 --- a/src/turtle/env/Dht.d +++ b/src/turtle/env/Dht.d @@ -22,6 +22,7 @@ import turtle.env.model.Node; import fakedht.DhtNode; import fakedht.Storage; +import ocean.core.Verify; import ocean.core.Test; import ocean.task.Scheduler; import ocean.task.util.Timer; @@ -50,12 +51,8 @@ public alias fakedht.Storage.MissingRecordException MissingRecordException; *******************************************************************************/ public Dht dht() -in -{ - assert (_dht !is null, "Must call `Dht.initialize` first"); -} -body { + verify(_dht !is null, "Must call `Dht.initialize` first"); return _dht; } @@ -421,7 +418,7 @@ public class Dht : Node!(DhtNode, "dht") override public AddrPort node_addrport ( ) { - assert(this.node); + verify(this.node !is null); AddrPort addrport; addrport.setAddress(this.node.node_item.Address);