nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: nats-io/nats.go
Pull request #1877 (2025-05-27 21:54:01)

Add nc.LocalAddr, similar to nc.ConnectedAddr
Currently, the Go client library exposes the remote address of the underlying net.Conn.
It would be helpful if it also exposed the LocalAddr.
The usecase is to help determine which network was used to reach the remote NATS server.


Patch:
diff --git a/nats.go b/nats.go
index 1496fea..c032402 100644
--- a/nats.go
+++ b/nats.go
@@ -2292,6 +2292,21 @@ func (nc *Conn) ConnectedAddr() string {
 	return nc.conn.RemoteAddr().String()
 }
 
+// LocalAddr returns the local network address of the connection
+func (nc *Conn) LocalAddr() string {
+	if nc == nil {
+		return _EMPTY_
+	}
+
+	nc.mu.RLock()
+	defer nc.mu.RUnlock()
+
+	if nc.status != CONNECTED {
+		return _EMPTY_
+	}
+	return nc.conn.LocalAddr().String()
+}
+
 // ConnectedServerId reports the connected server's Id
 func (nc *Conn) ConnectedServerId() string {
 	if nc == nil {


Test patch:
diff --git a/test/nats_test.go b/test/nats_test.go
index 91ed88d..15bf492 100644
--- a/test/nats_test.go
+++ b/test/nats_test.go
@@ -553,6 +553,39 @@ func TestConnectedAddr(t *testing.T) {
 	}
 }
 
+func TestLocalAddr(t *testing.T) {
+	s := RunServerOnPort(TEST_PORT)
+	defer s.Shutdown()
+
+	var nc *nats.Conn
+	if addr := nc.LocalAddr(); addr != "" {
+		t.Fatalf("Expected empty result for nil connection, got %q", addr)
+	}
+	nc, err := nats.Connect(fmt.Sprintf("localhost:%d", TEST_PORT))
+	if err != nil {
+		t.Fatalf("Error connecting: %v", err)
+	}
+	addr := nc.LocalAddr()
+	if addr == "" {
+		t.Fatalf("Expected non-empty local address")
+	}
+	// Verify it's a valid address format
+	host, port, err := net.SplitHostPort(addr)
+	if err != nil {
+		t.Fatalf("Expected valid host:port format, got %q: %v", addr, err)
+	}
+	if host == "" {
+		t.Fatalf("Expected non-empty host in address %q", addr)
+	}
+	if port == "" {
+		t.Fatalf("Expected non-empty port in address %q", addr)
+	}
+	nc.Close()
+	if addr := nc.LocalAddr(); addr != "" {
+		t.Fatalf("Expected empty result for closed connection, got %q", addr)
+	}
+}
+
 func TestSubscribeSyncRace(t *testing.T) {
 	s := RunServerOnPort(TEST_PORT)
 	defer s.Shutdown()
Repository: nats-io/nats.go
Pull request #795 (2021-08-17 01:26:23)

[ADDED] Description in StreamConfig and ConsumerConfig
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>


Patch:
diff --git a/js.go b/js.go
index 92b6e54..34389d0 100644
--- a/js.go
+++ b/js.go
@@ -772,6 +772,7 @@ func Context(ctx context.Context) ContextOpt {
 // ConsumerConfig is the configuration of a JetStream consumer.
 type ConsumerConfig struct {
 	Durable         string        `json:"durable_name,omitempty"`
+	Description     string        `json:"description,omitempty"`
 	DeliverSubject  string        `json:"deliver_subject,omitempty"`
 	DeliverGroup    string        `json:"deliver_group,omitempty"`
 	DeliverPolicy   DeliverPolicy `json:"deliver_policy"`
diff --git a/jsm.go b/jsm.go
index 00ea173..f40086b 100644
--- a/jsm.go
+++ b/jsm.go
@@ -75,6 +75,7 @@ type JetStreamManager interface {
 // given the name will be used as the only subject.
 type StreamConfig struct {
 	Name              string          `json:"name"`
+	Description       string          `json:"description,omitempty"`
 	Subjects          []string        `json:"subjects,omitempty"`
 	Retention         RetentionPolicy `json:"retention"`
 	MaxConsumers      int             `json:"max_consumers"`


Test patch:
diff --git a/test/js_test.go b/test/js_test.go
index 619dca4..660029d 100644
--- a/test/js_test.go
+++ b/test/js_test.go
@@ -5915,3 +5915,49 @@ func TestJetStreamDomainInPubAck(t *testing.T) {
 		t.Fatalf("Expected PubAck to have domain of %q, got %q", "HUB", pa.Domain)
 	}
 }
+
+func TestJetStreamStreamAndConsumerDescription(t *testing.T) {
+	s := RunBasicJetStreamServer()
+	defer s.Shutdown()
+
+	if config := s.JetStreamConfig(); config != nil {
+		defer os.RemoveAll(config.StoreDir)
+	}
+
+	nc, err := nats.Connect(s.ClientURL())
+	if err != nil {
+		t.Fatalf("Unexpected error: %v", err)
+	}
+	defer nc.Close()
+
+	js, err := nc.JetStream()
+	if err != nil {
+		t.Fatalf("Unexpected error: %v", err)
+	}
+
+	streamDesc := "stream description"
+	si, err := js.AddStream(&nats.StreamConfig{
+		Name:        "TEST",
+		Description: streamDesc,
+		Subjects:    []string{"foo"},
+	})
+	if err != nil {
+		t.Fatalf("Error adding stream: %v", err)
+	}
+	if si.Config.Description != streamDesc {
+		t.Fatalf("Invalid description: %q vs %q", streamDesc, si.Config.Description)
+	}
+
+	consDesc := "consumer description"
+	ci, err := js.AddConsumer("TEST", &nats.ConsumerConfig{
+		Description:    consDesc,
+		Durable:        "dur",
+		DeliverSubject: "bar",
+	})
+	if err != nil {
+		t.Fatalf("Error adding consumer: %v", err)
+	}
+	if ci.Config.Description != consDesc {
+		t.Fatalf("Invalid description: %q vs %q", consDesc, ci.Config.Description)
+	}
+}
Repository: nats-io/nats.go
Pull request #797 (2021-08-17 15:34:05)

[ADDED] ExpectLastSequencePerSubject() publish option
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>


Patch:
diff --git a/js.go b/js.go
index 34389d0..d14bfe2 100644
--- a/js.go
+++ b/js.go
@@ -260,6 +260,7 @@ type pubOpts struct {
 	lid string // Expected last msgId
 	str string // Expected stream name
 	seq uint64 // Expected last sequence
+	lss uint64 // Expected last sequence per subject
 }
 
 // pubAckResponse is the ack response from the JetStream API when publishing a message.
@@ -278,10 +279,11 @@ type PubAck struct {
 
 // Headers for published messages.
 const (
-	MsgIdHdr             = "Nats-Msg-Id"
-	ExpectedStreamHdr    = "Nats-Expected-Stream"
-	ExpectedLastSeqHdr   = "Nats-Expected-Last-Sequence"
-	ExpectedLastMsgIdHdr = "Nats-Expected-Last-Msg-Id"
+	MsgIdHdr               = "Nats-Msg-Id"
+	ExpectedStreamHdr      = "Nats-Expected-Stream"
+	ExpectedLastSeqHdr     = "Nats-Expected-Last-Sequence"
+	ExpectedLastSubjSeqHdr = "Nats-Expected-Last-Subject-Sequence"
+	ExpectedLastMsgIdHdr   = "Nats-Expected-Last-Msg-Id"
 )
 
 // PublishMsg publishes a Msg to a stream from JetStream.
@@ -317,6 +319,9 @@ func (js *js) PublishMsg(m *Msg, opts ...PubOpt) (*PubAck, error) {
 	if o.seq > 0 {
 		m.Header.Set(ExpectedLastSeqHdr, strconv.FormatUint(o.seq, 10))
 	}
+	if o.lss > 0 {
+		m.Header.Set(ExpectedLastSubjSeqHdr, strconv.FormatUint(o.lss, 10))
+	}
 
 	var resp *Msg
 	var err error
@@ -618,6 +623,9 @@ func (js *js) PublishMsgAsync(m *Msg, opts ...PubOpt) (PubAckFuture, error) {
 	if o.seq > 0 {
 		m.Header.Set(ExpectedLastSeqHdr, strconv.FormatUint(o.seq, 10))
 	}
+	if o.lss > 0 {
+		m.Header.Set(ExpectedLastSubjSeqHdr, strconv.FormatUint(o.lss, 10))
+	}
 
 	// Reply
 	if m.Reply != _EMPTY_ {
@@ -687,6 +695,14 @@ func ExpectLastSequence(seq uint64) PubOpt {
 	})
 }
 
+// ExpectLastSequencePerSubject sets the expected sequence per subject in the response from the publish.
+func ExpectLastSequencePerSubject(seq uint64) PubOpt {
+	return pubOptFn(func(opts *pubOpts) error {
+		opts.lss = seq
+		return nil
+	})
+}
+
 // ExpectLastMsgId sets the expected last msgId in the response from the publish.
 func ExpectLastMsgId(id string) PubOpt {
 	return pubOptFn(func(opts *pubOpts) error {


Test patch:
diff --git a/test/js_test.go b/test/js_test.go
index 660029d..a544430 100644
--- a/test/js_test.go
+++ b/test/js_test.go
@@ -264,6 +264,20 @@ func TestJetStreamPublish(t *testing.T) {
 	if err != context.Canceled {
 		t.Fatalf("Expected %q, got %q", context.Canceled, err)
 	}
+
+	// Test ExpectLastSequencePerSubject. Just make sure that we set the header.
+	sub, err = nc.SubscribeSync("test")
+	if err != nil {
+		t.Fatalf("Error on subscribe: %v", err)
+	}
+	js.Publish("test", []byte("msg"), nats.ExpectLastSequencePerSubject(1))
+	m, err := sub.NextMsg(time.Second)
+	if err != nil {
+		t.Fatalf("Error on next msg: %v", err)
+	}
+	if m.Header.Get(nats.ExpectedLastSubjSeqHdr) != "1" {
+		t.Fatalf("Header ExpectLastSequencePerSubject not set: %+v", m.Header)
+	}
 }
 
 func TestJetStreamSubscribe(t *testing.T) {
Repository: nats-io/nats.go
Pull request #812 (2021-09-02 00:34:47)

[ADDED] Stringer for connection status
This change updates the connection status by implementing the Stringer interface, enabling users to log out the connection status in a human readable format.

I've updated an existing tests to verify the string output. It's not exhaustive, but covers the same cases the existing test exercises. If you'd rather I add a separate test that covers each permutation then let me know and I can update the pull request.


Patch:
diff --git a/nats.go b/nats.go
index 14b795d..cd8aaed 100644
--- a/nats.go
+++ b/nats.go
@@ -196,6 +196,26 @@ const (
 	DRAINING_PUBS
 )
 
+func (s Status) String() string {
+	switch s {
+	case DISCONNECTED:
+		return "DISCONNECTED"
+	case CONNECTED:
+		return "CONNECTED"
+	case CLOSED:
+		return "CLOSED"
+	case RECONNECTING:
+		return "RECONNECTING"
+	case CONNECTING:
+		return "CONNECTING"
+	case DRAINING_SUBS:
+		return "DRAINING_SUBS"
+	case DRAINING_PUBS:
+		return "DRAINING_PUBS"
+	}
+	return "unknown status"
+}
+
 // ConnHandler is used for asynchronous events such as
 // disconnected and closed connections.
 type ConnHandler func(*Conn)


Test patch:
diff --git a/test/conn_test.go b/test/conn_test.go
index 115fd81..0a70083 100644
--- a/test/conn_test.go
+++ b/test/conn_test.go
@@ -49,14 +49,15 @@ func TestConnectionStatus(t *testing.T) {
 	nc := NewDefaultConnection(t)
 	defer nc.Close()
 
-	if nc.Status() != nats.CONNECTED {
+	if nc.Status() != nats.CONNECTED || nc.Status().String() != "CONNECTED" {
 		t.Fatal("Should have status set to CONNECTED")
 	}
+
 	if !nc.IsConnected() {
 		t.Fatal("Should have status set to CONNECTED")
 	}
 	nc.Close()
-	if nc.Status() != nats.CLOSED {
+	if nc.Status() != nats.CLOSED || nc.Status().String() != "CLOSED" {
 		t.Fatal("Should have status set to CLOSED")
 	}
 	if !nc.IsClosed() {
Repository: FuelLabs/fuelup
Pull request #281 (2022-11-22 23:18:55)

feat: add fuel-indexer


Patch:
diff --git a/components.toml b/components.toml
index d44bcfbb..68010f71 100644
--- a/components.toml
+++ b/components.toml
@@ -63,3 +63,11 @@ executables = ["forc-wallet"]
 repository_name = "forc-wallet"
 targets = [ "aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin" ]
 publish = true
+
+[component.fuel-indexer]
+name = "fuel-indexer"
+tarball_prefix = "fuel-indexer"
+executables = ["fuel-indexer"]
+repository_name = "fuel-indexer"
+targets = [ "aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin" ]
+publish = true


Test patch:
diff --git a/tests/commands.rs b/tests/commands.rs
index 19099f76..1f99591c 100644
--- a/tests/commands.rs
+++ b/tests/commands.rs
@@ -252,6 +252,7 @@ my_toolchain (default)
     - forc-lsp - not found
     - forc-wallet - not found
   fuel-core - not found
+  fuel-indexer - not found
 "#
         );
         assert!(stdout.contains(expected_stdout));
Repository: FuelLabs/fuelup
Pull request #618 (2024-05-28 22:45:26)

feat: make latest toolchain point to testnet
Points latest toolchain to testnet.


Patch:
diff --git a/src/constants.rs b/src/constants.rs
index dbbd18bd..bff4e86c 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -5,8 +5,8 @@ pub const FUEL_TOOLCHAIN_TOML_FILE: &str = "fuel-toolchain.toml";
 pub const FUELS_VERSION_FILE: &str = "fuels_version";
 
 pub const CHANNEL_LATEST_URL: &str =
-    "https://raw.githubusercontent.com/FuelLabs/fuelup/gh-pages/channel-fuel-beta-5.toml";
-pub const CHANNEL_LATEST_FILE_NAME: &str = "channel-fuel-beta-5.toml";
+    "https://raw.githubusercontent.com/FuelLabs/fuelup/gh-pages/channel-fuel-testnet.toml";
+pub const CHANNEL_LATEST_FILE_NAME: &str = "channel-fuel-testnet.toml";
 pub const CHANNEL_NIGHTLY_FILE_NAME: &str = "channel-fuel-nightly.toml";
 pub const CHANNEL_BETA_1_FILE_NAME: &str = "channel-fuel-beta-1.toml";
 pub const CHANNEL_BETA_2_FILE_NAME: &str = "channel-fuel-beta-2.toml";


Test patch:
diff --git a/tests/component.rs b/tests/component.rs
index 3ad0f42d..c5213c60 100644
--- a/tests/component.rs
+++ b/tests/component.rs
@@ -15,7 +15,11 @@ fn fuelup_component_add() -> Result<()> {
         let _ = cfg.fuelup(&["component", "add", "fuel-core"]);
         expect_files_exist(
             &cfg.toolchain_bin_dir("my_toolchain"),
-            &["fuel-core", "fuel-core-keygen"],
+            &[
+                "fuel-core",
+                "fuel-core-keygen",
+                "fuel-core-wasm-executor.wasm",
+            ],
         );
     })?;