Merge pull request '[agent/codex:gpt-5.4-mini] Read docs/RFC.md fully. Find ONE feature described in the sp...' (#70) from main into dev
This commit is contained in:
commit
887d9fee42
2 changed files with 25 additions and 7 deletions
20
service.go
20
service.go
|
|
@ -102,12 +102,14 @@ type ServiceOptions struct {
|
|||
RecordDiscoverer func() (map[string]NameRecords, error)
|
||||
FallbackRecordDiscoverer func() (map[string]NameRecords, error)
|
||||
// RecordTTL keeps forward records and the reverse index alive for the same duration.
|
||||
RecordTTL time.Duration
|
||||
DNSPort int
|
||||
HTTPPort int
|
||||
HSDURL string
|
||||
HSDUsername string
|
||||
HSDPassword string
|
||||
RecordTTL time.Duration
|
||||
DNSPort int
|
||||
HTTPPort int
|
||||
HSDURL string
|
||||
HSDUsername string
|
||||
HSDPassword string
|
||||
// HSDApiKey is a compatibility alias for HSDPassword when only a token is available.
|
||||
HSDApiKey string
|
||||
MainchainURL string
|
||||
MainchainUsername string
|
||||
MainchainPassword string
|
||||
|
|
@ -150,10 +152,14 @@ func NewService(options ServiceOptions) *Service {
|
|||
|
||||
hsdClient := options.HSDClient
|
||||
if hsdClient == nil && strings.TrimSpace(options.HSDURL) != "" {
|
||||
hsdPassword := options.HSDPassword
|
||||
if hsdPassword == "" {
|
||||
hsdPassword = options.HSDApiKey
|
||||
}
|
||||
hsdClient = NewHSDClient(HSDClientOptions{
|
||||
URL: options.HSDURL,
|
||||
Username: options.HSDUsername,
|
||||
Password: options.HSDPassword,
|
||||
Password: hsdPassword,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -868,6 +868,7 @@ func TestNewServiceBuildsRPCClientsFromOptions(t *testing.T) {
|
|||
var chainCalls int32
|
||||
var treeRootCalls int32
|
||||
var nameResourceCalls int32
|
||||
expectedAuth := "Basic dXNlcjphcGkta2V5"
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
|
||||
var payload struct {
|
||||
|
|
@ -881,6 +882,9 @@ func TestNewServiceBuildsRPCClientsFromOptions(t *testing.T) {
|
|||
switch payload.Method {
|
||||
case "get_all_alias_details":
|
||||
atomic.AddInt32(&chainCalls, 1)
|
||||
if got := request.Header.Get("Authorization"); got != "" {
|
||||
t.Fatalf("expected no auth header for mainchain request, got %q", got)
|
||||
}
|
||||
responseWriter.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(responseWriter).Encode(map[string]any{
|
||||
"result": []any{
|
||||
|
|
@ -891,6 +895,9 @@ func TestNewServiceBuildsRPCClientsFromOptions(t *testing.T) {
|
|||
})
|
||||
case "getblockchaininfo":
|
||||
atomic.AddInt32(&treeRootCalls, 1)
|
||||
if got := request.Header.Get("Authorization"); got != expectedAuth {
|
||||
t.Fatalf("expected hsd auth header %q, got %q", expectedAuth, got)
|
||||
}
|
||||
responseWriter.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(responseWriter).Encode(map[string]any{
|
||||
"result": map[string]any{
|
||||
|
|
@ -899,6 +906,9 @@ func TestNewServiceBuildsRPCClientsFromOptions(t *testing.T) {
|
|||
})
|
||||
case "getnameresource":
|
||||
atomic.AddInt32(&nameResourceCalls, 1)
|
||||
if got := request.Header.Get("Authorization"); got != expectedAuth {
|
||||
t.Fatalf("expected hsd auth header %q, got %q", expectedAuth, got)
|
||||
}
|
||||
if len(payload.Params) != 1 || payload.Params[0] != "gateway.charon.lthn" {
|
||||
t.Fatalf("unexpected alias lookup: %#v", payload.Params)
|
||||
}
|
||||
|
|
@ -917,6 +927,8 @@ func TestNewServiceBuildsRPCClientsFromOptions(t *testing.T) {
|
|||
service := NewService(ServiceOptions{
|
||||
MainchainURL: server.URL,
|
||||
HSDURL: server.URL,
|
||||
HSDUsername: "user",
|
||||
HSDApiKey: "api-key",
|
||||
})
|
||||
|
||||
if err := service.DiscoverAliases(context.Background()); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue