Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
iamyulong committed Nov 20, 2024
1 parent 68bf4de commit 2c3182e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ public record ProtocolConfig(
public static final String GENESIS_PROTOCOL_VERSION_NAME = "babylon-genesis";
public static final String ANEMONE_PROTOCOL_VERSION_NAME = "anemone";
public static final String BOTTLENOSE_PROTOCOL_VERSION_NAME = "bottlenose";
public static final String CUTTLEFISH_PROTOCOL_VERSION_NAME = "cuttlefish";
public static final String CUTTLEFISH_PART1_PROTOCOL_VERSION_NAME = "cuttlefish";
public static final String CUTTLEFISH_PART2_PROTOCOL_VERSION_NAME = "cuttlefish-part2";

public static ImmutableList<String> VERSION_NAMES =
ImmutableList.of(
GENESIS_PROTOCOL_VERSION_NAME,
ANEMONE_PROTOCOL_VERSION_NAME,
BOTTLENOSE_PROTOCOL_VERSION_NAME,
CUTTLEFISH_PROTOCOL_VERSION_NAME);
CUTTLEFISH_PART1_PROTOCOL_VERSION_NAME,
CUTTLEFISH_PART2_PROTOCOL_VERSION_NAME);

public static final String LATEST_PROTOCOL_VERSION_NAME =
VERSION_NAMES.get(VERSION_NAMES.size() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@

public final class CuttlefishProtocolUpdateTest {
private static final long ENACTMENT_EPOCH = 8;
private static final ProtocolConfig IMMEDIATELY_CUTTLEFISH =
ProtocolConfig.launchAt(ProtocolConfig.CUTTLEFISH_PROTOCOL_VERSION_NAME);
private static final ProtocolConfig CUTTLEFISH_AT_EPOCH =
ProtocolConfig.enactAtEpoch(ProtocolConfig.CUTTLEFISH_PROTOCOL_VERSION_NAME, ENACTMENT_EPOCH);
private static final ProtocolConfig IMMEDIATELY_CUTTLEFISH_PART2 =
ProtocolConfig.launchAt(ProtocolConfig.CUTTLEFISH_PART2_PROTOCOL_VERSION_NAME);
private static final ProtocolConfig CUTTLEFISH_PART1_AT_EPOCH =
ProtocolConfig.enactAtEpoch(
ProtocolConfig.CUTTLEFISH_PART1_PROTOCOL_VERSION_NAME, ENACTMENT_EPOCH);

@Rule public TemporaryFolder folder = new TemporaryFolder();

Expand Down Expand Up @@ -121,7 +122,7 @@ private DeterministicTest createTest(ProtocolConfig protocolConfig, Module... ex
@Test
public void transaction_v2_behaviour_across_cuttlefish() throws ApiException {
final var coreApiHelper = new CoreApiHelper(Network.INTEGRATIONTESTNET);
try (var test = createTest(CUTTLEFISH_AT_EPOCH, coreApiHelper.module())) {
try (var test = createTest(CUTTLEFISH_PART1_AT_EPOCH, coreApiHelper.module())) {
final var stateComputer = test.getInstance(0, RustStateComputer.class);
test.runUntilState(allAtOrOverEpoch(ENACTMENT_EPOCH - 1));

Expand All @@ -148,13 +149,13 @@ public void transaction_v2_behaviour_across_cuttlefish() throws ApiException {

// Arrange: Run the protocol update:
test.runUntilState(
allAtExactlyProtocolVersion(ProtocolConfig.CUTTLEFISH_PROTOCOL_VERSION_NAME));
allAtExactlyProtocolVersion(ProtocolConfig.CUTTLEFISH_PART1_PROTOCOL_VERSION_NAME));

assertEquals(
ProtocolConfig.CUTTLEFISH_PROTOCOL_VERSION_NAME,
ProtocolConfig.CUTTLEFISH_PART1_PROTOCOL_VERSION_NAME,
stateComputer.protocolState().currentProtocolVersion());
assertEquals(
ProtocolConfig.CUTTLEFISH_PROTOCOL_VERSION_NAME,
ProtocolConfig.CUTTLEFISH_PART1_PROTOCOL_VERSION_NAME,
coreApiHelper.getNetworkStatus().getCurrentProtocolVersion());

// Act: Can now submit a new TransactionV2
Expand Down Expand Up @@ -189,7 +190,7 @@ public void transaction_v2_behaviour_across_cuttlefish() throws ApiException {
@Test
public void protocol_update_process_updates_status_summary() throws ApiException {
final var coreApiHelper = new CoreApiHelper(Network.INTEGRATIONTESTNET);
try (var test = createTest(IMMEDIATELY_CUTTLEFISH, coreApiHelper.module())) {
try (var test = createTest(IMMEDIATELY_CUTTLEFISH_PART2, coreApiHelper.module())) {
test.suppressUnusedWarning();

var latestStateVersion =
Expand All @@ -208,7 +209,7 @@ public void protocol_update_process_updates_status_summary() throws ApiException
.getNewValue()
.getSubstateData();
assertEquals(
ProtocolConfig.CUTTLEFISH_PROTOCOL_VERSION_NAME, latestStatus.getProtocolVersion());
ProtocolConfig.CUTTLEFISH_PART2_PROTOCOL_VERSION_NAME, latestStatus.getProtocolVersion());
assertEquals(ProtocolUpdateStatusType.COMPLETE, latestStatus.getUpdateStatus().getType());
}
}
Expand Down

0 comments on commit 2c3182e

Please sign in to comment.