@ -190,18 +190,20 @@ BOOST_FIXTURE_TEST_SUITE(versionbits_tests, TestingSetup)
BOOST_AUTO_TEST_CASE ( versionbits_test )
{
for ( int i = 0 ; i < 64 ; i + + ) {
// DEFINED -> FAILED
// DEFINED -> STARTED after timeout reached -> FAILED
VersionBitsTester ( ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 1 , TestTime ( 1 ) , 0x100 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 11 , TestTime ( 11 ) , 0x100 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 989 , TestTime ( 989 ) , 0x100 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 999 , TestTime ( 20000 ) , 0x100 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 1000 , TestTime ( 20000 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 1999 , TestTime ( 30001 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 2000 , TestTime ( 30002 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 2001 , TestTime ( 30003 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 2999 , TestTime ( 30004 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 3000 , TestTime ( 30005 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 999 , TestTime ( 20000 ) , 0x100 ) . TestDefined ( ) . TestStateSinceHeight ( 0 ) // Timeout and start time reached simultaneously
. Mine ( 1000 , TestTime ( 20000 ) , 0 ) . TestStarted ( ) . TestStateSinceHeight ( 1000 ) // Hit started, stop signalling
. Mine ( 1999 , TestTime ( 30001 ) , 0 ) . TestStarted ( ) . TestStateSinceHeight ( 1000 )
. Mine ( 2000 , TestTime ( 30002 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 2000 ) // Hit failed, start signalling again
. Mine ( 2001 , TestTime ( 30003 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 2000 )
. Mine ( 2999 , TestTime ( 30004 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 2000 )
. Mine ( 3000 , TestTime ( 30005 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 2000 )
. Mine ( 4000 , TestTime ( 30006 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 2000 )
// DEFINED -> STARTED -> FAILED
. Reset ( ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 1 , TestTime ( 1 ) , 0 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
@ -212,19 +214,19 @@ BOOST_AUTO_TEST_CASE(versionbits_test)
. Mine ( 3000 , TestTime ( 20000 ) , 0 ) . TestFailed ( ) . TestStateSinceHeight ( 3000 ) // 50 old blocks (so 899 out of the past 1000)
. Mine ( 4000 , TestTime ( 20010 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 3000 )
// DEFINED -> STARTED -> FAILED while threshold reached
// DEFINED -> STARTED -> LOCKEDIN after timeout reached -> ACTIVE
. Reset ( ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 1 , TestTime ( 1 ) , 0 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 1000 , TestTime ( 10000 ) - 1 , 0x101 ) . TestDefined ( ) . TestStateSinceHeight ( 0 ) // One second more and it would be defined
. Mine ( 2000 , TestTime ( 10000 ) , 0x101 ) . TestStarted ( ) . TestStateSinceHeight ( 2000 ) // So that's what happens the next period
. Mine ( 2999 , TestTime ( 30000 ) , 0x100 ) . TestStarted ( ) . TestStateSinceHeight ( 2000 ) // 999 new blocks
. Mine ( 3000 , TestTime ( 30000 ) , 0x100 ) . Test Failed ( ) . TestStateSinceHeight ( 3000 ) // 1 new block (so 1000 out of the past 1000 are new)
. Mine ( 3999 , TestTime ( 30001 ) , 0 ) . Test Failed ( ) . TestStateSinceHeight ( 3000 )
. Mine ( 4000 , TestTime ( 30002 ) , 0 ) . Test Fail ed( ) . TestStateSinceHeight ( 3000 )
. Mine ( 14333 , TestTime ( 30003 ) , 0 ) . Test Fail ed( ) . TestStateSinceHeight ( 3000 )
. Mine ( 24000 , TestTime ( 40000 ) , 0 ) . Test Failed( ) . TestStateSinceHeight ( 3 000)
. Mine ( 3000 , TestTime ( 30000 ) , 0x100 ) . Test LockedIn ( ) . TestStateSinceHeight ( 3000 ) // 1 new block (so 1000 out of the past 1000 are new)
. Mine ( 3999 , TestTime ( 30001 ) , 0 ) . Test LockedIn ( ) . TestStateSinceHeight ( 3000 )
. Mine ( 4000 , TestTime ( 30002 ) , 0 ) . Test ActiveDelay ed( ) . TestStateSinceHeight ( 4000 , 3000 )
. Mine ( 14333 , TestTime ( 30003 ) , 0 ) . Test ActiveDelay ed( ) . TestStateSinceHeight ( 4000 , 3000 )
. Mine ( 24000 , TestTime ( 40000 ) , 0 ) . Test Active( ) . TestStateSinceHeight ( 4000 , 15 000)
// DEFINED -> STARTED -> LOCKEDIN at the last minute -> ACTIVE
// DEFINED -> STARTED -> LOCKEDIN before timeout -> ACTIVE
. Reset ( ) . TestDefined ( )
. Mine ( 1 , TestTime ( 1 ) , 0 ) . TestDefined ( ) . TestStateSinceHeight ( 0 )
. Mine ( 1000 , TestTime ( 10000 ) - 1 , 0x101 ) . TestDefined ( ) . TestStateSinceHeight ( 0 ) // One second more and it would be defined
@ -247,8 +249,10 @@ BOOST_AUTO_TEST_CASE(versionbits_test)
. Mine ( 3000 , TestTime ( 10000 ) , 0 ) . TestStarted ( ) . TestStateSinceHeight ( 3000 )
. Mine ( 4000 , TestTime ( 10000 ) , 0 ) . TestStarted ( ) . TestStateSinceHeight ( 3000 )
. Mine ( 5000 , TestTime ( 10000 ) , 0 ) . TestStarted ( ) . TestStateSinceHeight ( 3000 )
. Mine ( 5999 , TestTime ( 20000 ) , 0 ) . TestStarted ( ) . TestStateSinceHeight ( 3000 )
. Mine ( 6000 , TestTime ( 20000 ) , 0 ) . TestFailed ( ) . TestStateSinceHeight ( 6000 )
. Mine ( 7000 , TestTime ( 20000 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 6000 )
. Mine ( 24000 , TestTime ( 20000 ) , 0x100 ) . TestFailed ( ) . TestStateSinceHeight ( 6000 ) // stay in FAILED no matter how much we signal
;
}
}