@@ -40,13 +40,19 @@ var seedFlag = cli.Int64Flag{
4040 Value : 0 ,
4141}
4242
43- func parseThreeIntegers () (int , int , int , error ) {
43+ var codecFlag = cli.IntFlag {
44+ Name : "codec" ,
45+ Usage : "codec version, valid from 6, default(auto) is 0" ,
46+ Value : 0 ,
47+ }
48+
49+ func parseThreeIntegers (value string ) (int , int , int , error ) {
4450 // Split the input string by comma
45- parts := strings .Split (outputNumFlag . Value , "," )
51+ parts := strings .Split (value , "," )
4652
4753 // Check that we have exactly 3 parts
4854 if len (parts ) != 3 {
49- return 0 , 0 , 0 , fmt .Errorf ("input must contain exactly 3 comma-separated integers, got %s" , outputNumFlag . Value )
55+ return 0 , 0 , 0 , fmt .Errorf ("input must contain exactly 3 comma-separated integers, got %s" , value )
5056 }
5157
5258 // Parse the three integers
@@ -90,6 +96,7 @@ func init() {
9096 app .Name = "integration-test-tool"
9197 app .Usage = "The Scroll L2 Integration Test Tool"
9298 app .Version = version .Version
99+ app .Flags = append (app .Flags , & codecFlag , & seedFlag , & outputNumFlag , & outputPathFlag )
93100 app .Flags = append (app .Flags , utils .CommonFlags ... )
94101 app .Before = func (ctx * cli.Context ) error {
95102 if err := utils .LogSetup (ctx ); err != nil {
@@ -127,6 +134,21 @@ func action(ctx *cli.Context) error {
127134 return fmt .Errorf ("specify begin and end block number" )
128135 }
129136
137+ codecFl := ctx .Int (codecFlag .Name )
138+ if codecFl != 0 {
139+ switch codecFl {
140+ case 6 :
141+ codecCfg = encoding .CodecV6
142+ case 7 :
143+ codecCfg = encoding .CodecV7
144+ case 8 :
145+ codecCfg = encoding .CodecV8
146+ default :
147+ return fmt .Errorf ("invalid codec version %d" , codecFl )
148+ }
149+ log .Info ("set codec" , "version" , codecCfg )
150+ }
151+
130152 beginBlk , err := strconv .ParseUint (ctx .Args ().First (), 10 , 64 )
131153 if err != nil {
132154 return fmt .Errorf ("invalid begin block number: %w" , err )
@@ -136,17 +158,18 @@ func action(ctx *cli.Context) error {
136158 return fmt .Errorf ("invalid begin block number: %w" , err )
137159 }
138160
139- chkNum , batchNum , bundleNum , err := parseThreeIntegers ()
161+ chkNum , batchNum , bundleNum , err := parseThreeIntegers (ctx . String ( outputNumFlag . Name ) )
140162 if err != nil {
141163 return err
142164 }
143165
144- seed := seedFlag .Value
166+ seed := ctx . Int64 ( seedFlag .Name )
145167 if seed == 0 {
146168 seed = rand .Int63 ()
147169 }
148170
149- log .Info ("output" , "Seed" , seed , "file" , outputPathFlag .Value )
171+ outputPath := ctx .String (outputPathFlag .Name )
172+ log .Info ("output" , "Seed" , seed , "file" , outputPath )
150173 ret , err := importData (ctx .Context , beginBlk , endBlk , chkNum , batchNum , bundleNum , seed )
151174 if err != nil {
152175 return err
@@ -158,9 +181,9 @@ func action(ctx *cli.Context) error {
158181 }
159182
160183 // Write the JSON data to the specified file
161- err = os .WriteFile (outputPathFlag . Value , jsonData , 0644 )
184+ err = os .WriteFile (outputPath , jsonData , 0644 )
162185 if err != nil {
163- return fmt .Errorf ("failed to write result to file %s: %w" , outputPathFlag . Value , err )
186+ return fmt .Errorf ("failed to write result to file %s: %w" , outputPath , err )
164187 }
165188
166189 return nil
0 commit comments