Repository: microsoft/garnet
File: test/Garnet.test.cluster/ClusterReplicationTests.cs (C#)

Code before:
            const string Password = "temp-password";

            const string ClusterUserName = "cluster-user";
            const string ClusterPassword = "cluster-password";

            // setup a cluster (mimicing the style in which this bug was first found)
            ServerCredential clusterCreds = new(ClusterUserName, ClusterPassword, IsAdmin: true, UsedForClusterAuth: true, IsClearText: true);
            ServerCredential userCreds = new(UserName, Password, IsAdmin: true, UsedForClusterAuth: false, IsClearText: true);

            context.GenerateCredentials([userCreds, clusterCreds]);
            context.CreateInstances(2, disableObjects: true, disablePubSub: true, enableAOF: true, clusterCreds: clusterCreds, useAcl: true, MainMemoryReplication: true, CommitFrequencyMs: -1);
            var primaryEndpoint = (IPEndPoint)context.endpoints.First();
            var replicaEndpoint = (IPEndPoint)context.endpoints.Last();

            Assert.AreNotEqual(primaryEndpoint, replicaEndpoint, "Should have different endpoints for nodes");

            using var primaryConnection = ConnectionMultiplexer.Connect($"{primaryEndpoint.Address}:{primaryEndpoint.Port},user={UserName},password={Password}");
            var primaryServer = primaryConnection.GetServer(primaryEndpoint);

            Assert.AreEqual("OK", (string)primaryServer.Execute("CLUSTER", ["ADDSLOTSRANGE", "0", "16383"], flags: CommandFlags.NoRedirect));
            Assert.AreEqual("OK", (string)primaryServer.Execute("CLUSTER", ["MEET", replicaEndpoint.Address.ToString(), replicaEndpoint.Port.ToString()], flags: CommandFlags.NoRedirect));

            using var replicaConnection = ConnectionMultiplexer.Connect($"{replicaEndpoint.Address}:{replicaEndpoint.Port},user={UserName},password={Password}");
            var replicaServer = replicaConnection.GetServer(replicaEndpoint);

            // try to replicate from a server that doesn't exist
            var exc = Assert.Throws<RedisServerException>(() => replicaServer.Execute("CLUSTER", ["REPLICATE", Guid.NewGuid().ToString()], flags: CommandFlags.NoRedirect));
            Assert.IsTrue(exc.Message.StartsWith("ERR I don't know about node "));
        }
    }
}

Review comment (suggestion):
```suggestion
            // Try to replicate from a server that doesn't exist
```

Code after:
            const string Password = "temp-password";

            const string ClusterUserName = "cluster-user";
            const string ClusterPassword = "cluster-password";

            // Setup a cluster (mimicking the style in which this bug was first found)
            ServerCredential clusterCreds = new(ClusterUserName, ClusterPassword, IsAdmin: true, UsedForClusterAuth: true, IsClearText: true);
            ServerCredential userCreds = new(UserName, Password, IsAdmin: true, UsedForClusterAuth: false, IsClearText: true);

            context.GenerateCredentials([userCreds, clusterCreds]);
            context.CreateInstances(2, disableObjects: true, disablePubSub: true, enableAOF: true, clusterCreds: clusterCreds, useAcl: true, MainMemoryReplication: true, CommitFrequencyMs: -1);
            var primaryEndpoint = (IPEndPoint)context.endpoints.First();
            var replicaEndpoint = (IPEndPoint)context.endpoints.Last();

            Assert.AreNotEqual(primaryEndpoint, replicaEndpoint, "Should have different endpoints for nodes");

            using var primaryConnection = ConnectionMultiplexer.Connect($"{primaryEndpoint.Address}:{primaryEndpoint.Port},user={UserName},password={Password}");
            var primaryServer = primaryConnection.GetServer(primaryEndpoint);

            Assert.AreEqual("OK", (string)primaryServer.Execute("CLUSTER", ["ADDSLOTSRANGE", "0", "16383"], flags: CommandFlags.NoRedirect));
            Assert.AreEqual("OK", (string)primaryServer.Execute("CLUSTER", ["MEET", replicaEndpoint.Address.ToString(), replicaEndpoint.Port.ToString()], flags: CommandFlags.NoRedirect));

            using var replicaConnection = ConnectionMultiplexer.Connect($"{replicaEndpoint.Address}:{replicaEndpoint.Port},user={UserName},password={Password}");
            var replicaServer = replicaConnection.GetServer(replicaEndpoint);

            // Try to replicate from a server that doesn't exist
            var exc = Assert.Throws<RedisServerException>(() => replicaServer.Execute("CLUSTER", ["REPLICATE", Guid.NewGuid().ToString()], flags: CommandFlags.NoRedirect));
            Assert.IsTrue(exc.Message.StartsWith("ERR I don't know about node "));
        }
    }
}