tendermint / go-amino

Protobuf3 with Interface support - Designed for blockchains (deterministic, upgradeable, fast, and compact)
Other
259 stars 78 forks source link

Add testcase for #180 #185

Open liamsi opened 6 years ago

liamsi commented 6 years ago

add a test case that fails before #180 was merged (and check for general test-coverage while at it):

        cdc.RegisterInterface((*Packet)(nil), nil)
    cdc.RegisterConcrete(PacketPing{}, "tendermint/p2p/PacketPing", nil)
    cdc.RegisterConcrete(PacketPong{}, "tendermint/p2p/PacketPong", nil)
    buf := bytes.NewBuffer(nil)
    buf.Write(cdc.MustMarshalBinary(PacketPing{}))
    fmt.Printf("%X", buf.Bytes())
    var pkt PacketPing
    _, err = cdc.UnmarshalBinaryReader(buf, &pkt, 1024)
    assert.NoError(t, err)

Above should do the job.