Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class OneOnEach extends DeployStrategy {

override def initialize(available: Array[Address]): Unit = {
this.available = available
this.index = 0
}

override def next(): Address = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,13 @@ class DeployStrategiesSpec extends AnyFlatSpec with Matchers {
assertThrows[IndexOutOfBoundsException](strategy.next())
}

it should "preserve its iteration cursor across re-initialization (current behavior)" in {
// Pin: initialize() replaces the array reference but does NOT reset the
// index, so a re-initialized strategy continues counting from the prior
// position. A future fix that zeroes index inside initialize will break
// this spec on purpose so the contract change is reviewed.
it should "reset its iteration cursor on re-initialization" in {
val strategy = OneOnEach()
strategy.initialize(Array(nodeA, nodeB))
strategy.next() shouldBe nodeA
strategy.next() shouldBe nodeB
strategy.initialize(Array(nodeC))
// index is still 1 from the previous run; the new single-element array
// is therefore reported as exhausted.
strategy.next() shouldBe nodeC
assertThrows[IndexOutOfBoundsException](strategy.next())
}

Expand Down
Loading