diff --git a/api/api/src/main/scala/aqua/api/AquaAPIConfig.scala b/api/api/src/main/scala/aqua/api/AquaAPIConfig.scala index ce0735a8..860d5e60 100644 --- a/api/api/src/main/scala/aqua/api/AquaAPIConfig.scala +++ b/api/api/src/main/scala/aqua/api/AquaAPIConfig.scala @@ -11,7 +11,7 @@ case class AquaAPIConfig( noXor: Boolean = false, // TODO: Remove noRelay: Boolean = false, tracing: Boolean = false, - noEmptyResponse: Boolean = false + noEmptyResponse: Boolean = true ) { def getTransformConfig: TransformConfig = { diff --git a/compiler/src/test/scala/aqua/compiler/AquaCompilerSpec.scala b/compiler/src/test/scala/aqua/compiler/AquaCompilerSpec.scala index a0f05157..a97812b0 100644 --- a/compiler/src/test/scala/aqua/compiler/AquaCompilerSpec.scala +++ b/compiler/src/test/scala/aqua/compiler/AquaCompilerSpec.scala @@ -221,6 +221,69 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside { } } + it should "not generate hop back with empty response" in { + val src = Map( + "index.aqua" -> + """service Op("op"): + | call(s: string) + | + |func exec(peers: []string): + | for peer <- peers par: + | on peer: + | Op.call("hahahahah") + |""".stripMargin + ) + + val transformCfg = TransformConfig( + noEmptyResponse = true + ) + + insideRes(src, transformCfg = transformCfg)("exec") { case exec :: _ => + val peers = VarModel("-peers-arg-", ArrayType(ScalarType.string)) + val peer = VarModel("peer-0", ScalarType.string) + val initPeer = LiteralModel.fromRaw(ValueRaw.InitPeerId) + + val expected = + XorRes.wrap( + SeqRes.wrap( + getDataSrv("-relay-", "-relay-", ScalarType.string), + getDataSrv("peers", peers.name, peers.`type`), + ParRes.wrap( + FoldRes + .lastNever(peer.name, peers) + .wrap( + ParRes.wrap( + XorRes.wrap( + SeqRes.wrap( + through(ValueModel.fromRaw(relay)), + CallServiceRes( + LiteralModel.fromRaw(LiteralRaw.quote("op")), + "call", + CallRes( + LiteralModel.fromRaw(LiteralRaw.quote("hahahahah")) :: Nil, + None + ), + peer + ).leaf + ), + SeqRes.wrap( + through(ValueModel.fromRaw(relay)), + through(initPeer), + failErrorRes + ) + ), + NextRes(peer.name).leaf + ) + ) + ) + ), + errorCall(transformCfg, 0, initPeer) + ) + + exec.body.equalsOrShowDiff(expected) shouldBe (true) + } + } + it should "compile with imports" in { val src = Map(