fixed tests

This commit is contained in:
Maxksim Fomenkov
2022-09-14 16:00:10 +03:00
parent a7a49425cd
commit f4f34f071e
25 changed files with 68 additions and 44 deletions

View File

@@ -73,9 +73,11 @@ open class NativeSubscribe(
is SilentException.UnsupportedBlockchain -> StatusException( is SilentException.UnsupportedBlockchain -> StatusException(
Status.UNAVAILABLE.withDescription("BLOCKCHAIN UNAVAILABLE: ${t.blockchainId}") Status.UNAVAILABLE.withDescription("BLOCKCHAIN UNAVAILABLE: ${t.blockchainId}")
) )
is UnsupportedOperationException -> StatusException( is UnsupportedOperationException -> StatusException(
Status.UNIMPLEMENTED.withDescription(t.message) Status.UNIMPLEMENTED.withDescription(t.message)
) )
else -> { else -> {
log.warn("Unhandled error", t) log.warn("Unhandled error", t)
StatusException( StatusException(
@@ -98,7 +100,7 @@ open class NativeSubscribe(
holder.nonce?.also { nonce -> holder.nonce?.also { nonce ->
holder.getSource()?.let { holder.getSource()?.let {
signer.sign(nonce, result, it) signer.sign(nonce, result, it)
}?.let { }?.let {
buildSignature(nonce, it) buildSignature(nonce, it)
}?.also { }?.also {

View File

@@ -58,7 +58,7 @@ class EthereumWsFactory(
) )
} }
fun create(id: String, upstream: DefaultUpstream?, validator: EthereumUpstreamValidator?): WsConnection { fun create(upstream: DefaultUpstream?, validator: EthereumUpstreamValidator?): WsConnection {
require(upstream == null || upstream.getId() == id) { require(upstream == null || upstream.getId() == id) {
"Creating instance for different upstream. ${upstream?.getId()} != id" "Creating instance for different upstream. ${upstream?.getId()} != id"
} }

View File

@@ -34,7 +34,7 @@ class EthereumRpcConnector(
init { init {
if (wsFactory != null) { if (wsFactory != null) {
// do not set upstream to the WS, since it doesn't control the RPC upstream // do not set upstream to the WS, since it doesn't control the RPC upstream
conn = wsFactory.create(id, null, null) conn = wsFactory.create(null, null)
val wsHead = EthereumWsHead(conn, id, forkChoice, blockValidator) val wsHead = EthereumWsHead(conn, id, forkChoice, blockValidator)
// receive bew blocks through WebSockets, but also periodically verify with RPC in case if WS failed // receive bew blocks through WebSockets, but also periodically verify with RPC in case if WS failed
val rpcHead = EthereumRpcHead(directReader, forkChoice, id, blockValidator, Duration.ofSeconds(60)) val rpcHead = EthereumRpcHead(directReader, forkChoice, id, blockValidator, Duration.ofSeconds(60))

View File

@@ -4,12 +4,14 @@ import io.emeraldpay.dshackle.reader.Reader
import io.emeraldpay.dshackle.upstream.BlockValidator import io.emeraldpay.dshackle.upstream.BlockValidator
import io.emeraldpay.dshackle.upstream.DefaultUpstream import io.emeraldpay.dshackle.upstream.DefaultUpstream
import io.emeraldpay.dshackle.upstream.Head import io.emeraldpay.dshackle.upstream.Head
import io.emeraldpay.dshackle.upstream.ethereum.* import io.emeraldpay.dshackle.upstream.ethereum.EthereumUpstreamValidator
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsFactory
import io.emeraldpay.dshackle.upstream.ethereum.EthereumWsHead
import io.emeraldpay.dshackle.upstream.ethereum.WsConnection
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcWsClient import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcWsClient
import io.emeraldpay.grpc.Chain
class EthereumWsConnector( class EthereumWsConnector(
wsFactory: EthereumWsFactory, wsFactory: EthereumWsFactory,
@@ -23,7 +25,7 @@ class EthereumWsConnector(
private val head: EthereumWsHead private val head: EthereumWsHead
init { init {
conn = wsFactory.create(upstream.getId(), upstream, validator) conn = wsFactory.create(upstream, validator)
head = EthereumWsHead(conn, upstream.getId(), forkChoice, blockValidator) head = EthereumWsHead(conn, upstream.getId(), forkChoice, blockValidator)
api = JsonRpcWsClient(conn) api = JsonRpcWsClient(conn)
} }

View File

@@ -27,7 +27,7 @@ class HeightByHashAddingSpec extends Specification {
def block = new BlockContainer( def block = new BlockContainer(
12079192L, BlockId.from("0xa6af163aab691919c595e2a466f0a7b01f1dff8cfd9631dee811df57064c2d32"), 12079192L, BlockId.from("0xa6af163aab691919c595e2a466f0a7b01f1dff8cfd9631dee811df57064c2d32"),
BigInteger.ONE, Instant.now(), false, "".bytes, null, [], 0 BigInteger.ONE, Instant.now(), false, "".bytes, null, [], 0, "upstream"
) )
def "use memory if available"() { def "use memory if available"() {

View File

@@ -87,7 +87,8 @@ class ReceiptMemCacheSpec extends Specification {
"{}".bytes, "{}".bytes,
null, null,
[TxId.from(receipt.transactionHash)], [TxId.from(receipt.transactionHash)],
0 0,
"unknown"
) )
when: when:

View File

@@ -22,6 +22,7 @@ import io.emeraldpay.dshackle.upstream.Selector
import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream import io.emeraldpay.dshackle.upstream.ethereum.EthereumMultistream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream import io.emeraldpay.dshackle.upstream.ethereum.EthereumPosMultiStream
import io.emeraldpay.dshackle.upstream.ethereum.EthereumSubscribe import io.emeraldpay.dshackle.upstream.ethereum.EthereumSubscribe
import io.emeraldpay.dshackle.upstream.signature.NoSigner
import io.emeraldpay.grpc.Chain import io.emeraldpay.grpc.Chain
import reactor.core.publisher.Flux import reactor.core.publisher.Flux
import reactor.test.StepVerifier import reactor.test.StepVerifier
@@ -30,6 +31,7 @@ import spock.lang.Specification
import java.time.Duration import java.time.Duration
class NativeSubscribeSpec extends Specification { class NativeSubscribeSpec extends Specification {
def signer = new NoSigner()
def "Call with empty params when not provided"() { def "Call with empty params when not provided"() {
setup: setup:
@@ -40,7 +42,7 @@ class NativeSubscribeSpec extends Specification {
1 * it.getSubscribe() >> subscribe 1 * it.getSubscribe() >> subscribe
} }
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up)) def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer)
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id) .setChainValue(Chain.ETHEREUM.id)
.setMethod("newHeads") .setMethod("newHeads")
@@ -50,7 +52,7 @@ class NativeSubscribeSpec extends Specification {
then: then:
StepVerifier.create(act) StepVerifier.create(act)
.expectNext("{}") .expectNext(new NativeSubscribe.ResponseHolder("{}", null))
.expectComplete() .expectComplete()
.verify(Duration.ofSeconds(1)) .verify(Duration.ofSeconds(1))
} }
@@ -72,7 +74,7 @@ class NativeSubscribeSpec extends Specification {
1 * it.getSubscribe() >> subscribe 1 * it.getSubscribe() >> subscribe
} }
def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up)) def nativeSubscribe = new NativeSubscribe(new MultistreamHolderMock(Chain.ETHEREUM, up), signer)
def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder() def call = BlockchainOuterClass.NativeSubscribeRequest.newBuilder()
.setChainValue(Chain.ETHEREUM.id) .setChainValue(Chain.ETHEREUM.id)
.setMethod("logs") .setMethod("logs")
@@ -86,7 +88,7 @@ class NativeSubscribeSpec extends Specification {
then: then:
StepVerifier.create(act) StepVerifier.create(act)
.expectNext("{}") .expectNext(new NativeSubscribe.ResponseHolder("{}", null))
.expectComplete() .expectComplete()
.verify(Duration.ofSeconds(1)) .verify(Duration.ofSeconds(1))
} }

View File

@@ -271,7 +271,7 @@ class TrackBitcoinAddressSpec extends Specification {
Head head = Mock(Head) { Head head = Mock(Head) {
1 * getFlux() >> Flux.concat( 1 * getFlux() >> Flux.concat(
Flux.just( Flux.just(
new BlockContainer(0L, BlockId.from(hash1), BigInteger.ZERO, Instant.now(), false, null, null, [], 0) new BlockContainer(0L, BlockId.from(hash1), BigInteger.ZERO, Instant.now(), false, null, null, [], 0, "TrackBitcoinAddressSpec")
), ),
blocks.asFlux() blocks.asFlux()
) )
@@ -312,7 +312,7 @@ class TrackBitcoinAddressSpec extends Specification {
StepVerifier.create(resp) StepVerifier.create(resp)
.expectNext("0") .expectNext("0")
.then { .then {
blocks.tryEmitNext(new BlockContainer(1L, BlockId.from(hash1), BigInteger.ONE, Instant.now(), false, null, null, [], 0)) blocks.tryEmitNext(new BlockContainer(1L, BlockId.from(hash1), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "TrackBitcoinAddressSpec"))
} }
.expectNext("1230000") .expectNext("1230000")
.then { .then {

View File

@@ -142,7 +142,7 @@ class TrackBitcoinTxSpec extends Specification {
def txid = "69cd44d7c641db82e69824523c7ac0c5c1e5628f025474529cf5ffe64527efc9" def txid = "69cd44d7c641db82e69824523c7ac0c5c1e5628f025474529cf5ffe64527efc9"
// start with the current block // start with the current block
def next = Flux.fromIterable([10, 12, 13, 14, 15]).map { h -> def next = Flux.fromIterable([10, 12, 13, 14, 15]).map { h ->
new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0) new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "unknown")
} }
Head head = Mock(Head) { Head head = Mock(Head) {
1 * getFlux() >> next 1 * getFlux() >> next
@@ -173,7 +173,7 @@ class TrackBitcoinTxSpec extends Specification {
def txid = "69cd44d7c641db82e69824523c7ac0c5c1e5628f025474529cf5ffe64527efc9" def txid = "69cd44d7c641db82e69824523c7ac0c5c1e5628f025474529cf5ffe64527efc9"
// start with the current block // start with the current block
def next = Flux.fromIterable([10, 12, 13]).map { h -> def next = Flux.fromIterable([10, 12, 13]).map { h ->
new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0) new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "unknown")
} }
Head head = Mock(Head) { Head head = Mock(Head) {
1 * getFlux() >> next 1 * getFlux() >> next
@@ -268,7 +268,7 @@ class TrackBitcoinTxSpec extends Specification {
]) ])
} }
def next = Flux.fromIterable([10, 11, 12]).map { h -> def next = Flux.fromIterable([10, 11, 12]).map { h ->
new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0) new BlockContainer(h.longValue(), BlockId.from("0000000000000000000895d1b9d3898700e1deecc3b0e69f439aa77875e6042f"), BigInteger.ONE, Instant.now(), false, null, null, [], 0, "unknown")
} }
Head head = Mock(Head) { Head head = Mock(Head) {
_ * getFlux() >> next _ * getFlux() >> next

View File

@@ -165,7 +165,8 @@ class TrackERC20AddressSpec extends Specification {
], ],
TransactionId.from("0x5a7898e27120575c33d3d0179af3b6353c7268bbad4255df079ed26b743a21a5"), TransactionId.from("0x5a7898e27120575c33d3d0179af3b6353c7268bbad4255df079ed26b743a21a5"),
1, 1,
false false,
"unknown"
) )
] ]
def logs = Mock(ConnectLogs) { def logs = Mock(ConnectLogs) {

View File

@@ -199,7 +199,7 @@ class TrackEthereumTxSpec extends Specification {
def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6) def tx = new TrackEthereumTx.TxDetails(Chain.ETHEREUM, Instant.now(), TransactionId.from(txId), 6)
def block = new BlockContainer( def block = new BlockContainer(
100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, 100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null,
[TxId.from(txId)], 0 [TxId.from(txId)], 0, "unknown"
) )
when: when:
@@ -222,7 +222,7 @@ class TrackEthereumTxSpec extends Specification {
def block = new BlockContainer( def block = new BlockContainer(
100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null, 100, BlockId.from(txId), BigInteger.ONE, Instant.now(), false, "".bytes, null,
[TxId.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22")], [TxId.from("0xa0e65cbc1b52a8ca60562112c6060552d882f16f34a9dba2ccdc05c0a6a27c22")],
0 0, "unknown"
) )
apiMock.answer("eth_getTransactionByHash", [txId], null) apiMock.answer("eth_getTransactionByHash", [txId], null)

View File

@@ -114,7 +114,8 @@ class TestingCommons {
null, null,
null, null,
[], [],
0 0,
"upstream"
) )
} }

View File

@@ -34,7 +34,7 @@ class AbstractHeadSpec extends Specification {
def blocks = [1L, 2, 3, 4].collect { i -> def blocks = [1L, 2, 3, 4].collect { i ->
byte[] hash = new byte[32] byte[] hash = new byte[32]
hash[0] = i as byte hash[0] = i as byte
new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0) new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0, "AbstractHeadSpec")
} }
def "Calls beforeBlock on each block"() { def "Calls beforeBlock on each block"() {
@@ -96,7 +96,7 @@ class AbstractHeadSpec extends Specification {
blocks[1].height, BlockId.from(blocks[1].hash.value.clone().tap { it[1] = 0xff as byte }), blocks[1].height, BlockId.from(blocks[1].hash.value.clone().tap { it[1] = 0xff as byte }),
blocks[1].difficulty - 1, blocks[1].difficulty - 1,
Instant.now(), Instant.now(),
false, null, null, [], 0 false, null, null, [], 0, "AbstractHeadSpec"
) )
when: when:
head.follow(source.asFlux()) head.follow(source.asFlux())

View File

@@ -32,7 +32,7 @@ import java.time.Instant
class DefaultEthereumHeadSpec extends Specification { class DefaultEthereumHeadSpec extends Specification {
DefaultEthereumHead head = new DefaultEthereumHead(new MostWorkForkChoice(), BlockValidator.@Companion.ALWAYS_VALID) DefaultEthereumHead head = new DefaultEthereumHead("upstream", new MostWorkForkChoice(), BlockValidator.@Companion.ALWAYS_VALID)
ObjectMapper objectMapper = Global.objectMapper ObjectMapper objectMapper = Global.objectMapper
def blocks = (10L..20L).collect { i -> def blocks = (10L..20L).collect { i ->

View File

@@ -52,6 +52,8 @@ class EthereumBlockValidatorSpec extends Specification {
true, bytes, true, bytes,
block, block,
Collections.emptyList(), Collections.emptyList(),
1) 1,
"upstream"
)
} }
} }

View File

@@ -302,7 +302,7 @@ class EthereumFullBlocksReaderSpec extends Specification {
"extraField2": "extraValue2" "extraField2": "extraValue2"
} }
''' '''
blocks.add(BlockContainer.fromEthereumJson(blockJson.bytes)) blocks.add(BlockContainer.fromEthereumJson(blockJson.bytes, "EthereumFullBlocksReaderSpec"))
def tx1 = ''' def tx1 = '''
{ {

View File

@@ -81,7 +81,7 @@ class ConnectBlockUpdatesSpec extends Specification {
] ]
}) })
when: when:
def act = connectBlockUpdates.whenReplaced(block) def act = connectBlockUpdates.whenReplaced(block, "ConnectBlockUpdatesSpec")
.collectList().block(Duration.ofSeconds(3)) .collectList().block(Duration.ofSeconds(3))
then: then:

View File

@@ -40,7 +40,8 @@ class ConnectLogsSpec extends Specification {
], ],
TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
1L, 1L,
false false,
"upstream"
) )
def log2 = new LogMessage( def log2 = new LogMessage(
@@ -54,7 +55,8 @@ class ConnectLogsSpec extends Specification {
], ],
TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
1L, 1L,
false false,
"upstream"
) )
def log3 = new LogMessage( def log3 = new LogMessage(
@@ -68,7 +70,8 @@ class ConnectLogsSpec extends Specification {
], ],
TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
1L, 1L,
false false,
"upstream"
) )
def log4 = new LogMessage( def log4 = new LogMessage(
@@ -82,7 +85,8 @@ class ConnectLogsSpec extends Specification {
], ],
TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"), TransactionId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
1L, 1L,
false false,
"upstream"
) )
def "Filter is empty"() { def "Filter is empty"() {

View File

@@ -45,7 +45,8 @@ class ProduceLogsSpec extends Specification {
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.NEW, ConnectBlockUpdates.UpdateType.NEW,
TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"),
"upstream"
) )
when: when:
def act = producer.produceAdded(update) def act = producer.produceAdded(update)
@@ -67,7 +68,8 @@ class ProduceLogsSpec extends Specification {
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.NEW, ConnectBlockUpdates.UpdateType.NEW,
TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"),
"upstream"
) )
when: when:
def act = producer.produceAdded(update) def act = producer.produceAdded(update)
@@ -112,7 +114,8 @@ class ProduceLogsSpec extends Specification {
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.NEW, ConnectBlockUpdates.UpdateType.NEW,
TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"),
"upstream"
) )
when: when:
def act = producer.produceAdded(update) def act = producer.produceAdded(update)
@@ -157,7 +160,8 @@ class ProduceLogsSpec extends Specification {
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.NEW, ConnectBlockUpdates.UpdateType.NEW,
TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af") TxId.from("0x6c88df9d65ccc9351db65676c3581b29483e8dabb71c48ef7671c44b0d5568af"),
"upstream"
) )
when: when:
def act = producer.produceAdded(update) def act = producer.produceAdded(update)
@@ -267,7 +271,8 @@ class ProduceLogsSpec extends Specification {
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.NEW, ConnectBlockUpdates.UpdateType.NEW,
TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec") TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
"upstream"
) )
when: when:
def act = producer.produceAdded(update) def act = producer.produceAdded(update)
@@ -345,13 +350,15 @@ class ProduceLogsSpec extends Specification {
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.NEW, ConnectBlockUpdates.UpdateType.NEW,
TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec") TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
"upstream"
) )
def update2 = new ConnectBlockUpdates.Update( def update2 = new ConnectBlockUpdates.Update(
BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"), BlockId.from("0x668b92d6b8c7db1350fd527fec4885ce5be2159b2b7daf6b126babdcbaa349da"),
13412871, 13412871,
ConnectBlockUpdates.UpdateType.DROP, ConnectBlockUpdates.UpdateType.DROP,
TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec") TxId.from("0xb5e554178a94fd993111f2ae64cb708cb0899d7b5182024e70d5c468164a8bec"),
"upstream"
) )
when: when:
// first need to produce them as added, because that's when it remembers logs to "remove" // first need to produce them as added, because that's when it remembers logs to "remove"

