Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions ports/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,29 +270,15 @@ func (bhs *BuilderHubHandler) RegisterCredentials(w http.ResponseWriter, r *http
return
}

// Validate payload based on service type
var tlsCert string
var ecdsaPubkey []byte
if sc.ECDSAPubkey == nil && sc.TLSCert == "" {
http.Error(w, "No credentials provided", http.StatusBadRequest)
return
}

switch service {
case "instance":
if sc.TLSCert == "" {
http.Error(w, "TLS cert is required for instance service", http.StatusBadRequest)
return
}
tlsCert = sc.TLSCert
case "orderflow_proxy", "rbuilder":
if sc.ECDSAPubkey == nil {
http.Error(w, "ECDSA pubkey is required for service", http.StatusBadRequest)
return
}
ecdsaPubkey = sc.ECDSAPubkey.Bytes()
default:
if sc.TLSCert == "" && sc.ECDSAPubkey == nil {
http.Error(w, "No credentials provided", http.StatusBadRequest)
return
}
tlsCert = sc.TLSCert
tlsCert := sc.TLSCert

var ecdsaPubkey []byte
if sc.ECDSAPubkey != nil {
ecdsaPubkey = sc.ECDSAPubkey.Bytes()
}

Expand Down
47 changes: 38 additions & 9 deletions scripts/ci/setup.hurl → scripts/ci/e2e-test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,42 @@ jsonpath "$.[0].ip" == "1.2.3.4"
jsonpath "$.[0].name" == "test_builder"

# [Builder API] Register credentials for 'rbuilder' service
#POST http://localhost:8888/api/l1-builder/v1/register_credentials/rbuilder
#{
# "ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5"
#}
POST http://localhost:8888/api/l1-builder/v1/register_credentials/rbuilder
{
"ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5"
}
HTTP 200

## [Builder API] List of peers now includes the added credentials
#GET http://localhost:8888/api/l1-builder/v1/builders
#HTTP 200
#[Asserts]
#jsonpath "$.[0].rbuilder.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
# [Builder API] Register credentials for 'orderflow_proxy' service
POST http://localhost:8888/api/l1-builder/v1/register_credentials/orderflow_proxy
{
"ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5",
"tls_cert": "abcdefghijklmnopqrstuvwxyz"
}
HTTP 200

# [Builder API] Register credentials for 'instance' service
POST http://localhost:8888/api/l1-builder/v1/register_credentials/instance
{
"tls_cert": "1234567890"
}
HTTP 200

# [Builder API] Register credentials for custom service
POST http://localhost:8888/api/l1-builder/v1/register_credentials/foobar123
{
"tls_cert": "1234567890",
"ecdsa_pubkey_address": "0x321f3426eEc20DE1910af1CD595c4DD83BEA0BA5"
}
HTTP 200

# [Builder API] Get the list of peers
GET http://localhost:8888/api/l1-builder/v1/builders
HTTP 200
[Asserts]
jsonpath "$.[0].orderflow_proxy.tls_cert" == "abcdefghijklmnopqrstuvwxyz"
jsonpath "$.[0].orderflow_proxy.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
jsonpath "$.[0].rbuilder.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
jsonpath "$.[0].instance.tls_cert" == "1234567890"
jsonpath "$.[0].foobar123.tls_cert" == "1234567890"
jsonpath "$.[0].foobar123.ecdsa_pubkey_address" == "0x321f3426eec20de1910af1cd595c4dd83bea0ba5"
2 changes: 1 addition & 1 deletion scripts/ci/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ printf 'GET http://localhost:8888/\nHTTP 404' | hurl --retry 60 > /dev/null;

# Run the tests
echo "Running integration tests..."
hurl --test scripts/ci/setup.hurl
hurl --test scripts/ci/e2e-test.hurl
echo "Integration tests completed successfully."

# Stop and remove the Docker containers
Expand Down