@@ -40,9 +40,11 @@ var anyTestConfig = []byte("config")
4040var anyTestTriggerValue = "test value"
4141
4242var testPath string
43+ var importWasmFileName string
4344
4445func init () {
4546 flag .StringVar (& testPath , "path" , "./standard_tests" , "Path to the standard tests" )
47+ flag .StringVar (& importWasmFileName , "importWasmFileName" , "" , "File name to import WASM instead of compiling" )
4648}
4749
4850func TestStandardConfig (t * testing.T ) {
@@ -461,11 +463,21 @@ func runWithBasicTrigger(t *testing.T, executor ExecutionHelper) *sdk.ExecutionR
461463// When subtests have their own binaries, those binaries are expected to be nested in a subfolder.
462464func makeTestModule (t * testing.T ) * module {
463465 testName := strcase .ToSnake (t .Name ()[len ("TestStandard" ):])
466+
467+ if importWasmFileName != "" {
468+ return importTestModuleByName (t , testName , nil )
469+ }
470+
464471 return makeTestModuleByName (t , testName , nil )
465472}
466473
467474func makeTestModuleWithCfg (t * testing.T , cfg * ModuleConfig ) * module {
468475 testName := strcase .ToSnake (t .Name ()[len ("TestStandard" ):])
476+
477+ if importWasmFileName != "" {
478+ return importTestModuleByName (t , testName , nil )
479+ }
480+
469481 return makeTestModuleByName (t , testName , cfg )
470482}
471483
@@ -490,6 +502,25 @@ func makeTestModuleByName(t *testing.T, testName string, cfg *ModuleConfig) *mod
490502 return mod
491503}
492504
505+ // importTestModuleByName imports pre-compiled test modules in the testPath directory
506+ // The test to import and run is determined by the test name.
507+ func importTestModuleByName (t * testing.T , testName string , cfg * ModuleConfig ) * module {
508+ wasmName := path .Join (testName , importWasmFileName )
509+ absPath , err := filepath .Abs (testPath )
510+ require .NoError (t , err , "Failed to get absolute path for test directory" )
511+
512+ wasmPath := filepath .Join (absPath , wasmName )
513+ binary , err := os .ReadFile (wasmPath )
514+ require .NoError (t , err , "Failed to read WASM file at %s" , wasmPath )
515+
516+ if cfg == nil {
517+ cfg = defaultNoDAGModCfg (t )
518+ }
519+ mod , err := NewModule (cfg , binary )
520+ require .NoError (t , err )
521+ return mod
522+ }
523+
493524func setupNodeCallAndConsensusCall (t * testing.T , output int32 ) func (_ context.Context , request * sdk.CapabilityRequest ) (* sdk.CapabilityResponse , error ) {
494525 return func (_ context.Context , request * sdk.CapabilityRequest ) (* sdk.CapabilityResponse , error ) {
495526 nodeResponse := & nodeaction.NodeOutputs {OutputThing : output }
0 commit comments