text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
func TestParseLocalboot(t *testing.T) {
b, _, err := parseLocalbootFlags("grub", []string{})
if err != nil {
t.Errorf(`parseLocalbootFlags("grub", []string{}) = _, _, %v, want nil`, err)
}
if b.Method != "grub" {
t.Errorf(`b.Method = %q, want "grub"`, b.Method)
}
flags := []string{
"device",
"path",
}
b, _, err = parseLocalbootFlags("path", flags)
if err != nil {
t.Errorf(`parseLocalbootFlags("grub", %v) = _, _, %v, want nil`, flags, err)
}
if b.Method != "path" || b.DeviceGUID != "device" || b.Kernel != "path" {
t.Errorf(`b.Method, b.DeviceGUID, b.Kernel = %q, %q, %q`, b.Method, b.DeviceGUID, b.Kernel)
}
} | explode_data.jsonl/25074 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
14463,
7319,
4619,
1155,
353,
8840,
836,
8,
341,
2233,
11,
8358,
1848,
1669,
4715,
7319,
4619,
9195,
445,
901,
392,
497,
3056,
917,
37790,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
5809,
6400,
7319,
4619,
9195,
445,
901... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestELEMENTMul(t *testing.T) {
parameters := gopter.DefaultTestParameters()
parameters.MinSuccessfulTests = 10000
properties := gopter.NewProperties(parameters)
genA := gen()
genB := gen()
properties.Property("Having the receiver as operand should output the same result", prop.ForAll(
func(a, b testPairElement) bool {
var c, d Element
d.Set(&a.element)
c.Mul(&a.element, &b.element)
a.element.Mul(&a.element, &b.element)
b.element.Mul(&d, &b.element)
return a.element.Equal(&b.element) && a.element.Equal(&c) && b.element.Equal(&c)
},
genA,
genB,
))
properties.Property("Operation result must match big.Int result", prop.ForAll(
func(a, b testPairElement) bool {
var c Element
c.Mul(&a.element, &b.element)
var d, e big.Int
d.Mul(&a.bigint, &b.bigint).Mod(&d, Modulus())
return c.FromMont().ToBigInt(&e).Cmp(&d) == 0
},
genA,
genB,
))
properties.Property("Operation result must be smaller than modulus", prop.ForAll(
func(a, b testPairElement) bool {
var c Element
c.Mul(&a.element, &b.element)
return !c.biggerOrEqualModulus()
},
genA,
genB,
))
properties.Property("Assembly implementation must be consistent with generic one", prop.ForAll(
func(a, b testPairElement) bool {
var c, d Element
c.Mul(&a.element, &b.element)
_mulGeneric(&d, &a.element, &b.element)
return c.Equal(&d)
},
genA,
genB,
))
properties.TestingRun(t, gopter.ConsoleReporter(false))
} | explode_data.jsonl/70338 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 606
} | [
2830,
3393,
91754,
59155,
1155,
353,
8840,
836,
8,
1476,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
17070,
36374,
18200,
284,
220,
16,
15,
15,
15,
15,
271,
86928,
1669,
728,
73137,
7121,
7903,
37959,
692,
82281,
32,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGeoIP(t *testing.T) {
ip := net.ParseIP("103.14.100.100")
t.Log(Query(ip))
if Query(ip) != "HK" {
t.Error("ip mismatch")
}
} | explode_data.jsonl/52885 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
37344,
3298,
1155,
353,
8840,
836,
8,
341,
46531,
1669,
4179,
8937,
3298,
445,
16,
15,
18,
13,
16,
19,
13,
16,
15,
15,
13,
16,
15,
15,
5130,
3244,
5247,
59036,
23443,
1171,
743,
11361,
23443,
8,
961,
330,
57447,
1,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestLocalPrefix(t *testing.T) {
defer func(s string) { LocalPrefix = s }(LocalPrefix)
LocalPrefix = "foo/"
testConfig{
gopathFiles: map[string]string{
"foo/bar/bar.go": "package bar \n const X = 1",
},
}.test(t, func(t *goimportTest) {
buf, err := Process(t.gopath+"/src/test/t.go", []byte("package main \n const Y = bar.X \n const _ = runtime.GOOS"), &Options{})
if err != nil {
t.Fatal(err)
}
const want = `package main
import (
"runtime"
"foo/bar"
)
const Y = bar.X
const _ = runtime.GOOS
`
if string(buf) != want {
t.Errorf("Got:\n%s\nWant:\n%s", buf, want)
}
})
} | explode_data.jsonl/12432 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
7319,
14335,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
1141,
914,
8,
314,
8774,
14335,
284,
274,
95916,
7319,
14335,
340,
82404,
14335,
284,
330,
7975,
85312,
18185,
2648,
515,
197,
3174,
35111,
10809,
25,
2415,
14032,
3095... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue19384(t *testing.T) {
cookies := []*http.Cookie{{Name: "name", Value: "value"}}
for _, host := range []string{"", ".", "..", "..."} {
jar, _ := New(nil)
u := &url.URL{Scheme: "http", Host: host, Path: "/"}
if got := jar.Cookies(u); len(got) != 0 {
t.Errorf("host %q, got %v", host, got)
}
jar.SetCookies(u, cookies)
if got := jar.Cookies(u); len(got) != 1 || got[0].Value != "value" {
t.Errorf("host %q, got %v", host, got)
}
}
} | explode_data.jsonl/14673 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
42006,
16,
24,
18,
23,
19,
1155,
353,
8840,
836,
8,
341,
197,
44317,
1669,
29838,
1254,
82918,
2979,
675,
25,
330,
606,
497,
5162,
25,
330,
957,
95642,
2023,
8358,
3468,
1669,
2088,
3056,
917,
4913,
497,
68514,
32213,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPreAuthorizeSuffix(t *testing.T) {
runPreAuthorizeHandler(
t, nil, "/different-authorize",
regexp.MustCompile(`/authorize\z`),
&api.Response{},
200, 404)
} | explode_data.jsonl/2401 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
4703,
37483,
40177,
1155,
353,
8840,
836,
8,
341,
56742,
4703,
37483,
3050,
1006,
197,
3244,
11,
2092,
11,
3521,
63650,
42702,
551,
756,
197,
37013,
4580,
98626,
31813,
52022,
59,
89,
89746,
197,
197,
5,
2068,
12574,
38837,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestRedactf(t *testing.T) {
backend := InitForTesting(DEBUG)
password := Password("123456")
log := NewLogger("test")
log.Debugf("foo %s", password)
if "foo ******" != MemoryRecordN(backend, 0).Formatted(0, false) {
t.Errorf("redacted line: %v", MemoryRecordN(backend, 0).Formatted(0, false))
}
} | explode_data.jsonl/76185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
6033,
531,
69,
1155,
353,
8840,
836,
8,
341,
197,
20942,
1669,
15690,
2461,
16451,
52792,
340,
58199,
1669,
12362,
445,
16,
17,
18,
19,
20,
21,
1138,
6725,
1669,
1532,
7395,
445,
1944,
1138,
6725,
88278,
445,
7975,
1018,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFormatterUnusedError(test *testing.T) {
writer := &WriterError{
Skip: 1,
}
assert.Error(test, formatter.New().FormatWriter(writer, "{p}", 2, 5))
} | explode_data.jsonl/39741 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 61
} | [
2830,
3393,
14183,
94033,
1454,
8623,
353,
8840,
836,
8,
341,
38959,
1669,
609,
6492,
1454,
515,
197,
7568,
13389,
25,
220,
16,
345,
197,
630,
6948,
6141,
8623,
11,
24814,
7121,
1005,
4061,
6492,
38356,
11,
13868,
79,
9545,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestBitMatrixParser_ReadFormatInformation(t *testing.T) {
img, _ := gozxing.ParseStringToBitMatrix(qrstr, "##", " ")
p, _ := NewBitMatrixParser(img)
info, e := p.ReadFormatInformation()
if e != nil {
t.Fatalf("ReadFormatInformation returns error, %v", e)
}
if r := info.GetErrorCorrectionLevel(); r != ErrorCorrectionLevel_L {
t.Fatalf("ErrorCollectionLevel = %v, expect L", r)
}
if r := info.GetDataMask(); r != 7 {
t.Fatalf("DataMask = %v, expect 7", r)
}
info2, e := p.ReadFormatInformation()
if e != nil {
t.Fatalf("ReadFormatInformation returns error, %v", e)
}
if info != info2 {
t.Fatalf("info and info2 must be same, %p, %p", info, info2)
}
for i := 0; i < 21; i++ {
img.Unset(i, 8)
}
p, _ = NewBitMatrixParser(img)
info, e = p.ReadFormatInformation()
if _, ok := e.(gozxing.FormatException); !ok {
t.Fatalf("ReadFormatInformation must return FormatException, %T", e)
}
} | explode_data.jsonl/32239 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 359
} | [
2830,
3393,
8344,
6689,
6570,
38381,
4061,
14873,
1155,
353,
8840,
836,
8,
341,
39162,
11,
716,
1669,
728,
66700,
287,
8937,
703,
1249,
8344,
6689,
10583,
81,
495,
11,
330,
565,
497,
330,
220,
14167,
3223,
11,
716,
1669,
1532,
8344,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestRuneEncodeDecode(t *testing.T) {
tt := &TestType{}
r := 'r'
rp := &r
tt.Rune = r
tt.RunePtr = &r
tt.RunePtrPtr = &rp
tt.RuneSlice = []rune{'a', 'b', '😳'}
var buf bytes.Buffer
wrt := msgp.NewWriter(&buf)
if err := tt.EncodeMsg(wrt); err != nil {
t.Errorf("%v", err)
}
wrt.Flush()
var out TestType
rdr := msgp.NewReader(&buf)
if err := (&out).DecodeMsg(rdr); err != nil {
t.Errorf("%v", err)
}
if r != out.Rune {
t.Errorf("rune mismatch: expected %c found %c", r, out.Rune)
}
if r != *out.RunePtr {
t.Errorf("rune ptr mismatch: expected %c found %c", r, *out.RunePtr)
}
if r != **out.RunePtrPtr {
t.Errorf("rune ptr ptr mismatch: expected %c found %c", r, **out.RunePtrPtr)
}
if !reflect.DeepEqual(tt.RuneSlice, out.RuneSlice) {
t.Errorf("rune slice mismatch")
}
} | explode_data.jsonl/76327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 383
} | [
2830,
3393,
49,
2886,
32535,
32564,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
609,
2271,
929,
16094,
7000,
1669,
364,
81,
1248,
7000,
79,
1669,
609,
81,
198,
3244,
83,
2013,
2886,
284,
435,
198,
3244,
83,
2013,
2886,
5348,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAveragingInIncrementProposerPriorityWithVotingPower(t *testing.T) {
// Other than TestAveragingInIncrementProposerPriority this is a more complete test showing
// how each ProposerPriority changes in relation to the validator's voting power respectively.
// average is zero in each round:
vp0 := int64(10)
vp1 := int64(1)
vp2 := int64(1)
total := vp0 + vp1 + vp2
avg := (vp0 + vp1 + vp2 - total) / 3
vals := ValidatorSet{Validators: []*Validator{
{Address: []byte{0}, ProposerPriority: 0, VotingPower: vp0},
{Address: []byte{1}, ProposerPriority: 0, VotingPower: vp1},
{Address: []byte{2}, ProposerPriority: 0, VotingPower: vp2}}}
tcs := []struct {
vals *ValidatorSet
wantProposerPrioritys []int64
times int
wantProposer *Validator
}{
0: {
vals.Copy(),
[]int64{
// Acumm+VotingPower-Avg:
0 + vp0 - total - avg, // mostest will be subtracted by total voting power (12)
0 + vp1,
0 + vp2},
1,
vals.Validators[0]},
1: {
vals.Copy(),
[]int64{
(0 + vp0 - total) + vp0 - total - avg, // this will be mostest on 2nd iter, too
(0 + vp1) + vp1,
(0 + vp2) + vp2},
2,
vals.Validators[0]}, // increment twice -> expect average to be subtracted twice
2: {
vals.Copy(),
[]int64{
0 + 3*(vp0-total) - avg, // still mostest
0 + 3*vp1,
0 + 3*vp2},
3,
vals.Validators[0]},
3: {
vals.Copy(),
[]int64{
0 + 4*(vp0-total), // still mostest
0 + 4*vp1,
0 + 4*vp2},
4,
vals.Validators[0]},
4: {
vals.Copy(),
[]int64{
0 + 4*(vp0-total) + vp0, // 4 iters was mostest
0 + 5*vp1 - total, // now this val is mostest for the 1st time (hence -12==totalVotingPower)
0 + 5*vp2},
5,
vals.Validators[1]},
5: {
vals.Copy(),
[]int64{
0 + 6*vp0 - 5*total, // mostest again
0 + 6*vp1 - total, // mostest once up to here
0 + 6*vp2},
6,
vals.Validators[0]},
6: {
vals.Copy(),
[]int64{
0 + 7*vp0 - 6*total, // in 7 iters this val is mostest 6 times
0 + 7*vp1 - total, // in 7 iters this val is mostest 1 time
0 + 7*vp2},
7,
vals.Validators[0]},
7: {
vals.Copy(),
[]int64{
0 + 8*vp0 - 7*total, // mostest again
0 + 8*vp1 - total,
0 + 8*vp2},
8,
vals.Validators[0]},
8: {
vals.Copy(),
[]int64{
0 + 9*vp0 - 7*total,
0 + 9*vp1 - total,
0 + 9*vp2 - total}, // mostest
9,
vals.Validators[2]},
9: {
vals.Copy(),
[]int64{
0 + 10*vp0 - 8*total, // after 10 iters this is mostest again
0 + 10*vp1 - total, // after 6 iters this val is "mostest" once and not in between
0 + 10*vp2 - total}, // in between 10 iters this val is "mostest" once
10,
vals.Validators[0]},
10: {
vals.Copy(),
[]int64{
0 + 11*vp0 - 9*total,
0 + 11*vp1 - total, // after 6 iters this val is "mostest" once and not in between
0 + 11*vp2 - total}, // after 10 iters this val is "mostest" once
11,
vals.Validators[0]},
}
for i, tc := range tcs {
tc.vals.IncrementProposerPriority(tc.times)
assert.Equal(t, tc.wantProposer.Address, tc.vals.GetProposer().Address,
"test case: %v",
i)
for valIdx, val := range tc.vals.Validators {
assert.Equal(t,
tc.wantProposerPrioritys[valIdx],
val.ProposerPriority,
"test case: %v, validator: %v",
i,
valIdx)
}
}
} | explode_data.jsonl/28321 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1641
} | [
2830,
3393,
32,
423,
4118,
641,
38311,
2008,
23438,
20555,
2354,
53,
11519,
14986,
1155,
353,
8840,
836,
8,
341,
197,
322,
6944,
1091,
3393,
32,
423,
4118,
641,
38311,
2008,
23438,
20555,
419,
374,
264,
803,
4583,
1273,
9027,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRuleInsertSelect(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := []string{
`INSERT INTO tbl SELECT * FROM tbl2;`,
}
for _, sql := range sqls {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleInsertSelect()
if rule.Item != "LCK.001" {
t.Error("Rule not match:", rule.Item, "Expect : LCK.001")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76777 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
11337,
13780,
3379,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
3056,
917,
515,
197,
197,
63,
12698,
12496,
21173,
19094,
353,
4295,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestTxnCoordSenderHeartbeat(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
s := createTestDBWithKnobs(t, &kvserver.StoreTestingKnobs{
DisableScanner: true,
DisableSplitQueue: true,
DisableMergeQueue: true,
})
defer s.Stop()
ctx := context.Background()
keyA := roachpb.Key("a")
keyC := roachpb.Key("c")
splitKey := roachpb.Key("b")
if err := s.DB.AdminSplit(ctx, splitKey /* splitKey */, hlc.MaxTimestamp /* expirationTimestamp */); err != nil {
t.Fatal(err)
}
// Make a db with a short heartbeat interval.
ambient := log.AmbientContext{Tracer: tracing.NewTracer()}
tsf := NewTxnCoordSenderFactory(
TxnCoordSenderFactoryConfig{
AmbientCtx: ambient,
// Short heartbeat interval.
HeartbeatInterval: time.Millisecond,
Settings: s.Cfg.Settings,
Clock: s.Clock,
Stopper: s.Stopper(),
},
NewDistSenderForLocalTestCluster(
s.Cfg.Settings, &roachpb.NodeDescriptor{NodeID: 1},
ambient.Tracer, s.Clock, s.Latency, s.Stores, s.Stopper(), s.Gossip,
),
)
quickHeartbeatDB := kv.NewDB(ambient, tsf, s.Clock, s.Stopper())
// We're going to test twice. In both cases the heartbeat is supposed to
// notice that its transaction is aborted, but:
// - once the abort span is populated on the txn's range.
// - once the abort span is not populated.
// The two conditions are created by either clearing an intent from the txn's
// range or not (i.e. clearing an intent from another range).
// The difference is supposed to be immaterial for the heartbeat loop (that's
// what we're testing). As of June 2018, HeartbeatTxnRequests don't check the
// abort span.
for _, pusherKey := range []roachpb.Key{keyA, keyC} {
t.Run(fmt.Sprintf("pusher:%s", pusherKey), func(t *testing.T) {
// Make a db with a short heartbeat interval.
initialTxn := kv.NewTxn(ctx, quickHeartbeatDB, 0 /* gatewayNodeID */)
tc := initialTxn.Sender().(*TxnCoordSender)
if err := initialTxn.Put(ctx, keyA, []byte("value")); err != nil {
t.Fatal(err)
}
if err := initialTxn.Put(ctx, keyC, []byte("value")); err != nil {
t.Fatal(err)
}
// Verify 3 heartbeats.
var heartbeatTS hlc.Timestamp
for i := 0; i < 3; i++ {
testutils.SucceedsSoon(t, func() error {
txn, pErr := getTxn(ctx, initialTxn)
if pErr != nil {
t.Fatal(pErr)
}
// Advance clock by 1ns.
s.Manual.Increment(1)
if lastActive := txn.LastActive(); heartbeatTS.Less(lastActive) {
heartbeatTS = lastActive
return nil
}
return errors.Errorf("expected heartbeat")
})
}
// Push our txn with another high-priority txn.
{
if err := s.DB.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error {
if err := txn.SetUserPriority(roachpb.MaxUserPriority); err != nil {
return err
}
return txn.Put(ctx, pusherKey, []byte("pusher val"))
}); err != nil {
t.Fatal(err)
}
}
// Verify that the abort is discovered and the heartbeat discontinued.
// This relies on the heartbeat loop stopping once it figures out that the txn
// has been aborted.
testutils.SucceedsSoon(t, func() error {
if tc.IsTracking() {
return fmt.Errorf("transaction is not aborted")
}
return nil
})
// Trying to do something else should give us a TransactionAbortedError.
_, err := initialTxn.Get(ctx, "a")
assertTransactionAbortedError(t, err)
})
}
} | explode_data.jsonl/76884 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1395
} | [
2830,
3393,
31584,
77,
19437,
20381,
45384,
22227,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
340,
1903,
1669,
1855,
2271,
3506,
2354,
36253,
5481,
1155,
11,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSaveUndeliveredEvents(t *testing.T) {
common.SetUpMockConfig()
defer func() {
err := common.TruncateDB(common.OnDisk)
if err != nil {
t.Fatalf("error: %v", err)
}
}()
eventByte := []byte(`event`)
if cerr := SaveUndeliveredEvents("destination", eventByte); cerr != nil {
t.Errorf("Error while making save undelivered events : %v\n", cerr.Error())
}
} | explode_data.jsonl/49419 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
8784,
19957,
301,
43056,
7900,
1155,
353,
8840,
836,
8,
341,
83825,
4202,
2324,
11571,
2648,
741,
16867,
2915,
368,
341,
197,
9859,
1669,
4185,
8240,
26900,
3506,
57802,
8071,
47583,
340,
197,
743,
1848,
961,
2092,
341,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNextGreatestLetter(t *testing.T) {
if NextGreatestLetter([]byte("cfj"), byte('a')) != byte('c') {
t.Fail()
}
if NextGreatestLetter([]byte("cfj"), byte('c')) != byte('f') {
t.Fail()
}
if NextGreatestLetter([]byte("cfj"), byte('d')) != byte('f') {
t.Fail()
}
if NextGreatestLetter([]byte("cfj"), byte('g')) != byte('j') {
t.Fail()
}
if NextGreatestLetter([]byte("cfj"), byte('j')) != byte('c') {
t.Fail()
}
if NextGreatestLetter([]byte("cfj"), byte('k')) != byte('c') {
t.Fail()
}
if NextGreatestLetter([]byte("eeeeeennnn"), byte('e')) != byte('n') {
t.Fail()
}
} | explode_data.jsonl/11608 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
5847,
38,
11175,
34264,
1155,
353,
8840,
836,
8,
220,
341,
743,
9295,
38,
11175,
34264,
10556,
3782,
445,
9792,
73,
3975,
4922,
492,
64,
3789,
961,
4922,
492,
66,
863,
341,
197,
3244,
57243,
741,
197,
630,
743,
9295,
38,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestFeeUpdateOldDiskFormat(t *testing.T) {
t.Parallel()
// Create a test channel which will be used for the duration of this
// unittest. The channel will be funded evenly with Alice having 5 BTC,
// and Bob having 5 BTC.
aliceChannel, bobChannel, cleanUp, err := CreateTestChannels()
if err != nil {
t.Fatalf("unable to create test channels: %v", err)
}
defer cleanUp()
// helper that counts the number of updates, and number of fee updates
// in the given log.
countLog := func(log *updateLog) (int, int) {
var numUpdates, numFee int
for e := log.Front(); e != nil; e = e.Next() {
htlc := e.Value.(*PaymentDescriptor)
if htlc.EntryType == FeeUpdate {
numFee++
}
numUpdates++
}
return numUpdates, numFee
}
// helper that asserts that Alice's local log and Bob's remote log
// contains the expected number of fee updates and adds.
assertLogItems := func(expFee, expAdd int) {
t.Helper()
expUpd := expFee + expAdd
upd, fees := countLog(aliceChannel.localUpdateLog)
if upd != expUpd {
t.Fatalf("expected %d updates, found %d in Alice's "+
"log", expUpd, upd)
}
if fees != expFee {
t.Fatalf("expected %d fee updates, found %d in "+
"Alice's log", expFee, fees)
}
upd, fees = countLog(bobChannel.remoteUpdateLog)
if upd != expUpd {
t.Fatalf("expected %d updates, found %d in Bob's log",
expUpd, upd)
}
if fees != expFee {
t.Fatalf("expected %d fee updates, found %d in Bob's "+
"log", expFee, fees)
}
}
// First, we'll fetch the current fee rate present within the
// commitment transactions.
startingFeeRate := SatPerKWeight(
aliceChannel.channelState.LocalCommitment.FeePerKw,
)
newFeeRate := startingFeeRate
// We will send a few HTLCs and a fee update.
htlcAmt := lnwire.NewMSatFromSatoshis(0.1 * btcutil.SatoshiPerBitcoin)
const numHTLCs = 30
var htlcs []*lnwire.UpdateAddHTLC
for i := 0; i < numHTLCs; i++ {
htlc, _ := createHTLC(i, htlcAmt)
if _, err := aliceChannel.AddHTLC(htlc, nil); err != nil {
t.Fatalf("unable to add htlc: %v", err)
}
if _, err := bobChannel.ReceiveHTLC(htlc); err != nil {
t.Fatalf("unable to recv htlc: %v", err)
}
htlcs = append(htlcs, htlc)
if i%5 != 0 {
continue
}
// After every 5th HTLC, we'll also include a fee update.
newFeeRate += startingFeeRate
if err := aliceChannel.UpdateFee(newFeeRate); err != nil {
t.Fatalf("unable to update fee for Alice's channel: %v",
err)
}
if err := bobChannel.ReceiveUpdateFee(newFeeRate); err != nil {
t.Fatalf("unable to update fee for Bob's channel: %v",
err)
}
}
// Check that the expected number of items is found in the logs.
expFee := numHTLCs / 5
assertLogItems(expFee, numHTLCs)
// Now, Alice will send a new commitment to Bob, but we'll simulate a
// connection failure, so Bob doesn't get the signature.
aliceSig, aliceHtlcSigs, err := aliceChannel.SignNextCommitment()
if err != nil {
t.Fatalf("unable to sign commitment: %v", err)
}
// Before restarting Alice, to mimic the old format, we fetch the
// pending remote commit from disk, set the UpdateFee message's
// logIndex to 0, and re-write it.
pendingRemoteCommitDiff, err := aliceChannel.channelState.RemoteCommitChainTip()
if err != nil {
t.Fatal(err)
}
for i, u := range pendingRemoteCommitDiff.LogUpdates {
switch u.UpdateMsg.(type) {
case *lnwire.UpdateFee:
pendingRemoteCommitDiff.LogUpdates[i].LogIndex = 0
}
}
err = aliceChannel.channelState.AppendRemoteCommitChain(
pendingRemoteCommitDiff,
)
if err != nil {
t.Fatal(err)
}
// Restart both channels to simulate a connection restart. This will
// trigger a update logs restoration.
aliceChannel, err = restartChannel(aliceChannel)
if err != nil {
t.Fatalf("unable to restart alice: %v", err)
}
bobChannel, err = restartChannel(bobChannel)
if err != nil {
t.Fatalf("unable to restart channel: %v", err)
}
// After a reconnection, Alice will resend the pending updates, that
// was not ACKed by Bob, so we re-send the HTLCs and fee updates.
newFeeRate = startingFeeRate
for i := 0; i < numHTLCs; i++ {
htlc := htlcs[i]
if _, err := bobChannel.ReceiveHTLC(htlc); err != nil {
t.Fatalf("unable to recv htlc: %v", err)
}
if i%5 != 0 {
continue
}
newFeeRate += startingFeeRate
if err := bobChannel.ReceiveUpdateFee(newFeeRate); err != nil {
t.Fatalf("unable to update fee for Bob's channel: %v",
err)
}
}
assertLogItems(expFee, numHTLCs)
// We send Alice's commitment signatures, and finish the state
// transition.
err = bobChannel.ReceiveNewCommitment(aliceSig, aliceHtlcSigs)
if err != nil {
t.Fatalf("bob unable to process alice's commitment: %v", err)
}
bobRevocation, _, err := bobChannel.RevokeCurrentCommitment()
if err != nil {
t.Fatalf("unable to revoke bob commitment: %v", err)
}
bobSig, bobHtlcSigs, err := bobChannel.SignNextCommitment()
if err != nil {
t.Fatalf("bob unable to sign commitment: %v", err)
}
_, _, _, err = aliceChannel.ReceiveRevocation(bobRevocation)
if err != nil {
t.Fatalf("alice unable to recv revocation: %v", err)
}
err = aliceChannel.ReceiveNewCommitment(bobSig, bobHtlcSigs)
if err != nil {
t.Fatalf("alice unable to rev bob's commitment: %v", err)
}
aliceRevocation, _, err := aliceChannel.RevokeCurrentCommitment()
if err != nil {
t.Fatalf("alice unable to revoke commitment: %v", err)
}
_, _, _, err = bobChannel.ReceiveRevocation(aliceRevocation)
if err != nil {
t.Fatalf("bob unable to recv revocation: %v", err)
}
// Both parties should now have the latest fee rate locked-in.
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) != newFeeRate {
t.Fatalf("alice's feePerKw was not locked in")
}
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) != newFeeRate {
t.Fatalf("bob's feePerKw was not locked in")
}
// Finally, to trigger a compactLogs execution, we'll add a new HTLC,
// then force a state transition.
htlc, _ := createHTLC(numHTLCs, htlcAmt)
if _, err := aliceChannel.AddHTLC(htlc, nil); err != nil {
t.Fatalf("unable to add htlc: %v", err)
}
if _, err := bobChannel.ReceiveHTLC(htlc); err != nil {
t.Fatalf("unable to recv htlc: %v", err)
}
if err := forceStateTransition(aliceChannel, bobChannel); err != nil {
t.Fatalf("unable to complete bob's state transition: %v", err)
}
// Finally, check the logs to make sure all fee updates have been
// removed...
assertLogItems(0, numHTLCs+1)
// ...and the final fee rate locked in.
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) != newFeeRate {
t.Fatalf("alice's feePerKw was not locked in")
}
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) != newFeeRate {
t.Fatalf("bob's feePerKw was not locked in")
}
} | explode_data.jsonl/46439 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2614
} | [
2830,
3393,
41941,
4289,
18284,
47583,
4061,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
4230,
264,
1273,
5496,
892,
686,
387,
1483,
369,
279,
8090,
315,
419,
198,
197,
322,
19905,
13,
576,
5496,
686,
387,
23906,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestStreamSelectEqual(t *testing.T) {
executor, _, _, _ := createLegacyExecutorEnv()
sql := "select id from user where id = 1"
result, err := executorStream(executor, sql)
require.NoError(t, err)
wantResult := sandboxconn.StreamRowResult
if !result.Equal(wantResult) {
t.Errorf("result: %+v, want %+v", result, wantResult)
}
} | explode_data.jsonl/67404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
3027,
3379,
2993,
1155,
353,
8840,
836,
8,
341,
67328,
4831,
11,
8358,
8358,
716,
1669,
1855,
77415,
25255,
14359,
2822,
30633,
1669,
330,
1742,
877,
504,
1196,
1380,
877,
284,
220,
16,
698,
9559,
11,
1848,
1669,
31558,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDB_SubscribePush(t *testing.T) {
db := newTestDB(t, nil)
chunks := make([]swarm.Chunk, 0)
var chunksMu sync.Mutex
chunkProcessedTimes := make([]int, 0)
uploadRandomChunks := func(count int) {
chunksMu.Lock()
defer chunksMu.Unlock()
for i := 0; i < count; i++ {
ch := generateTestRandomChunk()
_, err := db.Put(context.Background(), storage.ModePutUpload, ch)
if err != nil {
t.Fatal(err)
}
chunks = append(chunks, ch)
chunkProcessedTimes = append(chunkProcessedTimes, 0)
}
}
// prepopulate database with some chunks
// before the subscription
uploadRandomChunks(10)
// set a timeout on subscription
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// collect all errors from validating addresses, even nil ones
// to validate the number of addresses received by the subscription
errChan := make(chan error)
ch, stop := db.SubscribePush(ctx)
defer stop()
// receive and validate addresses from the subscription
go func() {
var err error
var i int // address index
for {
select {
case got, ok := <-ch:
if !ok {
return
}
chunksMu.Lock()
cIndex := i
want := chunks[cIndex]
chunkProcessedTimes[cIndex]++
chunksMu.Unlock()
if !bytes.Equal(got.Data(), want.Data()) {
err = fmt.Errorf("got chunk %v data %x, want %x", i, got.Data(), want.Data())
}
if !got.Address().Equal(want.Address()) {
err = fmt.Errorf("got chunk %v address %s, want %s", i, got.Address(), want.Address())
}
i++
// send one and only one error per received address
select {
case errChan <- err:
case <-ctx.Done():
return
}
case <-ctx.Done():
return
}
}
}()
// upload some chunks just after subscribe
uploadRandomChunks(5)
time.Sleep(200 * time.Millisecond)
// upload some chunks after some short time
// to ensure that subscription will include them
// in a dynamic environment
uploadRandomChunks(3)
checkErrChan(ctx, t, errChan, len(chunks))
chunksMu.Lock()
for i, pc := range chunkProcessedTimes {
if pc != 1 {
t.Fatalf("chunk on address %s processed %d times, should be only once", chunks[i].Address(), pc)
}
}
chunksMu.Unlock()
} | explode_data.jsonl/68485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 850
} | [
2830,
3393,
3506,
36359,
6273,
16644,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
501,
2271,
3506,
1155,
11,
2092,
692,
23049,
15296,
1669,
1281,
10556,
2280,
2178,
6353,
3122,
11,
220,
15,
340,
2405,
26757,
39120,
12811,
99014,
271,
230... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTxGasLimits(t *testing.T) {
gasGranted := uint64(10)
ante := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
count := tx.(txTest).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-ante")
return ctx, nil
}
txHandlerOpt := func(bapp *baseapp.BaseApp) {
legacyRouter := middleware.NewLegacyRouter()
r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(*msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
any, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return nil, err
}
return &sdk.Result{
MsgResponses: []*codectypes.Any{any},
}, nil
})
legacyRouter.AddRoute(r)
txHandler := testTxHandler(
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry),
TxDecoder: testTxDecoder(encCfg.Amino),
},
ante,
)
bapp.SetTxHandler(txHandler)
}
app := setupBaseApp(t, txHandlerOpt)
header := tmproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
testCases := []struct {
tx txTest
gasUsed uint64
fail bool
}{
{newTxCounter(0, 0), 0, false},
{newTxCounter(1, 1), 2, false},
{newTxCounter(9, 1), 10, false},
{newTxCounter(1, 9), 10, false},
{newTxCounter(10, 0), 10, false},
{newTxCounter(0, 10), 10, false},
{newTxCounter(0, 8, 2), 10, false},
{newTxCounter(0, 5, 1, 1, 1, 1, 1), 10, false},
{newTxCounter(0, 5, 1, 1, 1, 1), 9, false},
{newTxCounter(9, 2), 11, true},
{newTxCounter(2, 9), 11, true},
{newTxCounter(9, 1, 1), 11, true},
{newTxCounter(1, 8, 1, 1), 11, true},
{newTxCounter(11, 0), 11, true},
{newTxCounter(0, 11), 11, true},
{newTxCounter(0, 5, 11), 16, true},
}
for i, tc := range testCases {
tx := tc.tx
tx.GasLimit = gasGranted
gInfo, result, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx)
// check gas used and wanted
require.Equal(t, tc.gasUsed, gInfo.GasUsed, fmt.Sprintf("tc #%d; gas: %v, result: %v, err: %s", i, gInfo, result, err))
// check for out of gas
if !tc.fail {
require.NotNil(t, result, fmt.Sprintf("%d: %v, %v", i, tc, err))
} else {
require.Error(t, err)
require.Nil(t, result)
space, code, _ := sdkerrors.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err)
}
}
} | explode_data.jsonl/30042 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1105
} | [
2830,
3393,
31584,
58728,
94588,
1155,
353,
8840,
836,
8,
341,
3174,
300,
55481,
1669,
2622,
21,
19,
7,
16,
15,
692,
197,
4942,
1669,
2915,
7502,
45402,
9328,
11,
9854,
45402,
81362,
11,
37453,
1807,
8,
320,
51295,
9328,
11,
1465,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTrimElement(t *testing.T) {
var input, result []string
input = []string{"1", " ", "3"}
result = []string{"1", "3"}
assert.Equal(t, result, trimElement(input))
input = []string{"1", "2"}
result = []string{"1", "2"}
assert.Equal(t, result, trimElement(input))
} | explode_data.jsonl/17932 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
25656,
1691,
1155,
353,
8840,
836,
8,
341,
2405,
1946,
11,
1102,
3056,
917,
271,
22427,
284,
3056,
917,
4913,
16,
497,
330,
257,
3670,
330,
18,
16707,
9559,
284,
3056,
917,
4913,
16,
497,
330,
18,
63159,
6948,
12808,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_awsSagemakerPlugin_getEventInfoForHyperparameterTuningJob(t *testing.T) {
// Default config does not contain a roleAnnotationKey -> expecting to get the role from default config
ctx := context.TODO()
defaultCfg := config.GetSagemakerConfig()
defer func() {
_ = config.SetSagemakerConfig(defaultCfg)
}()
t.Run("get event info should return correctly formatted log links for custom training job", func(t *testing.T) {
// Injecting a config which contains a mismatched roleAnnotationKey -> expecting to get the role from the config
configAccessor := viper.NewAccessor(stdConfig.Options{
StrictMode: true,
// Use a different
SearchPaths: []string{"testdata/config2.yaml"},
})
err := configAccessor.UpdateConfig(context.TODO())
assert.NoError(t, err)
awsSageMakerHPOJobHandler := awsSagemakerPlugin{TaskType: hyperparameterTuningJobTaskType}
tjObj := generateMockTrainingJobCustomObj(
sagemakerIdl.InputMode_FILE, sagemakerIdl.AlgorithmName_XGBOOST, "0.90", []*sagemakerIdl.MetricDefinition{},
sagemakerIdl.InputContentType_TEXT_CSV, 1, "ml.m4.xlarge", 25, sagemakerIdl.DistributedProtocol_UNSPECIFIED)
htObj := generateMockHyperparameterTuningJobCustomObj(tjObj, 10, 5)
taskTemplate := generateMockHyperparameterTuningJobTaskTemplate("the job", htObj)
taskCtx := generateMockHyperparameterTuningJobTaskContext(taskTemplate)
hpoJobResource, err := awsSageMakerHPOJobHandler.BuildResource(ctx, taskCtx)
assert.NoError(t, err)
assert.NotNil(t, hpoJobResource)
hpoJob, ok := hpoJobResource.(*hpojobv1.HyperparameterTuningJob)
assert.True(t, ok)
taskInfo, err := awsSageMakerHPOJobHandler.getEventInfoForHyperparameterTuningJob(ctx, hpoJob)
if err != nil {
panic(err)
}
expectedTaskLogs := []*flyteIdlCore.TaskLog{
{
Uri: fmt.Sprintf("https://%s.console.aws.amazon.com/cloudwatch/home?region=%s#logStream:group=/aws/sagemaker/TrainingJobs;prefix=%s;streamFilter=typeLogStreamPrefix",
"us-west-2", "us-west-2", taskCtx.TaskExecutionMetadata().GetTaskExecutionID().GetGeneratedName()),
Name: CloudWatchLogLinkName,
MessageFormat: flyteIdlCore.TaskLog_JSON,
},
{
Uri: fmt.Sprintf("https://%s.console.aws.amazon.com/sagemaker/home?region=%s#/%s/%s",
"us-west-2", "us-west-2", "hyper-tuning-jobs", taskCtx.TaskExecutionMetadata().GetTaskExecutionID().GetGeneratedName()),
Name: HyperparameterTuningJobSageMakerLinkName,
MessageFormat: flyteIdlCore.TaskLog_UNKNOWN,
},
}
expectedCustomInfo, _ := utils.MarshalObjToStruct(map[string]string{})
assert.Equal(t,
func(tis []*flyteIdlCore.TaskLog) []flyteIdlCore.TaskLog {
ret := make([]flyteIdlCore.TaskLog, 0, len(tis))
for _, ti := range tis {
ret = append(ret, *ti)
}
return ret
}(expectedTaskLogs),
func(tis []*flyteIdlCore.TaskLog) []flyteIdlCore.TaskLog {
ret := make([]flyteIdlCore.TaskLog, 0, len(tis))
for _, ti := range tis {
ret = append(ret, *ti)
}
return ret
}(taskInfo.Logs))
if diff := deep.Equal(expectedCustomInfo, taskInfo.CustomInfo); diff != nil {
assert.FailNow(t, "Should be equal.", "Diff: %v", diff)
}
assert.True(t, proto.Equal(taskInfo.Metadata, &event.TaskExecutionMetadata{
ExternalResources: []*event.ExternalResourceInfo{
{
ExternalId: "some-acceptable-name",
},
},
}))
})
} | explode_data.jsonl/51688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1332
} | [
2830,
3393,
62,
8635,
50,
14661,
4407,
11546,
3062,
1556,
1731,
2461,
73946,
16181,
51,
37202,
12245,
1155,
353,
8840,
836,
8,
341,
197,
322,
7899,
2193,
1558,
537,
6644,
264,
3476,
19711,
1592,
1464,
22331,
311,
633,
279,
3476,
504,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateCertTime(t *testing.T) {
cert := Certificate{
ValidPrincipals: []string{"user"},
Key: testPublicKeys["rsa"],
ValidAfter: 50,
ValidBefore: 100,
}
cert.SignCert(rand.Reader, testSigners["ecdsa"])
for ts, ok := range map[int64]bool{
25: false,
50: true,
99: true,
100: false,
125: false,
} {
checker := CertChecker{
Clock: func() time.Time {
return time.Unix(ts, 0)
},
}
checker.IsAuthority = func(k PublicKey) bool {
return bytes.Equal(k.Marshal(),
testPublicKeys["ecdsa"].Marshal())
}
if v := checker.CheckCert("user", &cert); (v == nil) != ok {
t.Errorf("Authenticate(%d): %v", ts, v)
}
}
} | explode_data.jsonl/30249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 458
} | [
2830,
3393,
17926,
36934,
1462,
1155,
353,
8840,
836,
8,
341,
262,
2777,
1669,
31402,
515,
286,
7818,
3533,
5706,
1127,
25,
3056,
917,
4913,
872,
7115,
286,
5309,
25,
1797,
1273,
12676,
8850,
1183,
60869,
8097,
286,
7818,
6025,
25,
41... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDSV_Serialize_FullPkg(t *testing.T) {
d := dsv.NewDSVMust(dsv.DSVOpt{
ParseHeader: dsv.DBool(false),
Serializers: dsv.DSerial(map[string]func(interface{}) ([]byte, bool){
"*dsv_test.X": func(i interface{}) ([]byte, bool) {
switch i.(type) {
case *X:
if i.(*X) == nil {
return []byte("nil"), true
}
return []byte(fmt.Sprintf("+%0.0f", i.(*X).F)), true
}
return []byte{}, false
},
}),
})
bs, e := d.Serialize(&[]Y{
{X: &X{F: 5.00}},
{},
})
if e != nil {
t.Logf("serialization error: %s", e)
t.FailNow()
}
if string(bs) != "+5\nnil" {
t.Logf("serialization wrong: expected=\"+5\\nnil\",got=%q", string(bs))
t.FailNow()
}
} | explode_data.jsonl/11887 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
5936,
53,
1098,
9050,
1400,
617,
47,
7351,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
294,
3492,
7121,
5936,
11187,
590,
1500,
3492,
909,
50,
11169,
417,
515,
197,
10025,
2583,
4047,
25,
294,
3492,
909,
11233,
3576,
1326,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTLSConfig_TLSCertNegative(t *testing.T) {
// test with wrong path
tlsConfig := &TLSConfig{
Path: "dummy/path",
Pem: "",
}
e := tlsConfig.LoadBytes()
assert.NotNil(t, e, "expected error loading certificate for wrong cert path")
c, ok, e := tlsConfig.TLSCert()
assert.Nil(t, e, "error supposed to be nil for empty bytes")
assert.False(t, ok, "expected error loading certificate for wrong cert path")
assert.Nil(t, c, "cert's TLSCert() call returned non empty certificate for wrong cert path")
// test with empty path and empty pem
tlsConfig.Path = ""
e = tlsConfig.LoadBytes()
assert.Nil(t, e, "not supposed to get error for empty path/pem")
c, ok, e = tlsConfig.TLSCert()
assert.Nil(t, e, "error supposed to be nil for empty bytes")
assert.False(t, ok, "expected error loading certificate for empty cert path and empty pem")
assert.Nil(t, c, "cert's TLSCert() call returned non empty certificate for wrong cert path and empty pem")
// test with wrong pem and empty path
tlsConfig.Path = ""
tlsConfig.Pem = "wrongcertpem"
e = tlsConfig.LoadBytes()
assert.Nil(t, e, "unexpected error loading certificate with wrong pem")
c, ok, e = tlsConfig.TLSCert()
assert.Nil(t, c, "cert's TLSCert() call returned non empty certificate")
assert.False(t, ok, "error loading certificate for empty cert path and and wrong pem ")
assert.Nil(t, e, "cert's TLSCert() call returned unexpected error")
} | explode_data.jsonl/78490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 485
} | [
2830,
3393,
45439,
2648,
1139,
43,
3540,
529,
38489,
1155,
353,
8840,
836,
8,
1476,
197,
322,
1273,
448,
4969,
1815,
198,
3244,
4730,
2648,
1669,
609,
45439,
2648,
515,
197,
69640,
25,
330,
31390,
50976,
756,
197,
10025,
336,
25,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRESTMapper(t *testing.T) {
resources := []*APIGroupResources{
{
Group: metav1.APIGroup{
Name: "extensions",
Versions: []metav1.GroupVersionForDiscovery{
{Version: "v1beta"},
},
PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1beta"},
},
VersionedResources: map[string][]metav1.APIResource{
"v1beta": {
{Name: "jobs", Namespaced: true, Kind: "Job"},
{Name: "pods", Namespaced: true, Kind: "Pod"},
},
},
},
{
Group: metav1.APIGroup{
Versions: []metav1.GroupVersionForDiscovery{
{Version: "v1"},
{Version: "v2"},
},
PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1"},
},
VersionedResources: map[string][]metav1.APIResource{
"v1": {
{Name: "pods", Namespaced: true, Kind: "Pod"},
},
"v2": {
{Name: "pods", Namespaced: true, Kind: "Pod"},
},
},
},
// This group tests finding and prioritizing resources that only exist in non-preferred versions
{
Group: metav1.APIGroup{
Name: "unpreferred",
Versions: []metav1.GroupVersionForDiscovery{
{Version: "v1"},
{Version: "v2beta1"},
{Version: "v2alpha1"},
},
PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1"},
},
VersionedResources: map[string][]metav1.APIResource{
"v1": {
{Name: "broccoli", Namespaced: true, Kind: "Broccoli"},
},
"v2beta1": {
{Name: "broccoli", Namespaced: true, Kind: "Broccoli"},
{Name: "peas", Namespaced: true, Kind: "Pea"},
},
"v2alpha1": {
{Name: "broccoli", Namespaced: true, Kind: "Broccoli"},
{Name: "peas", Namespaced: true, Kind: "Pea"},
},
},
},
}
restMapper := NewRESTMapper(resources, nil)
kindTCs := []struct {
input schema.GroupVersionResource
want schema.GroupVersionKind
}{
{
input: schema.GroupVersionResource{
Resource: "pods",
},
want: schema.GroupVersionKind{
Version: "v1",
Kind: "Pod",
},
},
{
input: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
want: schema.GroupVersionKind{
Version: "v1",
Kind: "Pod",
},
},
{
input: schema.GroupVersionResource{
Version: "v2",
Resource: "pods",
},
want: schema.GroupVersionKind{
Version: "v2",
Kind: "Pod",
},
},
{
input: schema.GroupVersionResource{
Resource: "pods",
},
want: schema.GroupVersionKind{
Version: "v1",
Kind: "Pod",
},
},
{
input: schema.GroupVersionResource{
Resource: "jobs",
},
want: schema.GroupVersionKind{
Group: "extensions",
Version: "v1beta",
Kind: "Job",
},
},
{
input: schema.GroupVersionResource{
Resource: "peas",
},
want: schema.GroupVersionKind{
Group: "unpreferred",
Version: "v2beta1",
Kind: "Pea",
},
},
}
for _, tc := range kindTCs {
got, err := restMapper.KindFor(tc.input)
if err != nil {
t.Errorf("KindFor(%#v) unexpected error: %v", tc.input, err)
continue
}
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("KindFor(%#v) = %#v, want %#v", tc.input, got, tc.want)
}
}
resourceTCs := []struct {
input schema.GroupVersionResource
want schema.GroupVersionResource
}{
{
input: schema.GroupVersionResource{
Resource: "pods",
},
want: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
},
{
input: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
want: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
},
{
input: schema.GroupVersionResource{
Version: "v2",
Resource: "pods",
},
want: schema.GroupVersionResource{
Version: "v2",
Resource: "pods",
},
},
{
input: schema.GroupVersionResource{
Resource: "pods",
},
want: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
},
{
input: schema.GroupVersionResource{
Resource: "jobs",
},
want: schema.GroupVersionResource{
Group: "extensions",
Version: "v1beta",
Resource: "jobs",
},
},
}
for _, tc := range resourceTCs {
got, err := restMapper.ResourceFor(tc.input)
if err != nil {
t.Errorf("ResourceFor(%#v) unexpected error: %v", tc.input, err)
continue
}
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("ResourceFor(%#v) = %#v, want %#v", tc.input, got, tc.want)
}
}
} | explode_data.jsonl/14797 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2068
} | [
2830,
3393,
38307,
10989,
1155,
353,
8840,
836,
8,
341,
10202,
2360,
1669,
29838,
7082,
2808,
11277,
515,
197,
197,
515,
298,
197,
2808,
25,
77520,
16,
24922,
2808,
515,
571,
21297,
25,
330,
27609,
756,
571,
17446,
35279,
25,
3056,
40... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAncestoryNames(t *testing.T) {
tests := []struct {
name string
chain []string
to string
want []string
}{
{name: "no parent to root", chain: []string{"foo"}, want: []string{"foo"}},
{name: "no parent to self", chain: []string{"foo"}, to: "foo", want: []string{"foo"}},
{name: "two-level to root", chain: []string{"foo", "bar"}, want: []string{"foo", "bar"}},
{name: "two-level to top", chain: []string{"foo", "bar"}, to: "foo", want: []string{"foo", "bar"}},
{name: "two-level to bottom", chain: []string{"foo", "bar"}, to: "bar", want: []string{"bar"}},
{name: "three-level to mid", chain: []string{"foo", "bar", "baz"}, to: "bar", want: []string{"bar", "baz"}},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
g := NewGomegaWithT(t)
// Create the chain
f := NewForest()
var last *Namespace
for _, nm := range tc.chain {
parent := last
last = f.Get(nm)
last.SetParent(parent)
}
to := f.Get(tc.to)
g.Expect(last.AncestoryNames(to)).Should(Equal(tc.want))
})
}
} | explode_data.jsonl/28405 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 439
} | [
2830,
3393,
2082,
15184,
679,
7980,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
197,
8819,
3056,
917,
198,
197,
31709,
262,
914,
198,
197,
50780,
220,
3056,
917,
198,
197,
59403,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDocTypes(t *testing.T) {
for _, tt := range docTests {
data, err := ioutil.ReadFile(tt.file)
require.Nil(t, err)
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(data))
require.Nil(t, err)
if tt.fn(doc) != tt.expected {
t.Errorf("expect doc check of %v to be %v", tt.file, tt.expected)
}
}
} | explode_data.jsonl/4317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
9550,
4173,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
4629,
18200,
341,
197,
8924,
11,
1848,
1669,
43144,
78976,
47152,
9715,
340,
197,
17957,
59678,
1155,
11,
1848,
692,
197,
59536,
11,
1848,
1669,
728,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMetricProcessorAddPath(t *testing.T) {
processor := GetMetricProcessor()
temp := PathConfig{
Namespace: "xyz",
Path: "/abc",
}
processor.AddPath(temp)
out, _ := processor.paths[temp.Path]
assert.NotNil(t, out)
assert.Equal(t, out.Namespace, temp.Namespace)
} | explode_data.jsonl/70871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
54310,
22946,
2212,
1820,
1155,
353,
8840,
836,
8,
341,
197,
29474,
1669,
2126,
54310,
22946,
741,
16280,
1669,
7933,
2648,
515,
197,
90823,
25,
330,
28854,
756,
197,
69640,
25,
414,
3521,
13683,
756,
197,
532,
197,
29474,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateEcsPlacementConstraint(t *testing.T) {
cases := []struct {
constType string
constExpr string
Err bool
}{
{
constType: "distinctInstance",
constExpr: "",
Err: false,
},
{
constType: "memberOf",
constExpr: "",
Err: true,
},
{
constType: "distinctInstance",
constExpr: "expression",
Err: false,
},
{
constType: "memberOf",
constExpr: "expression",
Err: false,
},
}
for _, tc := range cases {
if err := validateAwsEcsPlacementConstraint(tc.constType, tc.constExpr); err != nil && !tc.Err {
t.Fatalf("Unexpected validation error for \"%s:%s\": %s",
tc.constType, tc.constExpr, err)
}
}
} | explode_data.jsonl/78595 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
17926,
36,
4837,
28237,
17890,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
4777,
929,
914,
198,
197,
4777,
16041,
914,
198,
197,
197,
7747,
981,
1807,
198,
197,
59403,
197,
197,
515,
298,
4777,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestTxInvalidUnsignedTx(t *testing.T) {
ctx := NewContext(t)
c, m := setupCodec()
if err := c.RegisterType(&avax.TestVerifiable{}); err != nil {
t.Fatal(err)
}
tx := &Tx{
UnsignedTx: &BaseTx{BaseTx: avax.BaseTx{
NetworkID: networkID,
BlockchainID: chainID,
Ins: []*avax.TransferableInput{
{
UTXOID: avax.UTXOID{
TxID: ids.Empty,
OutputIndex: 0,
},
Asset: avax.Asset{ID: assetID},
In: &secp256k1fx.TransferInput{
Amt: 20 * units.KiloAvax,
Input: secp256k1fx.Input{
SigIndices: []uint32{
0,
},
},
},
},
{
UTXOID: avax.UTXOID{
TxID: ids.Empty,
OutputIndex: 0,
},
Asset: avax.Asset{ID: assetID},
In: &secp256k1fx.TransferInput{
Amt: 20 * units.KiloAvax,
Input: secp256k1fx.Input{
SigIndices: []uint32{
0,
},
},
},
},
},
}},
Creds: []*FxCredential{
{Verifiable: &avax.TestVerifiable{}},
{Verifiable: &avax.TestVerifiable{}},
},
}
if err := tx.SignSECP256K1Fx(m, nil); err != nil {
t.Fatal(err)
}
if err := tx.SyntacticVerify(ctx, m, ids.Empty, 0, 0, 1); err == nil {
t.Fatalf("Tx should have failed due to an invalid unsigned tx")
}
} | explode_data.jsonl/48914 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 692
} | [
2830,
3393,
31584,
7928,
56421,
31584,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1532,
1972,
1155,
340,
1444,
11,
296,
1669,
6505,
36913,
741,
743,
1848,
1669,
272,
81703,
2099,
10914,
8787,
10141,
22619,
6257,
1215,
1848,
961,
2092,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestIsIPAddress(t *testing.T) {
testCases := []struct {
host string
result bool
}{
{"8.8.8.8", true},
{"example.com", false},
}
for i, tc := range testCases {
t.Run(fmt.Sprintf("%d: %+v", i, tc.host), func(t *testing.T) {
isIP, _ := isIPAddress(tc.host)
if isIP != tc.result {
t.Fatalf("Unexpected result: %+v", isIP)
}
})
}
} | explode_data.jsonl/61135 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
3872,
87976,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
63104,
256,
914,
198,
197,
9559,
1807,
198,
197,
59403,
197,
197,
4913,
23,
13,
23,
13,
23,
13,
23,
497,
830,
1583,
197,
197,
4913,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetYaml(t *testing.T) {
testTables := []struct {
validConfigs ValidConfigs
expectedStrings []string
expectedErr bool
}{
{
validConfigs: ValidConfigs{
configList: &configList{
Items: []config{
{
Params: []ConfigParams{
{
OS: "ubuntu-1710",
Roles: []gceconfigv1.MachineRole{gceconfigv1.MasterRole},
Versions: clusterv1.MachineVersionInfo{
Kubelet: "1.9.4",
ControlPlane: "1.9.4",
},
},
},
Image: "projects/ubuntu-os-cloud/global/images/family/ubuntu-1710",
Metadata: Metadata{
StartupScript: "Master startup script",
},
},
{
Params: []ConfigParams{
{
OS: "ubuntu-1710",
Roles: []gceconfigv1.MachineRole{gceconfigv1.NodeRole},
Versions: clusterv1.MachineVersionInfo{
Kubelet: "1.9.4",
},
},
},
Image: "projects/ubuntu-os-cloud/global/images/family/ubuntu-1710",
Metadata: Metadata{
StartupScript: "Node startup script",
},
},
},
},
},
expectedStrings: []string{"startupScript: Master startup script", "startupScript: Node startup script"},
expectedErr: false,
},
}
for _, table := range testTables {
yaml, err := table.validConfigs.GetYaml()
if err == nil && table.expectedErr {
t.Errorf("An error was not received as expected.")
}
if err != nil && !table.expectedErr {
t.Errorf("Got unexpected error: %s", err)
}
for _, expectedString := range table.expectedStrings {
if !strings.Contains(yaml, expectedString) {
t.Errorf("Yaml did not contain expected string, got:\n%s\nwant:\n%s", yaml, expectedString)
}
}
}
} | explode_data.jsonl/44887 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 852
} | [
2830,
3393,
88300,
9467,
1155,
353,
8840,
836,
8,
341,
18185,
21670,
1669,
3056,
1235,
341,
197,
56322,
84905,
262,
7818,
84905,
198,
197,
42400,
20859,
3056,
917,
198,
197,
42400,
7747,
257,
1807,
198,
197,
59403,
197,
197,
515,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestValidateAuthenticationMeshPolicy(t *testing.T) {
cases := []struct {
name string
configName string
in proto.Message
valid bool
}{
{
name: "good name",
configName: DefaultAuthenticationPolicyName,
in: &authn.Policy{},
valid: true,
},
{
name: "bad-name",
configName: someName,
in: &authn.Policy{},
valid: false,
},
{
name: "has targets",
configName: DefaultAuthenticationPolicyName,
in: &authn.Policy{
Targets: []*authn.TargetSelector{{
Name: "foo",
}},
},
valid: false,
},
{
name: "good",
configName: DefaultAuthenticationPolicyName,
in: &authn.Policy{
Peers: []*authn.PeerAuthenticationMethod{{
Params: &authn.PeerAuthenticationMethod_Mtls{},
}},
},
valid: true,
},
}
for _, c := range cases {
if got := ValidateAuthenticationPolicy(c.configName, "", c.in); (got == nil) != c.valid {
t.Errorf("ValidateAuthenticationPolicy(%v): got(%v) != want(%v): %v\n", c.name, got == nil, c.valid, got)
}
}
} | explode_data.jsonl/56930 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 520
} | [
2830,
3393,
17926,
19297,
14194,
13825,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
25873,
675,
914,
198,
197,
17430,
260,
18433,
8472,
198,
197,
56322,
414,
1807,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_DomainUpdate(t *testing.T) {
client := NewClient("", "", false)
domain, _, err := client.Domain.Update(TestDomainID, "test")
assert.Nil(t, err)
assert.NotEqual(t, domain.Id, "", "Domain Id can not be empty")
return
} | explode_data.jsonl/12040 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
1557,
3121,
4289,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
1532,
2959,
19814,
7342,
895,
692,
2698,
3121,
11,
8358,
1848,
1669,
2943,
20442,
16689,
31159,
13636,
915,
11,
330,
1944,
1138,
6948,
59678,
1155,
11,
1848,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestNewWithStack(t *testing.T) {
t.Parallel()
expect := "abc"
actual := NewWithStack(expect)
//goland:noinspection GoNilness
assert.Equal(t, expect, actual.Error())
} | explode_data.jsonl/80868 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
3564,
2354,
4336,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
24952,
1669,
330,
13683,
1837,
88814,
1669,
1532,
2354,
4336,
89443,
692,
197,
322,
70,
96440,
66479,
53395,
5994,
19064,
2090,
198,
6948,
12808,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestAccAWSDataSourceIAMServerCertificate_basic(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
key := tlsRsaPrivateKeyPem(2048)
certificate := tlsRsaX509SelfSignedCertificatePem(key, "example.com")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckIAMServerCertificateDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsDataIAMServerCertConfig(rName, key, certificate),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("aws_iam_server_certificate.test_cert", "arn"),
resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", "arn"),
resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", "id"),
resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", "name"),
resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", "path"),
resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", "upload_date"),
resource.TestCheckResourceAttr("data.aws_iam_server_certificate.test", "certificate_chain", ""),
resource.TestMatchResourceAttr("data.aws_iam_server_certificate.test", "certificate_body", regexp.MustCompile("^-----BEGIN CERTIFICATE-----")),
),
},
},
})
} | explode_data.jsonl/6772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 502
} | [
2830,
3393,
14603,
36136,
17173,
73707,
5475,
33202,
34729,
1155,
353,
8840,
836,
8,
341,
7000,
675,
1669,
1613,
67880,
26709,
2354,
14335,
445,
8935,
12,
4475,
16839,
5130,
23634,
1669,
55026,
49,
9081,
75981,
47,
336,
7,
17,
15,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSelectMove(t *testing.T) {
e := new(Editor)
e.SetText(`0123456789`)
gtx := layout.Context{Ops: new(op.Ops)}
cache := text.NewCache(gofont.Collection())
font := text.Font{}
fontSize := unit.Px(10)
// Layout once to populate e.lines and get focus.
gtx.Queue = newQueue(key.FocusEvent{Focus: true})
e.Layout(gtx, cache, font, fontSize, nil)
testKey := func(keyName string) {
// Select 345
e.SetCaret(3, 6)
if expected, got := "345", e.SelectedText(); expected != got {
t.Errorf("KeyName %s, expected %q, got %q", keyName, expected, got)
}
// Press the key
gtx.Queue = newQueue(key.Event{State: key.Press, Name: keyName})
e.Layout(gtx, cache, font, fontSize, nil)
if expected, got := "", e.SelectedText(); expected != got {
t.Errorf("KeyName %s, expected %q, got %q", keyName, expected, got)
}
}
testKey(key.NameLeftArrow)
testKey(key.NameRightArrow)
testKey(key.NameUpArrow)
testKey(key.NameDownArrow)
} | explode_data.jsonl/27269 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 382
} | [
2830,
3393,
3379,
9860,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
501,
87136,
340,
7727,
92259,
5809,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
63,
692,
3174,
3998,
1669,
6789,
9328,
90,
38904,
25,
501,
17096,
8382,
1690,
10569,
526... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAddAgentAnnotations(t *testing.T) {
assert := assert.New(t)
config := vc.SandboxConfig{
Annotations: make(map[string]string),
AgentConfig: vc.KataAgentConfig{},
}
ocispec := specs.Spec{
Annotations: make(map[string]string),
}
expectedAgentConfig := vc.KataAgentConfig{
KernelModules: []string{
"e1000e InterruptThrottleRate=3000,3000,3000 EEE=1",
"i915 enable_ppgtt=0",
},
}
ocispec.Annotations[vcAnnotations.KernelModules] = strings.Join(expectedAgentConfig.KernelModules, KernelModulesSeparator)
addAnnotations(ocispec, &config)
assert.Exactly(expectedAgentConfig, config.AgentConfig)
} | explode_data.jsonl/44054 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
2212,
16810,
21418,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
25873,
1669,
24553,
808,
31536,
2648,
515,
197,
197,
21418,
25,
1281,
9147,
14032,
30953,
1326,
197,
197,
16810,
2648,
25,
24553,
11352,
45... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNonEmptyKubeconfig(t *testing.T) {
commands := testutil.CmdRunOut("kpt fn source .", ``).
AndRunOut("kpt fn run", testPod).
AndRunOut(fmt.Sprintf("kpt fn sink %v", tmpKustomizeDir), ``).
AndRunOut("kpt fn sink valid_path", ``).
AndRun("kpt live apply valid_path --context kubecontext --kubeconfig testConfigPath --namespace testNamespace")
testutil.Run(t, "", func(t *testutil.T) {
t.Override(&util.DefaultExecCommand, commands)
t.Override(&client.Client, deployutil.MockK8sClient)
k := NewDeployer(&kptConfig{config: "testConfigPath"}, nil, deploy.NoopComponentProvider, &latestV1.KptDeploy{
Dir: ".",
Live: latestV1.KptLive{
Apply: latestV1.KptApplyInventory{
Dir: "valid_path",
},
},
})
t.CheckNoError(os.Mkdir(k.Live.Apply.Dir, 0755))
defer os.RemoveAll(k.Live.Apply.Dir)
_, err := k.Deploy(context.Background(), ioutil.Discard, []graph.Artifact{})
t.CheckNoError(err)
})
} | explode_data.jsonl/9530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 384
} | [
2830,
3393,
8121,
3522,
42,
3760,
1676,
1155,
353,
8840,
836,
8,
341,
197,
24270,
1669,
1273,
1314,
64512,
6727,
2662,
445,
74,
417,
5168,
2530,
659,
497,
9902,
4292,
197,
197,
3036,
6727,
2662,
445,
74,
417,
5168,
1598,
497,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestObjectMultiWithDelete(t *testing.T) {
s := RunBasicJetStreamServer()
defer shutdown(s)
nc, js := jsClient(t, s)
defer nc.Close()
obs, err := js.CreateObjectStore(&nats.ObjectStoreConfig{Bucket: "2OD"})
expectOk(t, err)
pa := bytes.Repeat([]byte("A"), 2_000_000)
pb := bytes.Repeat([]byte("B"), 3_000_000)
_, err = obs.PutBytes("A", pa)
expectOk(t, err)
// Hold onto this so we can make sure DeleteObject clears all messages, chunks and meta.
si, err := js.StreamInfo("OBJ_2OD")
expectOk(t, err)
_, err = obs.PutBytes("B", pb)
expectOk(t, err)
pb2, err := obs.GetBytes("B")
expectOk(t, err)
if !bytes.Equal(pb, pb2) {
t.Fatalf("Did not retrieve same object")
}
// Now delete B
err = obs.Delete("B")
expectOk(t, err)
siad, err := js.StreamInfo("OBJ_2OD")
expectOk(t, err)
if siad.State.Msgs != si.State.Msgs+1 { // +1 more delete marker.
t.Fatalf("Expected to have %d msgs after delete, got %d", siad.State.Msgs, si.State.Msgs+1)
}
} | explode_data.jsonl/75493 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 411
} | [
2830,
3393,
1190,
20358,
2354,
6435,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
6452,
15944,
35641,
3027,
5475,
741,
16867,
23766,
1141,
692,
197,
1016,
11,
6994,
1669,
6994,
2959,
1155,
11,
274,
340,
16867,
25126,
10421,
2822,
197,
5481... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestValidateSsmParameterType(t *testing.T) {
validTypes := []string{
"String",
"StringList",
"SecureString",
}
for _, v := range validTypes {
_, errors := validateSsmParameterType(v, "name")
if len(errors) != 0 {
t.Fatalf("%q should be a valid SSM parameter type: %q", v, errors)
}
}
invalidTypes := []string{
"foo",
"string",
"Securestring",
}
for _, v := range invalidTypes {
_, errors := validateSsmParameterType(v, "name")
if len(errors) == 0 {
t.Fatalf("%q should be an invalid SSM parameter type", v)
}
}
} | explode_data.jsonl/78628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
17926,
50,
3563,
4971,
929,
1155,
353,
8840,
836,
8,
341,
56322,
4173,
1669,
3056,
917,
515,
197,
197,
1,
703,
756,
197,
197,
1,
703,
852,
756,
197,
197,
1,
49813,
703,
756,
197,
532,
2023,
8358,
348,
1669,
2088,
2697,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDeviceTokenReturnsErrorIfTokenEmptyAndStatusOK(t *testing.T) {
sender := mocks.NewSender()
body := mocks.NewBody("")
sender.AppendResponse(mocks.NewResponseWithBodyAndStatus(body, http.StatusOK, "OK"))
_, err := WaitForUserCompletion(sender, deviceCode())
if err != ErrOAuthTokenEmpty {
t.Fatalf("adal: got wrong error expected(%s) actual(%s)", ErrOAuthTokenEmpty.Error(), err.Error())
}
if body.IsOpen() {
t.Fatalf("response body was left open!")
}
} | explode_data.jsonl/27512 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
6985,
3323,
16446,
1454,
2679,
3323,
3522,
3036,
2522,
3925,
1155,
353,
8840,
836,
8,
341,
1903,
1659,
1669,
68909,
7121,
20381,
741,
35402,
1669,
68909,
7121,
5444,
31764,
1903,
1659,
8982,
2582,
1255,
25183,
7121,
2582,
2354... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAddMessageHook(t *testing.T) {
r := prework_pri(CROSS_ACCOUNT)
r.AddMessageHook(func(msg *Msg) error {
// 添加你的方法
fmt.Println("这是自定义MessageHook")
fmt.Println("当前数据是", msg)
return nil
})
select {}
} | explode_data.jsonl/61325 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
2212,
2052,
31679,
1155,
353,
8840,
836,
8,
1476,
7000,
1669,
855,
1778,
85639,
3025,
44484,
38831,
692,
7000,
1904,
2052,
31679,
18552,
8119,
353,
6611,
8,
1465,
341,
197,
197,
322,
82339,
103929,
39907,
198,
197,
11009,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_ChunkReaderPool(t *testing.T) {
PutChunkReader(nil)
cr1 := GetChunkReader(strings.NewReader(influxText))
assertReadAll(t, cr1)
PutChunkReader(cr1)
cr2 := GetChunkReader(strings.NewReader(influxText))
assertReadAll(t, cr2)
} | explode_data.jsonl/74835 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
27588,
3122,
5062,
10551,
1155,
353,
8840,
836,
8,
341,
10025,
332,
28304,
5062,
27907,
692,
91492,
16,
1669,
2126,
28304,
5062,
51442,
68587,
5900,
36706,
1178,
1171,
6948,
4418,
2403,
1155,
11,
1560,
16,
340,
10025,
332,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_increasingBST(t *testing.T) {
type args struct {
root *TreeNode
}
tests := []struct {
name string
args args
want *TreeNode
}{
// TODO: Add test cases.
{
name: "",
args: args{
root: StrToTreeNode("[5,3,6,2,4,null,8,1,null,null,null,7,9]"),
},
want: StrToTreeNode("[1,null,2,null,3,null,4,null,5,null,6,null,7,null,8,null,9]"),
},
{
name: "",
args: args{
root: StrToTreeNode("[5,1,7]"),
},
want: StrToTreeNode("[1,null,5,null,7]"),
},
}
for _, tt := range tests {
t.Run(
tt.name, func(t *testing.T) {
if got := increasingBST(tt.args.root); !reflect.DeepEqual(got, tt.want) {
t.Errorf("increasingBST() = %v, want %v", got, tt.want)
}
},
)
}
} | explode_data.jsonl/81213 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
1243,
75462,
61006,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
33698,
353,
26597,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
353,
26597,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAssembleCreateSource(t *testing.T) {
Convey("Given a parseStack", t, func() {
ps := parseStack{}
Convey("When the stack contains the correct CREATE SOURCE items", func() {
ps.PushComponent(0, 2, Yes)
ps.PushComponent(2, 4, StreamIdentifier("a"))
ps.PushComponent(4, 6, SourceSinkType("b"))
ps.PushComponent(6, 8, SourceSinkParamAST{"c", data.String("d")})
ps.PushComponent(8, 10, SourceSinkParamAST{"e", data.String("f")})
ps.AssembleSourceSinkSpecs(6, 10)
ps.AssembleCreateSource()
Convey("Then AssembleCreateSource transforms them into one item", func() {
So(ps.Len(), ShouldEqual, 1)
Convey("And that item is a CreateSourceStmt", func() {
top := ps.Peek()
So(top, ShouldNotBeNil)
So(top.begin, ShouldEqual, 0)
So(top.end, ShouldEqual, 10)
So(top.comp, ShouldHaveSameTypeAs, CreateSourceStmt{})
Convey("And it contains the previously pushed data", func() {
comp := top.comp.(CreateSourceStmt)
So(comp.Paused, ShouldEqual, Yes)
So(comp.Name, ShouldEqual, "a")
So(comp.Type, ShouldEqual, "b")
So(len(comp.Params), ShouldEqual, 2)
So(comp.Params[0].Key, ShouldEqual, "c")
So(comp.Params[0].Value, ShouldEqual, data.String("d"))
So(comp.Params[1].Key, ShouldEqual, "e")
So(comp.Params[1].Value, ShouldEqual, data.String("f"))
})
})
})
})
Convey("When the stack does not contain enough items", func() {
ps.PushComponent(6, 7, RowValue{"", "a"})
ps.AssembleProjections(6, 7)
Convey("Then AssembleCreateSource panics", func() {
So(ps.AssembleCreateSource, ShouldPanic)
})
})
Convey("When the stack contains a wrong item", func() {
ps.PushComponent(0, 2, Yes)
ps.PushComponent(2, 4, Raw{"a"}) // must be StreamIdentifier
ps.PushComponent(4, 6, SourceSinkType("b"))
ps.PushComponent(6, 8, SourceSinkParamAST{"c", data.String("d")})
ps.PushComponent(8, 10, SourceSinkParamAST{"e", data.String("f")})
ps.AssembleSourceSinkSpecs(6, 10)
Convey("Then AssembleCreateSource panics", func() {
So(ps.AssembleCreateSource, ShouldPanic)
})
})
})
Convey("Given a parser", t, func() {
p := &bqlPeg{}
Convey("When doing a full CREATE SOURCE", func() {
p.Buffer = `CREATE PAUSED SOURCE a_1 TYPE b_b WITH c=27, e_="f_'1"`
p.Init()
Convey("Then the statement should be parsed correctly", func() {
err := p.Parse()
So(err, ShouldBeNil)
p.Execute()
ps := p.parseStack
So(ps.Len(), ShouldEqual, 1)
top := ps.Peek().comp
So(top, ShouldHaveSameTypeAs, CreateSourceStmt{})
comp := top.(CreateSourceStmt)
So(comp.Paused, ShouldEqual, Yes)
So(comp.Name, ShouldEqual, "a_1")
So(comp.Type, ShouldEqual, "b_b")
So(len(comp.Params), ShouldEqual, 2)
So(comp.Params[0].Key, ShouldEqual, "c")
So(comp.Params[0].Value, ShouldEqual, data.Int(27))
So(comp.Params[1].Key, ShouldEqual, "e_")
So(comp.Params[1].Value, ShouldEqual, data.String("f_'1"))
Convey("And String() should return the original statement", func() {
So(comp.String(), ShouldEqual, p.Buffer)
})
})
})
})
} | explode_data.jsonl/18072 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1350
} | [
2830,
3393,
2121,
15790,
4021,
3608,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
264,
4715,
4336,
497,
259,
11,
2915,
368,
341,
197,
35009,
1669,
4715,
4336,
16094,
197,
93070,
5617,
445,
4498,
279,
5611,
5610,
279,
4396,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJudgeIncureServiceCharge(t *testing.T) {
cases := []struct {
name string
bJudge judiciary // base
input shared.Resources
expectedReturn bool
expectedCommonPool shared.Resources
expectedJudgeBudget shared.Resources
}{
{
name: "Excess pay",
bJudge: judiciary{
JudgeID: shared.Teams["Team1"],
gameState: &gamestate.GameState{
CommonPool: 400,
IIGORolesBudget: map[shared.Role]shared.Resources{
shared.President: 10,
shared.Speaker: 10,
shared.Judge: 100,
},
},
},
input: 50,
expectedReturn: true,
expectedCommonPool: 350,
expectedJudgeBudget: 50,
},
{
name: "Negative Budget",
bJudge: judiciary{
JudgeID: shared.Teams["Team1"],
gameState: &gamestate.GameState{
CommonPool: 400,
IIGORolesBudget: map[shared.Role]shared.Resources{
shared.President: 10,
shared.Speaker: 10,
shared.Judge: 10,
},
},
},
input: 50,
expectedReturn: true,
expectedCommonPool: 350,
expectedJudgeBudget: -40,
},
{
name: "Limited common pool",
bJudge: judiciary{
JudgeID: shared.Teams["Team1"],
gameState: &gamestate.GameState{
CommonPool: 40,
IIGORolesBudget: map[shared.Role]shared.Resources{
shared.President: 10,
shared.Speaker: 10,
shared.Judge: 10,
},
},
},
input: 50,
expectedReturn: false,
expectedCommonPool: 40,
expectedJudgeBudget: 10,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
returned := tc.bJudge.incurServiceCharge(tc.input)
commonPool := tc.bJudge.gameState.CommonPool
judgeBudget := tc.bJudge.gameState.IIGORolesBudget[shared.Judge]
if returned != tc.expectedReturn ||
commonPool != tc.expectedCommonPool ||
judgeBudget != tc.expectedJudgeBudget {
t.Errorf("%v - Failed. Got '%v, %v, %v', but expected '%v, %v, %v'",
tc.name, returned, commonPool, judgeBudget,
tc.expectedReturn, tc.expectedCommonPool, tc.expectedJudgeBudget)
}
})
}
} | explode_data.jsonl/74056 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1002
} | [
2830,
3393,
60256,
39245,
552,
1860,
55363,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
394,
914,
198,
197,
2233,
60256,
1060,
71875,
442,
2331,
198,
197,
22427,
2290,
6094,
21703,
198,
197,
42400,
5598,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestIndexGetEscaped(t *testing.T) {
f := newFixture(t)
get, err := http.NewRequest(http.MethodGet, `/?q=</textarea><script>alert(1)</script>`, strings.NewReader(""))
if err != nil {
panic(err)
}
f.server.Handler.ServeHTTP(f.recorder, get)
if f.recorder.Code != 200 {
t.Errorf("Expected success but got: %v", f.recorder)
return
}
page := f.recorder.Body.String()
exp := "</textarea><script>alert(1)</script>"
if !strings.Contains(page, exp) {
t.Fatalf("Expected page to contain escaped URL parameter but got: %v", page)
}
} | explode_data.jsonl/79004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
1552,
1949,
36121,
10185,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
10366,
11,
1848,
1669,
1758,
75274,
19886,
20798,
1949,
11,
1565,
17763,
80,
28,
522,
11741,
1784,
2282,
52777,
7,
16,
12533,
2282,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestIsOsFs(t *testing.T) {
c := qt.New(t)
c.Assert(IsOsFs(Os), qt.Equals, true)
c.Assert(IsOsFs(&afero.MemMapFs{}), qt.Equals, false)
c.Assert(IsOsFs(afero.NewBasePathFs(&afero.MemMapFs{}, "/public")), qt.Equals, false)
c.Assert(IsOsFs(afero.NewBasePathFs(Os, t.TempDir())), qt.Equals, true)
} | explode_data.jsonl/4616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
3872,
28867,
48300,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
38949,
7121,
1155,
692,
1444,
11711,
65473,
28867,
48300,
19238,
82,
701,
38949,
16207,
11,
830,
340,
1444,
11711,
65473,
28867,
48300,
2099,
64,
802,
78,
1321,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMinerCommitSector(t *testing.T) {
tf.UnitTest(t)
ctx := context.Background()
st, vms := core.CreateStorages(ctx, t)
origPid := th.RequireRandomPeerID(t)
minerAddr := createTestMiner(t, st, vms, address.TestAddress, []byte("my public key"), origPid)
commR := th.MakeCommitment()
commRStar := th.MakeCommitment()
commD := th.MakeCommitment()
res, err := th.CreateAndApplyTestMessage(t, st, vms, minerAddr, 0, 3, "commitSector", nil, uint64(1), commD, commR, commRStar, th.MakeRandomBytes(types.TwoPoRepProofPartitions.ProofLen()))
require.NoError(t, err)
require.NoError(t, res.ExecutionError)
require.Equal(t, uint8(0), res.Receipt.ExitCode)
// check that the proving period matches
res, err = th.CreateAndApplyTestMessage(t, st, vms, minerAddr, 0, 3, "getProvingPeriodStart", nil)
require.NoError(t, err)
require.NoError(t, res.ExecutionError)
// blockheight was 3
require.Equal(t, types.NewBlockHeight(3), types.NewBlockHeightFromBytes(res.Receipt.Return[0]))
// fail because commR already exists
res, err = th.CreateAndApplyTestMessage(t, st, vms, minerAddr, 0, 4, "commitSector", nil, uint64(1), commD, commR, commRStar, th.MakeRandomBytes(types.TwoPoRepProofPartitions.ProofLen()))
require.NoError(t, err)
require.EqualError(t, res.ExecutionError, "sector already committed")
require.Equal(t, uint8(0x23), res.Receipt.ExitCode)
} | explode_data.jsonl/55768 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 514
} | [
2830,
3393,
6217,
261,
33441,
68188,
1155,
353,
8840,
836,
8,
341,
3244,
69,
25159,
2271,
1155,
692,
20985,
1669,
2266,
19047,
741,
18388,
11,
348,
1011,
1669,
6200,
7251,
623,
269,
1134,
7502,
11,
259,
692,
197,
4670,
32339,
1669,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApplyFeatureGates(t *testing.T) {
for _, pn := range algorithmProviderNames {
p, err := factory.GetAlgorithmProvider(pn)
if err != nil {
t.Errorf("Error retrieving '%s' provider: %v", pn, err)
break
}
if !p.FitPredicateKeys.Has("CheckNodeCondition") {
t.Errorf("Failed to find predicate: 'CheckNodeCondition'")
break
}
if !p.FitPredicateKeys.Has("PodToleratesNodeTaints") {
t.Errorf("Failed to find predicate: 'PodToleratesNodeTaints'")
break
}
}
// Apply features for algorithm providers.
utilfeature.DefaultFeatureGate.Set("TaintNodesByCondition=True")
ApplyFeatureGates()
for _, pn := range algorithmProviderNames {
p, err := factory.GetAlgorithmProvider(pn)
if err != nil {
t.Errorf("Error retrieving '%s' provider: %v", pn, err)
break
}
if !p.FitPredicateKeys.Has("PodToleratesNodeTaints") {
t.Errorf("Failed to find predicate: 'PodToleratesNodeTaints'")
break
}
if p.FitPredicateKeys.Has("CheckNodeCondition") {
t.Errorf("Unexpected predicate: 'CheckNodeCondition'")
break
}
}
} | explode_data.jsonl/2597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
28497,
13859,
38,
973,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
43050,
1669,
2088,
12111,
5179,
7980,
341,
197,
3223,
11,
1848,
1669,
8633,
2234,
27847,
5179,
1295,
77,
340,
197,
743,
1848,
961,
2092,
341,
298,
3244,
1308... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestRepeatedPropertyName(t *testing.T) {
good := []interface{}{
struct {
A int `datastore:"-"`
}{},
struct {
A int `datastore:"b"`
B int
}{},
struct {
A int
B int `datastore:"B"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"-"`
}{},
struct {
A int `datastore:"-"`
B int `datastore:"A"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"A"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"C"`
C int `datastore:"A"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"C"`
C int `datastore:"D"`
}{},
}
bad := []interface{}{
struct {
A int `datastore:"B"`
B int
}{},
struct {
A int
B int `datastore:"A"`
}{},
struct {
A int `datastore:"C"`
B int `datastore:"C"`
}{},
struct {
A int `datastore:"B"`
B int `datastore:"C"`
C int `datastore:"B"`
}{},
}
testGetStructCodec(t, good, bad)
} | explode_data.jsonl/60715 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 557
} | [
2830,
3393,
90989,
31043,
1155,
353,
8840,
836,
8,
972,
3174,
1386,
1669,
3056,
4970,
6257,
1666,
197,
6472,
972,
298,
22985,
526,
1565,
691,
4314,
2974,
27651,
75679,
197,
197,
92,
6257,
1871,
197,
6472,
972,
298,
22985,
526,
1565,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConfigReset_Hydra(t *testing.T) {
s, _, _, h, iss, err := setupHydraTest(true)
if err != nil {
t.Fatalf("setupHydraTest() failed: %v", err)
}
cid := "c1"
existingID := "00000000-0000-0000-0000-000000000000"
newID := "00000000-0000-0000-0000-000000000002"
h.ListClientsResp = []*hydraapi.Client{
{ClientID: cid},
{ClientID: existingID, Name: "foo"},
}
h.CreateClientResp = &hydraapi.Client{
ClientID: newID,
}
h.UpdateClientResp = &hydraapi.Client{
ClientID: existingID,
}
pname := "admin"
var p *cpb.TestPersona
if iss.Config() != nil {
p = iss.Config().TestPersonas[pname]
}
tok, _, err := persona.NewAccessToken(pname, hydraPublicURL, test.TestClientID, noScope, p)
if err != nil {
t.Fatalf("persona.NewAccessToken(%q, %q, _, _) failed: %v", pname, hydraPublicURL, err)
}
q := url.Values{
"client_id": []string{test.TestClientID},
"client_secret": []string{test.TestClientSecret},
}
path := strings.ReplaceAll(configResetPath, "{realm}", "master")
header := http.Header{"Authorization": []string{"Bearer " + string(tok)}}
resp := testhttp.SendTestRequest(t, s.Handler, http.MethodGet, path, q, nil, header)
if resp.StatusCode != http.StatusOK {
t.Errorf("resp.StatusCode = %d, wants %d", resp.StatusCode, http.StatusOK)
}
if h.DeleteClientID != cid {
t.Errorf("h.DeleteClientID = %s, wants %s", h.DeleteClientID, cid)
}
if h.UpdateClientReq.Name != "test_client" {
t.Errorf("h.UpdateClientReq.Name = %s, wants test_client", h.UpdateClientReq.Name)
}
if h.CreateClientReq.Name != "test_client2" {
t.Errorf("h.CreateClientReq.Name = %s, wants test_client2", h.CreateClientReq.Name)
}
} | explode_data.jsonl/18529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 670
} | [
2830,
3393,
2648,
14828,
2039,
88,
22248,
1155,
353,
8840,
836,
8,
341,
1903,
11,
8358,
8358,
305,
11,
2369,
11,
1848,
1669,
6505,
30816,
22248,
2271,
3715,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
15188,
30816,
22248,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestInvariants(t *testing.T) {
k := testKeeper(5)
require.Equal(t, k.InvCheckPeriod(), uint(5))
k.RegisterRoute("testModule", "testRoute", testPassingInvariant)
require.Len(t, k.Routes(), 1)
} | explode_data.jsonl/46282 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
641,
54611,
1155,
353,
8840,
836,
8,
341,
16463,
1669,
1273,
77233,
7,
20,
340,
17957,
12808,
1155,
11,
595,
68401,
3973,
23750,
1507,
2622,
7,
20,
4390,
16463,
19983,
4899,
445,
1944,
3332,
497,
330,
1944,
4899,
497,
1273... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestInvalidECKeyGen(t *testing.T) {
gen := ecKeyGenerator{
size: 16,
algID: "A128GCM",
publicKey: &ecTestKey256.PublicKey,
}
if gen.keySize() != 16 {
t.Error("ec key generator reported incorrect key size")
}
_, _, err := gen.genKey()
if err != nil {
t.Error("ec key generator failed to generate key", err)
}
} | explode_data.jsonl/63202 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
7928,
7498,
1592,
9967,
1155,
353,
8840,
836,
8,
341,
82281,
1669,
11942,
1592,
12561,
515,
197,
13832,
25,
414,
220,
16,
21,
345,
197,
197,
23881,
915,
25,
257,
330,
32,
16,
17,
23,
38,
9985,
756,
197,
1219,
1592,
25,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTransportReusesConn_RequestClose(t *testing.T) {
if onSameConn(t, func(r *http.Request) { r.Close = true }) {
t.Errorf("first and second responses were not on different connections")
}
} | explode_data.jsonl/16049 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
27560,
693,
4776,
9701,
44024,
7925,
1155,
353,
8840,
836,
8,
341,
743,
389,
19198,
9701,
1155,
11,
2915,
2601,
353,
1254,
9659,
8,
314,
435,
10421,
284,
830,
6413,
341,
197,
3244,
13080,
445,
3896,
323,
2086,
14507,
1033,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestHeaderTooShort(t *testing.T) {
h := FileHeader{
Name: "foo.txt",
Method: Deflate,
Extra: []byte{zip64ExtraId}, // missing size and second half of tag, but Extra is best-effort parsing
}
testValidHeader(&h, t)
} | explode_data.jsonl/18865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
4047,
31246,
12472,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
2887,
4047,
515,
197,
21297,
25,
256,
330,
7975,
3909,
756,
197,
84589,
25,
3892,
5075,
345,
197,
197,
11612,
25,
220,
3056,
3782,
90,
9964,
21,
19,
11612,
76... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewPeerEndorserTLS(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
config := mockfab.DefaultMockConfig(mockCtrl)
url := "grpcs://0.0.0.0:1234"
conn, err := newPeerEndorser(getPeerEndorserRequest(url, mockfab.GoodCert, "", config, kap, false, false))
if err != nil {
t.Fatal("Peer conn should be constructed")
}
optInsecure := reflect.ValueOf(grpc.WithInsecure())
for _, opt := range conn.grpcDialOption {
optr := reflect.ValueOf(opt)
if optr.Pointer() == optInsecure.Pointer() {
t.Fatal("TLS enabled - insecure not allowed")
}
}
} | explode_data.jsonl/45084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
3564,
30888,
3727,
269,
799,
45439,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
2822,
25873,
1669,
7860,
36855,
13275,
11571,
2648,
30389,
15001,
692... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestShiftWithOver(t *testing.T) {
jsonIn := `{"rating":{"primary":[{"value":3},{"value":5}],"example":{"value":3}}}`
jsonOut := `{"rating":{"primary":[{"new_value":3},{"new_value":5}],"example":{"value":3}}}`
spec := `[{"operation": "shift", "over": "rating.primary", "spec": {"new_value":"value"}}]`
kazaamTransform, _ := kazaam.NewKazaam(spec)
kazaamOut, _ := kazaamTransform.TransformJSONStringToString(jsonIn)
areEqual, _ := checkJSONStringsEqual(kazaamOut, jsonOut)
if !areEqual {
t.Error("Transformed data does not match expectation.")
t.Log("Expected: ", jsonOut)
t.Log("Actual: ", kazaamOut)
t.FailNow()
}
} | explode_data.jsonl/11859 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
24841,
2354,
1918,
1155,
353,
8840,
836,
8,
341,
30847,
641,
1669,
1565,
4913,
21931,
22317,
6545,
66582,
957,
788,
18,
36828,
957,
788,
20,
92,
28503,
8687,
22317,
957,
788,
18,
3417,
31257,
30847,
2662,
1669,
1565,
4913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMergeSchema_union(t *testing.T) {
t.Run("Matching", func(t *testing.T) {
// the directive that we are always comparing to
originalSchema, err := graphql.LoadSchema(`
type CatPhoto {
species: String
}
type DogPhoto {
species: String
}
union Photo = CatPhoto | DogPhoto
`)
// make sure nothing went wrong
if !assert.Nil(t, err, "original schema didn't parse") {
return
}
// merge the schema with one that should work
schema, err := testMergeSchemas(t, originalSchema, `
type CatPhoto {
species: String
}
type DogPhoto {
species: String
}
union Photo = CatPhoto | DogPhoto
`)
if err != nil {
t.Error(err.Error())
}
schemaUnion := schema.Types["Photo"]
previousTypes := Set{}
for _, subType := range schemaUnion.Types {
previousTypes.Add(subType)
}
assert.True(t, previousTypes["CatPhoto"])
assert.True(t, previousTypes["DogPhoto"])
})
// the table we are testing
testMergeRunNegativeTable(t, []testMergeTableRow{
{
"Different Subtypes",
`
type CatPhoto {
species: String
}
type DogPhoto {
species: String
}
union Photo = CatPhoto | DogPhoto
`,
`
type NotCatPhoto {
url: String
}
type NotDogPhoto {
url: String
}
union Photo = NotCatPhoto | NotDogPhoto
`,
},
{
"Different number of subtypes",
`
type CatPhoto {
species: String
}
type DogPhoto {
species: String
}
union Photo = CatPhoto | DogPhoto
`,
`
type CatPhoto {
url: String
}
type DogPhoto {
url: String
}
type LemurPhoto {
url: String
}
union Photo = CatPhoto | DogPhoto | LemurPhoto
`,
},
})
} | explode_data.jsonl/20239 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 754
} | [
2830,
3393,
52096,
8632,
51621,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
64430,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197,
322,
279,
33859,
429,
582,
525,
2677,
26297,
311,
198,
197,
197,
9889,
8632,
11,
1848,
1669,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestKafkaClient_Configure_BadRegexp(t *testing.T) {
module := fixtureModule()
viper.Set("consumer.test.group-whitelist", "[")
assert.Panics(t, func() { module.Configure("test", "consumer.test") }, "The code did not panic")
} | explode_data.jsonl/34251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
42,
21883,
2959,
15100,
17781,
1668,
329,
3477,
4580,
1155,
353,
8840,
836,
8,
341,
54020,
1669,
12507,
3332,
741,
5195,
12858,
4202,
445,
46764,
5958,
6175,
55332,
57645,
497,
10545,
1138,
6948,
1069,
276,
1211,
1155,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestReorder(t *testing.T) {
for _, test := range reorderTests {
q := queue.New()
q.PushBack(test.is...)
for _, f := range test.as {
err := f(q)
if err != nil {
t.Error(err)
}
}
var res []interface{}
for q.Length() > 0 {
res = append(res, q.PopFront())
}
if len(res) == 0 && len(test.res) == 0 {
} else if e := reflect.DeepEqual(res, test.res); !e {
t.Errorf("expected: %v got: %v", test.res, res)
}
}
} | explode_data.jsonl/5298 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
693,
1358,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
83184,
18200,
341,
197,
18534,
1669,
7177,
7121,
741,
197,
18534,
34981,
3707,
8623,
2079,
31218,
197,
2023,
8358,
282,
1669,
2088,
1273,
5357,
341,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestMapProxy_DeleteWithNonSerializableKey(t *testing.T) {
err := mp.Delete(student{})
AssertErrorNotNil(t, err, "delete did not return an error for nonserializable key")
mp.Clear()
} | explode_data.jsonl/57054 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
2227,
16219,
57418,
2354,
8121,
29268,
1592,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
10490,
18872,
39004,
37790,
18017,
1454,
96144,
1155,
11,
1848,
11,
330,
4542,
1521,
537,
470,
458,
1465,
369,
2477,
10182,
8335,
1376,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestAcceptError(t *testing.T) {
o := DefaultOptions()
s := New(o)
s.mu.Lock()
s.running = true
s.mu.Unlock()
defer s.Shutdown()
orgDelay := time.Hour
delay := s.acceptError("Test", fmt.Errorf("any error"), orgDelay)
if delay != orgDelay {
t.Fatalf("With this type of error, delay should have stayed same, got %v", delay)
}
// Create any net.Error and make it a temporary
ne := &net.DNSError{IsTemporary: true}
orgDelay = 10 * time.Millisecond
delay = s.acceptError("Test", ne, orgDelay)
if delay != 2*orgDelay {
t.Fatalf("Expected delay to double, got %v", delay)
}
// Now check the max
orgDelay = 60 * ACCEPT_MAX_SLEEP / 100
delay = s.acceptError("Test", ne, orgDelay)
if delay != ACCEPT_MAX_SLEEP {
t.Fatalf("Expected delay to double, got %v", delay)
}
wg := sync.WaitGroup{}
wg.Add(1)
start := time.Now()
go func() {
s.acceptError("Test", ne, orgDelay)
wg.Done()
}()
time.Sleep(100 * time.Millisecond)
// This should kick out the sleep in acceptError
s.Shutdown()
if dur := time.Since(start); dur >= ACCEPT_MAX_SLEEP {
t.Fatalf("Shutdown took too long: %v", dur)
}
} | explode_data.jsonl/3618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 448
} | [
2830,
3393,
16646,
1454,
1155,
353,
8840,
836,
8,
341,
22229,
1669,
7899,
3798,
741,
1903,
1669,
1532,
10108,
340,
1903,
48830,
31403,
741,
1903,
57617,
284,
830,
198,
1903,
48830,
39188,
741,
16867,
274,
10849,
18452,
741,
87625,
20039,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateSecurityGroup(t *testing.T) {
type args struct {
ctx context.Context
req service.CreateSecurityGroupRequest
}
tests := []struct {
name string
args args
wantSecurityGroupId string
wantErr bool
}{
{
name: "测试创建安全组",
args: args{
ctx: nil,
req: service.CreateSecurityGroupRequest{
VpcId: "vpc-m5ey3pofeclswmv796tgd",
SecurityGroupName: "测试的第一个安全组",
SecurityGroupType: "normal",
},
},
wantSecurityGroupId: "",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotSecurityGroupId, err := service.CreateSecurityGroup(tt.args.ctx, tt.args.req)
if (err != nil) != tt.wantErr {
t.Errorf("CreateSecurityGroup() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotSecurityGroupId == tt.wantSecurityGroupId {
t.Errorf("CreateSecurityGroup() gotSecurityGroupId = %v, want %v", gotSecurityGroupId, tt.wantSecurityGroupId)
}
})
}
} | explode_data.jsonl/72641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 505
} | [
2830,
3393,
4021,
15352,
2808,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
20985,
2266,
9328,
198,
197,
24395,
2473,
7251,
15352,
2808,
1900,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
394,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestStateTransition(t *testing.T) {
order := &Order{}
if err := getStateMachine().Trigger("checkout", order, db); err != nil {
t.Errorf("should not raise any error when trigger event checkout")
}
if order.GetState() != "checkout" {
t.Errorf("state doesn't changed to checkout")
}
var stateChangeLogs = transition.GetStateChangeLogs(order, db)
if len(stateChangeLogs) != 1 {
t.Errorf("should get one state change log with GetStateChangeLogs")
} else {
var stateChangeLog = stateChangeLogs[0]
if stateChangeLog.From != "draft" {
t.Errorf("state from not set")
}
if stateChangeLog.To != "checkout" {
t.Errorf("state to not set")
}
}
} | explode_data.jsonl/2611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
1397,
21768,
1155,
353,
8840,
836,
8,
341,
42245,
1669,
609,
4431,
31483,
743,
1848,
1669,
39070,
21605,
1005,
17939,
445,
33035,
497,
1973,
11,
2927,
1215,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
5445,
537,
4828,
894,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestStartClusterUpNoFlags(t *testing.T) {
setUp(t)
defer os.RemoveAll(testDir)
defer minitesting.ResetDefaultRoundTripper()
defer viper.Reset()
clusterUpParams := determineClusterUpParameters(testConfig)
clusterup.ClusterUp(testConfig, clusterUpParams, testRunner)
if testRunner.Cmd != testConfig.OcPath {
t.Errorf("Expected command '%s'. Received '%s'", testConfig.OcPath, testRunner.Cmd)
}
expectedArguments := []string{
"cluster",
"up",
"--use-existing-config",
"--host-config-dir", hostConfigDirectory,
"--host-data-dir", hostDataDirectory,
"--host-pv-dir", hostPvDirectory,
"--host-volumes-dir", hostVolumesDirectory,
"--routing-suffix", testConfig.Ip + ".nip.io",
}
assertCommandLineArguments(expectedArguments, t)
} | explode_data.jsonl/12412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
3479,
28678,
2324,
2753,
9195,
1155,
353,
8840,
836,
8,
341,
8196,
2324,
1155,
340,
16867,
2643,
84427,
8623,
6184,
340,
16867,
1308,
275,
59855,
36660,
3675,
27497,
21884,
6922,
741,
16867,
95132,
36660,
2822,
197,
18855,
232... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEngineAdd(t *testing.T) {
vdr, _, sender, vm, te, _ := setup(t)
if !te.Context().ChainID.Equals(ids.Empty) {
t.Fatalf("Wrong chain ID")
}
blk := &Blk{
parent: &Blk{
id: GenerateID(),
status: choices.Unknown,
},
id: GenerateID(),
status: choices.Processing,
bytes: []byte{1},
}
asked := new(bool)
sender.GetF = func(inVdr ids.ShortID, _ uint32, blkID ids.ID) {
if *asked {
t.Fatalf("Asked multiple times")
}
*asked = true
if !vdr.ID().Equals(inVdr) {
t.Fatalf("Asking wrong validator for block")
}
if !blkID.Equals(blk.Parent().ID()) {
t.Fatalf("Asking for wrong block")
}
}
vm.ParseBlockF = func(b []byte) (snowman.Block, error) {
if !bytes.Equal(b, blk.Bytes()) {
t.Fatalf("Wrong bytes")
}
return blk, nil
}
te.Put(vdr.ID(), 0, blk.ID(), blk.Bytes())
vm.ParseBlockF = nil
if !*asked {
t.Fatalf("Didn't ask for a missing block")
}
if len(te.blocked) != 1 {
t.Fatalf("Should have been blocking on request")
}
vm.ParseBlockF = func(b []byte) (snowman.Block, error) { return nil, errParseBlock }
te.Put(vdr.ID(), 0, blk.Parent().ID(), nil)
vm.ParseBlockF = nil
if len(te.blocked) != 0 {
t.Fatalf("Should have finished blocking issue")
}
} | explode_data.jsonl/3556 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 564
} | [
2830,
3393,
4571,
2212,
1155,
353,
8840,
836,
8,
341,
5195,
3612,
11,
8358,
4646,
11,
10995,
11,
1013,
11,
716,
1669,
6505,
1155,
692,
743,
753,
665,
9328,
1005,
18837,
915,
16207,
43448,
11180,
8,
341,
197,
3244,
30762,
445,
29185,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestParallelInitializeConditions(t *testing.T) {
tests := []struct {
name string
ts *ParallelStatus
want *ParallelStatus
}{{
name: "empty",
ts: &ParallelStatus{},
want: &ParallelStatus{
Status: duckv1.Status{
Conditions: []apis.Condition{{
Type: ParallelConditionAddressable,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionChannelsReady,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionReady,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionSubscriptionsReady,
Status: corev1.ConditionUnknown,
}},
},
},
}, {
name: "one false",
ts: &ParallelStatus{
Status: duckv1.Status{
Conditions: []apis.Condition{{
Type: ParallelConditionChannelsReady,
Status: corev1.ConditionFalse,
}},
},
},
want: &ParallelStatus{
Status: duckv1.Status{
Conditions: []apis.Condition{{
Type: ParallelConditionAddressable,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionChannelsReady,
Status: corev1.ConditionFalse,
}, {
Type: ParallelConditionReady,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionSubscriptionsReady,
Status: corev1.ConditionUnknown,
}},
},
},
}, {
name: "one true",
ts: &ParallelStatus{
Status: duckv1.Status{
Conditions: []apis.Condition{{
Type: ParallelConditionSubscriptionsReady,
Status: corev1.ConditionTrue,
}},
},
},
want: &ParallelStatus{
Status: duckv1.Status{
Conditions: []apis.Condition{{
Type: ParallelConditionAddressable,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionChannelsReady,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionReady,
Status: corev1.ConditionUnknown,
}, {
Type: ParallelConditionSubscriptionsReady,
Status: corev1.ConditionTrue,
}},
},
},
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
test.ts.InitializeConditions()
if diff := cmp.Diff(test.want, test.ts, ignoreAllButTypeAndStatus); diff != "" {
t.Errorf("unexpected conditions (-want, +got) = %v", diff)
}
})
}
} | explode_data.jsonl/29236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 965
} | [
2830,
3393,
16547,
9928,
35435,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
57441,
256,
353,
16547,
2522,
198,
197,
50780,
353,
16547,
2522,
198,
197,
15170,
515,
197,
11609,
25,
330,
3194,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGithub_Branch_Ref(t *testing.T) {
ci := &Github{CIBranchName: "refs/heads/feature1"}
assert.Equal(t, "feature1", ci.Branch())
} | explode_data.jsonl/53502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 60
} | [
2830,
3393,
78717,
1668,
81,
3497,
81086,
1155,
353,
8840,
836,
8,
341,
1444,
72,
1669,
609,
78717,
90,
34,
3256,
81,
3497,
675,
25,
330,
16149,
14,
35810,
14,
12753,
16,
63159,
6948,
12808,
1155,
11,
330,
12753,
16,
497,
11825,
972... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestTeam(t *testing.T) {
var rr *map[string]interface{} = &map[string]interface{}{}
Convey("Login as root", t, func() {
resp, _ := resty.R().
SetQueryParam("name", root_user_name).SetQueryParam("password", root_user_password).SetResult(rr).
Post(fmt.Sprintf("%s/user/login", api_v1))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["name"], ShouldEqual, root_user_name)
So((*rr)["sig"], ShouldNotBeBlank)
So((*rr)["admin"], ShouldBeTrue)
})
api_token := fmt.Sprintf(`{"name": "%v", "sig": "%v"}`, (*rr)["name"], (*rr)["sig"])
Convey("Get user info by name: GET /user/name/:user", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().
SetHeader("Apitoken", api_token).
SetResult(rr).
Get(fmt.Sprintf("%s/user/name/%s", api_v1, root_user_name))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["role"], ShouldEqual, 2)
So((*rr)["id"], ShouldBeGreaterThanOrEqualTo, 0)
})
root_user_id := (*rr)["id"]
Convey("Create team: POST /team", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("Apitoken", api_token).
SetBody(fmt.Sprintf(`{"team_name": "%s","resume": "i'm descript", "users": [1]}`, test_team_name)).
SetResult(rr).
Post(fmt.Sprintf("%s/team", api_v1))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["message"], ShouldContainSubstring, "created")
})
Convey("Get team by name: GET /team/name/:name", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().SetHeader("Apitoken", api_token).SetResult(rr).
Get(fmt.Sprintf("%s/team/name/%s", api_v1, test_team_name))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["name"], ShouldEqual, test_team_name)
So((*rr)["users"], ShouldNotBeEmpty)
So((*rr)["id"], ShouldBeGreaterThan, 0)
})
test_team_id := (*rr)["id"]
Convey("Get team by id: GET /team/t/:tid", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().SetHeader("Apitoken", api_token).SetResult(rr).
Get(fmt.Sprintf("%s/team/t/%v", api_v1, test_team_id))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["name"], ShouldEqual, test_team_name)
So((*rr)["users"], ShouldNotBeEmpty)
So((*rr)["id"], ShouldEqual, test_team_id)
})
Convey("Update team by id: PUT /team", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("Apitoken", api_token).
SetBody(fmt.Sprintf(`{"team_id": %v,"resume": "descript2", "name":"%v", "users": [1]}`,
test_team_id, test_team_name)).
SetResult(rr).
Put(fmt.Sprintf("%s/team", api_v1))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["message"], ShouldContainSubstring, "updated")
Convey("Get team by name: GET /team/name/:name", func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().SetHeader("Apitoken", api_token).SetResult(rr).
Get(fmt.Sprintf("%s/team/name/%s", api_v1, test_team_name))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["resume"], ShouldEqual, "descript2")
})
})
Convey("Add users to team: POST /team/user", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().
SetHeader("Content-Type", "application/json").
SetHeader("Apitoken", api_token).
SetBody(map[string]interface{}{
"team_id": test_team_id,
"users": []string{root_user_name},
}).
SetResult(rr).
Post(fmt.Sprintf("%s/team/user", api_v1))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["message"], ShouldContainSubstring, "successful")
})
Convey("Get teams which user belong to: GET /user/u/:uid/teams", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().SetHeader("Apitoken", api_token).SetResult(rr).
Get(fmt.Sprintf("%s/user/u/%v/teams", api_v1, root_user_id))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["teams"], ShouldNotBeEmpty)
})
Convey("Check user in teams or not: GET /user/u/:uid/in_teams", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().
SetHeader("Apitoken", api_token).
SetQueryParam("team_names", test_team_name).
SetResult(rr).
Get(fmt.Sprintf("%s/user/u/%v/in_teams", api_v1, root_user_id))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["message"], ShouldEqual, "true")
})
Convey("Get team list: GET /team", t, func() {
var r []map[string]interface{}
resp, _ := resty.R().SetHeader("Apitoken", api_token).SetResult(&r).
Get(fmt.Sprintf("%s/team", api_v1))
So(resp.StatusCode(), ShouldEqual, 200)
So(r, ShouldNotBeEmpty)
So(r[0]["team"], ShouldNotBeEmpty)
So(r[0]["users"], ShouldNotBeEmpty)
So(r[0]["creator_name"], ShouldNotBeBlank)
})
Convey("Delete team by id: DELETE /team/:tid", t, func() {
*rr = map[string]interface{}{}
resp, _ := resty.R().
SetHeader("Apitoken", api_token).
SetResult(rr).
Delete(fmt.Sprintf("%s/team/%v", api_v1, test_team_id))
So(resp.StatusCode(), ShouldEqual, 200)
So(*rr, ShouldNotBeEmpty)
So((*rr)["message"], ShouldContainSubstring, "deleted")
})
} | explode_data.jsonl/48355 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2285
} | [
2830,
3393,
14597,
1155,
353,
8840,
836,
8,
341,
2405,
34393,
353,
2186,
14032,
31344,
6257,
284,
609,
2186,
14032,
31344,
6257,
31483,
93070,
5617,
445,
6231,
438,
3704,
497,
259,
11,
2915,
368,
341,
197,
34653,
11,
716,
1669,
2732,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSliceTypeConversion(t *testing.T) {
testcases := []struct {
GoType string
Scanner sql.Scanner
PrestoResponseUnmarshalledSample interface{}
TestScanner func(t *testing.T, s sql.Scanner)
}{
{
GoType: "[]bool",
Scanner: &NullSliceBool{},
PrestoResponseUnmarshalledSample: []interface{}{true},
TestScanner: func(t *testing.T, s sql.Scanner) {
v, _ := s.(*NullSliceBool)
if !v.Valid {
t.Fatal("scanner failed")
}
},
},
{
GoType: "[]string",
Scanner: &NullSliceString{},
PrestoResponseUnmarshalledSample: []interface{}{"hello"},
TestScanner: func(t *testing.T, s sql.Scanner) {
v, _ := s.(*NullSliceString)
if !v.Valid {
t.Fatal("scanner failed")
}
},
},
{
GoType: "[]int64",
Scanner: &NullSliceInt64{},
PrestoResponseUnmarshalledSample: []interface{}{float64(1)},
TestScanner: func(t *testing.T, s sql.Scanner) {
v, _ := s.(*NullSliceInt64)
if !v.Valid {
t.Fatal("scanner failed")
}
},
},
{
GoType: "[]float64",
Scanner: &NullSliceFloat64{},
PrestoResponseUnmarshalledSample: []interface{}{float64(1)},
TestScanner: func(t *testing.T, s sql.Scanner) {
v, _ := s.(*NullSliceFloat64)
if !v.Valid {
t.Fatal("scanner failed")
}
},
},
{
GoType: "[]time.Time",
Scanner: &NullSliceTime{},
PrestoResponseUnmarshalledSample: []interface{}{"2017-07-01"},
TestScanner: func(t *testing.T, s sql.Scanner) {
v, _ := s.(*NullSliceTime)
if !v.Valid {
t.Fatal("scanner failed")
}
},
},
{
GoType: "[]map[string]interface{}",
Scanner: &NullSliceMap{},
PrestoResponseUnmarshalledSample: []interface{}{map[string]interface{}{"hello": "world"}},
TestScanner: func(t *testing.T, s sql.Scanner) {
v, _ := s.(*NullSliceMap)
if !v.Valid {
t.Fatal("scanner failed")
}
},
},
}
for _, tc := range testcases {
t.Run(tc.GoType+":nil", func(t *testing.T) {
if err := tc.Scanner.Scan(nil); err != nil {
t.Error(err)
}
})
t.Run(tc.GoType+":bogus", func(t *testing.T) {
if err := tc.Scanner.Scan(struct{}{}); err == nil {
t.Error("bogus data scanned with no error")
}
if err := tc.Scanner.Scan([]interface{}{struct{}{}}); err == nil {
t.Error("bogus data scanned with no error")
}
})
t.Run(tc.GoType+":sample", func(t *testing.T) {
if err := tc.Scanner.Scan(tc.PrestoResponseUnmarshalledSample); err != nil {
t.Error(err)
}
tc.TestScanner(t, tc.Scanner)
})
}
} | explode_data.jsonl/62445 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1275
} | [
2830,
3393,
33236,
929,
48237,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
9600,
78,
929,
5968,
914,
198,
197,
57281,
3502,
5704,
32098,
198,
197,
10025,
3927,
78,
2582,
1806,
36239,
4736,
17571,
3749,
16094,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPIDPressureCondition(t *testing.T) {
now := time.Now()
before := now.Add(-time.Second)
nowFunc := func() time.Time { return now }
cases := []struct {
desc string
node *v1.Node
pressure bool
expectConditions []v1.NodeCondition
expectEvents []testEvent
}{
{
desc: "new, no pressure",
node: &v1.Node{},
pressure: false,
expectConditions: []v1.NodeCondition{*makePIDPressureCondition(false, now, now)},
expectEvents: []testEvent{
{
eventType: v1.EventTypeNormal,
event: "NodeHasSufficientPID",
},
},
},
{
desc: "new, pressure",
node: &v1.Node{},
pressure: true,
expectConditions: []v1.NodeCondition{*makePIDPressureCondition(true, now, now)},
expectEvents: []testEvent{
{
eventType: v1.EventTypeNormal,
event: "NodeHasInsufficientPID",
},
},
},
{
desc: "transition to pressure",
node: &v1.Node{
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{*makePIDPressureCondition(false, before, before)},
},
},
pressure: true,
expectConditions: []v1.NodeCondition{*makePIDPressureCondition(true, now, now)},
expectEvents: []testEvent{
{
eventType: v1.EventTypeNormal,
event: "NodeHasInsufficientPID",
},
},
},
{
desc: "transition to no pressure",
node: &v1.Node{
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{*makePIDPressureCondition(true, before, before)},
},
},
pressure: false,
expectConditions: []v1.NodeCondition{*makePIDPressureCondition(false, now, now)},
expectEvents: []testEvent{
{
eventType: v1.EventTypeNormal,
event: "NodeHasSufficientPID",
},
},
},
{
desc: "pressure, no transition",
node: &v1.Node{
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{*makePIDPressureCondition(true, before, before)},
},
},
pressure: true,
expectConditions: []v1.NodeCondition{*makePIDPressureCondition(true, before, now)},
expectEvents: []testEvent{},
},
{
desc: "no pressure, no transition",
node: &v1.Node{
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{*makePIDPressureCondition(false, before, before)},
},
},
pressure: false,
expectConditions: []v1.NodeCondition{*makePIDPressureCondition(false, before, now)},
expectEvents: []testEvent{},
},
}
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
events := []testEvent{}
recordEventFunc := func(eventType, event string) {
events = append(events, testEvent{
eventType: eventType,
event: event,
})
}
pressureFunc := func() bool {
return tc.pressure
}
// construct setter
setter := PIDPressureCondition(nowFunc, pressureFunc, recordEventFunc)
// call setter on node
if err := setter(tc.node); err != nil {
t.Fatalf("unexpected error: %v", err)
}
// check expected condition
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions))
// check expected events
require.Equal(t, len(tc.expectEvents), len(events))
for i := range tc.expectEvents {
assert.Equal(t, tc.expectEvents[i], events[i])
}
})
}
} | explode_data.jsonl/31859 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1560
} | [
2830,
3393,
33751,
68269,
10547,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
882,
13244,
741,
63234,
1669,
1431,
1904,
4080,
1678,
32435,
340,
80922,
9626,
1669,
2915,
368,
882,
16299,
314,
470,
1431,
555,
1444,
2264,
1669,
3056,
1235,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIncreaseWindowOnBufferResize(t *testing.T) {
// This test ensures that the endpoint sends an ack,
// after available recv buffer grows to more than 1 MSS.
c := context.New(t, defaultMTU)
defer c.Cleanup()
const rcvBuf = 65535 * 10
c.CreateConnected(context.TestInitialSequenceNumber, 30000, rcvBuf)
// Write chunks of ~30000 bytes. It's important that two
// payloads make it equal or longer than MSS.
remain := rcvBuf
sent := 0
data := make([]byte, defaultMTU/2)
iss := seqnum.Value(context.TestInitialSequenceNumber).Add(1)
for remain > len(data) {
c.SendPacket(data, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: iss.Add(seqnum.Size(sent)),
AckNum: c.IRS.Add(1),
RcvWnd: 30000,
})
sent += len(data)
remain -= len(data)
checker.IPv4(t, c.GetPacket(),
checker.PayloadLen(header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS)+1),
checker.TCPAckNum(uint32(iss)+uint32(sent)),
checker.TCPWindowLessThanEq(0xffff),
checker.TCPFlags(header.TCPFlagAck),
),
)
}
// Increasing the buffer from should generate an ACK,
// since window grew from small value to larger equal MSS
c.EP.SocketOptions().SetReceiveBufferSize(rcvBuf*4, true /* notify */)
checker.IPv4(t, c.GetPacket(),
checker.PayloadLen(header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS)+1),
checker.TCPAckNum(uint32(iss)+uint32(sent)),
checker.TCPWindow(uint16(0xffff)),
checker.TCPFlags(header.TCPFlagAck),
),
)
} | explode_data.jsonl/76029 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 694
} | [
2830,
3393,
69556,
4267,
1925,
4095,
30561,
1155,
353,
8840,
836,
8,
341,
197,
322,
1096,
1273,
25351,
429,
279,
14887,
21308,
458,
10725,
345,
197,
322,
1283,
2500,
27006,
4147,
27715,
311,
803,
1091,
220,
16,
91649,
624,
1444,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNilValueSemantics(t *testing.T) {
require := require.New(t)
tree := NewVersionedTree(db.NewMemDB(), 0)
require.Panics(func() {
tree.Set([]byte("k"), nil)
})
} | explode_data.jsonl/47382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
19064,
1130,
29499,
36233,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
340,
51968,
1669,
1532,
5637,
291,
6533,
9791,
7121,
18816,
3506,
1507,
220,
15,
692,
17957,
1069,
276,
1211,
18552,
368,
341,
197,
5196... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestUpdateSql(t *testing.T) {
rawsqls := "select * from mysql123 ;select * from mysql345;"
syncSQLs := []string{"select * from mysql123", "select * from mysql345"}
got := updateSqls(rawsqls, time.Now())
assert.EqualValues(t, syncSQLs, got)
} | explode_data.jsonl/61890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
4289,
8269,
1155,
353,
8840,
836,
8,
341,
76559,
3544,
82,
1669,
330,
1742,
353,
504,
10564,
16,
17,
18,
220,
2587,
1742,
353,
504,
10564,
18,
19,
20,
41655,
1903,
1721,
6688,
82,
1669,
3056,
917,
4913,
1742,
353,
504,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRespondentClosed(t *testing.T) {
VerifyClosedRecv(t, NewSocket)
VerifyClosedSend(t, NewSocket)
VerifyClosedClose(t, NewSocket)
VerifyClosedDial(t, NewSocket)
VerifyClosedListen(t, NewSocket)
VerifyClosedAddPipe(t, NewSocket)
} | explode_data.jsonl/57389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
65354,
306,
26884,
1155,
353,
8840,
836,
8,
341,
197,
32627,
26884,
63483,
1155,
11,
1532,
10286,
340,
197,
32627,
26884,
11505,
1155,
11,
1532,
10286,
340,
197,
32627,
26884,
7925,
1155,
11,
1532,
10286,
340,
197,
32627,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSetTeamIcon(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
data, err := testutils.ReadTestFile("test.png")
require.Nil(t, err, err)
th.LoginTeamAdmin()
ok, resp := Client.SetTeamIcon(team.Id, data)
require.True(t, ok, resp.Error)
CheckNoError(t, resp)
ok, resp = Client.SetTeamIcon(model.NewId(), data)
require.False(t, ok, "Should return false, set team icon not allowed")
CheckForbiddenStatus(t, resp)
th.LoginBasic()
_, resp = Client.SetTeamIcon(team.Id, data)
if resp.StatusCode == http.StatusForbidden {
CheckForbiddenStatus(t, resp)
} else if resp.StatusCode == http.StatusUnauthorized {
CheckUnauthorizedStatus(t, resp)
} else {
require.Fail(t, "Should have failed either forbidden or unauthorized")
}
Client.Logout()
_, resp = Client.SetTeamIcon(team.Id, data)
if resp.StatusCode == http.StatusForbidden {
CheckForbiddenStatus(t, resp)
} else if resp.StatusCode == http.StatusUnauthorized {
CheckUnauthorizedStatus(t, resp)
} else {
require.Fail(t, "Should have failed either forbidden or unauthorized")
}
teamBefore, err := th.App.GetTeam(team.Id)
require.Nil(t, err)
_, resp = th.SystemAdminClient.SetTeamIcon(team.Id, data)
CheckNoError(t, resp)
teamAfter, err := th.App.GetTeam(team.Id)
require.Nil(t, err)
assert.True(t, teamBefore.LastTeamIconUpdate < teamAfter.LastTeamIconUpdate, "LastTeamIconUpdate should have been updated for team")
info := &model.FileInfo{Path: "teams/" + team.Id + "/teamIcon.png"}
err = th.cleanupTestFile(info)
require.Nil(t, err, err)
} | explode_data.jsonl/70741 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 579
} | [
2830,
3393,
1649,
14597,
4395,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
198,
197,
9196,
1669,
270,
48868,
14597,
271,
8924,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestWholeStory(t *testing.T) {
for _, tc := range wholeStoryTestCases {
s := tc.String
expected := tc.Text
expectedErr := tc.Error
got, err := strings.WholeStory(s)
if expected != got {
t.Errorf("%q: expected %q, got %q", s, expected, got)
}
if expectedErr != err {
t.Errorf("%q: expected error %v, got %v", s, expectedErr, err)
}
}
} | explode_data.jsonl/12030 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
90582,
17938,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
4361,
17938,
2271,
37302,
341,
197,
1903,
1669,
17130,
6431,
198,
197,
42400,
1669,
17130,
1979,
198,
197,
42400,
7747,
1669,
17130,
6141,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSTMApplyOnConcurrentDeletion(t *testing.T) {
clus := NewClusterV3(t, &ClusterConfig{Size: 1})
defer clus.Terminate(t)
etcdc := clus.RandClient()
if _, err := etcdc.Put(context.TODO(), "foo", "bar"); err != nil {
t.Fatal(err)
}
donec, readyc := make(chan struct{}), make(chan struct{})
go func() {
<-readyc
if _, err := etcdc.Delete(context.TODO(), "foo"); err != nil {
t.Fatal(err)
}
close(donec)
}()
try := 0
applyf := func(stm concurrency.STM) error {
try++
stm.Get("foo")
if try == 1 {
// trigger delete to make GET rev comparison outdated
close(readyc)
<-donec
}
stm.Put("foo2", "bar2")
return nil
}
iso := concurrency.WithIsolation(concurrency.RepeatableReads)
if _, err := concurrency.NewSTM(etcdc, applyf, iso); err != nil {
t.Fatalf("error on stm txn (%v)", err)
}
if try != 2 {
t.Fatalf("STM apply expected to run twice, got %d", try)
}
resp, err := etcdc.Get(context.TODO(), "foo2")
if err != nil {
t.Fatalf("error fetching key (%v)", err)
}
if string(resp.Kvs[0].Value) != "bar2" {
t.Fatalf("bad value. got %+v, expected 'bar2' value", resp)
}
} | explode_data.jsonl/51053 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
35849,
28497,
1925,
1109,
3231,
1912,
52625,
1155,
353,
8840,
836,
8,
341,
197,
4163,
1669,
1532,
28678,
53,
18,
1155,
11,
609,
28678,
2648,
90,
1695,
25,
220,
16,
3518,
16867,
1185,
355,
836,
261,
34016,
1155,
692,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestOrderGet(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/orders/123456.json", client.pathPrefix),
httpmock.NewBytesResponder(200, loadFixture("order.json")))
order, err := client.Order.Get(123456, nil)
if err != nil {
t.Errorf("Order.List returned error: %v", err)
}
// Check that dates are parsed
timezone, _ := time.LoadLocation("America/New_York")
d := time.Date(2016, time.May, 17, 4, 14, 36, 0, timezone)
if !d.Equal(*order.CancelledAt) {
t.Errorf("Order.CancelledAt returned %+v, expected %+v", order.CancelledAt, d)
}
orderTests(t, *order)
} | explode_data.jsonl/17987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 256
} | [
2830,
3393,
4431,
1949,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
28080,
16712,
19983,
30884,
445,
3806,
497,
8879,
17305,
445,
2428,
1110,
824,
9267,
453,
12618,
8675,
1437,
905,
12627,
82,
82818,
14,
16,
17,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRangeStmtUDT(t *testing.T) {
gopClTest(t, `
type foo struct {
}
func (p *foo) Gop_Enum(c func(key int, val string)) {
}
for k, v := range new(foo) {
println(k, v)
}
`, `package main
import fmt "fmt"
type foo struct {
}
func (p *foo) Gop_Enum(c func(key int, val string)) {
}
func main() {
new(foo).Gop_Enum(func(k int, v string) {
fmt.Println(k, v)
})
}
`)
} | explode_data.jsonl/73640 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
6046,
31063,
4656,
51,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
1313,
15229,
2036,
341,
630,
2830,
320,
79,
353,
7975,
8,
479,
453,
62,
10766,
1337,
2915,
4857,
526,
11,
1044,
914,
593,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDecodeIPv6Jumbogram(t *testing.T) {
// Haven't found any of these in the wild or on example pcaps online, so had
// to generate one myself via scapy. Unfortunately, scapy can only
// str(packet) for packets with length < 65536, due to limitations in python's
// struct library, so I generated the header with:
// Ether() / IPv6(src='::1', dst='::2') / IPv6ExtHdrHopByHop(options=[Jumbo(jumboplen=70000)]) / TCP(sport=8888, dport=80)
// then added the payload manually ("payload" * 9996). The checksums here are
// not correct, but we don't check, so who cares ;)
dataStr := "\x00\x1f\xca\xb3v@$\xbe\x05'\x0b\x17\x86\xdd`\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x06\x00\xc2\x04\x00\x01\x11p\"\xb8\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00l\xd8\x00\x00"
payload := strings.Repeat("payload", 9996)
data := []byte(dataStr + payload)
p := gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeIPv6HopByHop, LayerTypeTCP, gopacket.LayerTypePayload}, t)
if p.ApplicationLayer() == nil {
t.Error("Packet has no application layer")
} else if string(p.ApplicationLayer().Payload()) != payload {
t.Errorf("Jumbogram payload wrong")
}
// Check truncated for jumbograms
data = data[:len(data)-1]
p = gopacket.NewPacket(data, LinkTypeEthernet, testDecodeOptions)
checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeIPv6HopByHop, LayerTypeTCP, gopacket.LayerTypePayload}, t)
if !p.Metadata().Truncated {
t.Error("Jumbogram should be truncated")
}
} | explode_data.jsonl/42257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 715
} | [
2830,
3393,
32564,
58056,
21,
41,
3551,
12958,
1155,
353,
8840,
836,
8,
341,
197,
322,
41614,
944,
1730,
894,
315,
1493,
304,
279,
8380,
476,
389,
3110,
13312,
2625,
2860,
11,
773,
1030,
198,
197,
322,
311,
6923,
825,
7037,
4566,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRange(t *testing.T) {
data := Data{1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 0, 6, 5, 4, 43, 53, 4, 3, 43}
r, _ := Range(data)
if r != 53 {
t.Errorf("Range(data) is block")
}
} | explode_data.jsonl/9491 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
6046,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
2885,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
11,
220,
23,
11,
220,
24,
11,
220,
15,
11,
220,
21,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
marketplacePlugins := []*model.MarketplacePlugin{
{
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
HomepageURL: "https://example.com/mattermost/mattermost-plugin-nps",
IconData: "https://example.com/icon.svg",
DownloadURL: "www.github.com/example",
Manifest: &model.Manifest{
Id: "marketplace.test",
Name: "marketplacetest",
Description: "a marketplace plugin",
Version: "0.1.2",
MinServerVersion: "",
},
},
InstalledVersion: "",
},
}
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusOK)
json, err := json.Marshal([]*model.MarketplacePlugin{marketplacePlugins[0]})
require.NoError(t, err)
res.Write(json)
}))
defer testServer.Close()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableMarketplace = true
*cfg.PluginSettings.MarketplaceUrl = testServer.URL
})
prepackagePlugin := &plugin.PrepackagedPlugin{
Manifest: &model.Manifest{
Version: "0.0.1",
Id: "prepackaged.test",
},
}
env := th.App.GetPluginsEnvironment()
env.SetPrepackagedPlugins([]*plugin.PrepackagedPlugin{prepackagePlugin})
t.Run("get remote and prepackaged plugins", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.EnableRemoteMarketplace = true
*cfg.PluginSettings.EnableUploads = true
})
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
CheckNoError(t, resp)
expectedPlugins := marketplacePlugins
expectedPlugins = append(expectedPlugins, &model.MarketplacePlugin{
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
Manifest: prepackagePlugin.Manifest,
},
})
require.ElementsMatch(t, expectedPlugins, plugins)
require.Len(t, plugins, 2)
})
t.Run("EnableRemoteMarketplace disabled", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.EnableRemoteMarketplace = false
*cfg.PluginSettings.EnableUploads = true
})
// No marketplace plugins returned
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
CheckNoError(t, resp)
// Only returns the prepackaged plugins
require.Len(t, plugins, 1)
require.Equal(t, prepackagePlugin.Manifest, plugins[0].Manifest)
})
t.Run("get prepackaged plugin if newer", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.EnableRemoteMarketplace = true
*cfg.PluginSettings.EnableUploads = true
})
manifest := &model.Manifest{
Version: "1.2.3",
Id: "marketplace.test",
}
newerPrepackagePlugin := &plugin.PrepackagedPlugin{
Manifest: manifest,
}
env := th.App.GetPluginsEnvironment()
env.SetPrepackagedPlugins([]*plugin.PrepackagedPlugin{newerPrepackagePlugin})
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
CheckNoError(t, resp)
require.Len(t, plugins, 1)
require.Equal(t, newerPrepackagePlugin.Manifest, plugins[0].Manifest)
})
} | explode_data.jsonl/27541 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1231
} | [
2830,
3393,
1949,
4703,
4748,
3279,
11546,
641,
38822,
2007,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
2109,
54560,
2007,
45378,
1669,
29838,
2528,
1321,
54560,
2007,
11546... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEvalSymlinksCanonicalNamesWith8dot3Disabled(t *testing.T) {
if !*runFSModifyTests {
t.Skip("skipping test that modifies file system setting; enable with -run_fs_modify_tests")
}
tempVol := filepath.VolumeName(os.TempDir())
if len(tempVol) != 2 {
t.Fatalf("unexpected temp volume name %q", tempVol)
}
err := checkVolume8dot3Setting(tempVol, true)
if err != nil {
t.Fatal(err)
}
err = setVolume8dot3Setting(tempVol, false)
if err != nil {
t.Fatal(err)
}
defer func() {
err := setVolume8dot3Setting(tempVol, true)
if err != nil {
t.Fatal(err)
}
err = checkVolume8dot3Setting(tempVol, true)
if err != nil {
t.Fatal(err)
}
}()
err = checkVolume8dot3Setting(tempVol, false)
if err != nil {
t.Fatal(err)
}
TestEvalSymlinksCanonicalNames(t)
} | explode_data.jsonl/28123 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
54469,
34667,
1014,
15504,
70914,
7980,
2354,
23,
16119,
18,
25907,
1155,
353,
8840,
836,
8,
341,
743,
753,
9,
6108,
8485,
44427,
18200,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
429,
82949,
1034,
1849,
6243,
26,
7283,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestT(t *testing.T) {
const want = "tachitsuteto"
for _, v := range [2]string{"たちつてと", "タチツテト"} {
got, err := KanaToRomaji(v)
assert.Equal(t, want, got)
assert.Nil(t, err)
}
} | explode_data.jsonl/11300 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
51,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
330,
83,
610,
1199,
332,
11023,
1837,
2023,
8358,
348,
1669,
2088,
508,
17,
30953,
4913,
125565,
58639,
37044,
19182,
497,
330,
46207,
77359,
124788,
56833,
19674,
9207,
341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFormatJsonIntoTraditional(t *testing.T) {
idx := 11
for _, j := range exp[idx : idx+1] {
pretty.Println(j)
pretty.Println(FormatJSONIntoTraditional(j))
}
} | explode_data.jsonl/55047 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
4061,
5014,
26591,
84682,
1155,
353,
8840,
836,
8,
341,
62077,
1669,
220,
16,
16,
198,
2023,
8358,
502,
1669,
2088,
1343,
11597,
549,
7187,
10,
16,
60,
341,
197,
197,
32955,
12419,
3325,
340,
197,
197,
32955,
12419,
7,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestSummaryDataPoint_Timestamp(t *testing.T) {
ms := NewSummaryDataPoint()
assert.EqualValues(t, Timestamp(0), ms.Timestamp())
testValTimestamp := Timestamp(1234567890)
ms.SetTimestamp(testValTimestamp)
assert.EqualValues(t, testValTimestamp, ms.Timestamp())
} | explode_data.jsonl/32750 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
19237,
1043,
2609,
1139,
4702,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
19237,
1043,
2609,
741,
6948,
12808,
6227,
1155,
11,
32758,
7,
15,
701,
9829,
49024,
2398,
18185,
2208,
20812,
1669,
32758,
7,
16,
17,
18,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCryptionHandlerFlush(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/any", nil)
handler := CryptionHandler(aesKey)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(respText))
flusher, ok := w.(http.Flusher)
assert.Equal(t, ok, true)
flusher.Flush()
}))
recorder := httptest.NewRecorder()
handler.ServeHTTP(recorder, req)
expect, err := codec.EcbEncrypt(aesKey, []byte(respText))
assert.Nil(t, err)
assert.Equal(t, base64.StdEncoding.EncodeToString(expect), recorder.Body.String())
} | explode_data.jsonl/24320 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
34,
15597,
3050,
46874,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
54320,
70334,
75274,
19886,
20798,
1949,
11,
3521,
3767,
497,
2092,
340,
53326,
1669,
356,
15597,
3050,
2877,
288,
1592,
2376,
1254,
89164,
18552,
3622,
1758,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnknownNetwork(t *testing.T) {
if !testutils.IsRunningInContainer() {
defer testutils.SetupTestOSContext(t)()
}
netOption := options.Generic{
"BridgeName": "testnetwork",
}
option := options.Generic{
netlabel.GenericData: netOption,
}
network, err := createTestNetwork(bridgeNetType, "testnetwork", option, nil, nil)
if err != nil {
t.Fatal(err)
}
err = network.Delete()
if err != nil {
t.Fatal(err)
}
err = network.Delete()
if err == nil {
t.Fatal("Expected to fail. But instead succeeded")
}
if _, ok := err.(*libnetwork.UnknownNetworkError); !ok {
t.Fatalf("Did not fail with expected error. Actual error: %v", err)
}
} | explode_data.jsonl/6357 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
13790,
12320,
1155,
353,
8840,
836,
8,
341,
743,
753,
1944,
6031,
4506,
18990,
641,
4502,
368,
341,
197,
16867,
1273,
6031,
39820,
2271,
3126,
1972,
1155,
8,
741,
197,
630,
59486,
5341,
1669,
2606,
4341,
515,
197,
197,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestSigning(t *testing.T) {
msp, err := setup("testdata/idemix/MSP1OU1", "MSP1")
assert.NoError(t, err)
id, err := getDefaultSigner(msp)
assert.NoError(t, err)
msg := []byte("TestMessage")
sig, err := id.Sign(msg)
assert.NoError(t, err)
err = id.Verify(msg, sig)
assert.NoError(t, err)
err = id.Verify([]byte("OtherMessage"), sig)
assert.Error(t, err)
assert.Contains(t, err.Error(), "pseudonym signature invalid: zero-knowledge proof is invalid")
verMsp, err := setup("testdata/idemix/MSP1Verifier", "MSP1")
assert.NoError(t, err)
err = verMsp.Validate(id)
assert.NoError(t, err)
_, err = verMsp.GetDefaultSigningIdentity()
assert.Error(t, err)
assert.Contains(t, err.Error(), "no default signer setup")
} | explode_data.jsonl/46030 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
93358,
1155,
353,
8840,
836,
8,
341,
47691,
79,
11,
1848,
1669,
6505,
445,
92425,
38146,
336,
941,
10270,
4592,
16,
11922,
16,
497,
330,
44,
4592,
16,
1138,
6948,
35699,
1155,
11,
1848,
692,
15710,
11,
1848,
1669,
69106,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCommentedNode(t *testing.T) {
const (
input = `package main
func foo() {
// comment inside func
}
// leading comment
type bar int // comment2
`
foo = `func foo() {
// comment inside func
}`
bar = `// leading comment
type bar int // comment2
`
)
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "input.go", input, parser.ParseComments)
if err != nil {
t.Fatal(err)
}
var buf bytes.Buffer
err = Fprint(&buf, fset, &CommentedNode{Node: f.Decls[0], Comments: f.Comments})
if err != nil {
t.Fatal(err)
}
if buf.String() != foo {
t.Errorf("got %q, want %q", buf.String(), foo)
}
buf.Reset()
err = Fprint(&buf, fset, &CommentedNode{Node: f.Decls[1], Comments: f.Comments})
if err != nil {
t.Fatal(err)
}
if buf.String() != bar {
t.Errorf("got %q, want %q", buf.String(), bar)
}
} | explode_data.jsonl/64607 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
10677,
291,
1955,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
22427,
284,
1565,
1722,
1887,
271,
2830,
15229,
368,
341,
197,
322,
3980,
4766,
2915,
198,
630,
322,
6388,
3980,
198,
1313,
3619,
526,
442,
3980,
17,
271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func Test_ddosxDomainWAFAdvancedRuleListCmd_Args(t *testing.T) {
t.Run("ValidArgs_NoError", func(t *testing.T) {
cmd := ddosxDomainWAFAdvancedRuleListCmd()
err := cmd.Args(nil, []string{"testdomain1.co.uk"})
assert.Nil(t, err)
})
t.Run("MissingDomain_Error", func(t *testing.T) {
cmd := ddosxDomainWAFAdvancedRuleListCmd()
err := cmd.Args(nil, []string{})
assert.NotNil(t, err)
assert.Equal(t, "Missing domain", err.Error())
})
} | explode_data.jsonl/43029 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
43174,
436,
87,
13636,
54,
8276,
35457,
11337,
852,
15613,
87581,
82,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4088,
4117,
36989,
1454,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
25920,
1669,
19647,
436,
87,
1363... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDefaultsUsed(t *testing.T) {
defer restoreDflts(dfltFiles, dfltDirs)
tmpdir := t.TempDir()
tmpFile, err := os.CreateTemp(tmpdir, "ip_conntrack_count")
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tmpFile.Close()) })
dfltDirs = []string{tmpdir}
fname := path.Base(tmpFile.Name())
dfltFiles = []string{fname}
count := 1234321
require.NoError(t, os.WriteFile(tmpFile.Name(), []byte(strconv.Itoa(count)), 0660))
c := &Conntrack{}
acc := &testutil.Accumulator{}
require.NoError(t, c.Gather(acc))
acc.AssertContainsFields(t, inputName, map[string]interface{}{
fname: float64(count)})
} | explode_data.jsonl/37565 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
16273,
22743,
1155,
353,
8840,
836,
8,
341,
16867,
14952,
35,
1489,
2576,
1500,
79209,
10809,
11,
294,
79209,
97384,
340,
20082,
3741,
1669,
259,
65009,
6184,
2822,
20082,
1703,
11,
1848,
1669,
2643,
7251,
12151,
10368,
3741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoggerInfoExpected(t *testing.T) {
checkMessages(t, zapcore.DebugLevel, nil, zapcore.InfoLevel, []string{
"hello",
"world",
"foo",
}, func(logger *Logger) {
logger.Print("hello")
logger.Printf("world")
logger.Println("foo")
})
} | explode_data.jsonl/58459 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
7395,
1731,
18896,
1155,
353,
8840,
836,
8,
341,
25157,
15820,
1155,
11,
32978,
2153,
20345,
4449,
11,
2092,
11,
32978,
2153,
20132,
4449,
11,
3056,
917,
515,
197,
197,
1,
14990,
756,
197,
197,
1,
14615,
756,
197,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_notLocked(t *testing.T) {
var username string
var object, schema types.M
var accountLockout *AccountLockout
var err, expectErr error
var expiresAtStr string
/*****************************************************************/
config.TConfig.AccountLockoutThreshold = 3
config.TConfig.AccountLockoutDuration = 5
expiresAtStr = utils.TimetoString(time.Now().UTC().Add(time.Duration(config.TConfig.AccountLockoutDuration) * time.Minute))
initEnv()
username = "joe"
schema = types.M{
"fields": types.M{
"username": types.M{"type": "String"},
"password": types.M{"type": "String"},
},
}
orm.Adapter.CreateClass("_User", schema)
object = types.M{
"objectId": "01",
"username": username,
"_account_lockout_expires_at": types.M{
"__type": "Date",
"iso": expiresAtStr,
},
"_failed_login_count": 3,
}
orm.Adapter.CreateObject("_User", schema, object)
accountLockout = NewAccountLockout(username)
err = accountLockout.notLocked()
expectErr = errs.E(errs.ObjectNotFound, "Your account is locked due to multiple failed login attempts. Please try again after "+
strconv.Itoa(config.TConfig.AccountLockoutDuration)+" minute(s)")
if reflect.DeepEqual(expectErr, err) == false {
t.Error("expect:", expectErr, "result:", err)
}
orm.TomatoDBController.DeleteEverything()
/*****************************************************************/
config.TConfig.AccountLockoutThreshold = 3
config.TConfig.AccountLockoutDuration = 5
expiresAtStr = utils.TimetoString(time.Now().UTC().Add(time.Duration(config.TConfig.AccountLockoutDuration) * time.Minute))
initEnv()
username = "joe"
schema = types.M{
"fields": types.M{
"username": types.M{"type": "String"},
"password": types.M{"type": "String"},
},
}
orm.Adapter.CreateClass("_User", schema)
object = types.M{
"objectId": "01",
"username": username,
"_account_lockout_expires_at": types.M{
"__type": "Date",
"iso": expiresAtStr,
},
"_failed_login_count": 1,
}
orm.Adapter.CreateObject("_User", schema, object)
accountLockout = NewAccountLockout(username)
err = accountLockout.notLocked()
expectErr = nil
if reflect.DeepEqual(expectErr, err) == false {
t.Error("expect:", expectErr, "result:", err)
}
orm.TomatoDBController.DeleteEverything()
/*****************************************************************/
config.TConfig.AccountLockoutThreshold = 3
config.TConfig.AccountLockoutDuration = 5
expiresAtStr = utils.TimetoString(time.Now().UTC().Add(-time.Duration(config.TConfig.AccountLockoutDuration) * time.Minute))
initEnv()
username = "joe"
schema = types.M{
"fields": types.M{
"username": types.M{"type": "String"},
"password": types.M{"type": "String"},
},
}
orm.Adapter.CreateClass("_User", schema)
object = types.M{
"objectId": "01",
"username": username,
"_account_lockout_expires_at": types.M{
"__type": "Date",
"iso": expiresAtStr,
},
"_failed_login_count": 3,
}
orm.Adapter.CreateObject("_User", schema, object)
accountLockout = NewAccountLockout(username)
err = accountLockout.notLocked()
expectErr = nil
if reflect.DeepEqual(expectErr, err) == false {
t.Error("expect:", expectErr, "result:", err)
}
orm.TomatoDBController.DeleteEverything()
} | explode_data.jsonl/73715 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1180
} | [
2830,
3393,
7913,
49010,
1155,
353,
8840,
836,
8,
341,
2405,
5934,
914,
198,
2405,
1633,
11,
10802,
4494,
1321,
198,
2405,
2692,
11989,
411,
353,
7365,
11989,
411,
198,
2405,
1848,
11,
1720,
7747,
1465,
198,
2405,
27902,
1655,
2580,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestMapUnpin(t *testing.T) {
tmp := testutils.TempBPFFS(t)
c := qt.New(t)
spec := spec1.Copy()
m, err := NewMapWithOptions(spec, MapOptions{PinPath: tmp})
if err != nil {
t.Fatal("Failed to create map:", err)
}
defer m.Close()
pinned := m.IsPinned()
c.Assert(pinned, qt.Equals, true)
path := filepath.Join(tmp, spec.Name)
m2, err := LoadPinnedMap(path, nil)
c.Assert(err, qt.IsNil)
defer m2.Close()
if err = m.Unpin(); err != nil {
t.Fatal("Failed to unpin map:", err)
}
if _, err := os.Stat(path); err == nil {
t.Fatal("Pinned map path still exists after unpinning:", err)
}
} | explode_data.jsonl/21655 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
2227,
1806,
13273,
1155,
353,
8840,
836,
8,
341,
20082,
1669,
1273,
6031,
65009,
26095,
1748,
50,
1155,
340,
1444,
1669,
38949,
7121,
1155,
340,
98100,
1669,
1398,
16,
31770,
2822,
2109,
11,
1848,
1669,
1532,
2227,
74238,
38... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDecode_ES384Compact_NoSigTrim(t *testing.T) {
incoming := "eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCIsImtpZCI6IjE5MzFmZTQ0YmFhMWNhZTkyZWUzNzYzOTQ0MDU1OGMwODdlMTRlNjk5ZWU5NjVhM2Q1OGU1MmU2NGY4MDE0NWIifQ.eyJpc3MiOiJicmt0LWNsaS0xLjAuN3ByZTEiLCJpYXQiOjE0ODQ2OTU1MjAsImp0aSI6IjgxYjczY2Y3In0.DdFi0KmPHSv4PfIMGcWGMSRLmZsfRPQ3muLFW6Ly2HpiLFFQWZ0VEanyrFV263wjlp3udfedgw_vrBLz3XC8CkbvCo_xeHMzaTr_yfhjoheSj8gWRLwB-22rOnUX_M0A"
t.Logf("incoming = '%s'", incoming)
const jwksrc = `{
"kty":"EC",
"crv":"P-384",
"x":"YHVZ4gc1RDoqxKm4NzaN_Y1r7R7h3RM3JMteC478apSKUiLVb4UNytqWaLoE6ygH",
"y":"CRKSqP-aYTIsqJfg_wZEEYUayUR5JhZaS2m4NLk2t1DfXZgfApAJ2lBO0vWKnUMp"
}`
pubkey, err := ecdsautil.PublicKeyFromJSON([]byte(jwksrc))
if !assert.NoError(t, err, "parsing jwk should be successful") {
return
}
v, err := verify.New(jwa.ES384)
if !assert.NoError(t, err, "EcdsaVerify created") {
return
}
protected, payload, signature, err := jws.SplitCompact(strings.NewReader(incoming))
if !assert.NoError(t, err, `jws.SplitCompact should succeed`) {
return
}
var buf bytes.Buffer
buf.Write(protected)
buf.WriteByte('.')
buf.Write(payload)
decodedSignature := make([]byte, base64.RawURLEncoding.DecodedLen(len(signature)))
if _, err := base64.RawURLEncoding.Decode(decodedSignature, signature); !assert.NoError(t, err, `decoding signature should succeed`) {
return
}
if !assert.NoError(t, v.Verify(buf.Bytes(), decodedSignature, pubkey), "Verify succeeds") {
return
}
} | explode_data.jsonl/1565 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 784
} | [
2830,
3393,
32564,
30275,
18,
23,
19,
98335,
36989,
47246,
25656,
1155,
353,
8840,
836,
8,
341,
17430,
4959,
1669,
330,
84609,
49039,
38,
5855,
81096,
41,
81213,
65215,
19,
9949,
3872,
641,
49,
20,
66,
11237,
21,
40,
48495,
55,
11287,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestGetClientTLSConfig(t *testing.T) {
cfg := &ClientTLSConfig{
CertFiles: []string{"root.pem"},
Client: KeyCertFiles{
KeyFile: "tls_client-key.pem",
CertFile: "tls_client-cert.pem",
},
}
err := AbsTLSClient(cfg, configDir)
if err != nil {
t.Errorf("Failed to get absolute path for client TLS config: %s", err)
}
_, err = GetClientTLSConfig(cfg, nil)
if err != nil {
t.Errorf("Failed to get TLS Config: %s", err)
}
} | explode_data.jsonl/43278 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
1949,
2959,
45439,
2648,
1155,
353,
8840,
836,
8,
1476,
50286,
1669,
609,
2959,
45439,
2648,
515,
197,
6258,
529,
10809,
25,
3056,
917,
4913,
2888,
49373,
7115,
197,
71724,
25,
5309,
36934,
10809,
515,
298,
55242,
1703,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.