mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-28 18:55:42 +00:00
This pull request adds the report tool and modifies the loadtime libraries to better support its use.
(cherry picked from commit 8655080a0f)
Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
This commit is contained in:
co-authored by
William Banfield
parent
6ed1bb96d7
commit
d9fd26ce93
@@ -0,0 +1,50 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user