@@ -719,19 +719,17 @@ private void testAllowTvmSelfdestructRestrictionProposal() {
719719 }
720720
721721 private void testAllowMarketTransaction () {
722- byte [] stats = new byte [27 ];
723- Arrays .fill (stats , (byte ) 1 );
724-
725722 ThrowingRunnable off = () -> ProposalUtil .validator (dynamicPropertiesStore , forkUtils ,
726723 ProposalType .ALLOW_MARKET_TRANSACTION .getCode (), 0 );
727724 ThrowingRunnable open = () -> ProposalUtil .validator (dynamicPropertiesStore , forkUtils ,
728725 ProposalType .ALLOW_MARKET_TRANSACTION .getCode (), 1 );
726+ String err = "Bad chain parameter id [ALLOW_MARKET_TRANSACTION]" ;
729727
730728 ContractValidateException thrown = assertThrows (ContractValidateException .class , open );
731- assertEquals ("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]" , thrown .getMessage ());
729+ assertEquals (err , thrown .getMessage ());
730+
731+ activateFork (ForkBlockVersionEnum .VERSION_4_1 );
732732
733- forkUtils .getManager ().getDynamicPropertiesStore ()
734- .statsByVersion (ForkBlockVersionEnum .VERSION_4_1 .getValue (), stats );
735733 try {
736734 open .run ();
737735 } catch (Throwable e ) {
@@ -742,13 +740,27 @@ private void testAllowMarketTransaction() {
742740 assertEquals ("This value[ALLOW_MARKET_TRANSACTION] is only allowed to be 1" ,
743741 thrown .getMessage ());
744742
745- forkUtils .getManager ().getDynamicPropertiesStore ()
746- .statsByVersion (ForkBlockVersionEnum .VERSION_4_8_1 .getValue (), stats );
743+ activateFork (ForkBlockVersionEnum .VERSION_4_8_1 );
747744
748745 thrown = assertThrows (ContractValidateException .class , open );
749- assertEquals ("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]" , thrown .getMessage ());
746+ assertEquals (err , thrown .getMessage ());
747+
750748 thrown = assertThrows (ContractValidateException .class , off );
751- assertEquals ("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]" , thrown .getMessage ());
749+ assertEquals (err , thrown .getMessage ());
750+ }
751+
752+ private void activateFork (ForkBlockVersionEnum forkVersion ) {
753+ byte [] stats = new byte [27 ];
754+ Arrays .fill (stats , (byte ) 1 );
755+ forkUtils .getManager ().getDynamicPropertiesStore ()
756+ .statsByVersion (forkVersion .getValue (), stats );
757+
758+ long maintenanceTimeInterval = forkUtils .getManager ().getDynamicPropertiesStore ()
759+ .getMaintenanceTimeInterval ();
760+ long hardForkTime = ((forkVersion .getHardForkTime () - 1 ) / maintenanceTimeInterval + 1 )
761+ * maintenanceTimeInterval ;
762+ forkUtils .getManager ().getDynamicPropertiesStore ()
763+ .saveLatestBlockHeaderTimestamp (hardForkTime + 1 );
752764 }
753765
754766 @ Test
0 commit comments