nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ecadlabs/taquito
Pull request #1867 (2022-08-29 22:31:07)

test(integration test): 1 manager operation per manager per block
Added a test showing the expected error message if we try to inject multiple maganer operations in
the same block

re #1748

Thank you for your contribution to Taquito.

Before submitting this PR, please make sure:

- [ ] Your code builds cleanly without any errors or warnings
- [ ] You have added unit tests
- [ ] You have added integration tests (if relevant/appropriate)
- [ ] All public methods or types have TypeDoc coverage with a complete description, and ideally an @example
- [ ] You have added or updated corresponding documentation
- [ ] If relevant, you have written a first draft summary describing the change for inclusion in Release Notes. 

## Release Note Draft Snippet

__If relevant, please write a summary of your change that will be suitable for
inclusion in the Release Notes for the next Taquito release.__



Patch:
diff --git a/docs/batch-api.md b/docs/batch-api.md
index fa8dc0221..f465065b2 100644
--- a/docs/batch-api.md
+++ b/docs/batch-api.md
@@ -20,7 +20,12 @@ await op1.confirmation();
 await op2.confirmation();
 
 /*
- * Error Message returned by the node:
+ * Error Message returned by the node (since Kathmandu):
+ * Error while applying operation opHash: 
+ * Only one manager operation per manager per block allowed (found opHash2 with Xtez fee. 
+ * You may want to use --replace to provide adequate fee and replace it).
+ * 
+ * Error Message that was returned by the node (before Kathmandu):
  * "Error while applying operation opWH2nEcmmzUwK4T6agHg3bn9GDR7fW1ynqWL58AVRAb7aZFciD:
  * branch refused (Error:
  * Counter 1122148 already used for contract tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb (expected 1122149))"


Test patch:
diff --git a/integration-tests/injecting-multiple-manager-operations-in-a-block.spec.ts b/integration-tests/injecting-multiple-manager-operations-in-a-block.spec.ts
new file mode 100644
index 000000000..81dfd17f9
--- /dev/null
+++ b/integration-tests/injecting-multiple-manager-operations-in-a-block.spec.ts
@@ -0,0 +1,25 @@
+import { CONFIGS } from "./config";
+
+CONFIGS().forEach(({ lib, rpc, setup }) => {
+    const Tezos = lib;
+    describe(`Test injecting more than one manager operation in a block: ${rpc}`, () => {
+
+        beforeEach(async (done) => {
+            await setup()
+            done()
+        })
+        test('Verify that doing transfers without awaiting the confirmation after each will fail', async (done) => {
+            try {
+                const op1 = await Tezos.contract.transfer({ to: 'tz1ZfrERcALBwmAqwonRXYVQBDT9BjNjBHJu', amount: 1 });
+                const op2 = await Tezos.contract.transfer({ to: 'tz1ZfrERcALBwmAqwonRXYVQBDT9BjNjBHJu', amount: 2 });
+
+                await op1.confirmation();
+                await op2.confirmation();
+
+            } catch (error) {
+                expect(error.message).toContain('Only one manager operation per manager per block allowed');
+            }
+            done();
+        })
+    });
+})
Repository: kubernetes/klog
Pull request #225 (2021-03-12 00:06:51)

KObj should be able to handle nil objects
**What this PR does / why we need it**:

Prevents `klog.KObj` from panicking when passed `nil`.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:

See https://github.com/kubernetes/kubernetes/pull/100109

**Special notes for your reviewer**:

_Please confirm that if this PR changes any image versions, then that's the sole change this PR makes._

**Release note**:
<!--  Write your release note:
1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, include the string "action required".
2. If no release note is required, just write "NONE".
-->
```release-note
KObj now supports nil objects
```


Patch:
diff --git a/klog.go b/klog.go
index e042e2b..4892da6 100644
--- a/klog.go
+++ b/klog.go
@@ -1577,6 +1577,10 @@ type KMetadata interface {
 
 // KObj returns ObjectRef from ObjectMeta
 func KObj(obj KMetadata) ObjectRef {
+	if obj == nil {
+		return ObjectRef{}
+	}
+
 	return ObjectRef{
 		Name:      obj.GetName(),
 		Namespace: obj.GetNamespace(),


Test patch:
diff --git a/klog_test.go b/klog_test.go
index ba4349b..671e4c1 100644
--- a/klog_test.go
+++ b/klog_test.go
@@ -763,6 +763,11 @@ func TestKObj(t *testing.T) {
 		obj  KMetadata
 		want ObjectRef
 	}{
+		{
+			name: "nil",
+			obj:  nil,
+			want: ObjectRef{},
+		},
 		{
 			name: "with ns",
 			obj:  mockKmeta{"test-name", "test-ns"},
Repository: kubernetes/klog
Pull request #257 (2021-08-04 09:42:07)

export ClearLogger
**What this PR does / why we need it**:

Code in Kubernetes also needs the ability to unset a logger.

**Release note**:
<!--  Write your release note:
1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, include the string "action required".
2. If no release note is required, just write "NONE".
-->
```release-note
ClearLogger can be used to remove a logger that was set previously with SetLogger.
```


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes/klog/pull/257#" title="Author self-approved">pohly</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **thockin** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @thockin` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes%2Fklog).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes/klog/blob/main/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["thockin"]} -->

Patch:
diff --git a/klog.go b/klog.go
index d6f52bd..5b33973 100644
--- a/klog.go
+++ b/klog.go
@@ -862,6 +862,9 @@ func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) {
 // Use as:
 //   ...
 //   klog.SetLogger(zapr.NewLogger(zapLog))
+//
+// To remove a backing logr implemention, use ClearLogger. Setting an
+// empty logger with SetLogger(logr.Logger{}) does not work.
 func SetLogger(logr logr.Logger) {
 	logging.mu.Lock()
 	defer logging.mu.Unlock()
@@ -869,7 +872,9 @@ func SetLogger(logr logr.Logger) {
 	logging.logr = &logr
 }
 
-func clearLogger() {
+// ClearLogger removes a backing logr implementation if one was set earlier
+// with SetLogger.
+func ClearLogger() {
 	logging.mu.Lock()
 	defer logging.mu.Unlock()
 


Test patch:
diff --git a/klog_test.go b/klog_test.go
index 0df1420..9a44c6b 100644
--- a/klog_test.go
+++ b/klog_test.go
@@ -1377,7 +1377,7 @@ func TestInfoSWithLogr(t *testing.T) {
 		t.Run(data.msg, func(t *testing.T) {
 			l := logr.New(logger)
 			SetLogger(l)
-			defer clearLogger()
+			defer ClearLogger()
 			defer logger.reset()
 
 			InfoS(data.msg, data.keysValues...)
@@ -1445,7 +1445,7 @@ func TestErrorSWithLogr(t *testing.T) {
 		t.Run(data.msg, func(t *testing.T) {
 			l := logr.New(logger)
 			SetLogger(l)
-			defer clearLogger()
+			defer ClearLogger()
 			defer logger.reset()
 
 			ErrorS(data.err, data.msg, data.keysValues...)
@@ -1503,7 +1503,7 @@ func TestCallDepthLogr(t *testing.T) {
 		t.Run(tc.name, func(t *testing.T) {
 			l := logr.New(logger)
 			SetLogger(l)
-			defer clearLogger()
+			defer ClearLogger()
 			defer logger.reset()
 			defer logger.resetCallDepth()
Repository: kubernetes/klog
Pull request #283 (2022-01-19 07:29:36)

Panic on empty info with custom logr
**What this PR does / why we need it**:
Prevent panic on logging empty string.

**Release note**:
```release-note
1. Prevent panic when using info or error with custom logger.
```


Patch:
diff --git a/klog.go b/klog.go
index dacdf91..73a0c93 100644
--- a/klog.go
+++ b/klog.go
@@ -729,7 +729,7 @@ func (l *loggingT) printDepth(s severity, logger *logr.Logger, filter LogFilter,
 		args = filter.Filter(args)
 	}
 	fmt.Fprint(buf, args...)
-	if buf.Bytes()[buf.Len()-1] != '\n' {
+	if buf.Len() == 0 || buf.Bytes()[buf.Len()-1] != '\n' {
 		buf.WriteByte('\n')
 	}
 	l.output(s, logger, buf, depth, file, line, false)


Test patch:
diff --git a/klog_test.go b/klog_test.go
index a371845..17caaf4 100644
--- a/klog_test.go
+++ b/klog_test.go
@@ -1416,6 +1416,42 @@ func TestLogFilter(t *testing.T) {
 	}
 }
 
+func TestInfoWithLogr(t *testing.T) {
+	logger := new(testLogr)
+
+	testDataInfo := []struct {
+		msg      string
+		expected testLogrEntry
+	}{{
+		msg: "foo",
+		expected: testLogrEntry{
+			severity: infoLog,
+			msg:      "foo\n",
+		},
+	}, {
+		msg: "",
+		expected: testLogrEntry{
+			severity: infoLog,
+			msg:      "\n",
+		},
+	}}
+
+	for _, data := range testDataInfo {
+		t.Run(data.msg, func(t *testing.T) {
+			l := logr.New(logger)
+			SetLogger(l)
+			defer ClearLogger()
+			defer logger.reset()
+
+			Info(data.msg)
+
+			if !reflect.DeepEqual(logger.entries, []testLogrEntry{data.expected}) {
+				t.Errorf("expected: %+v; but got: %+v", []testLogrEntry{data.expected}, logger.entries)
+			}
+		})
+	}
+}
+
 func TestInfoSWithLogr(t *testing.T) {
 	logger := new(testLogr)