use of com.hedera.hashgraph.sdk.proto.ResponseCodeEnum.ACCOUNT_DELETED in project hedera-mirror-node by hashgraph.
the class TransactionPublisherTest method validationRecovers.
@Test
@Timeout(3)
void validationRecovers() {
// Initialize publisher internals with first transaction
var request = request().build();
cryptoServiceStub.addTransactions(Mono.just(response(OK)));
transactionPublisher.publish(request).as(StepVerifier::create).expectNextCount(1L).expectComplete().verify(Duration.ofSeconds(1L));
var scenario = request.getScenario();
assertThat(scenario.getCount()).isEqualTo(1);
assertThat(scenario.getErrors()).isEmpty();
// Validate node as down manually
NodeProperties nodeProperties = monitorProperties.getNodes().iterator().next();
cryptoServiceStub.addQueries(Mono.just(receipt(ACCOUNT_DELETED)));
cryptoServiceStub.addTransactions(Mono.just(response(OK)));
assertThat(transactionPublisher.validateNode(nodeProperties)).isFalse();
request = request().build();
transactionPublisher.publish(request).as(StepVerifier::create).expectErrorSatisfies(t -> assertThat(t).isInstanceOf(PublishException.class).hasMessageContaining("No valid nodes available").hasCauseInstanceOf(IllegalArgumentException.class)).verify(Duration.ofSeconds(1L));
scenario = request.getScenario();
assertThat(scenario.getCount()).isZero();
assertThat(scenario.getErrors()).containsOnly(Map.entry(IllegalArgumentException.class.getSimpleName(), 1));
// Node recovers
cryptoServiceStub.addQueries(Mono.just(receipt(SUCCESS)));
cryptoServiceStub.addTransactions(Mono.just(response(OK)));
assertThat(transactionPublisher.validateNode(nodeProperties)).isTrue();
request = request().build();
cryptoServiceStub.addTransactions(Mono.just(response(OK)));
transactionPublisher.publish(request).as(StepVerifier::create).expectNextCount(1L).expectComplete().verify(Duration.ofSeconds(1L));
scenario = request.getScenario();
assertThat(scenario.getCount()).isEqualTo(1);
assertThat(scenario.getErrors()).isEmpty();
}
Aggregations