mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 03:35:19 +00:00
This pull request adds the report tool and modifies the loadtime libraries to better support its use.
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package payload_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tendermint/tendermint/test/loadtime/payload"
|
|
)
|
|
|
|
const payloadSizeTarget = 1024 // 1kb
|
|
|
|
func TestSize(t *testing.T) {
|
|
s, err := payload.MaxUnpaddedSize()
|
|
if err != nil {
|
|
t.Fatalf("calculating max unpadded size %s", err)
|
|
}
|
|
if s > payloadSizeTarget {
|
|
t.Fatalf("unpadded payload size %d exceeds target %d", s, payloadSizeTarget)
|
|
}
|
|
}
|
|
|
|
func TestRoundTrip(t *testing.T) {
|
|
const (
|
|
testConns = 512
|
|
testRate = 4
|
|
)
|
|
b, err := payload.NewBytes(&payload.Payload{
|
|
Size: payloadSizeTarget,
|
|
Connections: testConns,
|
|
Rate: testRate,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("generating payload %s", err)
|
|
}
|
|
if len(b) < payloadSizeTarget {
|
|
t.Fatalf("payload size in bytes %d less than expected %d", len(b), payloadSizeTarget)
|
|
}
|
|
p, err := payload.FromBytes(b)
|
|
if err != nil {
|
|
t.Fatalf("reading payload %s", err)
|
|
}
|
|
if p.Size != payloadSizeTarget {
|
|
t.Fatalf("payload size value %d does not match expected %d", p.Size, payloadSizeTarget)
|
|
}
|
|
if p.Connections != testConns {
|
|
t.Fatalf("payload connections value %d does not match expected %d", p.Connections, testConns)
|
|
}
|
|
if p.Rate != testRate {
|
|
t.Fatalf("payload rate value %d does not match expected %d", p.Rate, testRate)
|
|
}
|
|
}
|