Files
zeekay 6439541c91 Prove the two backends agree, on bytes neither of them wrote
Generating C++ is a claim. This runs it.

Both probes build the same cases from the same inputs — every type the dialect
has, plus the request and response envelopes the generated client and dispatch
produce — and print the hex; the two outputs are the same file. Then each
probe reads both probes' bytes with its own generated accessors, four
crossings, all agreeing. Then both read a corpus of real P-chain transactions
produced by the Go chain implementation, 134 vectors of which 44 are truncated
or malformed on purpose, and answer the same fields in the same places.

Neither probe decides anything: every value printed comes from a generated
accessor or a generated builder, so a disagreement between the probes is a
disagreement between the backends and nowhere else.

It earned its keep immediately. Five corpus vectors separated a Go [N]byte
accessor answering zeros from a C++ span answering empty, and the round trip
found the zero Object panicking in the Go runtime where C++ answered zero.
Both are fixed; neither was visible by reading.

list<T> carries a pointer and a count and nothing about elements — the dialect
cannot state a stride — so both languages agree on the count, which is all
either can say. That gap is in the dialect, in both backends at once.
2026-09-06 08:35:14 -07:00

153 lines
4.0 KiB
Go

// Code generated by zapgen; DO NOT EDIT.
// source: probe.zap
package probe
import (
zap "github.com/zap-proto/go"
)
const (
innerTagOff = 0
innerValOff = 4
innerSize = 12
)
// Inner is a zero-copy view into a ZAP-encoded Inner message.
type Inner struct{ o zap.Object }
// WrapInner parses b and returns a typed view. Returns an error if the
// wire-level checks (magic, version, size) fail.
func WrapInner(b []byte) (Inner, error) {
m, err := zap.Parse(b)
if err != nil {
return Inner{}, err
}
return Inner{o: m.Root()}, nil
}
func (t Inner) Tag() uint32 { return t.o.Uint32(innerTagOff) }
func (t Inner) Val() uint64 { return t.o.Uint64(innerValOff) }
// InnerInput collects the field values for NewInner.
type InnerInput struct {
Tag uint32
Val uint64
}
// NewInner builds a ZAP-encoded Inner message from in and returns the bytes.
func NewInner(in InnerInput) []byte {
b := zap.NewBuilder(256)
ob := b.StartObject(innerSize)
ob.SetUint32(innerTagOff, in.Tag)
ob.SetUint64(innerValOff, in.Val)
ob.FinishAsRoot()
return b.Finish()
}
const (
wideFlagOff = 0
wideA8Off = 1
wideA16Off = 2
wideA32Off = 4
wideA64Off = 8
wideS8Off = 16
wideS16Off = 18
wideS32Off = 20
wideS64Off = 24
wideF32Off = 32
wideF64Off = 40
wideIdOff = 48
wideNameOff = 64
wideBlobOff = 72
wideItemsOff = 80
wideChildOff = 88
wideSize = 92
)
// Wide is a zero-copy view into a ZAP-encoded Wide message.
type Wide struct{ o zap.Object }
// WrapWide parses b and returns a typed view. Returns an error if the
// wire-level checks (magic, version, size) fail.
func WrapWide(b []byte) (Wide, error) {
m, err := zap.Parse(b)
if err != nil {
return Wide{}, err
}
return Wide{o: m.Root()}, nil
}
func (t Wide) Flag() bool { return t.o.Bool(wideFlagOff) }
func (t Wide) A8() uint8 { return t.o.Uint8(wideA8Off) }
func (t Wide) A16() uint16 { return t.o.Uint16(wideA16Off) }
func (t Wide) A32() uint32 { return t.o.Uint32(wideA32Off) }
func (t Wide) A64() uint64 { return t.o.Uint64(wideA64Off) }
func (t Wide) S8() int8 { return t.o.Int8(wideS8Off) }
func (t Wide) S16() int16 { return t.o.Int16(wideS16Off) }
func (t Wide) S32() int32 { return t.o.Int32(wideS32Off) }
func (t Wide) S64() int64 { return t.o.Int64(wideS64Off) }
func (t Wide) F32() float32 { return t.o.Float32(wideF32Off) }
func (t Wide) F64() float64 { return t.o.Float64(wideF64Off) }
func (t Wide) Id() [16]byte {
var out [16]byte
copy(out[:], t.o.BytesFixed(wideIdOff, 16))
return out
}
func (t Wide) Name() string { return t.o.Text(wideNameOff) }
func (t Wide) Blob() []byte { return t.o.Bytes(wideBlobOff) }
func (t Wide) Items() zap.List { return t.o.List(wideItemsOff) }
func (t Wide) Child() Inner { return Inner{o: t.o.Object(wideChildOff)} }
// WideInput collects the field values for NewWide.
type WideInput struct {
Flag bool
A8 uint8
A16 uint16
A32 uint32
A64 uint64
S8 int8
S16 int16
S32 int32
S64 int64
F32 float32
F64 float64
Id [16]byte
Name string
Blob []byte
Items [][]byte
Child []byte
}
// NewWide builds a ZAP-encoded Wide message from in and returns the bytes.
func NewWide(in WideInput) []byte {
b := zap.NewBuilder(256)
ob := b.StartObject(wideSize)
ob.SetBool(wideFlagOff, in.Flag)
ob.SetUint8(wideA8Off, in.A8)
ob.SetUint16(wideA16Off, in.A16)
ob.SetUint32(wideA32Off, in.A32)
ob.SetUint64(wideA64Off, in.A64)
ob.SetUint8(wideS8Off, uint8(in.S8))
ob.SetUint16(wideS16Off, uint16(in.S16))
ob.SetUint32(wideS32Off, uint32(in.S32))
ob.SetUint64(wideS64Off, uint64(in.S64))
ob.SetFloat32(wideF32Off, in.F32)
ob.SetFloat64(wideF64Off, in.F64)
ob.SetBytesFixed(wideIdOff, in.Id[:])
ob.SetText(wideNameOff, in.Name)
ob.SetBytes(wideBlobOff, in.Blob)
itemsLB := b.StartList(0)
for _, elem := range in.Items {
itemsLB.AddObjectBytes(elem)
}
ob.SetList(wideItemsOff, itemsLB.FinishOffset(), len(in.Items))
if len(in.Child) > 0 {
nested := b.StartObject(len(in.Child))
nested.SetBytesFixed(0, in.Child)
ob.SetObject(wideChildOff, nested.Finish())
}
ob.FinishAsRoot()
return b.Finish()
}