Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service test doesn't work with types involving lists #46

Open
tristanbuckner opened this issue Jul 18, 2016 · 0 comments
Open

Service test doesn't work with types involving lists #46

tristanbuckner opened this issue Jul 18, 2016 · 0 comments

Comments

@tristanbuckner
Copy link

tristanbuckner commented Jul 18, 2016

I'm able to use testFunctionService for signatures involving non-container types but when I use List or Vector there appear to be serialization errors that don't occur when I test encode/decode manually.

package blah

import io.github.finagle.serial.scodec.ScodecSerial
import io.github.finagle.serial.tests.SerialIntegrationTest
import org.scalacheck._
import org.scalatest.FunSuite
import scodec.Attempt.Successful
import scodec.bits.BitVector
import scodec.codecs._
import scodec.{Codec, DecodeResult}

class ListSpec extends FunSuite with ScodecSerial with SerialIntegrationTest {

  implicit val listCodec = list(utf8_32)

  implicit val intCodec = int32

  implicit val lists: Arbitrary[List[String]] = Arbitrary {
    Gen.nonEmptyContainerOf[List, String](Gen.alphaStr)
  }

  test("List encode decode") {
    check((p: List[String]) => {
      listCodec.encode(p).flatMap(listCodec.decode) === Successful(DecodeResult(p, BitVector.empty))
      }
    )
  }

  test("List service test") {
    testFunctionService[List[String], Int]((p1: List[String]) => p1.length)
  }

}

The first test passes but the second fails with this (technically I had to modify a future with onFailure to dump this, but it is the root cause):

io.github.finagle.serial.CodecError: cannot acquire 32 bits from a vector that contains 7 bits
    at io.github.finagle.serial.scodec.ScodecSerial$fresh$macro$49$1.from(ScodecSerial.scala:27)
    at io.github.finagle.serial.scodec.ScodecSerial$fresh$macro$49$1.from(ScodecSerial.scala:27)
    at scodec.Transformer$$anon$7$$anonfun$apply$12.apply(Transform.scala:121)
    at scodec.DecodeResult.map(DecodeResult.scala:17)
    at scodec.Codec$$anon$2$$anonfun$decode$1.apply(Codec.scala:201)
    at scodec.Codec$$anon$2$$anonfun$decode$1.apply(Codec.scala:201)
    at scodec.Attempt$Successful.map(Attempt.scala:92)
    at scodec.Codec$$anon$2.decode(Codec.scala:201)
    at scodec.Codec$$anon$2.decode(Codec.scala:201)
    at scodec.codecs.ToCoproductCodecs$$anon$8$$anon$1.decode(CoproductCodec.scala:108)
    at scodec.codecs.ToCoproductCodecs$$anon$8$$anonfun$1$$anon$2.decode(CoproductCodec.scala:120)
    at scodec.Decoder$$anon$2.decode(Decoder.scala:46)
    at scodec.GenCodec$$anon$2.decode(GenCodec.scala:76)
    at scodec.Decoder$$anon$3$$anonfun$decode$2.apply(Decoder.scala:54)
    at scodec.Decoder$$anon$3$$anonfun$decode$2.apply(Decoder.scala:54)
    at scodec.Attempt$Successful.flatMap(Attempt.scala:94)
    at scodec.Decoder$$anon$3.decode(Decoder.scala:54)
    at scodec.Decoder$$anon$3$$anonfun$decode$2.apply(Decoder.scala:54)
    at scodec.Decoder$$anon$3$$anonfun$decode$2.apply(Decoder.scala:54)
    at scodec.Attempt$Successful.flatMap(Attempt.scala:94)
    at scodec.Decoder$$anon$3.decode(Decoder.scala:54)
    at scodec.Decoder$$anon$3$$anonfun$decode$2.apply(Decoder.scala:54)
    at scodec.Decoder$$anon$3$$anonfun$decode$2.apply(Decoder.scala:54)
    at scodec.Attempt$Successful.flatMap(Attempt.scala:94)
    at scodec.Decoder$$anon$3.decode(Decoder.scala:54)
    at scodec.codecs.CoproductCodec$Discriminated.decode(CoproductCodec.scala:60)
    at scodec.Decoder$$anon$4.decode(Decoder.scala:62)
    at scodec.GenCodec$$anon$2.decode(GenCodec.scala:76)
    at scodec.Codec$$anon$1.decode(Codec.scala:191)
    at scodec.Codec$$anon$2.decode(Codec.scala:201)
    at io.github.finagle.serial.scodec.ScodecSerial$class.decodeRep(ScodecSerial.scala:103)
    at com.chartboost.protocol.request.ListSpec.decodeRep(ListSpec.scala:12)
    at com.chartboost.protocol.request.ListSpec.decodeRep(ListSpec.scala:12)
    at io.github.finagle.serial.Serial$Client$$anon$4$$anonfun$apply$1$$anonfun$apply$2.apply(Serial.scala:161)
    at io.github.finagle.serial.Serial$Client$$anon$4$$anonfun$apply$1$$anonfun$apply$2.apply(Serial.scala:160)
    at com.twitter.util.Future$$anonfun$flatMap$1.apply(Future.scala:986)
    at com.twitter.util.Future$$anonfun$flatMap$1.apply(Future.scala:985)
    at com.twitter.util.Promise$Transformer.liftedTree1$1(Promise.scala:112)
    at com.twitter.util.Promise$Transformer.k(Promise.scala:112)
    at com.twitter.util.Promise$Transformer.apply(Promise.scala:122)
    at com.twitter.util.Promise$Transformer.apply(Promise.scala:103)
    at com.twitter.util.Promise$$anon$1.run(Promise.scala:381)
    at com.twitter.concurrent.LocalScheduler$Activation.run(Scheduler.scala:178)
    at com.twitter.concurrent.LocalScheduler$Activation.submit(Scheduler.scala:136)
    at com.twitter.concurrent.LocalScheduler.submit(Scheduler.scala:207)
    at com.twitter.concurrent.Scheduler$.submit(Scheduler.scala:92)
    at com.twitter.util.Promise.runq(Promise.scala:350)
    at com.twitter.util.Promise.updateIfEmpty(Promise.scala:721)
    at com.twitter.util.Promise.update(Promise.scala:694)
    at com.twitter.util.Promise.setValue(Promise.scala:670)
    at com.twitter.concurrent.AsyncQueue.offer(AsyncQueue.scala:111)
    at com.twitter.finagle.netty3.transport.ChannelTransport.handleUpstream(ChannelTransport.scala:55)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at com.twitter.finagle.mux.transport.Netty3Framer$Framer.handleUpstream(Netty3Framer.scala:31)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:142)
    at com.twitter.finagle.netty3.channel.ChannelStatsHandler.messageReceived(ChannelStatsHandler.scala:68)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:142)
    at com.twitter.finagle.netty3.channel.ChannelRequestStatsHandler.messageReceived(ChannelRequestStatsHandler.scala:32)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant