@@ -673,6 +673,67 @@ struct Wasm_test : public beast::unit_test::suite
673673 }
674674 }
675675
676+ void
677+ testInfiniteLoop ()
678+ {
679+ testcase (" infinite loop" );
680+
681+ using namespace test ::jtx;
682+ Env env{*this };
683+
684+ /*
685+ void
686+ loop()
687+ {
688+ int volatile x = 0;
689+ while (1)
690+ x++;
691+ }
692+ */
693+ static std::string const infiniteWasmHex =
694+ " 0061736d01000000010401600000030302000005030100020638097f004180080b"
695+ " 7f004180"
696+ " 080b7f004180080b7f00418088040b7f004180080b7f00418088040b7f00418080"
697+ " 080b7f00"
698+ " 41000b7f0041010b07a8010c066d656d6f72790200115f5f7761736d5f63616c6c"
699+ " 5f63746f"
700+ " 72730000046c6f6f7000010c5f5f64736f5f68616e646c6503000a5f5f64617461"
701+ " 5f656e64"
702+ " 03010b5f5f737461636b5f6c6f7703020c5f5f737461636b5f6869676803030d5f"
703+ " 5f676c6f"
704+ " 62616c5f6261736503040b5f5f686561705f6261736503050a5f5f686561705f65"
705+ " 6e640306"
706+ " 0d5f5f6d656d6f72795f6261736503070c5f5f7461626c655f6261736503080a27"
707+ " 0202000b"
708+ " 220041fc87044100360200034041fc870441fc870428020041016a3602000c000b"
709+ " 000b007f"
710+ " 0970726f647563657273010c70726f6365737365642d62790105636c616e675f31"
711+ " 392e312e"
712+ " 352d776173692d73646b202868747470733a2f2f6769746875622e636f6d2f6c6c"
713+ " 766d2f6c"
714+ " 6c766d2d70726f6a65637420616234623561326462353832393538616631656533"
715+ " 30386137"
716+ " 3930636664623432626432343732302900490f7461726765745f66656174757265"
717+ " 73042b0f"
718+ " 6d757461626c652d676c6f62616c732b087369676e2d6578742b0f726566657265"
719+ " 6e63652d"
720+ " 74797065732b0a6d756c746976616c7565" ;
721+ auto const wasmStr = boost::algorithm::unhex (infiniteWasmHex);
722+ Bytes wasm (wasmStr.begin (), wasmStr.end ());
723+ std::string const funcName (" infinite" );
724+ TestHostFunctions hfs (env, 0 );
725+
726+ {
727+ // f32 set constant, opcode disabled exception
728+ auto const re =
729+ runEscrowWasm (wasm, funcName, {}, &hfs, 1'000'000 , env.journal );
730+ if (BEAST_EXPECT (!re.has_value ()))
731+ {
732+ BEAST_EXPECT (re.error () == tecFAILED_PROCESSING);
733+ }
734+ }
735+ }
736+
676737 void
677738 run () override
678739 {
@@ -698,6 +759,7 @@ struct Wasm_test : public beast::unit_test::suite
698759
699760 testCodecovWasm ();
700761 // testDisabledFloat();
762+ testInfiniteLoop ();
701763
702764 // perfTest();
703765 }
0 commit comments