-
Notifications
You must be signed in to change notification settings - Fork 240
chore: cherry-pick celo's PR from proxy repo #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ab26f06
2c50038
6d7159c
dd7ed1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ linters: | |
- unused # checks for unused constants, variables, functions and types | ||
## disabled by default | ||
- asasalint # checks for pass []any as any in variadic func(...any) | ||
- asciicheck # checks that your code does not contain non-ASCII identifiers | ||
- asciicheck # checks that your code does not contain non-ASCII identifiers1 | ||
- bidichk # checks for dangerous unicode character sequences | ||
- bodyclose # checks whether HTTP response body is closed successfully | ||
- cyclop # checks function and package cyclomatic complexity | ||
|
@@ -195,7 +195,7 @@ linters: | |
- unparam | ||
|
||
# Allow certain patterns to be ignored by lll (long lines) | ||
- source: '".{120,}"' # Ignores double-quoted strings longer than 120 chars | ||
- source: '".{100,}"' # Ignores double-quoted strings longer than 120 chars | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in favor of this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know... but otherwise there was a bug which the celo engineer was running into and he didn't find another way to solve it. See https://eigenlabs.slack.com/archives/C07614NNXDH/p1751913947976629?thread_ts=1750965737.272329&cid=C07614NNXDH There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed comment and added some "explanation" in 2c50038 |
||
linters: [lll] | ||
- source: "// https?://" # This pattern matches comments containing URLs | ||
linters: [lll] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package testutils | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/crypto" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/minio/minio-go/v7" | ||
"github.com/minio/minio-go/v7/pkg/credentials" | ||
"golang.org/x/exp/rand" | ||
) | ||
|
||
func RandStr(n int) string { | ||
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz") | ||
b := make([]rune, n) | ||
for i := range b { | ||
b[i] = letterRunes[rand.Intn(len(letterRunes))] | ||
} | ||
return string(b) | ||
} | ||
|
||
func RandBytes(n int) []byte { | ||
return []byte(RandStr(n)) | ||
} | ||
|
||
// Panics if the bucket does not exist | ||
func RemoveBlobInfoFromBucket(bucketName string, blobInfo []byte) error { | ||
// Initialize minio client object. | ||
endpoint := minioEndpoint | ||
accessKeyID := minioAdmin | ||
secretAccessKey := minioAdmin | ||
useSSL := false | ||
minioClient, err := minio.New( | ||
endpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), | ||
Secure: useSSL, | ||
}) | ||
// Panic, the bucket should already exist | ||
if err != nil { | ||
panic(err) | ||
} | ||
key := crypto.Keccak256(blobInfo[1:]) | ||
objectName := hex.EncodeToString(key) | ||
ctx := context.Background() | ||
err = minioClient.RemoveObject(ctx, bucketName, objectName, minio.RemoveObjectOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
log.Info(fmt.Sprintf("Successfully removed %s from %s\n", objectName, bucketName)) | ||
|
||
return nil | ||
} | ||
|
||
// Panics if the bucket does not exist | ||
func ExistsBlobInfotInBucket(bucketName string, blobInfo []byte) (bool, error) { | ||
// Initialize minio client object. | ||
endpoint := minioEndpoint | ||
accessKeyID := minioAdmin | ||
secretAccessKey := minioAdmin | ||
useSSL := false | ||
minioClient, err := minio.New( | ||
endpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), | ||
Secure: useSSL, | ||
}) | ||
// Panic, the bucket should already exist | ||
if err != nil { | ||
panic(err) | ||
} | ||
key := crypto.Keccak256(blobInfo[1:]) | ||
objectName := hex.EncodeToString(key) | ||
ctx := context.Background() | ||
_, err = minioClient.StatObject(ctx, bucketName, objectName, minio.StatObjectOptions{}) | ||
if err != nil { | ||
errResponse := minio.ToErrorResponse(err) | ||
if errResponse.Code == "NoSuchKey" { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
return true, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray keystroke
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2c50038