Search in sources :

Example 1 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmTransactionExecutorTest method setupClass.

@BeforeClass
public static void setupClass() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(VERSION_1_FORK, VERSION_2_FORK, TOLERANCE);
    AvmConfigurations.initializeConfigurationsAsReadAndWriteable(schedule, AvmPathManager.getPathOfProjectRootDirectory());
    projectRootDir = AvmPathManager.getPathOfProjectRootDirectory();
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) BeforeClass(org.junit.BeforeClass)

Example 2 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testProhibitionWithZeroToleranceUsingSingleAvmSupport.

@Test
public void testProhibitionWithZeroToleranceUsingSingleAvmSupport() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForOnlySingleVersionSupport(0, 0);
    // Version 1 is permitted over blocks 0 onwards.
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 0));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 1));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, Long.MAX_VALUE));
    // Ensure that version 2 is always prohibited.
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 0));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 1));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Example 3 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testWhichVersionToRun1.

@Test
public void testWhichVersionToRun1() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(0, 10, 3);
    Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(0));
    Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(9));
    Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(10));
    Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Example 4 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testProhibitionWhenForksAreBlockNeighboursWithLargeTolerance.

@Test
public void testProhibitionWhenForksAreBlockNeighboursWithLargeTolerance() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(11, 12, 8);
    // Version 1 is permitted over blocks [3, 19]
    // Version 2 is permitted over blocks 4 onwards.
    // Verify when version 1 is prohibited.
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 0));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 2));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 3));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 10));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 11));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 12));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 13));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 19));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 20));
    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, 3));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 4));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 10));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 11));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 12));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 13));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Example 5 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testWhichVersionToRun3.

@Test
public void testWhichVersionToRun3() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(61, 62, 30);
    Assert.assertNull(schedule.whichVersionToRunWith(0));
    Assert.assertNull(schedule.whichVersionToRunWith(60));
    Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(61));
    Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(62));
    Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Aggregations

AvmVersionSchedule (org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule)19 Test (org.junit.Test)13 Console (java.io.Console)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 AvmVersion (org.aion.avm.stub.AvmVersion)1 LogEnum (org.aion.log.LogEnum)1 LogLevel (org.aion.log.LogLevel)1 AionBlockchainImpl (org.aion.zero.impl.blockchain.AionBlockchainImpl)1 CfgAion (org.aion.zero.impl.config.CfgAion)1 CfgDb (org.aion.zero.impl.config.CfgDb)1 AionRepositoryImpl (org.aion.zero.impl.db.AionRepositoryImpl)1 BeforeClass (org.junit.BeforeClass)1 Logger (org.slf4j.Logger)1 CommandLine (picocli.CommandLine)1 CommandSpec (picocli.CommandLine.Model.CommandSpec)1