Merge pull request #1 from codex-storage/tweaks-suggestions

Tweaks suggestions
This commit is contained in:
Giuliano Mega 2023-08-22 08:37:05 -03:00 committed by GitHub
commit 53009b1391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 34 additions and 28 deletions

1
.tool-versions Normal file
View File

@ -0,0 +1 @@
nim 2.0.0

View File

@ -1 +0,0 @@
switch("path", "$projectDir/")

View File

@ -1,5 +1,8 @@
# This is just an example to get you started. A typical binary package
# uses this file as the main entry point of the application.
import ./swarmsim/schedulable
import ./swarmsim/eventdrivenengine
import ./swarmsim/engine/schedulableevent
import ./swarmsim/engine/eventdrivenengine
export schedulableevent
export eventdrivenengine

View File

@ -1,13 +1,10 @@
import ../engine/protocol
import ../engine/network
import ../engine/schedulableevent
import ../timeutils
import std/times
import std/options
import std/algorithm
import std/tables
import sequtils
import std/sequtils
import ../engine
export protocol
export options

6
swarmsim/engine.nim Normal file
View File

@ -0,0 +1,6 @@
import engine/protocol
import engine/network
import engine/schedulableevent
import timeutils
export protocol, network, schedulableevent, timeutils

View File

@ -9,7 +9,7 @@ export options
export sets
export peer
export eventdrivenengine
export Network
export types
type
MessageSend = ref object of SchedulableEvent

View File

@ -1,8 +1,8 @@
import ./swarmsim/engine/eventdrivenengine
import ./swarmsim/engine/schedulableevent
import ./swarmsim/engine/network
import ./swarmsim/engine/peer
import ./swarmsim/codex/dhttracker
import engine/teventdrivenengine
import engine/tschedulableevent
import engine/tnetwork
import engine/tpeer
import codex/tdhttracker
{.warning[UnusedImport]: off.}

View File

@ -4,8 +4,8 @@ import sugar
import std/algorithm
import pkg/swarmsim/engine/schedulableevent
import pkg/swarmsim/engine/eventdrivenengine
import swarmsim/engine/schedulableevent
import swarmsim/engine/eventdrivenengine
type TestSchedulable = ref object of SchedulableEvent
@ -16,7 +16,7 @@ suite "event driven engine tests":
test "should run schedulables at the right time":
let times = @[1, 10, 5].map(time => uint64(time))
let times = @[1'u64, 10, 5]
let schedulables = times.map(time => TestSchedulable(time: time))
let engine = EventDrivenEngine()
@ -30,8 +30,8 @@ suite "event driven engine tests":
check(engine.nextStep().isNone)
test "should allow clients to wait until a scheduled event happens":
let times = @[1, 2, 3, 4, 5, 6, 7, 8]
let schedulables = times.map(time => TestSchedulable(time: uint64(time)))
let times = @[1'u64, 2, 3, 4, 5, 6, 7, 8]
let schedulables = times.map(time => TestSchedulable(time: time))
let engine = EventDrivenEngine()
let handles = schedulables.map(schedulable =>
@ -46,8 +46,8 @@ suite "event driven engine tests":
check(engine.currentTime == 8)
test "should allow clients run until the desired simulation time":
let times = @[50, 100, 150]
let schedulables = times.map(time => TestSchedulable(time: uint64(time)))
let times = @[50'u64, 100, 150]
let schedulables = times.map(time => TestSchedulable(time: time))
let engine = EventDrivenEngine()
engine.scheduleAll(schedulables)

View File

@ -1,9 +1,9 @@
import unittest
import pkg/swarmsim/engine/eventdrivenengine
import pkg/swarmsim/engine/network
import pkg/swarmsim/engine/peer
import pkg/swarmsim/engine/protocol
import swarmsim/engine/eventdrivenengine
import swarmsim/engine/network
import swarmsim/engine/peer
import swarmsim/engine/protocol
type
FakeProtocol = ref object of Protocol

View File

@ -1,7 +1,7 @@
import std/unittest
import std/sets
import pkg/swarmsim/engine/peer
import swarmsim/engine/peer
suite "peer":
test "should allow inclusion and membership tests on a HashSet":

View File

@ -1,6 +1,6 @@
import unittest
import pkg/swarmsim/engine/schedulableevent
import swarmsim/engine/schedulableevent
suite "schedulable event":
test "should be ordered by time":