Skip to content

Commit

Permalink
Test improvements (Layr-Labs#1251)
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley authored Feb 11, 2025
1 parent 37fb138 commit 7d32544
Show file tree
Hide file tree
Showing 17 changed files with 776 additions and 498 deletions.
4 changes: 2 additions & 2 deletions api/clients/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func (rc *ValidatorPayloadRetrieverConfig) checkAndSetDefaults() error {
func GetDefaultPayloadDisperserConfig() *PayloadDisperserConfig {
return &PayloadDisperserConfig{
PayloadClientConfig: *GetDefaultPayloadClientConfig(),
DisperseBlobTimeout: 5 * time.Second,
BlobCertifiedTimeout: 10 * time.Second,
DisperseBlobTimeout: 2 * time.Minute,
BlobCertifiedTimeout: 2 * time.Minute,
BlobStatusPollInterval: 1 * time.Second,
Quorums: []core.QuorumID{0, 1},
}
Expand Down
14 changes: 12 additions & 2 deletions common/testutils/random/test_random.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type TestRandom struct {

// NewTestRandom creates a new instance of TestRandom
// This method may either be seeded, or not seeded. If no seed is provided, then current unix nano time is used.
//
// The testing.T object is optional, but if it is nil then this utility will panic if an internal error occurs.
func NewTestRandom(t *testing.T, fixedSeed ...int64) *TestRandom {
var seed int64
if len(fixedSeed) == 0 {
Expand Down Expand Up @@ -144,7 +146,7 @@ func (r *TestRandom) IOReader() io.Reader {
// NOT CRYPTOGRAPHICALLY SECURE!!! FOR TESTING PURPOSES ONLY. DO NOT USE THESE KEYS FOR SECURITY PURPOSES.
func (r *TestRandom) ECDSA() (*ecdsa.PublicKey, *ecdsa.PrivateKey) {
key, err := ecdsa.GenerateKey(crypto.S256(), crand.Reader)
require.NoError(r.t, err)
r.requireNoError(err)
return &key.PublicKey, key
}

Expand All @@ -158,8 +160,16 @@ func (r *TestRandom) BLS() *core.KeyPair {

//Generate cryptographically strong pseudo-random between 0 - max
n, err := crand.Int(r.IOReader(), maxValue)
require.NoError(r.t, err)
r.requireNoError(err)

sk := new(core.PrivateKey).SetBigInt(n)
return core.MakeKeyPair(sk)
}

func (r *TestRandom) requireNoError(err error) {
if r.t != nil {
require.NoError(r.t, err)
} else if err != nil {
panic(err)
}
}
10 changes: 8 additions & 2 deletions test/v2/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
clean:
rm -rf bin 2>/dev/null || true

build: clean
go build -o bin/load load/main/load_main.go

test:
cd correctness && go test

load:
cd load && go test
generate-load: build
./bin/load $(ARGS)
Loading

0 comments on commit 7d32544

Please sign in to comment.