Annotation Type GenerateTScore


  • @Target({TYPE,METHOD})
    @Retention(SOURCE)
    @Repeatable(GenerateTScores.class)
    public @interface GenerateTScore
    @GenerateTScore is used to generate a wrapper SCORE class for testing. If you deploy the generated SCORE class using the unittest framework, the following additional features are available.
    • Log a proper event on calling the method tagged with EventLog
    • Check if a method is properly tagged with External and Payable
    • Check if a parameter is properly tagged with Optional
    For this, the class and its methods should be non-final in order to be extended by the generated SCORE class.

    For example, the following is your contract implementation.

     public class MyContract {
         public MyContract() { }
    
         @External
         public void setValue(String value) {
             ...
         }
     }
     
    Then you may deploy the contract with the generated SCORE class in the unittest. Note that the default suffix for the generated class is TS.
     public class MyContractTest {
         @Test
         @GenerateTScore(MyContract.class)
         public void testSetValue() {
             var score = sm.deploy(MyContractTS.class);
         }
     }
     
    Of course, you may use the class as is, without any additional features.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String suffix  
      java.lang.Class<?> value  
    • Element Detail

      • value

        java.lang.Class<?> value
        Default:
        com.iconloop.score.test.GenerateTScore.class
      • suffix

        java.lang.String suffix
        Default:
        "TS"