1616import org .junit .Ignore ;
1717import org .junit .Test ;
1818import org .mockito .Mockito ;
19+ import org .springframework .beans .factory .annotation .Autowired ;
1920import org .springframework .util .StringUtils ;
2021import org .tron .common .BaseTest ;
2122import org .tron .common .parameter .CommonParameter ;
2223import org .tron .common .runtime .InternalTransaction ;
2324import org .tron .common .utils .DecodeUtil ;
2425import org .tron .core .Constant ;
26+ import org .tron .core .Wallet ;
2527import org .tron .core .capsule .AccountCapsule ;
2628import org .tron .core .config .args .Args ;
2729import org .tron .core .exception .ContractValidateException ;
2830import org .tron .core .store .StoreFactory ;
2931import org .tron .core .vm .EnergyCost ;
3032import org .tron .core .vm .JumpTable ;
33+ import org .tron .core .vm .MessageCall ;
3134import org .tron .core .vm .Op ;
3235import org .tron .core .vm .Operation ;
3336import org .tron .core .vm .OperationActions ;
3437import org .tron .core .vm .OperationRegistry ;
38+ import org .tron .core .vm .PrecompiledContracts ;
3539import org .tron .core .vm .VM ;
3640import org .tron .core .vm .config .ConfigLoader ;
3741import org .tron .core .vm .config .VMConfig ;
@@ -46,6 +50,8 @@ public class OperationsTest extends BaseTest {
4650 private ProgramInvokeMockImpl invoke ;
4751 private Program program ;
4852 private final JumpTable jumpTable = OperationRegistry .getTable ();
53+ @ Autowired
54+ private Wallet wallet ;
4955
5056 @ BeforeClass
5157 public static void init () {
@@ -755,6 +761,30 @@ public void testPushDupSwapAndLogOperations() throws ContractValidateException {
755761 Assert .assertEquals (2158 , program .getResult ().getEnergyUsed ());
756762 }
757763
764+ @ Test
765+ public void testCallOperations () throws ContractValidateException {
766+ invoke = new ProgramInvokeMockImpl ();
767+ Protocol .Transaction trx = Protocol .Transaction .getDefaultInstance ();
768+ InternalTransaction interTrx =
769+ new InternalTransaction (trx , InternalTransaction .TrxType .TRX_UNKNOWN_TYPE );
770+
771+ byte prePrefixByte = DecodeUtil .addressPreFixByte ;
772+ DecodeUtil .addressPreFixByte = Constant .ADD_PRE_FIX_BYTE_MAINNET ;
773+ VMConfig .initAllowTvmSelfdestructRestriction (1 );
774+
775+ program = new Program (new byte [0 ], new byte [0 ], invoke , interTrx );
776+ MessageCall messageCall = new MessageCall (
777+ Op .CALL , new DataWord (10000 ),
778+ DataWord .ZERO (), DataWord .ZERO (),
779+ DataWord .ZERO (), DataWord .ZERO (),
780+ DataWord .ZERO (), DataWord .ZERO (),
781+ DataWord .ZERO (), false );
782+ program .callToPrecompiledAddress (messageCall , new PrecompiledContracts .ECRecover ());
783+
784+ DecodeUtil .addressPreFixByte = prePrefixByte ;
785+ VMConfig .initAllowTvmSelfdestructRestriction (0 );
786+ }
787+
758788 @ Test
759789 public void testOtherOperations () throws ContractValidateException {
760790 invoke = new ProgramInvokeMockImpl ();
0 commit comments