Skip to content

Commit

Permalink
add test and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Sep 20, 2024
1 parent db773e1 commit 27d50d2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
25 changes: 23 additions & 2 deletions core/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ func TestAuthentication(t *testing.T) {
privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
signer := auth.NewLocalBlobRequestSigner(privateKeyHex)

accountId, err := signer.GetAccountID()
assert.NoError(t, err)

testHeader := core.BlobAuthHeader{
BlobCommitments: encoding.BlobCommitments{},
AccountID: signer.GetAccountID(),
AccountID: accountId,
Nonce: rand.Uint32(),
AuthenticationData: []byte{},
}
Expand All @@ -46,9 +49,12 @@ func TestAuthenticationFail(t *testing.T) {
privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
signer := auth.NewLocalBlobRequestSigner(privateKeyHex)

accountId, err := signer.GetAccountID()
assert.NoError(t, err)

testHeader := core.BlobAuthHeader{
BlobCommitments: encoding.BlobCommitments{},
AccountID: signer.GetAccountID(),
AccountID: accountId,
Nonce: rand.Uint32(),
AuthenticationData: []byte{},
}
Expand All @@ -66,3 +72,18 @@ func TestAuthenticationFail(t *testing.T) {
assert.Error(t, err)

}

func TestNoopSignerFail(t *testing.T) {
signer := auth.NewLocalNoopSigner()
accountId, err := signer.GetAccountID()
assert.EqualError(t, err, "noop signer cannot get accountID")

testHeader := core.BlobAuthHeader{
BlobCommitments: encoding.BlobCommitments{},
AccountID: accountId,
Nonce: rand.Uint32(),
AuthenticationData: []byte{},
}
_, err = signer.SignBlobRequest(testHeader)
assert.EqualError(t, err, "noop signer cannot sign blob request")
}
7 changes: 5 additions & 2 deletions disperser/apiserver/ratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,15 @@ func simulateClient(t *testing.T, signer core.BlobRequestSigner, origin string,
stream.Close()
}()

err := stream.SendFromClient(&pb.AuthenticatedRequest{
accountId, err := signer.GetAccountID()
assert.NoError(t, err)

err = stream.SendFromClient(&pb.AuthenticatedRequest{
Payload: &pb.AuthenticatedRequest_DisperseRequest{
DisperseRequest: &pb.DisperseBlobRequest{
Data: data,
CustomQuorumNumbers: quorums,
AccountId: signer.GetAccountID(),
AccountId: accountId,
},
},
})
Expand Down

0 comments on commit 27d50d2

Please sign in to comment.