use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.
the class AvmVersionScheduleTest method testProhibitionWithZeroTolerance.
@Test
public void testProhibitionWithZeroTolerance() {
AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(0, 10, 0);
// Version 1 is permitted over blocks [0, 9]
// Version 2 is permitted over blocks 10 onwards.
// Verify when version 1 is prohibited.
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 0));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 9));
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 10));
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, Long.MAX_VALUE));
// Verify when version 2 is prohibited.
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 0));
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 9));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 10));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, Long.MAX_VALUE));
}
use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.
the class AvmTestConfig method supportBothAvmVersions.
/**
* Uses an avm version schedule that supports both version 1 and 2 at the specified block
* numbers.
*
* The tolerance parameter is the amount of blocks (plus/minus) to keep an avm version alive
* at a block where it is no longer used.
*
* @param blockNumberToUseVersion1 The block number at which version 1 starts being used.
* @param blockNumberToUseVersion2 The block number at which version 2 starts being used.
* @param activeVersionTolerance The amount of blocks to keep an old version alive.
*/
public static void supportBothAvmVersions(long blockNumberToUseVersion1, long blockNumberToUseVersion2, long activeVersionTolerance) {
AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(blockNumberToUseVersion1, blockNumberToUseVersion2, activeVersionTolerance);
String projectRoot = AvmPathManager.getPathOfProjectRootDirectory();
AvmConfigurations.initializeConfigurationsAsReadAndWriteable(schedule, projectRoot);
}
use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.
the class AvmVersionScheduleTest method testWhichVersionToRun2.
@Test
public void testWhichVersionToRun2() {
AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(12, 31, 3);
Assert.assertNull(schedule.whichVersionToRunWith(0));
Assert.assertNull(schedule.whichVersionToRunWith(11));
Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(12));
Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(30));
Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(31));
Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(Long.MAX_VALUE));
}
use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.
the class AvmVersionScheduleTest method testProhibitionWithOneTolerance.
@Test
public void testProhibitionWithOneTolerance() {
AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(0, 16, 1);
// Version 1 is permitted over blocks [0, 16]
// Version 2 is permitted over blocks 15 onwards.
// Verify when version 1 is prohibited.
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 0));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 15));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 16));
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 17));
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, Long.MAX_VALUE));
// Verify when version 2 is prohibited.
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 0));
Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 14));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 15));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 16));
Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, Long.MAX_VALUE));
}
use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.
the class AvmTestConfig method supportOnlyAvmVersion1.
/**
* Uses an avm version schedule that only supports version 1 - no version 2 support at all.
* Version 1 is active from block zero onwards.
*/
public static void supportOnlyAvmVersion1() {
AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForOnlySingleVersionSupport(0, 0);
String projectRoot = AvmPathManager.getPathOfProjectRootDirectory();
AvmConfigurations.initializeConfigurationsAsReadAndWriteable(schedule, projectRoot);
}
Aggregations