View File

@@ -41,7 +41,8 @@ class LogMessageSpec extends Specification {
], ],
TransactionId.from("0xc7529e79f78f58125abafeaea01fe3abdc6f45c173d5dfb36716cbc526e5b2d1"), TransactionId.from("0xc7529e79f78f58125abafeaea01fe3abdc6f45c173d5dfb36716cbc526e5b2d1"),
0xa3, 0xa3,
false) false,
"LogMessageSpec")
ObjectMapper objectMapper = Global.getObjectMapper() ObjectMapper objectMapper = Global.getObjectMapper()
def exp = '{' + def exp = '{' +
'"address":"0x011b6e24ffb0b5f5fcc564cf4183c5bbbc96d515",' + '"address":"0x011b6e24ffb0b5f5fcc564cf4183c5bbbc96d515",' +

View File

@@ -23,7 +23,8 @@ class NewHeadMessageSpec extends Specification {
0x7bb33e, 0x7bb33e,
Bloom.from("0x012040020880820356a20b8e980a2004c19f1291800501040001180bb029d0002d8c49440e002048ca00d48581000d900a458100c90139056140880582f22a0a8050224c020c233be8c3080c0a016aa4226a2001446c800822080445a2454118139804001202068401841900840c484222420c4b2022046052c0011e81a9e450085883708545810592e40040010411442300080b0130711f602880600a30c90702cb420a0102a644820650908802840810948142541404884300acc69d000840702020224c000020200880c10858418408098a61445b0ab0480234862655a5000434311b91044849c165040411aa0400b00008222642d24313020d9022219120"), Bloom.from("0x012040020880820356a20b8e980a2004c19f1291800501040001180bb029d0002d8c49440e002048ca00d48581000d900a458100c90139056140880582f22a0a8050224c020c233be8c3080c0a016aa4226a2001446c800822080445a2454118139804001202068401841900840c484222420c4b2022046052c0011e81a9e450085883708545810592e40040010411442300080b0130711f602880600a30c90702cb420a0102a644820650908802840810948142541404884300acc69d000840702020224c000020200880c10858418408098a61445b0ab0480234862655a5000434311b91044849c165040411aa0400b00008222642d24313020d9022219120"),
Address.from("0x829bd824b016326a401d083b33d092293333a830"), Address.from("0x829bd824b016326a401d083b33d092293333a830"),
null null,
"NewHeadMessageSpec"
) )
ObjectMapper objectMapper = Global.getObjectMapper() ObjectMapper objectMapper = Global.getObjectMapper()
def exp = '{' + def exp = '{' +

