better stuck head handling

This commit is contained in:
Maksim Fomenkov
2022-10-10 13:48:34 +03:00
parent 0aacc09862
commit c53913db6a
13 changed files with 90 additions and 42 deletions

View File

@@ -69,7 +69,12 @@ class EthereumHeadMock implements Head {
}
@Override
long getLastUpdateTime() {
return 0
void start() {
}
@Override
void stop() {
}
}

View File

@@ -60,6 +60,7 @@ class AbstractHeadSpec extends Specification {
.expectNext(blocks[1])
.then {
assert called
head.stop()
source.tryEmitComplete()
}
.expectComplete()
@@ -83,7 +84,10 @@ class AbstractHeadSpec extends Specification {
.expectNext(blocks[2])
.then { source.tryEmitNext(blocks[3]) }
.expectNext(blocks[3])
.then { source.tryEmitComplete() }
.then {
head.stop()
source.tryEmitComplete()
}
.expectComplete()
.verify(Duration.ofSeconds(1))
}
@@ -110,7 +114,10 @@ class AbstractHeadSpec extends Specification {
.then { source.tryEmitNext(wrongblock) }
.then { source.tryEmitNext(blocks[3]) }
.expectNext(blocks[3])
.then { source.tryEmitComplete() }
.then {
head.stop()
source.tryEmitComplete()
}
.expectComplete()
.verify(Duration.ofSeconds(1))
}
@@ -132,7 +139,7 @@ class AbstractHeadSpec extends Specification {
BlockContainer getHead() {
return null
}
}, new BlockValidator.AlwaysValid())
}, new BlockValidator.AlwaysValid(), 100_000)
}
}
}

View File

@@ -46,14 +46,14 @@ class MergedHeadSpec extends Specification {
class TestHead1 extends AbstractHead {
TestHead1() {
super(new MostWorkForkChoice())
super(new MostWorkForkChoice(), new BlockValidator.AlwaysValid(), 100_000)
}
}
class TestHead2 extends AbstractHead implements Lifecycle {
TestHead2() {
super(new MostWorkForkChoice())
super(new MostWorkForkChoice(), new BlockValidator.AlwaysValid(), 100_000)
}
@Override