Skip to content

Commit

Permalink
chore: change default era to Conway in LocalStateQueryClientIT
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-HuyLe3a committed Aug 27, 2024
1 parent 47424b7 commit 2a13fb2
Showing 1 changed file with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.bloxbean.cardano.yaci.helper;

import com.bloxbean.cardano.client.address.Address;
import com.bloxbean.cardano.client.transaction.spec.governance.Constitution;
import com.bloxbean.cardano.client.transaction.spec.governance.DRep;
import com.bloxbean.cardano.yaci.core.common.Constants;
import com.bloxbean.cardano.yaci.core.model.Credential;
import com.bloxbean.cardano.yaci.core.model.certs.StakeCredType;
import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point;
Expand All @@ -16,14 +14,14 @@
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import reactor.test.StepVerifier;

import java.math.BigInteger;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;

import static com.bloxbean.cardano.yaci.core.common.Constants.SANCHONET_PROTOCOL_MAGIC;
import static org.assertj.core.api.Assertions.assertThat;

@Slf4j
Expand All @@ -35,7 +33,7 @@ class LocalStateQueryClientIT extends BaseTest {

@BeforeEach
public void setup() {
this.era = Era.Babbage;
this.era = Era.Conway;
this.localQueryProvider = new LocalClientProvider(nodeSocketFile, protocolMagic);
this.localStateQueryClient = localQueryProvider.getLocalStateQueryClient();
localQueryProvider.start();
Expand Down Expand Up @@ -111,12 +109,7 @@ void chainPointQuery() {
@Test
void protocolParameters() {
Mono<CurrentProtocolParamQueryResult> mono = null;

if (protocolMagic == Constants.SANCHONET_PROTOCOL_MAGIC) {
mono = localStateQueryClient.executeQuery(new CurrentProtocolParamsQuery(Era.Conway));
} else {
mono = localStateQueryClient.executeQuery(new CurrentProtocolParamsQuery(Era.Babbage));
}
mono = localStateQueryClient.executeQuery(new CurrentProtocolParamsQuery(Era.Conway));

mono = mono.log();

Expand Down Expand Up @@ -157,7 +150,7 @@ void utxoByAddress() {
@Test
void acquireReacquireAndQuery() {
localStateQueryClient.acquire().block(Duration.ofSeconds(15));
Mono<CurrentProtocolParamQueryResult> mono = localStateQueryClient.executeQuery(new CurrentProtocolParamsQuery(Era.Babbage));
Mono<CurrentProtocolParamQueryResult> mono = localStateQueryClient.executeQuery(new CurrentProtocolParamsQuery(Era.Conway));
CurrentProtocolParamQueryResult protocolParams = mono.block(Duration.ofSeconds(8));
log.info("Protocol Params >> " + protocolParams);

Expand Down Expand Up @@ -216,7 +209,7 @@ void stakeDistributionQuery() {
@Test
void stakeSnapshotsQuery() {
Mono<StakeSnapshotQueryResult> mono = localStateQueryClient.executeQuery(new StakeSnapshotQuery("032a04334a846fdf542fd5633c9b3928998691b8276e004facbc8af1"));
StakeSnapshotQueryResult result = mono.block();
StakeSnapshotQueryResult result = mono.block(Duration.ofSeconds(5));

System.out.println(result);
}
Expand Down Expand Up @@ -248,7 +241,7 @@ void epochStateQuery() {

@Test
void genesisConfigQuery() {
Mono<GenesisConfigQueryResult> mono = localStateQueryClient.executeQuery(new GenesisConfigQuery(Era.Babbage));
Mono<GenesisConfigQueryResult> mono = localStateQueryClient.executeQuery(new GenesisConfigQuery(Era.Conway));
GenesisConfigQueryResult result = mono.block(Duration.ofSeconds(5));

LocalDate localDate = LocalDate.ofYearDay(2017, 30);
Expand Down Expand Up @@ -303,7 +296,7 @@ void delegationRewardsQuery() {

@Test
void accountStateQuery() {
Mono<AccountStateQueryResult> mono = localStateQueryClient.executeQuery(new AccountStateQuery(Era.Babbage));
Mono<AccountStateQueryResult> mono = localStateQueryClient.executeQuery(new AccountStateQuery(Era.Conway));

mono = mono.log();

Expand All @@ -320,8 +313,8 @@ void dRepStakeDistributionQuery() {
new DRepStakeDistributionQuery(
Era.Conway,
List.of(
DRep.addrKeyHash("001021a9b538f693f5293b9ad77e9fd2febe5ecd66cf8bb2844b4a8d")
, DRep.scriptHash("1ffa2ae5f54e88a2e6a29642936aceebdd3aea948d70ace645912440")
DRep.addrKeyHash("23bc63ced4e40b22dd4e6051c258ba38d5679d81e33f34fe5e5cdb4d")
, DRep.addrKeyHash("fa6a8dc2635dddcf9af495cb144f7eb4ff845866fe48695ad7cb65d3")
))
);

Expand Down Expand Up @@ -358,29 +351,29 @@ void dRepStateQuery() {
Credential
.builder()
.type(StakeCredType.ADDR_KEYHASH)
.hash("5e80b2b80990a738aece6d6068b2991eaea21c52e79c7974719ac275")
.hash("23bc63ced4e40b22dd4e6051c258ba38d5679d81e33f34fe5e5cdb4d")
.build(),
Credential
.builder()
.type(StakeCredType.ADDR_KEYHASH)
.hash("6e066d1a8bce348956b34438556abb43d597d075f9fdab03bb6f4d39")
.hash("fa6a8dc2635dddcf9af495cb144f7eb4ff845866fe48695ad7cb65d3")
.build()
))
);
mono = mono.log();

DRepStateQueryResult result = mono.block(Duration.ofSeconds(5));
assertThat(result.getDRepStates()).isNotNull();
assertThat(result.getDRepStates()).hasSizeGreaterThan(0);
}

@Test
void SPOStakeDistrQuery() {
Mono<SPOStakeDistributionQueryResult> mono = localStateQueryClient.executeQuery(new SPOStakeDistributionQuery(
List.of("3c4fb94e1a2c5649a870aee5a70f21cd64807c7dc38632efcaf3d921")
List.of("032a04334a846fdf542fd5633c9b3928998691b8276e004facbc8af1")
)
);

SPOStakeDistributionQueryResult result = mono.block();
assertThat(result.getSpoStakeMap()).isNotNull();
assertThat(result.getSpoStakeMap()).hasSize(1);
}
}

0 comments on commit 2a13fb2

Please sign in to comment.