View File

@@ -11,7 +11,7 @@ class MostWorkForkChoiceSpec extends Specification {
def blocks = [1L, 2, 3, 4].collect { i -> def blocks = [1L, 2, 3, 4].collect { i ->
byte[] hash = new byte[32] byte[] hash = new byte[32]
hash[0] = i as byte hash[0] = i as byte
new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0) new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0, "MostWorkForkChoiceSpec")
} }
def "filters blocks"() { def "filters blocks"() {

View File

@@ -10,7 +10,7 @@ class NoChoiceWithPriorityForkChoiceSpec extends Specification {
def blocks = [1L, 2, 3, 4].collect { i -> def blocks = [1L, 2, 3, 4].collect { i ->
byte[] hash = new byte[32] byte[] hash = new byte[32]
hash[0] = i as byte hash[0] = i as byte
new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0) new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], 0, "NoChoiceWithPriorityForkChoiceSpec")
} }
def "filters blocks"() { def "filters blocks"() {

View File

@@ -10,7 +10,7 @@ class PriorityForkChoiceSpec extends Specification {
def blocks = [1L, 2, 3, 4].collect { i -> def blocks = [1L, 2, 3, 4].collect { i ->
byte[] hash = new byte[32] byte[] hash = new byte[32]
hash[0] = i as byte hash[0] = i as byte
new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], i.toInteger()) new BlockContainer(i, BlockId.from(hash), BigInteger.valueOf(i), Instant.now(), false, null, null, [], i.toInteger(), "PriorityForkChoiceSpec")
} }
def "filters blocks"() { def "filters blocks"() {
def choice = new PriorityForkChoice() def choice = new PriorityForkChoice()

View File

@@ -95,7 +95,7 @@ class EcdsaSignerSpec extends Specification {
def signer = new EcdsaSigner(Stub(ECPrivateKey), 100L) def signer = new EcdsaSigner(Stub(ECPrivateKey), 100L)
when: when:
def act = signer.wrapMessage(10, "test".bytes, up) def act = signer.wrapMessage(10, "test".bytes, up.id)
then: then:
act == "DSHACKLESIG/10/infura/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" act == "DSHACKLESIG/10/infura/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"