diff --git a/e2e/newenemy/newenemy_test.go b/e2e/newenemy/newenemy_test.go index 0bb031eeca..8b9eace313 100644 --- a/e2e/newenemy/newenemy_test.go +++ b/e2e/newenemy/newenemy_test.go @@ -162,20 +162,20 @@ func TestNoNewEnemy(t *testing.T) { protected, attempts = checkSchemaNoNewEnemy(ctx, t, schemaData, slowNodeId, crdb, vulnerableSpiceDb, 100) } require.False(t, protected) - t.Logf("determined spicedb vulnerable in %d attempts", attempts+1) + t.Logf("determined spicedb vulnerable in %d attempts", attempts) return attempts } protectedFn := func(t *testing.T, count int) { - t.Logf("check spicedb is protected after %d attempts", count+1) + t.Logf("check spicedb is protected after %d attempts", count) protected := true var attempts int for protected { - protected, attempts = checkDataNoNewEnemy(ctx, t, schemaData, slowNodeId, crdb, protectedSpiceDb, count) + protected, attempts = checkSchemaNoNewEnemy(ctx, t, schemaData, slowNodeId, crdb, protectedSpiceDb, count) if attempts < count { continue } require.True(t, protected, "protection is enabled, but newenemy detected") - require.Equal(t, attempts, count) + require.Equal(t, count, attempts) t.Logf("spicedb is protected after %d attempts", count) return } @@ -205,7 +205,7 @@ func TestNoNewEnemy(t *testing.T) { continue } require.True(t, protected, "protection is enabled, but newenemy detected") - require.Equal(t, attempts, count) + require.Equal(t, count, attempts) t.Logf("spicedb is protected after %d attempts", count) return } @@ -276,7 +276,8 @@ func checkDataNoNewEnemy(ctx context.Context, t testing.TB, schemaData []SchemaD t.Log("filling with data to span multiple ranges for prefix", prefix) fill(t, spicedb[0].Client().V0().ACL(), prefix, 4000, 1000) - for attempts := 1; attempts < maxAttempts+1; attempts++ { + attempts := 1 + for ; attempts <= maxAttempts; attempts++ { direct, exclude := generateTuple(prefix, objIdGenerator) // write to node 1 @@ -379,7 +380,8 @@ func checkSchemaNoNewEnemy(ctx context.Context, t testing.TB, schemaData []Schem require.NoError(t, schemaTpl.Execute(&b, SchemaData{Prefixes: []string{prefix}})) excludeSchema := b.String() - for attempts := 1; attempts < maxAttempts+1; attempts++ { + attempts := 1 + for ; attempts <= maxAttempts; attempts++ { direct, exclude := generateTuple(prefix, objIdGenerator) // write the "allow" schema @@ -448,7 +450,7 @@ func checkSchemaNoNewEnemy(ctx context.Context, t testing.TB, schemaData []Schem continue } } - return true, maxAttempts + 1 + return true, maxAttempts } func BenchmarkBatchWrites(b *testing.B) {